babylon.max.js 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826
  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. })(window, 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. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  336. /**
  337. * Does exist one action manager with at least one trigger
  338. **/
  339. get: function () {
  340. for (var t in AbstractActionManager.Triggers) {
  341. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  342. return true;
  343. }
  344. }
  345. return false;
  346. },
  347. enumerable: true,
  348. configurable: true
  349. });
  350. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  351. /**
  352. * Does exist one action manager with at least one pick trigger
  353. **/
  354. get: function () {
  355. for (var t in AbstractActionManager.Triggers) {
  356. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  357. var t_int = parseInt(t);
  358. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  359. return true;
  360. }
  361. }
  362. }
  363. return false;
  364. },
  365. enumerable: true,
  366. configurable: true
  367. });
  368. /**
  369. * Does exist one action manager that handles actions of a given trigger
  370. * @param trigger defines the trigger to be tested
  371. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  372. **/
  373. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  374. for (var t in AbstractActionManager.Triggers) {
  375. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  376. var t_int = parseInt(t);
  377. if (t_int === trigger) {
  378. return true;
  379. }
  380. }
  381. }
  382. return false;
  383. };
  384. /** Gets the list of active triggers */
  385. AbstractActionManager.Triggers = {};
  386. return AbstractActionManager;
  387. }());
  388. /***/ }),
  389. /***/ "./Actions/action.ts":
  390. /*!***************************!*\
  391. !*** ./Actions/action.ts ***!
  392. \***************************/
  393. /*! exports provided: Action */
  394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  395. "use strict";
  396. __webpack_require__.r(__webpack_exports__);
  397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  398. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  400. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  401. /**
  402. * The action to be carried out following a trigger
  403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  404. */
  405. var Action = /** @class */ (function () {
  406. /**
  407. * Creates a new Action
  408. * @param triggerOptions the trigger, with or without parameters, for the action
  409. * @param condition an optional determinant of action
  410. */
  411. function Action(
  412. /** the trigger, with or without parameters, for the action */
  413. triggerOptions, condition) {
  414. this.triggerOptions = triggerOptions;
  415. /**
  416. * An event triggered prior to action being executed.
  417. */
  418. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  419. if (triggerOptions.parameter) {
  420. this.trigger = triggerOptions.trigger;
  421. this._triggerParameter = triggerOptions.parameter;
  422. }
  423. else if (triggerOptions.trigger) {
  424. this.trigger = triggerOptions.trigger;
  425. }
  426. else {
  427. this.trigger = triggerOptions;
  428. }
  429. this._nextActiveAction = this;
  430. this._condition = condition;
  431. }
  432. /**
  433. * Internal only
  434. * @hidden
  435. */
  436. Action.prototype._prepare = function () {
  437. };
  438. /**
  439. * Gets the trigger parameters
  440. * @returns the trigger parameters
  441. */
  442. Action.prototype.getTriggerParameter = function () {
  443. return this._triggerParameter;
  444. };
  445. /**
  446. * Internal only - executes current action event
  447. * @hidden
  448. */
  449. Action.prototype._executeCurrent = function (evt) {
  450. if (this._nextActiveAction._condition) {
  451. var condition = this._nextActiveAction._condition;
  452. var currentRenderId = this._actionManager.getScene().getRenderId();
  453. // We cache the current evaluation for the current frame
  454. if (condition._evaluationId === currentRenderId) {
  455. if (!condition._currentResult) {
  456. return;
  457. }
  458. }
  459. else {
  460. condition._evaluationId = currentRenderId;
  461. if (!condition.isValid()) {
  462. condition._currentResult = false;
  463. return;
  464. }
  465. condition._currentResult = true;
  466. }
  467. }
  468. this.onBeforeExecuteObservable.notifyObservers(this);
  469. this._nextActiveAction.execute(evt);
  470. this.skipToNextActiveAction();
  471. };
  472. /**
  473. * Execute placeholder for child classes
  474. * @param evt optional action event
  475. */
  476. Action.prototype.execute = function (evt) {
  477. };
  478. /**
  479. * Skips to next active action
  480. */
  481. Action.prototype.skipToNextActiveAction = function () {
  482. if (this._nextActiveAction._child) {
  483. if (!this._nextActiveAction._child._actionManager) {
  484. this._nextActiveAction._child._actionManager = this._actionManager;
  485. }
  486. this._nextActiveAction = this._nextActiveAction._child;
  487. }
  488. else {
  489. this._nextActiveAction = this;
  490. }
  491. };
  492. /**
  493. * Adds action to chain of actions, may be a DoNothingAction
  494. * @param action defines the next action to execute
  495. * @returns The action passed in
  496. * @see https://www.babylonjs-playground.com/#1T30HR#0
  497. */
  498. Action.prototype.then = function (action) {
  499. this._child = action;
  500. action._actionManager = this._actionManager;
  501. action._prepare();
  502. return action;
  503. };
  504. /**
  505. * Internal only
  506. * @hidden
  507. */
  508. Action.prototype._getProperty = function (propertyPath) {
  509. return this._actionManager._getProperty(propertyPath);
  510. };
  511. /**
  512. * Internal only
  513. * @hidden
  514. */
  515. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  516. return this._actionManager._getEffectiveTarget(target, propertyPath);
  517. };
  518. /**
  519. * Serialize placeholder for child classes
  520. * @param parent of child
  521. * @returns the serialized object
  522. */
  523. Action.prototype.serialize = function (parent) {
  524. };
  525. /**
  526. * Internal only called by serialize
  527. * @hidden
  528. */
  529. Action.prototype._serialize = function (serializedAction, parent) {
  530. var serializationObject = {
  531. type: 1,
  532. children: [],
  533. name: serializedAction.name,
  534. properties: serializedAction.properties || []
  535. };
  536. // Serialize child
  537. if (this._child) {
  538. this._child.serialize(serializationObject);
  539. }
  540. // Check if "this" has a condition
  541. if (this._condition) {
  542. var serializedCondition = this._condition.serialize();
  543. serializedCondition.children.push(serializationObject);
  544. if (parent) {
  545. parent.children.push(serializedCondition);
  546. }
  547. return serializedCondition;
  548. }
  549. if (parent) {
  550. parent.children.push(serializationObject);
  551. }
  552. return serializationObject;
  553. };
  554. /**
  555. * Internal only
  556. * @hidden
  557. */
  558. Action._SerializeValueAsString = function (value) {
  559. if (typeof value === "number") {
  560. return value.toString();
  561. }
  562. if (typeof value === "boolean") {
  563. return value ? "true" : "false";
  564. }
  565. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  566. return value.x + ", " + value.y;
  567. }
  568. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  569. return value.x + ", " + value.y + ", " + value.z;
  570. }
  571. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  572. return value.r + ", " + value.g + ", " + value.b;
  573. }
  574. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  575. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  576. }
  577. return value; // string
  578. };
  579. /**
  580. * Internal only
  581. * @hidden
  582. */
  583. Action._GetTargetProperty = function (target) {
  584. return {
  585. name: "target",
  586. targetType: target._isMesh ? "MeshProperties"
  587. : target._isLight ? "LightProperties"
  588. : target._isCamera ? "CameraProperties"
  589. : "SceneProperties",
  590. value: target._isScene ? "Scene" : target.name
  591. };
  592. };
  593. return Action;
  594. }());
  595. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  596. /***/ }),
  597. /***/ "./Actions/actionEvent.ts":
  598. /*!********************************!*\
  599. !*** ./Actions/actionEvent.ts ***!
  600. \********************************/
  601. /*! exports provided: ActionEvent */
  602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  603. "use strict";
  604. __webpack_require__.r(__webpack_exports__);
  605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  606. /**
  607. * ActionEvent is the event being sent when an action is triggered.
  608. */
  609. var ActionEvent = /** @class */ (function () {
  610. /**
  611. * Creates a new ActionEvent
  612. * @param source The mesh or sprite that triggered the action
  613. * @param pointerX The X mouse cursor position at the time of the event
  614. * @param pointerY The Y mouse cursor position at the time of the event
  615. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  616. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  617. * @param additionalData additional data for the event
  618. */
  619. function ActionEvent(
  620. /** The mesh or sprite that triggered the action */
  621. source,
  622. /** The X mouse cursor position at the time of the event */
  623. pointerX,
  624. /** The Y mouse cursor position at the time of the event */
  625. pointerY,
  626. /** The mesh that is currently pointed at (can be null) */
  627. meshUnderPointer,
  628. /** the original (browser) event that triggered the ActionEvent */
  629. sourceEvent,
  630. /** additional data for the event */
  631. additionalData) {
  632. this.source = source;
  633. this.pointerX = pointerX;
  634. this.pointerY = pointerY;
  635. this.meshUnderPointer = meshUnderPointer;
  636. this.sourceEvent = sourceEvent;
  637. this.additionalData = additionalData;
  638. }
  639. /**
  640. * Helper function to auto-create an ActionEvent from a source mesh.
  641. * @param source The source mesh that triggered the event
  642. * @param evt The original (browser) event
  643. * @param additionalData additional data for the event
  644. * @returns the new ActionEvent
  645. */
  646. ActionEvent.CreateNew = function (source, evt, additionalData) {
  647. var scene = source.getScene();
  648. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  649. };
  650. /**
  651. * Helper function to auto-create an ActionEvent from a source sprite
  652. * @param source The source sprite that triggered the event
  653. * @param scene Scene associated with the sprite
  654. * @param evt The original (browser) event
  655. * @param additionalData additional data for the event
  656. * @returns the new ActionEvent
  657. */
  658. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  659. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  660. };
  661. /**
  662. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  663. * @param scene the scene where the event occurred
  664. * @param evt The original (browser) event
  665. * @returns the new ActionEvent
  666. */
  667. ActionEvent.CreateNewFromScene = function (scene, evt) {
  668. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  669. };
  670. /**
  671. * Helper function to auto-create an ActionEvent from a primitive
  672. * @param prim defines the target primitive
  673. * @param pointerPos defines the pointer position
  674. * @param evt The original (browser) event
  675. * @param additionalData additional data for the event
  676. * @returns the new ActionEvent
  677. */
  678. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  679. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  680. };
  681. return ActionEvent;
  682. }());
  683. /***/ }),
  684. /***/ "./Actions/actionManager.ts":
  685. /*!**********************************!*\
  686. !*** ./Actions/actionManager.ts ***!
  687. \**********************************/
  688. /*! exports provided: ActionManager */
  689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  690. "use strict";
  691. __webpack_require__.r(__webpack_exports__);
  692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  694. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  695. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  696. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  697. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  698. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  699. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  700. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  701. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  702. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  703. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  704. /**
  705. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  706. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  708. */
  709. var ActionManager = /** @class */ (function (_super) {
  710. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  711. /**
  712. * Creates a new action manager
  713. * @param scene defines the hosting scene
  714. */
  715. function ActionManager(scene) {
  716. var _this = _super.call(this) || this;
  717. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  718. scene.actionManagers.push(_this);
  719. return _this;
  720. }
  721. // Methods
  722. /**
  723. * Releases all associated resources
  724. */
  725. ActionManager.prototype.dispose = function () {
  726. var index = this._scene.actionManagers.indexOf(this);
  727. for (var i = 0; i < this.actions.length; i++) {
  728. var action = this.actions[i];
  729. ActionManager.Triggers[action.trigger]--;
  730. if (ActionManager.Triggers[action.trigger] === 0) {
  731. delete ActionManager.Triggers[action.trigger];
  732. }
  733. }
  734. if (index > -1) {
  735. this._scene.actionManagers.splice(index, 1);
  736. }
  737. };
  738. /**
  739. * Gets hosting scene
  740. * @returns the hosting scene
  741. */
  742. ActionManager.prototype.getScene = function () {
  743. return this._scene;
  744. };
  745. /**
  746. * Does this action manager handles actions of any of the given triggers
  747. * @param triggers defines the triggers to be tested
  748. * @return a boolean indicating whether one (or more) of the triggers is handled
  749. */
  750. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  751. for (var index = 0; index < this.actions.length; index++) {
  752. var action = this.actions[index];
  753. if (triggers.indexOf(action.trigger) > -1) {
  754. return true;
  755. }
  756. }
  757. return false;
  758. };
  759. /**
  760. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  761. * speed.
  762. * @param triggerA defines the trigger to be tested
  763. * @param triggerB defines the trigger to be tested
  764. * @return a boolean indicating whether one (or more) of the triggers is handled
  765. */
  766. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  767. for (var index = 0; index < this.actions.length; index++) {
  768. var action = this.actions[index];
  769. if (triggerA == action.trigger || triggerB == action.trigger) {
  770. return true;
  771. }
  772. }
  773. return false;
  774. };
  775. /**
  776. * Does this action manager handles actions of a given trigger
  777. * @param trigger defines the trigger to be tested
  778. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  779. * @return whether the trigger is handled
  780. */
  781. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  782. for (var index = 0; index < this.actions.length; index++) {
  783. var action = this.actions[index];
  784. if (action.trigger === trigger) {
  785. if (parameterPredicate) {
  786. if (parameterPredicate(action.getTriggerParameter())) {
  787. return true;
  788. }
  789. }
  790. else {
  791. return true;
  792. }
  793. }
  794. }
  795. return false;
  796. };
  797. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  798. /**
  799. * Does this action manager has pointer triggers
  800. */
  801. get: function () {
  802. for (var index = 0; index < this.actions.length; index++) {
  803. var action = this.actions[index];
  804. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  805. return true;
  806. }
  807. }
  808. return false;
  809. },
  810. enumerable: true,
  811. configurable: true
  812. });
  813. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  814. /**
  815. * Does this action manager has pick triggers
  816. */
  817. get: function () {
  818. for (var index = 0; index < this.actions.length; index++) {
  819. var action = this.actions[index];
  820. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  821. return true;
  822. }
  823. }
  824. return false;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Registers an action to this action manager
  831. * @param action defines the action to be registered
  832. * @return the action amended (prepared) after registration
  833. */
  834. ActionManager.prototype.registerAction = function (action) {
  835. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  836. if (this.getScene().actionManager !== this) {
  837. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  838. return null;
  839. }
  840. }
  841. this.actions.push(action);
  842. if (ActionManager.Triggers[action.trigger]) {
  843. ActionManager.Triggers[action.trigger]++;
  844. }
  845. else {
  846. ActionManager.Triggers[action.trigger] = 1;
  847. }
  848. action._actionManager = this;
  849. action._prepare();
  850. return action;
  851. };
  852. /**
  853. * Unregisters an action to this action manager
  854. * @param action defines the action to be unregistered
  855. * @return a boolean indicating whether the action has been unregistered
  856. */
  857. ActionManager.prototype.unregisterAction = function (action) {
  858. var index = this.actions.indexOf(action);
  859. if (index !== -1) {
  860. this.actions.splice(index, 1);
  861. ActionManager.Triggers[action.trigger] -= 1;
  862. if (ActionManager.Triggers[action.trigger] === 0) {
  863. delete ActionManager.Triggers[action.trigger];
  864. }
  865. delete action._actionManager;
  866. return true;
  867. }
  868. return false;
  869. };
  870. /**
  871. * Process a specific trigger
  872. * @param trigger defines the trigger to process
  873. * @param evt defines the event details to be processed
  874. */
  875. ActionManager.prototype.processTrigger = function (trigger, evt) {
  876. for (var index = 0; index < this.actions.length; index++) {
  877. var action = this.actions[index];
  878. if (action.trigger === trigger) {
  879. if (evt) {
  880. if (trigger === ActionManager.OnKeyUpTrigger
  881. || trigger === ActionManager.OnKeyDownTrigger) {
  882. var parameter = action.getTriggerParameter();
  883. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  884. if (!parameter.toLowerCase) {
  885. continue;
  886. }
  887. var lowerCase = parameter.toLowerCase();
  888. if (lowerCase !== evt.sourceEvent.key) {
  889. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  890. var actualkey = String.fromCharCode(unicode).toLowerCase();
  891. if (actualkey !== lowerCase) {
  892. continue;
  893. }
  894. }
  895. }
  896. }
  897. }
  898. action._executeCurrent(evt);
  899. }
  900. }
  901. };
  902. /** @hidden */
  903. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  904. var properties = propertyPath.split(".");
  905. for (var index = 0; index < properties.length - 1; index++) {
  906. target = target[properties[index]];
  907. }
  908. return target;
  909. };
  910. /** @hidden */
  911. ActionManager.prototype._getProperty = function (propertyPath) {
  912. var properties = propertyPath.split(".");
  913. return properties[properties.length - 1];
  914. };
  915. /**
  916. * Serialize this manager to a JSON object
  917. * @param name defines the property name to store this manager
  918. * @returns a JSON representation of this manager
  919. */
  920. ActionManager.prototype.serialize = function (name) {
  921. var root = {
  922. children: new Array(),
  923. name: name,
  924. type: 3,
  925. properties: new Array() // Empty for root but required
  926. };
  927. for (var i = 0; i < this.actions.length; i++) {
  928. var triggerObject = {
  929. type: 0,
  930. children: new Array(),
  931. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  932. properties: new Array()
  933. };
  934. var triggerOptions = this.actions[i].triggerOptions;
  935. if (triggerOptions && typeof triggerOptions !== "number") {
  936. if (triggerOptions.parameter instanceof Node) {
  937. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  938. }
  939. else {
  940. var parameter = {};
  941. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  942. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  943. parameter._meshId = triggerOptions.parameter.mesh.id;
  944. }
  945. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  946. }
  947. }
  948. // Serialize child action, recursively
  949. this.actions[i].serialize(triggerObject);
  950. // Add serialized trigger
  951. root.children.push(triggerObject);
  952. }
  953. return root;
  954. };
  955. /**
  956. * Creates a new ActionManager from a JSON data
  957. * @param parsedActions defines the JSON data to read from
  958. * @param object defines the hosting mesh
  959. * @param scene defines the hosting scene
  960. */
  961. ActionManager.Parse = function (parsedActions, object, scene) {
  962. var actionManager = new ActionManager(scene);
  963. if (object === null) {
  964. scene.actionManager = actionManager;
  965. }
  966. else {
  967. object.actionManager = actionManager;
  968. }
  969. // instanciate a new object
  970. var instanciate = function (name, params) {
  971. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  972. if (internalClassType) {
  973. var newInstance = Object.create(internalClassType.prototype);
  974. newInstance.constructor.apply(newInstance, params);
  975. return newInstance;
  976. }
  977. };
  978. var parseParameter = function (name, value, target, propertyPath) {
  979. if (propertyPath === null) {
  980. // String, boolean or float
  981. var floatValue = parseFloat(value);
  982. if (value === "true" || value === "false") {
  983. return value === "true";
  984. }
  985. else {
  986. return isNaN(floatValue) ? value : floatValue;
  987. }
  988. }
  989. var effectiveTarget = propertyPath.split(".");
  990. var values = value.split(",");
  991. // Get effective Target
  992. for (var i = 0; i < effectiveTarget.length; i++) {
  993. target = target[effectiveTarget[i]];
  994. }
  995. // Return appropriate value with its type
  996. if (typeof (target) === "boolean") {
  997. return values[0] === "true";
  998. }
  999. if (typeof (target) === "string") {
  1000. return values[0];
  1001. }
  1002. // Parameters with multiple values such as Vector3 etc.
  1003. var split = new Array();
  1004. for (var i = 0; i < values.length; i++) {
  1005. split.push(parseFloat(values[i]));
  1006. }
  1007. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1008. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1009. }
  1010. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1011. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1012. }
  1013. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1014. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1015. }
  1016. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1017. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1018. }
  1019. return parseFloat(values[0]);
  1020. };
  1021. // traverse graph per trigger
  1022. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1023. if (combineArray === void 0) { combineArray = null; }
  1024. if (parsedAction.detached) {
  1025. return;
  1026. }
  1027. var parameters = new Array();
  1028. var target = null;
  1029. var propertyPath = null;
  1030. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1031. // Parameters
  1032. if (parsedAction.type === 2) {
  1033. parameters.push(actionManager);
  1034. }
  1035. else {
  1036. parameters.push(trigger);
  1037. }
  1038. if (combine) {
  1039. var actions = new Array();
  1040. for (var j = 0; j < parsedAction.combine.length; j++) {
  1041. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1042. }
  1043. parameters.push(actions);
  1044. }
  1045. else {
  1046. for (var i = 0; i < parsedAction.properties.length; i++) {
  1047. var value = parsedAction.properties[i].value;
  1048. var name = parsedAction.properties[i].name;
  1049. var targetType = parsedAction.properties[i].targetType;
  1050. if (name === "target") {
  1051. if (targetType !== null && targetType === "SceneProperties") {
  1052. value = target = scene;
  1053. }
  1054. else {
  1055. value = target = scene.getNodeByName(value);
  1056. }
  1057. }
  1058. else if (name === "parent") {
  1059. value = scene.getNodeByName(value);
  1060. }
  1061. else if (name === "sound") {
  1062. // Can not externalize to component, so only checks for the presence off the API.
  1063. if (scene.getSoundByName) {
  1064. value = scene.getSoundByName(value);
  1065. }
  1066. }
  1067. else if (name !== "propertyPath") {
  1068. if (parsedAction.type === 2 && name === "operator") {
  1069. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1070. }
  1071. else {
  1072. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1073. }
  1074. }
  1075. else {
  1076. propertyPath = value;
  1077. }
  1078. parameters.push(value);
  1079. }
  1080. }
  1081. if (combineArray === null) {
  1082. parameters.push(condition);
  1083. }
  1084. else {
  1085. parameters.push(null);
  1086. }
  1087. // If interpolate value action
  1088. if (parsedAction.name === "InterpolateValueAction") {
  1089. var param = parameters[parameters.length - 2];
  1090. parameters[parameters.length - 1] = param;
  1091. parameters[parameters.length - 2] = condition;
  1092. }
  1093. // Action or condition(s) and not CombineAction
  1094. var newAction = instanciate(parsedAction.name, parameters);
  1095. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1096. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1097. if (action) {
  1098. action.then(nothing);
  1099. }
  1100. else {
  1101. actionManager.registerAction(nothing);
  1102. }
  1103. action = nothing;
  1104. }
  1105. if (combineArray === null) {
  1106. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1107. condition = newAction;
  1108. newAction = action;
  1109. }
  1110. else {
  1111. condition = null;
  1112. if (action) {
  1113. action.then(newAction);
  1114. }
  1115. else {
  1116. actionManager.registerAction(newAction);
  1117. }
  1118. }
  1119. }
  1120. else {
  1121. combineArray.push(newAction);
  1122. }
  1123. for (var i = 0; i < parsedAction.children.length; i++) {
  1124. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1125. }
  1126. };
  1127. // triggers
  1128. for (var i = 0; i < parsedActions.children.length; i++) {
  1129. var triggerParams;
  1130. var trigger = parsedActions.children[i];
  1131. if (trigger.properties.length > 0) {
  1132. var param = trigger.properties[0].value;
  1133. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1134. if (value._meshId) {
  1135. value.mesh = scene.getMeshByID(value._meshId);
  1136. }
  1137. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1138. }
  1139. else {
  1140. triggerParams = ActionManager[trigger.name];
  1141. }
  1142. for (var j = 0; j < trigger.children.length; j++) {
  1143. if (!trigger.detached) {
  1144. traverse(trigger.children[j], triggerParams, null, null);
  1145. }
  1146. }
  1147. }
  1148. };
  1149. /**
  1150. * Get a trigger name by index
  1151. * @param trigger defines the trigger index
  1152. * @returns a trigger name
  1153. */
  1154. ActionManager.GetTriggerName = function (trigger) {
  1155. switch (trigger) {
  1156. case 0: return "NothingTrigger";
  1157. case 1: return "OnPickTrigger";
  1158. case 2: return "OnLeftPickTrigger";
  1159. case 3: return "OnRightPickTrigger";
  1160. case 4: return "OnCenterPickTrigger";
  1161. case 5: return "OnPickDownTrigger";
  1162. case 6: return "OnPickUpTrigger";
  1163. case 7: return "OnLongPressTrigger";
  1164. case 8: return "OnPointerOverTrigger";
  1165. case 9: return "OnPointerOutTrigger";
  1166. case 10: return "OnEveryFrameTrigger";
  1167. case 11: return "OnIntersectionEnterTrigger";
  1168. case 12: return "OnIntersectionExitTrigger";
  1169. case 13: return "OnKeyDownTrigger";
  1170. case 14: return "OnKeyUpTrigger";
  1171. case 15: return "OnPickOutTrigger";
  1172. default: return "";
  1173. }
  1174. };
  1175. /**
  1176. * Nothing
  1177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1178. */
  1179. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1180. /**
  1181. * On pick
  1182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1183. */
  1184. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1185. /**
  1186. * On left pick
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1188. */
  1189. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1190. /**
  1191. * On right pick
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1193. */
  1194. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1195. /**
  1196. * On center pick
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1198. */
  1199. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1200. /**
  1201. * On pick down
  1202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1203. */
  1204. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1205. /**
  1206. * On double pick
  1207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1208. */
  1209. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1210. /**
  1211. * On pick up
  1212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1213. */
  1214. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1215. /**
  1216. * On pick out.
  1217. * This trigger will only be raised if you also declared a OnPickDown
  1218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1219. */
  1220. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1221. /**
  1222. * On long press
  1223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1224. */
  1225. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1226. /**
  1227. * On pointer over
  1228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1229. */
  1230. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1231. /**
  1232. * On pointer out
  1233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1234. */
  1235. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1236. /**
  1237. * On every frame
  1238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1239. */
  1240. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1241. /**
  1242. * On intersection enter
  1243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1244. */
  1245. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1246. /**
  1247. * On intersection exit
  1248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1249. */
  1250. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1251. /**
  1252. * On key down
  1253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1254. */
  1255. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1256. /**
  1257. * On key up
  1258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1259. */
  1260. ActionManager.OnKeyUpTrigger = 15;
  1261. return ActionManager;
  1262. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1263. /***/ }),
  1264. /***/ "./Actions/condition.ts":
  1265. /*!******************************!*\
  1266. !*** ./Actions/condition.ts ***!
  1267. \******************************/
  1268. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1270. "use strict";
  1271. __webpack_require__.r(__webpack_exports__);
  1272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1277. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1278. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1279. /**
  1280. * A Condition applied to an Action
  1281. */
  1282. var Condition = /** @class */ (function () {
  1283. /**
  1284. * Creates a new Condition
  1285. * @param actionManager the manager of the action the condition is applied to
  1286. */
  1287. function Condition(actionManager) {
  1288. this._actionManager = actionManager;
  1289. }
  1290. /**
  1291. * Check if the current condition is valid
  1292. * @returns a boolean
  1293. */
  1294. Condition.prototype.isValid = function () {
  1295. return true;
  1296. };
  1297. /**
  1298. * Internal only
  1299. * @hidden
  1300. */
  1301. Condition.prototype._getProperty = function (propertyPath) {
  1302. return this._actionManager._getProperty(propertyPath);
  1303. };
  1304. /**
  1305. * Internal only
  1306. * @hidden
  1307. */
  1308. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1309. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1310. };
  1311. /**
  1312. * Serialize placeholder for child classes
  1313. * @returns the serialized object
  1314. */
  1315. Condition.prototype.serialize = function () {
  1316. };
  1317. /**
  1318. * Internal only
  1319. * @hidden
  1320. */
  1321. Condition.prototype._serialize = function (serializedCondition) {
  1322. return {
  1323. type: 2,
  1324. children: [],
  1325. name: serializedCondition.name,
  1326. properties: serializedCondition.properties
  1327. };
  1328. };
  1329. return Condition;
  1330. }());
  1331. /**
  1332. * Defines specific conditional operators as extensions of Condition
  1333. */
  1334. var ValueCondition = /** @class */ (function (_super) {
  1335. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1336. /**
  1337. * Creates a new ValueCondition
  1338. * @param actionManager manager for the action the condition applies to
  1339. * @param target for the action
  1340. * @param propertyPath path to specify the property of the target the conditional operator uses
  1341. * @param value the value compared by the conditional operator against the current value of the property
  1342. * @param operator the conditional operator, default ValueCondition.IsEqual
  1343. */
  1344. function ValueCondition(actionManager, target,
  1345. /** path to specify the property of the target the conditional operator uses */
  1346. propertyPath,
  1347. /** the value compared by the conditional operator against the current value of the property */
  1348. value,
  1349. /** the conditional operator, default ValueCondition.IsEqual */
  1350. operator) {
  1351. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1352. var _this = _super.call(this, actionManager) || this;
  1353. _this.propertyPath = propertyPath;
  1354. _this.value = value;
  1355. _this.operator = operator;
  1356. _this._target = target;
  1357. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1358. _this._property = _this._getProperty(_this.propertyPath);
  1359. return _this;
  1360. }
  1361. Object.defineProperty(ValueCondition, "IsEqual", {
  1362. /**
  1363. * returns the number for IsEqual
  1364. */
  1365. get: function () {
  1366. return ValueCondition._IsEqual;
  1367. },
  1368. enumerable: true,
  1369. configurable: true
  1370. });
  1371. Object.defineProperty(ValueCondition, "IsDifferent", {
  1372. /**
  1373. * Returns the number for IsDifferent
  1374. */
  1375. get: function () {
  1376. return ValueCondition._IsDifferent;
  1377. },
  1378. enumerable: true,
  1379. configurable: true
  1380. });
  1381. Object.defineProperty(ValueCondition, "IsGreater", {
  1382. /**
  1383. * Returns the number for IsGreater
  1384. */
  1385. get: function () {
  1386. return ValueCondition._IsGreater;
  1387. },
  1388. enumerable: true,
  1389. configurable: true
  1390. });
  1391. Object.defineProperty(ValueCondition, "IsLesser", {
  1392. /**
  1393. * Returns the number for IsLesser
  1394. */
  1395. get: function () {
  1396. return ValueCondition._IsLesser;
  1397. },
  1398. enumerable: true,
  1399. configurable: true
  1400. });
  1401. /**
  1402. * Compares the given value with the property value for the specified conditional operator
  1403. * @returns the result of the comparison
  1404. */
  1405. ValueCondition.prototype.isValid = function () {
  1406. switch (this.operator) {
  1407. case ValueCondition.IsGreater:
  1408. return this._effectiveTarget[this._property] > this.value;
  1409. case ValueCondition.IsLesser:
  1410. return this._effectiveTarget[this._property] < this.value;
  1411. case ValueCondition.IsEqual:
  1412. case ValueCondition.IsDifferent:
  1413. var check;
  1414. if (this.value.equals) {
  1415. check = this.value.equals(this._effectiveTarget[this._property]);
  1416. }
  1417. else {
  1418. check = this.value === this._effectiveTarget[this._property];
  1419. }
  1420. return this.operator === ValueCondition.IsEqual ? check : !check;
  1421. }
  1422. return false;
  1423. };
  1424. /**
  1425. * Serialize the ValueCondition into a JSON compatible object
  1426. * @returns serialization object
  1427. */
  1428. ValueCondition.prototype.serialize = function () {
  1429. return this._serialize({
  1430. name: "ValueCondition",
  1431. properties: [
  1432. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1433. { name: "propertyPath", value: this.propertyPath },
  1434. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1435. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1436. ]
  1437. });
  1438. };
  1439. /**
  1440. * Gets the name of the conditional operator for the ValueCondition
  1441. * @param operator the conditional operator
  1442. * @returns the name
  1443. */
  1444. ValueCondition.GetOperatorName = function (operator) {
  1445. switch (operator) {
  1446. case ValueCondition._IsEqual: return "IsEqual";
  1447. case ValueCondition._IsDifferent: return "IsDifferent";
  1448. case ValueCondition._IsGreater: return "IsGreater";
  1449. case ValueCondition._IsLesser: return "IsLesser";
  1450. default: return "";
  1451. }
  1452. };
  1453. /**
  1454. * Internal only
  1455. * @hidden
  1456. */
  1457. ValueCondition._IsEqual = 0;
  1458. /**
  1459. * Internal only
  1460. * @hidden
  1461. */
  1462. ValueCondition._IsDifferent = 1;
  1463. /**
  1464. * Internal only
  1465. * @hidden
  1466. */
  1467. ValueCondition._IsGreater = 2;
  1468. /**
  1469. * Internal only
  1470. * @hidden
  1471. */
  1472. ValueCondition._IsLesser = 3;
  1473. return ValueCondition;
  1474. }(Condition));
  1475. /**
  1476. * Defines a predicate condition as an extension of Condition
  1477. */
  1478. var PredicateCondition = /** @class */ (function (_super) {
  1479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1480. /**
  1481. * Creates a new PredicateCondition
  1482. * @param actionManager manager for the action the condition applies to
  1483. * @param predicate defines the predicate function used to validate the condition
  1484. */
  1485. function PredicateCondition(actionManager,
  1486. /** defines the predicate function used to validate the condition */
  1487. predicate) {
  1488. var _this = _super.call(this, actionManager) || this;
  1489. _this.predicate = predicate;
  1490. return _this;
  1491. }
  1492. /**
  1493. * @returns the validity of the predicate condition
  1494. */
  1495. PredicateCondition.prototype.isValid = function () {
  1496. return this.predicate();
  1497. };
  1498. return PredicateCondition;
  1499. }(Condition));
  1500. /**
  1501. * Defines a state condition as an extension of Condition
  1502. */
  1503. var StateCondition = /** @class */ (function (_super) {
  1504. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1505. /**
  1506. * Creates a new StateCondition
  1507. * @param actionManager manager for the action the condition applies to
  1508. * @param target of the condition
  1509. * @param value to compare with target state
  1510. */
  1511. function StateCondition(actionManager, target,
  1512. /** Value to compare with target state */
  1513. value) {
  1514. var _this = _super.call(this, actionManager) || this;
  1515. _this.value = value;
  1516. _this._target = target;
  1517. return _this;
  1518. }
  1519. /**
  1520. * Gets a boolean indicating if the current condition is met
  1521. * @returns the validity of the state
  1522. */
  1523. StateCondition.prototype.isValid = function () {
  1524. return this._target.state === this.value;
  1525. };
  1526. /**
  1527. * Serialize the StateCondition into a JSON compatible object
  1528. * @returns serialization object
  1529. */
  1530. StateCondition.prototype.serialize = function () {
  1531. return this._serialize({
  1532. name: "StateCondition",
  1533. properties: [
  1534. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1535. { name: "value", value: this.value }
  1536. ]
  1537. });
  1538. };
  1539. return StateCondition;
  1540. }(Condition));
  1541. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1542. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1543. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1544. /***/ }),
  1545. /***/ "./Actions/directActions.ts":
  1546. /*!**********************************!*\
  1547. !*** ./Actions/directActions.ts ***!
  1548. \**********************************/
  1549. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1551. "use strict";
  1552. __webpack_require__.r(__webpack_exports__);
  1553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1563. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1564. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1565. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1566. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1567. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1568. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1569. /**
  1570. * This defines an action responsible to toggle a boolean once triggered.
  1571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1572. */
  1573. var SwitchBooleanAction = /** @class */ (function (_super) {
  1574. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1575. /**
  1576. * Instantiate the action
  1577. * @param triggerOptions defines the trigger options
  1578. * @param target defines the object containing the boolean
  1579. * @param propertyPath defines the path to the boolean property in the target object
  1580. * @param condition defines the trigger related conditions
  1581. */
  1582. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1583. var _this = _super.call(this, triggerOptions, condition) || this;
  1584. _this.propertyPath = propertyPath;
  1585. _this._target = _this._effectiveTarget = target;
  1586. return _this;
  1587. }
  1588. /** @hidden */
  1589. SwitchBooleanAction.prototype._prepare = function () {
  1590. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1591. this._property = this._getProperty(this.propertyPath);
  1592. };
  1593. /**
  1594. * Execute the action toggle the boolean value.
  1595. */
  1596. SwitchBooleanAction.prototype.execute = function () {
  1597. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1598. };
  1599. /**
  1600. * Serializes the actions and its related information.
  1601. * @param parent defines the object to serialize in
  1602. * @returns the serialized object
  1603. */
  1604. SwitchBooleanAction.prototype.serialize = function (parent) {
  1605. return _super.prototype._serialize.call(this, {
  1606. name: "SwitchBooleanAction",
  1607. properties: [
  1608. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1609. { name: "propertyPath", value: this.propertyPath }
  1610. ]
  1611. }, parent);
  1612. };
  1613. return SwitchBooleanAction;
  1614. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1615. /**
  1616. * This defines an action responsible to set a the state field of the target
  1617. * to a desired value once triggered.
  1618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1619. */
  1620. var SetStateAction = /** @class */ (function (_super) {
  1621. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1622. /**
  1623. * Instantiate the action
  1624. * @param triggerOptions defines the trigger options
  1625. * @param target defines the object containing the state property
  1626. * @param value defines the value to store in the state field
  1627. * @param condition defines the trigger related conditions
  1628. */
  1629. function SetStateAction(triggerOptions, target, value, condition) {
  1630. var _this = _super.call(this, triggerOptions, condition) || this;
  1631. _this.value = value;
  1632. _this._target = target;
  1633. return _this;
  1634. }
  1635. /**
  1636. * Execute the action and store the value on the target state property.
  1637. */
  1638. SetStateAction.prototype.execute = function () {
  1639. this._target.state = this.value;
  1640. };
  1641. /**
  1642. * Serializes the actions and its related information.
  1643. * @param parent defines the object to serialize in
  1644. * @returns the serialized object
  1645. */
  1646. SetStateAction.prototype.serialize = function (parent) {
  1647. return _super.prototype._serialize.call(this, {
  1648. name: "SetStateAction",
  1649. properties: [
  1650. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1651. { name: "value", value: this.value }
  1652. ]
  1653. }, parent);
  1654. };
  1655. return SetStateAction;
  1656. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1657. /**
  1658. * This defines an action responsible to set a property of the target
  1659. * to a desired value once triggered.
  1660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1661. */
  1662. var SetValueAction = /** @class */ (function (_super) {
  1663. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1664. /**
  1665. * Instantiate the action
  1666. * @param triggerOptions defines the trigger options
  1667. * @param target defines the object containing the property
  1668. * @param propertyPath defines the path of the property to set in the target
  1669. * @param value defines the value to set in the property
  1670. * @param condition defines the trigger related conditions
  1671. */
  1672. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1673. var _this = _super.call(this, triggerOptions, condition) || this;
  1674. _this.propertyPath = propertyPath;
  1675. _this.value = value;
  1676. _this._target = _this._effectiveTarget = target;
  1677. return _this;
  1678. }
  1679. /** @hidden */
  1680. SetValueAction.prototype._prepare = function () {
  1681. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1682. this._property = this._getProperty(this.propertyPath);
  1683. };
  1684. /**
  1685. * Execute the action and set the targetted property to the desired value.
  1686. */
  1687. SetValueAction.prototype.execute = function () {
  1688. this._effectiveTarget[this._property] = this.value;
  1689. if (this._target.markAsDirty) {
  1690. this._target.markAsDirty(this._property);
  1691. }
  1692. };
  1693. /**
  1694. * Serializes the actions and its related information.
  1695. * @param parent defines the object to serialize in
  1696. * @returns the serialized object
  1697. */
  1698. SetValueAction.prototype.serialize = function (parent) {
  1699. return _super.prototype._serialize.call(this, {
  1700. name: "SetValueAction",
  1701. properties: [
  1702. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1703. { name: "propertyPath", value: this.propertyPath },
  1704. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1705. ]
  1706. }, parent);
  1707. };
  1708. return SetValueAction;
  1709. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1710. /**
  1711. * This defines an action responsible to increment the target value
  1712. * to a desired value once triggered.
  1713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1714. */
  1715. var IncrementValueAction = /** @class */ (function (_super) {
  1716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1717. /**
  1718. * Instantiate the action
  1719. * @param triggerOptions defines the trigger options
  1720. * @param target defines the object containing the property
  1721. * @param propertyPath defines the path of the property to increment in the target
  1722. * @param value defines the value value we should increment the property by
  1723. * @param condition defines the trigger related conditions
  1724. */
  1725. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1726. var _this = _super.call(this, triggerOptions, condition) || this;
  1727. _this.propertyPath = propertyPath;
  1728. _this.value = value;
  1729. _this._target = _this._effectiveTarget = target;
  1730. return _this;
  1731. }
  1732. /** @hidden */
  1733. IncrementValueAction.prototype._prepare = function () {
  1734. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1735. this._property = this._getProperty(this.propertyPath);
  1736. if (typeof this._effectiveTarget[this._property] !== "number") {
  1737. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1738. }
  1739. };
  1740. /**
  1741. * Execute the action and increment the target of the value amount.
  1742. */
  1743. IncrementValueAction.prototype.execute = function () {
  1744. this._effectiveTarget[this._property] += this.value;
  1745. if (this._target.markAsDirty) {
  1746. this._target.markAsDirty(this._property);
  1747. }
  1748. };
  1749. /**
  1750. * Serializes the actions and its related information.
  1751. * @param parent defines the object to serialize in
  1752. * @returns the serialized object
  1753. */
  1754. IncrementValueAction.prototype.serialize = function (parent) {
  1755. return _super.prototype._serialize.call(this, {
  1756. name: "IncrementValueAction",
  1757. properties: [
  1758. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1759. { name: "propertyPath", value: this.propertyPath },
  1760. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1761. ]
  1762. }, parent);
  1763. };
  1764. return IncrementValueAction;
  1765. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1766. /**
  1767. * This defines an action responsible to start an animation once triggered.
  1768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1769. */
  1770. var PlayAnimationAction = /** @class */ (function (_super) {
  1771. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1772. /**
  1773. * Instantiate the action
  1774. * @param triggerOptions defines the trigger options
  1775. * @param target defines the target animation or animation name
  1776. * @param from defines from where the animation should start (animation frame)
  1777. * @param end defines where the animation should stop (animation frame)
  1778. * @param loop defines if the animation should loop or stop after the first play
  1779. * @param condition defines the trigger related conditions
  1780. */
  1781. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1782. var _this = _super.call(this, triggerOptions, condition) || this;
  1783. _this.from = from;
  1784. _this.to = to;
  1785. _this.loop = loop;
  1786. _this._target = target;
  1787. return _this;
  1788. }
  1789. /** @hidden */
  1790. PlayAnimationAction.prototype._prepare = function () {
  1791. };
  1792. /**
  1793. * Execute the action and play the animation.
  1794. */
  1795. PlayAnimationAction.prototype.execute = function () {
  1796. var scene = this._actionManager.getScene();
  1797. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1798. };
  1799. /**
  1800. * Serializes the actions and its related information.
  1801. * @param parent defines the object to serialize in
  1802. * @returns the serialized object
  1803. */
  1804. PlayAnimationAction.prototype.serialize = function (parent) {
  1805. return _super.prototype._serialize.call(this, {
  1806. name: "PlayAnimationAction",
  1807. properties: [
  1808. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1809. { name: "from", value: String(this.from) },
  1810. { name: "to", value: String(this.to) },
  1811. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1812. ]
  1813. }, parent);
  1814. };
  1815. return PlayAnimationAction;
  1816. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1817. /**
  1818. * This defines an action responsible to stop an animation once triggered.
  1819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1820. */
  1821. var StopAnimationAction = /** @class */ (function (_super) {
  1822. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1823. /**
  1824. * Instantiate the action
  1825. * @param triggerOptions defines the trigger options
  1826. * @param target defines the target animation or animation name
  1827. * @param condition defines the trigger related conditions
  1828. */
  1829. function StopAnimationAction(triggerOptions, target, condition) {
  1830. var _this = _super.call(this, triggerOptions, condition) || this;
  1831. _this._target = target;
  1832. return _this;
  1833. }
  1834. /** @hidden */
  1835. StopAnimationAction.prototype._prepare = function () {
  1836. };
  1837. /**
  1838. * Execute the action and stop the animation.
  1839. */
  1840. StopAnimationAction.prototype.execute = function () {
  1841. var scene = this._actionManager.getScene();
  1842. scene.stopAnimation(this._target);
  1843. };
  1844. /**
  1845. * Serializes the actions and its related information.
  1846. * @param parent defines the object to serialize in
  1847. * @returns the serialized object
  1848. */
  1849. StopAnimationAction.prototype.serialize = function (parent) {
  1850. return _super.prototype._serialize.call(this, {
  1851. name: "StopAnimationAction",
  1852. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1853. }, parent);
  1854. };
  1855. return StopAnimationAction;
  1856. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1857. /**
  1858. * This defines an action responsible that does nothing once triggered.
  1859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1860. */
  1861. var DoNothingAction = /** @class */ (function (_super) {
  1862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1863. /**
  1864. * Instantiate the action
  1865. * @param triggerOptions defines the trigger options
  1866. * @param condition defines the trigger related conditions
  1867. */
  1868. function DoNothingAction(triggerOptions, condition) {
  1869. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1870. return _super.call(this, triggerOptions, condition) || this;
  1871. }
  1872. /**
  1873. * Execute the action and do nothing.
  1874. */
  1875. DoNothingAction.prototype.execute = function () {
  1876. };
  1877. /**
  1878. * Serializes the actions and its related information.
  1879. * @param parent defines the object to serialize in
  1880. * @returns the serialized object
  1881. */
  1882. DoNothingAction.prototype.serialize = function (parent) {
  1883. return _super.prototype._serialize.call(this, {
  1884. name: "DoNothingAction",
  1885. properties: []
  1886. }, parent);
  1887. };
  1888. return DoNothingAction;
  1889. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1890. /**
  1891. * This defines an action responsible to trigger several actions once triggered.
  1892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1893. */
  1894. var CombineAction = /** @class */ (function (_super) {
  1895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1896. /**
  1897. * Instantiate the action
  1898. * @param triggerOptions defines the trigger options
  1899. * @param children defines the list of aggregated animations to run
  1900. * @param condition defines the trigger related conditions
  1901. */
  1902. function CombineAction(triggerOptions, children, condition) {
  1903. var _this = _super.call(this, triggerOptions, condition) || this;
  1904. _this.children = children;
  1905. return _this;
  1906. }
  1907. /** @hidden */
  1908. CombineAction.prototype._prepare = function () {
  1909. for (var index = 0; index < this.children.length; index++) {
  1910. this.children[index]._actionManager = this._actionManager;
  1911. this.children[index]._prepare();
  1912. }
  1913. };
  1914. /**
  1915. * Execute the action and executes all the aggregated actions.
  1916. */
  1917. CombineAction.prototype.execute = function (evt) {
  1918. for (var index = 0; index < this.children.length; index++) {
  1919. this.children[index].execute(evt);
  1920. }
  1921. };
  1922. /**
  1923. * Serializes the actions and its related information.
  1924. * @param parent defines the object to serialize in
  1925. * @returns the serialized object
  1926. */
  1927. CombineAction.prototype.serialize = function (parent) {
  1928. var serializationObject = _super.prototype._serialize.call(this, {
  1929. name: "CombineAction",
  1930. properties: [],
  1931. combine: []
  1932. }, parent);
  1933. for (var i = 0; i < this.children.length; i++) {
  1934. serializationObject.combine.push(this.children[i].serialize(null));
  1935. }
  1936. return serializationObject;
  1937. };
  1938. return CombineAction;
  1939. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1940. /**
  1941. * This defines an action responsible to run code (external event) once triggered.
  1942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1943. */
  1944. var ExecuteCodeAction = /** @class */ (function (_super) {
  1945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1946. /**
  1947. * Instantiate the action
  1948. * @param triggerOptions defines the trigger options
  1949. * @param func defines the callback function to run
  1950. * @param condition defines the trigger related conditions
  1951. */
  1952. function ExecuteCodeAction(triggerOptions, func, condition) {
  1953. var _this = _super.call(this, triggerOptions, condition) || this;
  1954. _this.func = func;
  1955. return _this;
  1956. }
  1957. /**
  1958. * Execute the action and run the attached code.
  1959. */
  1960. ExecuteCodeAction.prototype.execute = function (evt) {
  1961. this.func(evt);
  1962. };
  1963. return ExecuteCodeAction;
  1964. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1965. /**
  1966. * This defines an action responsible to set the parent property of the target once triggered.
  1967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1968. */
  1969. var SetParentAction = /** @class */ (function (_super) {
  1970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1971. /**
  1972. * Instantiate the action
  1973. * @param triggerOptions defines the trigger options
  1974. * @param target defines the target containing the parent property
  1975. * @param parent defines from where the animation should start (animation frame)
  1976. * @param condition defines the trigger related conditions
  1977. */
  1978. function SetParentAction(triggerOptions, target, parent, condition) {
  1979. var _this = _super.call(this, triggerOptions, condition) || this;
  1980. _this._target = target;
  1981. _this._parent = parent;
  1982. return _this;
  1983. }
  1984. /** @hidden */
  1985. SetParentAction.prototype._prepare = function () {
  1986. };
  1987. /**
  1988. * Execute the action and set the parent property.
  1989. */
  1990. SetParentAction.prototype.execute = function () {
  1991. if (this._target.parent === this._parent) {
  1992. return;
  1993. }
  1994. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1995. invertParentWorldMatrix.invert();
  1996. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  1997. this._target.parent = this._parent;
  1998. };
  1999. /**
  2000. * Serializes the actions and its related information.
  2001. * @param parent defines the object to serialize in
  2002. * @returns the serialized object
  2003. */
  2004. SetParentAction.prototype.serialize = function (parent) {
  2005. return _super.prototype._serialize.call(this, {
  2006. name: "SetParentAction",
  2007. properties: [
  2008. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2009. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2010. ]
  2011. }, parent);
  2012. };
  2013. return SetParentAction;
  2014. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2015. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2016. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2017. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2018. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2024. /***/ }),
  2025. /***/ "./Actions/directAudioActions.ts":
  2026. /*!***************************************!*\
  2027. !*** ./Actions/directAudioActions.ts ***!
  2028. \***************************************/
  2029. /*! exports provided: PlaySoundAction, StopSoundAction */
  2030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2031. "use strict";
  2032. __webpack_require__.r(__webpack_exports__);
  2033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2035. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2036. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2037. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2038. /**
  2039. * This defines an action helpful to play a defined sound on a triggered action.
  2040. */
  2041. var PlaySoundAction = /** @class */ (function (_super) {
  2042. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2043. /**
  2044. * Instantiate the action
  2045. * @param triggerOptions defines the trigger options
  2046. * @param sound defines the sound to play
  2047. * @param condition defines the trigger related conditions
  2048. */
  2049. function PlaySoundAction(triggerOptions, sound, condition) {
  2050. var _this = _super.call(this, triggerOptions, condition) || this;
  2051. _this._sound = sound;
  2052. return _this;
  2053. }
  2054. /** @hidden */
  2055. PlaySoundAction.prototype._prepare = function () {
  2056. };
  2057. /**
  2058. * Execute the action and play the sound.
  2059. */
  2060. PlaySoundAction.prototype.execute = function () {
  2061. if (this._sound !== undefined) {
  2062. this._sound.play();
  2063. }
  2064. };
  2065. /**
  2066. * Serializes the actions and its related information.
  2067. * @param parent defines the object to serialize in
  2068. * @returns the serialized object
  2069. */
  2070. PlaySoundAction.prototype.serialize = function (parent) {
  2071. return _super.prototype._serialize.call(this, {
  2072. name: "PlaySoundAction",
  2073. properties: [{ name: "sound", value: this._sound.name }]
  2074. }, parent);
  2075. };
  2076. return PlaySoundAction;
  2077. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2078. /**
  2079. * This defines an action helpful to stop a defined sound on a triggered action.
  2080. */
  2081. var StopSoundAction = /** @class */ (function (_super) {
  2082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2083. /**
  2084. * Instantiate the action
  2085. * @param triggerOptions defines the trigger options
  2086. * @param sound defines the sound to stop
  2087. * @param condition defines the trigger related conditions
  2088. */
  2089. function StopSoundAction(triggerOptions, sound, condition) {
  2090. var _this = _super.call(this, triggerOptions, condition) || this;
  2091. _this._sound = sound;
  2092. return _this;
  2093. }
  2094. /** @hidden */
  2095. StopSoundAction.prototype._prepare = function () {
  2096. };
  2097. /**
  2098. * Execute the action and stop the sound.
  2099. */
  2100. StopSoundAction.prototype.execute = function () {
  2101. if (this._sound !== undefined) {
  2102. this._sound.stop();
  2103. }
  2104. };
  2105. /**
  2106. * Serializes the actions and its related information.
  2107. * @param parent defines the object to serialize in
  2108. * @returns the serialized object
  2109. */
  2110. StopSoundAction.prototype.serialize = function (parent) {
  2111. return _super.prototype._serialize.call(this, {
  2112. name: "StopSoundAction",
  2113. properties: [{ name: "sound", value: this._sound.name }]
  2114. }, parent);
  2115. };
  2116. return StopSoundAction;
  2117. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2118. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2119. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2120. /***/ }),
  2121. /***/ "./Actions/index.ts":
  2122. /*!**************************!*\
  2123. !*** ./Actions/index.ts ***!
  2124. \**************************/
  2125. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2127. "use strict";
  2128. __webpack_require__.r(__webpack_exports__);
  2129. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2131. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2133. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2135. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2140. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2151. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2154. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2156. /***/ }),
  2157. /***/ "./Actions/interpolateValueAction.ts":
  2158. /*!*******************************************!*\
  2159. !*** ./Actions/interpolateValueAction.ts ***!
  2160. \*******************************************/
  2161. /*! exports provided: InterpolateValueAction */
  2162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2163. "use strict";
  2164. __webpack_require__.r(__webpack_exports__);
  2165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2166. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2167. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2168. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2169. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2170. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2171. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2172. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2173. /**
  2174. * This defines an action responsible to change the value of a property
  2175. * by interpolating between its current value and the newly set one once triggered.
  2176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2177. */
  2178. var InterpolateValueAction = /** @class */ (function (_super) {
  2179. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2180. /**
  2181. * Instantiate the action
  2182. * @param triggerOptions defines the trigger options
  2183. * @param target defines the object containing the value to interpolate
  2184. * @param propertyPath defines the path to the property in the target object
  2185. * @param value defines the target value at the end of the interpolation
  2186. * @param duration deines the time it will take for the property to interpolate to the value.
  2187. * @param condition defines the trigger related conditions
  2188. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2189. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2190. */
  2191. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2192. if (duration === void 0) { duration = 1000; }
  2193. var _this = _super.call(this, triggerOptions, condition) || this;
  2194. /**
  2195. * Defines the time it will take for the property to interpolate to the value.
  2196. */
  2197. _this.duration = 1000;
  2198. /**
  2199. * Observable triggered once the interpolation animation has been done.
  2200. */
  2201. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2202. _this.propertyPath = propertyPath;
  2203. _this.value = value;
  2204. _this.duration = duration;
  2205. _this.stopOtherAnimations = stopOtherAnimations;
  2206. _this.onInterpolationDone = onInterpolationDone;
  2207. _this._target = _this._effectiveTarget = target;
  2208. return _this;
  2209. }
  2210. /** @hidden */
  2211. InterpolateValueAction.prototype._prepare = function () {
  2212. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2213. this._property = this._getProperty(this.propertyPath);
  2214. };
  2215. /**
  2216. * Execute the action starts the value interpolation.
  2217. */
  2218. InterpolateValueAction.prototype.execute = function () {
  2219. var _this = this;
  2220. var scene = this._actionManager.getScene();
  2221. var keys = [
  2222. {
  2223. frame: 0,
  2224. value: this._effectiveTarget[this._property]
  2225. }, {
  2226. frame: 100,
  2227. value: this.value
  2228. }
  2229. ];
  2230. var dataType;
  2231. if (typeof this.value === "number") {
  2232. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2233. }
  2234. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2235. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2236. }
  2237. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2238. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2239. }
  2240. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2241. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2242. }
  2243. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2244. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2245. }
  2246. else {
  2247. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2248. return;
  2249. }
  2250. 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);
  2251. animation.setKeys(keys);
  2252. if (this.stopOtherAnimations) {
  2253. scene.stopAnimation(this._effectiveTarget);
  2254. }
  2255. var wrapper = function () {
  2256. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2257. if (_this.onInterpolationDone) {
  2258. _this.onInterpolationDone();
  2259. }
  2260. };
  2261. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2262. };
  2263. /**
  2264. * Serializes the actions and its related information.
  2265. * @param parent defines the object to serialize in
  2266. * @returns the serialized object
  2267. */
  2268. InterpolateValueAction.prototype.serialize = function (parent) {
  2269. return _super.prototype._serialize.call(this, {
  2270. name: "InterpolateValueAction",
  2271. properties: [
  2272. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2273. { name: "propertyPath", value: this.propertyPath },
  2274. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2275. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2276. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2277. ]
  2278. }, parent);
  2279. };
  2280. return InterpolateValueAction;
  2281. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2282. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2283. /***/ }),
  2284. /***/ "./Animations/animatable.ts":
  2285. /*!**********************************!*\
  2286. !*** ./Animations/animatable.ts ***!
  2287. \**********************************/
  2288. /*! exports provided: Animatable */
  2289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2290. "use strict";
  2291. __webpack_require__.r(__webpack_exports__);
  2292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2293. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2294. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2295. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2296. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2298. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2299. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2300. /**
  2301. * Class used to store an actual running animation
  2302. */
  2303. var Animatable = /** @class */ (function () {
  2304. /**
  2305. * Creates a new Animatable
  2306. * @param scene defines the hosting scene
  2307. * @param target defines the target object
  2308. * @param fromFrame defines the starting frame number (default is 0)
  2309. * @param toFrame defines the ending frame number (default is 100)
  2310. * @param loopAnimation defines if the animation must loop (default is false)
  2311. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2312. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2313. * @param animations defines a group of animation to add to the new Animatable
  2314. * @param onAnimationLoop defines a callback to call when animation loops
  2315. */
  2316. function Animatable(scene,
  2317. /** defines the target object */
  2318. target,
  2319. /** defines the starting frame number (default is 0) */
  2320. fromFrame,
  2321. /** defines the ending frame number (default is 100) */
  2322. toFrame,
  2323. /** defines if the animation must loop (default is false) */
  2324. loopAnimation, speedRatio,
  2325. /** defines a callback to call when animation ends if it is not looping */
  2326. onAnimationEnd, animations,
  2327. /** defines a callback to call when animation loops */
  2328. onAnimationLoop) {
  2329. if (fromFrame === void 0) { fromFrame = 0; }
  2330. if (toFrame === void 0) { toFrame = 100; }
  2331. if (loopAnimation === void 0) { loopAnimation = false; }
  2332. if (speedRatio === void 0) { speedRatio = 1.0; }
  2333. this.target = target;
  2334. this.fromFrame = fromFrame;
  2335. this.toFrame = toFrame;
  2336. this.loopAnimation = loopAnimation;
  2337. this.onAnimationEnd = onAnimationEnd;
  2338. this.onAnimationLoop = onAnimationLoop;
  2339. this._localDelayOffset = null;
  2340. this._pausedDelay = null;
  2341. this._runtimeAnimations = new Array();
  2342. this._paused = false;
  2343. this._speedRatio = 1;
  2344. this._weight = -1.0;
  2345. /**
  2346. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2347. * This will only apply for non looping animation (default is true)
  2348. */
  2349. this.disposeOnEnd = true;
  2350. /**
  2351. * Gets a boolean indicating if the animation has started
  2352. */
  2353. this.animationStarted = false;
  2354. /**
  2355. * Observer raised when the animation ends
  2356. */
  2357. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2358. /**
  2359. * Observer raised when the animation loops
  2360. */
  2361. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. this._scene = scene;
  2363. if (animations) {
  2364. this.appendAnimations(target, animations);
  2365. }
  2366. this._speedRatio = speedRatio;
  2367. scene._activeAnimatables.push(this);
  2368. }
  2369. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2370. /**
  2371. * Gets the root Animatable used to synchronize and normalize animations
  2372. */
  2373. get: function () {
  2374. return this._syncRoot;
  2375. },
  2376. enumerable: true,
  2377. configurable: true
  2378. });
  2379. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2380. /**
  2381. * Gets the current frame of the first RuntimeAnimation
  2382. * Used to synchronize Animatables
  2383. */
  2384. get: function () {
  2385. if (this._runtimeAnimations.length === 0) {
  2386. return 0;
  2387. }
  2388. return this._runtimeAnimations[0].currentFrame;
  2389. },
  2390. enumerable: true,
  2391. configurable: true
  2392. });
  2393. Object.defineProperty(Animatable.prototype, "weight", {
  2394. /**
  2395. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2396. */
  2397. get: function () {
  2398. return this._weight;
  2399. },
  2400. set: function (value) {
  2401. if (value === -1) { // -1 is ok and means no weight
  2402. this._weight = -1;
  2403. return;
  2404. }
  2405. // Else weight must be in [0, 1] range
  2406. this._weight = Math.min(Math.max(value, 0), 1.0);
  2407. },
  2408. enumerable: true,
  2409. configurable: true
  2410. });
  2411. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2412. /**
  2413. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2414. */
  2415. get: function () {
  2416. return this._speedRatio;
  2417. },
  2418. set: function (value) {
  2419. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2420. var animation = this._runtimeAnimations[index];
  2421. animation._prepareForSpeedRatioChange(value);
  2422. }
  2423. this._speedRatio = value;
  2424. },
  2425. enumerable: true,
  2426. configurable: true
  2427. });
  2428. // Methods
  2429. /**
  2430. * Synchronize and normalize current Animatable with a source Animatable
  2431. * This is useful when using animation weights and when animations are not of the same length
  2432. * @param root defines the root Animatable to synchronize with
  2433. * @returns the current Animatable
  2434. */
  2435. Animatable.prototype.syncWith = function (root) {
  2436. this._syncRoot = root;
  2437. if (root) {
  2438. // Make sure this animatable will animate after the root
  2439. var index = this._scene._activeAnimatables.indexOf(this);
  2440. if (index > -1) {
  2441. this._scene._activeAnimatables.splice(index, 1);
  2442. this._scene._activeAnimatables.push(this);
  2443. }
  2444. }
  2445. return this;
  2446. };
  2447. /**
  2448. * Gets the list of runtime animations
  2449. * @returns an array of RuntimeAnimation
  2450. */
  2451. Animatable.prototype.getAnimations = function () {
  2452. return this._runtimeAnimations;
  2453. };
  2454. /**
  2455. * Adds more animations to the current animatable
  2456. * @param target defines the target of the animations
  2457. * @param animations defines the new animations to add
  2458. */
  2459. Animatable.prototype.appendAnimations = function (target, animations) {
  2460. for (var index = 0; index < animations.length; index++) {
  2461. var animation = animations[index];
  2462. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2463. }
  2464. };
  2465. /**
  2466. * Gets the source animation for a specific property
  2467. * @param property defines the propertyu to look for
  2468. * @returns null or the source animation for the given property
  2469. */
  2470. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2471. var runtimeAnimations = this._runtimeAnimations;
  2472. for (var index = 0; index < runtimeAnimations.length; index++) {
  2473. if (runtimeAnimations[index].animation.targetProperty === property) {
  2474. return runtimeAnimations[index].animation;
  2475. }
  2476. }
  2477. return null;
  2478. };
  2479. /**
  2480. * Gets the runtime animation for a specific property
  2481. * @param property defines the propertyu to look for
  2482. * @returns null or the runtime animation for the given property
  2483. */
  2484. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2485. var runtimeAnimations = this._runtimeAnimations;
  2486. for (var index = 0; index < runtimeAnimations.length; index++) {
  2487. if (runtimeAnimations[index].animation.targetProperty === property) {
  2488. return runtimeAnimations[index];
  2489. }
  2490. }
  2491. return null;
  2492. };
  2493. /**
  2494. * Resets the animatable to its original state
  2495. */
  2496. Animatable.prototype.reset = function () {
  2497. var runtimeAnimations = this._runtimeAnimations;
  2498. for (var index = 0; index < runtimeAnimations.length; index++) {
  2499. runtimeAnimations[index].reset(true);
  2500. }
  2501. this._localDelayOffset = null;
  2502. this._pausedDelay = null;
  2503. };
  2504. /**
  2505. * Allows the animatable to blend with current running animations
  2506. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2507. * @param blendingSpeed defines the blending speed to use
  2508. */
  2509. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2510. var runtimeAnimations = this._runtimeAnimations;
  2511. for (var index = 0; index < runtimeAnimations.length; index++) {
  2512. runtimeAnimations[index].animation.enableBlending = true;
  2513. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2514. }
  2515. };
  2516. /**
  2517. * Disable animation blending
  2518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2519. */
  2520. Animatable.prototype.disableBlending = function () {
  2521. var runtimeAnimations = this._runtimeAnimations;
  2522. for (var index = 0; index < runtimeAnimations.length; index++) {
  2523. runtimeAnimations[index].animation.enableBlending = false;
  2524. }
  2525. };
  2526. /**
  2527. * Jump directly to a given frame
  2528. * @param frame defines the frame to jump to
  2529. */
  2530. Animatable.prototype.goToFrame = function (frame) {
  2531. var runtimeAnimations = this._runtimeAnimations;
  2532. if (runtimeAnimations[0]) {
  2533. var fps = runtimeAnimations[0].animation.framePerSecond;
  2534. var currentFrame = runtimeAnimations[0].currentFrame;
  2535. var adjustTime = frame - currentFrame;
  2536. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2537. if (this._localDelayOffset === null) {
  2538. this._localDelayOffset = 0;
  2539. }
  2540. this._localDelayOffset -= delay;
  2541. }
  2542. for (var index = 0; index < runtimeAnimations.length; index++) {
  2543. runtimeAnimations[index].goToFrame(frame);
  2544. }
  2545. };
  2546. /**
  2547. * Pause the animation
  2548. */
  2549. Animatable.prototype.pause = function () {
  2550. if (this._paused) {
  2551. return;
  2552. }
  2553. this._paused = true;
  2554. };
  2555. /**
  2556. * Restart the animation
  2557. */
  2558. Animatable.prototype.restart = function () {
  2559. this._paused = false;
  2560. };
  2561. Animatable.prototype._raiseOnAnimationEnd = function () {
  2562. if (this.onAnimationEnd) {
  2563. this.onAnimationEnd();
  2564. }
  2565. this.onAnimationEndObservable.notifyObservers(this);
  2566. };
  2567. /**
  2568. * Stop and delete the current animation
  2569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2570. * @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)
  2571. */
  2572. Animatable.prototype.stop = function (animationName, targetMask) {
  2573. if (animationName || targetMask) {
  2574. var idx = this._scene._activeAnimatables.indexOf(this);
  2575. if (idx > -1) {
  2576. var runtimeAnimations = this._runtimeAnimations;
  2577. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2578. var runtimeAnimation = runtimeAnimations[index];
  2579. if (animationName && runtimeAnimation.animation.name != animationName) {
  2580. continue;
  2581. }
  2582. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2583. continue;
  2584. }
  2585. runtimeAnimation.dispose();
  2586. runtimeAnimations.splice(index, 1);
  2587. }
  2588. if (runtimeAnimations.length == 0) {
  2589. this._scene._activeAnimatables.splice(idx, 1);
  2590. this._raiseOnAnimationEnd();
  2591. }
  2592. }
  2593. }
  2594. else {
  2595. var index = this._scene._activeAnimatables.indexOf(this);
  2596. if (index > -1) {
  2597. this._scene._activeAnimatables.splice(index, 1);
  2598. var runtimeAnimations = this._runtimeAnimations;
  2599. for (var index = 0; index < runtimeAnimations.length; index++) {
  2600. runtimeAnimations[index].dispose();
  2601. }
  2602. this._raiseOnAnimationEnd();
  2603. }
  2604. }
  2605. };
  2606. /**
  2607. * Wait asynchronously for the animation to end
  2608. * @returns a promise which will be fullfilled when the animation ends
  2609. */
  2610. Animatable.prototype.waitAsync = function () {
  2611. var _this = this;
  2612. return new Promise(function (resolve, reject) {
  2613. _this.onAnimationEndObservable.add(function () {
  2614. resolve(_this);
  2615. }, undefined, undefined, _this, true);
  2616. });
  2617. };
  2618. /** @hidden */
  2619. Animatable.prototype._animate = function (delay) {
  2620. var _this = this;
  2621. if (this._paused) {
  2622. this.animationStarted = false;
  2623. if (this._pausedDelay === null) {
  2624. this._pausedDelay = delay;
  2625. }
  2626. return true;
  2627. }
  2628. if (this._localDelayOffset === null) {
  2629. this._localDelayOffset = delay;
  2630. this._pausedDelay = null;
  2631. }
  2632. else if (this._pausedDelay !== null) {
  2633. this._localDelayOffset += delay - this._pausedDelay;
  2634. this._pausedDelay = null;
  2635. }
  2636. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2637. return true;
  2638. }
  2639. // Animating
  2640. var running = false;
  2641. var runtimeAnimations = this._runtimeAnimations;
  2642. var index;
  2643. for (index = 0; index < runtimeAnimations.length; index++) {
  2644. var animation = runtimeAnimations[index];
  2645. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2646. _this.onAnimationLoopObservable.notifyObservers(_this);
  2647. if (_this.onAnimationLoop) {
  2648. _this.onAnimationLoop();
  2649. }
  2650. });
  2651. running = running || isRunning;
  2652. }
  2653. this.animationStarted = running;
  2654. if (!running) {
  2655. if (this.disposeOnEnd) {
  2656. // Remove from active animatables
  2657. index = this._scene._activeAnimatables.indexOf(this);
  2658. this._scene._activeAnimatables.splice(index, 1);
  2659. // Dispose all runtime animations
  2660. for (index = 0; index < runtimeAnimations.length; index++) {
  2661. runtimeAnimations[index].dispose();
  2662. }
  2663. }
  2664. this._raiseOnAnimationEnd();
  2665. if (this.disposeOnEnd) {
  2666. this.onAnimationEnd = null;
  2667. this.onAnimationLoop = null;
  2668. this.onAnimationLoopObservable.clear();
  2669. this.onAnimationEndObservable.clear();
  2670. }
  2671. }
  2672. return running;
  2673. };
  2674. return Animatable;
  2675. }());
  2676. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2677. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2678. return;
  2679. }
  2680. // Getting time
  2681. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2682. if (!this._animationTimeLast) {
  2683. if (this._pendingData.length > 0) {
  2684. return;
  2685. }
  2686. this._animationTimeLast = now;
  2687. }
  2688. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2689. this._animationTime += deltaTime;
  2690. this._animationTimeLast = now;
  2691. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2692. this._activeAnimatables[index]._animate(this._animationTime);
  2693. }
  2694. // Late animation bindings
  2695. this._processLateAnimationBindings();
  2696. };
  2697. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2698. if (weight === void 0) { weight = 1.0; }
  2699. if (speedRatio === void 0) { speedRatio = 1.0; }
  2700. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2701. returnedAnimatable.weight = weight;
  2702. return returnedAnimatable;
  2703. };
  2704. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2705. if (speedRatio === void 0) { speedRatio = 1.0; }
  2706. if (stopCurrent === void 0) { stopCurrent = true; }
  2707. if (from > to && speedRatio > 0) {
  2708. speedRatio *= -1;
  2709. }
  2710. if (stopCurrent) {
  2711. this.stopAnimation(target, undefined, targetMask);
  2712. }
  2713. if (!animatable) {
  2714. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2715. }
  2716. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2717. // Local animations
  2718. if (target.animations && shouldRunTargetAnimations) {
  2719. animatable.appendAnimations(target, target.animations);
  2720. }
  2721. // Children animations
  2722. if (target.getAnimatables) {
  2723. var animatables = target.getAnimatables();
  2724. for (var index = 0; index < animatables.length; index++) {
  2725. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2726. }
  2727. }
  2728. animatable.reset();
  2729. return animatable;
  2730. };
  2731. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2732. if (speedRatio === void 0) { speedRatio = 1.0; }
  2733. if (stopCurrent === void 0) { stopCurrent = true; }
  2734. var children = target.getDescendants(directDescendantsOnly);
  2735. var result = [];
  2736. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2737. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2738. var child = children_1[_i];
  2739. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2740. }
  2741. return result;
  2742. };
  2743. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2744. if (speedRatio === undefined) {
  2745. speedRatio = 1.0;
  2746. }
  2747. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2748. return animatable;
  2749. };
  2750. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2751. var children = target.getDescendants(directDescendantsOnly);
  2752. var result = [];
  2753. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2754. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2755. var child = children_2[_i];
  2756. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2757. }
  2758. return result;
  2759. };
  2760. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2761. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2762. if (this._activeAnimatables[index].target === target) {
  2763. return this._activeAnimatables[index];
  2764. }
  2765. }
  2766. return null;
  2767. };
  2768. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2769. var result = [];
  2770. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2771. if (this._activeAnimatables[index].target === target) {
  2772. result.push(this._activeAnimatables[index]);
  2773. }
  2774. }
  2775. return result;
  2776. };
  2777. /**
  2778. * Will stop the animation of the given target
  2779. * @param target - the target
  2780. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2781. * @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)
  2782. */
  2783. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2784. var animatables = this.getAllAnimatablesByTarget(target);
  2785. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2786. var animatable = animatables_1[_i];
  2787. animatable.stop(animationName, targetMask);
  2788. }
  2789. };
  2790. /**
  2791. * Stops and removes all animations that have been applied to the scene
  2792. */
  2793. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2794. if (this._activeAnimatables) {
  2795. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2796. this._activeAnimatables[i].stop();
  2797. }
  2798. this._activeAnimatables = [];
  2799. }
  2800. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2801. var group = _a[_i];
  2802. group.stop();
  2803. }
  2804. };
  2805. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2806. var target = runtimeAnimation.target;
  2807. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2808. if (!target._lateAnimationHolders) {
  2809. target._lateAnimationHolders = {};
  2810. }
  2811. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2812. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2813. totalWeight: 0,
  2814. animations: [],
  2815. originalValue: originalValue
  2816. };
  2817. }
  2818. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2819. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2820. };
  2821. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2822. var normalizer = 1.0;
  2823. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2824. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2825. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2826. var startIndex = 0;
  2827. var originalAnimation = holder.animations[0];
  2828. var originalValue = holder.originalValue;
  2829. var scale = 1;
  2830. if (holder.totalWeight < 1.0) {
  2831. // We need to mix the original value in
  2832. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2833. scale = 1.0 - holder.totalWeight;
  2834. }
  2835. else {
  2836. startIndex = 1;
  2837. // We need to normalize the weights
  2838. normalizer = holder.totalWeight;
  2839. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2840. scale = originalAnimation.weight / normalizer;
  2841. if (scale == 1) {
  2842. return originalAnimation.currentValue;
  2843. }
  2844. }
  2845. finalScaling.scaleInPlace(scale);
  2846. finalPosition.scaleInPlace(scale);
  2847. finalQuaternion.scaleInPlace(scale);
  2848. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2849. var runtimeAnimation = holder.animations[animIndex];
  2850. var scale = runtimeAnimation.weight / normalizer;
  2851. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2852. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2853. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2854. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2855. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2856. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2857. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2858. }
  2859. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2860. return originalAnimation._workValue;
  2861. };
  2862. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2863. var originalAnimation = holder.animations[0];
  2864. var originalValue = holder.originalValue;
  2865. if (holder.animations.length === 1) {
  2866. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2867. return refQuaternion;
  2868. }
  2869. var normalizer = 1.0;
  2870. var quaternions;
  2871. var weights;
  2872. if (holder.totalWeight < 1.0) {
  2873. var scale = 1.0 - holder.totalWeight;
  2874. quaternions = [];
  2875. weights = [];
  2876. quaternions.push(originalValue);
  2877. weights.push(scale);
  2878. }
  2879. else {
  2880. if (holder.animations.length === 2) { // Slerp as soon as we can
  2881. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2882. return refQuaternion;
  2883. }
  2884. quaternions = [];
  2885. weights = [];
  2886. normalizer = holder.totalWeight;
  2887. }
  2888. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2889. var runtimeAnimation = holder.animations[animIndex];
  2890. quaternions.push(runtimeAnimation.currentValue);
  2891. weights.push(runtimeAnimation.weight / normalizer);
  2892. }
  2893. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2894. var cumulativeAmount = 0;
  2895. var cumulativeQuaternion = null;
  2896. for (var index = 0; index < quaternions.length;) {
  2897. if (!cumulativeQuaternion) {
  2898. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2899. cumulativeQuaternion = refQuaternion;
  2900. cumulativeAmount = weights[index] + weights[index + 1];
  2901. index += 2;
  2902. continue;
  2903. }
  2904. cumulativeAmount += weights[index];
  2905. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2906. index++;
  2907. }
  2908. return cumulativeQuaternion;
  2909. };
  2910. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2911. if (!this._registeredForLateAnimationBindings.length) {
  2912. return;
  2913. }
  2914. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2915. var target = this._registeredForLateAnimationBindings.data[index];
  2916. for (var path in target._lateAnimationHolders) {
  2917. var holder = target._lateAnimationHolders[path];
  2918. var originalAnimation = holder.animations[0];
  2919. var originalValue = holder.originalValue;
  2920. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2921. var finalValue = target[path];
  2922. if (matrixDecomposeMode) {
  2923. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2924. }
  2925. else {
  2926. var quaternionMode = originalValue.w !== undefined;
  2927. if (quaternionMode) {
  2928. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2929. }
  2930. else {
  2931. var startIndex = 0;
  2932. var normalizer = 1.0;
  2933. if (holder.totalWeight < 1.0) {
  2934. // We need to mix the original value in
  2935. if (originalValue.scale) {
  2936. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2937. }
  2938. else {
  2939. finalValue = originalValue * (1.0 - holder.totalWeight);
  2940. }
  2941. }
  2942. else {
  2943. // We need to normalize the weights
  2944. normalizer = holder.totalWeight;
  2945. var scale_1 = originalAnimation.weight / normalizer;
  2946. if (scale_1 !== 1) {
  2947. if (originalAnimation.currentValue.scale) {
  2948. finalValue = originalAnimation.currentValue.scale(scale_1);
  2949. }
  2950. else {
  2951. finalValue = originalAnimation.currentValue * scale_1;
  2952. }
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue;
  2956. }
  2957. startIndex = 1;
  2958. }
  2959. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2960. var runtimeAnimation = holder.animations[animIndex];
  2961. var scale = runtimeAnimation.weight / normalizer;
  2962. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2963. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2964. }
  2965. else {
  2966. finalValue += runtimeAnimation.currentValue * scale;
  2967. }
  2968. }
  2969. }
  2970. }
  2971. target[path] = finalValue;
  2972. }
  2973. target._lateAnimationHolders = {};
  2974. }
  2975. this._registeredForLateAnimationBindings.reset();
  2976. };
  2977. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2978. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2979. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2980. // all animation may be coming from a library skeleton, so may need to create animation
  2981. if (this.animations.length === 0) {
  2982. 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));
  2983. this.animations[0].setKeys([]);
  2984. }
  2985. // get animation info / verify there is such a range from the source bone
  2986. var sourceRange = source.animations[0].getRange(rangeName);
  2987. if (!sourceRange) {
  2988. return false;
  2989. }
  2990. var from = sourceRange.from;
  2991. var to = sourceRange.to;
  2992. var sourceKeys = source.animations[0].getKeys();
  2993. // rescaling prep
  2994. var sourceBoneLength = source.length;
  2995. var sourceParent = source.getParent();
  2996. var parent = this.getParent();
  2997. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  2998. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  2999. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3000. var destKeys = this.animations[0].getKeys();
  3001. // loop vars declaration
  3002. var orig;
  3003. var origTranslation;
  3004. var mat;
  3005. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3006. orig = sourceKeys[key];
  3007. if (orig.frame >= from && orig.frame <= to) {
  3008. if (rescaleAsRequired) {
  3009. mat = orig.value.clone();
  3010. // scale based on parent ratio, when bone has parent
  3011. if (parentScalingReqd) {
  3012. origTranslation = mat.getTranslation();
  3013. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3014. // scale based on skeleton dimension ratio when root bone, and value is passed
  3015. }
  3016. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3017. origTranslation = mat.getTranslation();
  3018. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3019. // use original when root bone, and no data for skelDimensionsRatio
  3020. }
  3021. else {
  3022. mat = orig.value;
  3023. }
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3029. }
  3030. }
  3031. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3032. return true;
  3033. };
  3034. /***/ }),
  3035. /***/ "./Animations/animation.ts":
  3036. /*!*********************************!*\
  3037. !*** ./Animations/animation.ts ***!
  3038. \*********************************/
  3039. /*! exports provided: Animation */
  3040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3041. "use strict";
  3042. __webpack_require__.r(__webpack_exports__);
  3043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3044. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3045. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3046. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3047. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3048. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3049. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3050. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3051. /**
  3052. * Class used to store any kind of animation
  3053. */
  3054. var Animation = /** @class */ (function () {
  3055. /**
  3056. * Initializes the animation
  3057. * @param name Name of the animation
  3058. * @param targetProperty Property to animate
  3059. * @param framePerSecond The frames per second of the animation
  3060. * @param dataType The data type of the animation
  3061. * @param loopMode The loop mode of the animation
  3062. * @param enableBlending Specifies if blending should be enabled
  3063. */
  3064. function Animation(
  3065. /**Name of the animation */
  3066. name,
  3067. /**Property to animate */
  3068. targetProperty,
  3069. /**The frames per second of the animation */
  3070. framePerSecond,
  3071. /**The data type of the animation */
  3072. dataType,
  3073. /**The loop mode of the animation */
  3074. loopMode,
  3075. /**Specifies if blending should be enabled */
  3076. enableBlending) {
  3077. this.name = name;
  3078. this.targetProperty = targetProperty;
  3079. this.framePerSecond = framePerSecond;
  3080. this.dataType = dataType;
  3081. this.loopMode = loopMode;
  3082. this.enableBlending = enableBlending;
  3083. /**
  3084. * @hidden Internal use only
  3085. */
  3086. this._runtimeAnimations = new Array();
  3087. /**
  3088. * The set of event that will be linked to this animation
  3089. */
  3090. this._events = new Array();
  3091. /**
  3092. * Stores the blending speed of the animation
  3093. */
  3094. this.blendingSpeed = 0.01;
  3095. /**
  3096. * Stores the animation ranges for the animation
  3097. */
  3098. this._ranges = {};
  3099. this.targetPropertyPath = targetProperty.split(".");
  3100. this.dataType = dataType;
  3101. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3102. }
  3103. /**
  3104. * @hidden Internal use
  3105. */
  3106. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3107. var dataType = undefined;
  3108. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3109. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3110. }
  3111. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3112. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3113. }
  3114. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3115. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3116. }
  3117. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3118. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3119. }
  3120. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3121. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3122. }
  3123. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3124. dataType = Animation.ANIMATIONTYPE_SIZE;
  3125. }
  3126. if (dataType == undefined) {
  3127. return null;
  3128. }
  3129. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3130. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3131. animation.setKeys(keys);
  3132. if (easingFunction !== undefined) {
  3133. animation.setEasingFunction(easingFunction);
  3134. }
  3135. return animation;
  3136. };
  3137. /**
  3138. * Sets up an animation
  3139. * @param property The property to animate
  3140. * @param animationType The animation type to apply
  3141. * @param framePerSecond The frames per second of the animation
  3142. * @param easingFunction The easing function used in the animation
  3143. * @returns The created animation
  3144. */
  3145. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3146. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3147. animation.setEasingFunction(easingFunction);
  3148. return animation;
  3149. };
  3150. /**
  3151. * Create and start an animation on a node
  3152. * @param name defines the name of the global animation that will be run on all nodes
  3153. * @param node defines the root node where the animation will take place
  3154. * @param targetProperty defines property to animate
  3155. * @param framePerSecond defines the number of frame per second yo use
  3156. * @param totalFrame defines the number of frames in total
  3157. * @param from defines the initial value
  3158. * @param to defines the final value
  3159. * @param loopMode defines which loop mode you want to use (off by default)
  3160. * @param easingFunction defines the easing function to use (linear by default)
  3161. * @param onAnimationEnd defines the callback to call when animation end
  3162. * @returns the animatable created for this animation
  3163. */
  3164. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3165. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3166. if (!animation) {
  3167. return null;
  3168. }
  3169. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3170. };
  3171. /**
  3172. * Create and start an animation on a node and its descendants
  3173. * @param name defines the name of the global animation that will be run on all nodes
  3174. * @param node defines the root node where the animation will take place
  3175. * @param 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
  3176. * @param targetProperty defines property to animate
  3177. * @param framePerSecond defines the number of frame per second to 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 an animation ends (will be called once per node)
  3184. * @returns the list of animatables created for all nodes
  3185. * @example https://www.babylonjs-playground.com/#MH0VLI
  3186. */
  3187. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3188. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3189. if (!animation) {
  3190. return null;
  3191. }
  3192. var scene = node.getScene();
  3193. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3194. };
  3195. /**
  3196. * Creates a new animation, merges it with the existing animations and starts it
  3197. * @param name Name of the animation
  3198. * @param node Node which contains the scene that begins the animations
  3199. * @param targetProperty Specifies which property to animate
  3200. * @param framePerSecond The frames per second of the animation
  3201. * @param totalFrame The total number of frames
  3202. * @param from The frame at the beginning of the animation
  3203. * @param to The frame at the end of the animation
  3204. * @param loopMode Specifies the loop mode of the animation
  3205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3206. * @param onAnimationEnd Callback to run once the animation is complete
  3207. * @returns Nullable animation
  3208. */
  3209. Animation.CreateMergeAndStartAnimation = function (name, node, 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. node.animations.push(animation);
  3215. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3216. };
  3217. /**
  3218. * Transition property of an host to the target Value
  3219. * @param property The property to transition
  3220. * @param targetValue The target Value of the property
  3221. * @param host The object where the property to animate belongs
  3222. * @param scene Scene used to run the animation
  3223. * @param frameRate Framerate (in frame/s) to use
  3224. * @param transition The transition type we want to use
  3225. * @param duration The duration of the animation, in milliseconds
  3226. * @param onAnimationEnd Callback trigger at the end of the animation
  3227. * @returns Nullable animation
  3228. */
  3229. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3230. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3231. if (duration <= 0) {
  3232. host[property] = targetValue;
  3233. if (onAnimationEnd) {
  3234. onAnimationEnd();
  3235. }
  3236. return null;
  3237. }
  3238. var endFrame = frameRate * (duration / 1000);
  3239. transition.setKeys([{
  3240. frame: 0,
  3241. value: host[property].clone ? host[property].clone() : host[property]
  3242. },
  3243. {
  3244. frame: endFrame,
  3245. value: targetValue
  3246. }]);
  3247. if (!host.animations) {
  3248. host.animations = [];
  3249. }
  3250. host.animations.push(transition);
  3251. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3252. animation.onAnimationEnd = onAnimationEnd;
  3253. return animation;
  3254. };
  3255. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3256. /**
  3257. * Return the array of runtime animations currently using this animation
  3258. */
  3259. get: function () {
  3260. return this._runtimeAnimations;
  3261. },
  3262. enumerable: true,
  3263. configurable: true
  3264. });
  3265. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3266. /**
  3267. * Specifies if any of the runtime animations are currently running
  3268. */
  3269. get: function () {
  3270. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3271. var runtimeAnimation = _a[_i];
  3272. if (!runtimeAnimation.isStopped) {
  3273. return true;
  3274. }
  3275. }
  3276. return false;
  3277. },
  3278. enumerable: true,
  3279. configurable: true
  3280. });
  3281. // Methods
  3282. /**
  3283. * Converts the animation to a string
  3284. * @param fullDetails support for multiple levels of logging within scene loading
  3285. * @returns String form of the animation
  3286. */
  3287. Animation.prototype.toString = function (fullDetails) {
  3288. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3289. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3290. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3291. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3292. if (fullDetails) {
  3293. ret += ", Ranges: {";
  3294. var first = true;
  3295. for (var name in this._ranges) {
  3296. if (first) {
  3297. ret += ", ";
  3298. first = false;
  3299. }
  3300. ret += name;
  3301. }
  3302. ret += "}";
  3303. }
  3304. return ret;
  3305. };
  3306. /**
  3307. * Add an event to this animation
  3308. * @param event Event to add
  3309. */
  3310. Animation.prototype.addEvent = function (event) {
  3311. this._events.push(event);
  3312. };
  3313. /**
  3314. * Remove all events found at the given frame
  3315. * @param frame The frame to remove events from
  3316. */
  3317. Animation.prototype.removeEvents = function (frame) {
  3318. for (var index = 0; index < this._events.length; index++) {
  3319. if (this._events[index].frame === frame) {
  3320. this._events.splice(index, 1);
  3321. index--;
  3322. }
  3323. }
  3324. };
  3325. /**
  3326. * Retrieves all the events from the animation
  3327. * @returns Events from the animation
  3328. */
  3329. Animation.prototype.getEvents = function () {
  3330. return this._events;
  3331. };
  3332. /**
  3333. * Creates an animation range
  3334. * @param name Name of the animation range
  3335. * @param from Starting frame of the animation range
  3336. * @param to Ending frame of the animation
  3337. */
  3338. Animation.prototype.createRange = function (name, from, to) {
  3339. // check name not already in use; could happen for bones after serialized
  3340. if (!this._ranges[name]) {
  3341. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3342. }
  3343. };
  3344. /**
  3345. * Deletes an animation range by name
  3346. * @param name Name of the animation range to delete
  3347. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3348. */
  3349. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3350. if (deleteFrames === void 0) { deleteFrames = true; }
  3351. var range = this._ranges[name];
  3352. if (!range) {
  3353. return;
  3354. }
  3355. if (deleteFrames) {
  3356. var from = range.from;
  3357. var to = range.to;
  3358. // this loop MUST go high to low for multiple splices to work
  3359. for (var key = this._keys.length - 1; key >= 0; key--) {
  3360. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3361. this._keys.splice(key, 1);
  3362. }
  3363. }
  3364. }
  3365. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3366. };
  3367. /**
  3368. * Gets the animation range by name, or null if not defined
  3369. * @param name Name of the animation range
  3370. * @returns Nullable animation range
  3371. */
  3372. Animation.prototype.getRange = function (name) {
  3373. return this._ranges[name];
  3374. };
  3375. /**
  3376. * Gets the key frames from the animation
  3377. * @returns The key frames of the animation
  3378. */
  3379. Animation.prototype.getKeys = function () {
  3380. return this._keys;
  3381. };
  3382. /**
  3383. * Gets the highest frame rate of the animation
  3384. * @returns Highest frame rate of the animation
  3385. */
  3386. Animation.prototype.getHighestFrame = function () {
  3387. var ret = 0;
  3388. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3389. if (ret < this._keys[key].frame) {
  3390. ret = this._keys[key].frame;
  3391. }
  3392. }
  3393. return ret;
  3394. };
  3395. /**
  3396. * Gets the easing function of the animation
  3397. * @returns Easing function of the animation
  3398. */
  3399. Animation.prototype.getEasingFunction = function () {
  3400. return this._easingFunction;
  3401. };
  3402. /**
  3403. * Sets the easing function of the animation
  3404. * @param easingFunction A custom mathematical formula for animation
  3405. */
  3406. Animation.prototype.setEasingFunction = function (easingFunction) {
  3407. this._easingFunction = easingFunction;
  3408. };
  3409. /**
  3410. * Interpolates a scalar linearly
  3411. * @param startValue Start value of the animation curve
  3412. * @param endValue End value of the animation curve
  3413. * @param gradient Scalar amount to interpolate
  3414. * @returns Interpolated scalar value
  3415. */
  3416. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3417. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3418. };
  3419. /**
  3420. * Interpolates a scalar cubically
  3421. * @param startValue Start value of the animation curve
  3422. * @param outTangent End tangent of the animation
  3423. * @param endValue End value of the animation curve
  3424. * @param inTangent Start tangent of the animation curve
  3425. * @param gradient Scalar amount to interpolate
  3426. * @returns Interpolated scalar value
  3427. */
  3428. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3429. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3430. };
  3431. /**
  3432. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  3437. */
  3438. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3439. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3440. };
  3441. /**
  3442. * Interpolates a quaternion cubically
  3443. * @param startValue Start value of the animation curve
  3444. * @param outTangent End tangent of the animation curve
  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 quaternion value
  3449. */
  3450. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3451. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3452. };
  3453. /**
  3454. * Interpolates a Vector3 linearl
  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 scalar value
  3459. */
  3460. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3461. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3462. };
  3463. /**
  3464. * Interpolates a Vector3 cubically
  3465. * @param startValue Start value of the animation curve
  3466. * @param outTangent End tangent of the animation
  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 InterpolatedVector3 value
  3471. */
  3472. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3473. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3474. };
  3475. /**
  3476. * Interpolates a Vector2 linearly
  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 Vector2 value
  3481. */
  3482. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3483. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3484. };
  3485. /**
  3486. * Interpolates a Vector2 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 Interpolated Vector2 value
  3493. */
  3494. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3495. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3496. };
  3497. /**
  3498. * Interpolates a size 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 Size value
  3503. */
  3504. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3505. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3506. };
  3507. /**
  3508. * Interpolates a Color3 linearly
  3509. * @param startValue Start value of the animation curve
  3510. * @param endValue End value of the animation curve
  3511. * @param gradient Scalar amount to interpolate
  3512. * @returns Interpolated Color3 value
  3513. */
  3514. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3515. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3516. };
  3517. /**
  3518. * @hidden Internal use only
  3519. */
  3520. Animation.prototype._getKeyValue = function (value) {
  3521. if (typeof value === "function") {
  3522. return value();
  3523. }
  3524. return value;
  3525. };
  3526. /**
  3527. * @hidden Internal use only
  3528. */
  3529. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3530. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3531. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3532. }
  3533. var keys = this.getKeys();
  3534. // Try to get a hash to find the right key
  3535. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3536. if (keys[startKeyIndex].frame >= currentFrame) {
  3537. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3538. startKeyIndex--;
  3539. }
  3540. }
  3541. for (var key = startKeyIndex; key < keys.length; key++) {
  3542. var endKey = keys[key + 1];
  3543. if (endKey.frame >= currentFrame) {
  3544. var startKey = keys[key];
  3545. var startValue = this._getKeyValue(startKey.value);
  3546. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3547. return startValue;
  3548. }
  3549. var endValue = this._getKeyValue(endKey.value);
  3550. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3551. var frameDelta = endKey.frame - startKey.frame;
  3552. // gradient : percent of currentFrame between the frame inf and the frame sup
  3553. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3554. // check for easingFunction and correction of gradient
  3555. var easingFunction = this.getEasingFunction();
  3556. if (easingFunction != null) {
  3557. gradient = easingFunction.ease(gradient);
  3558. }
  3559. switch (this.dataType) {
  3560. // Float
  3561. case Animation.ANIMATIONTYPE_FLOAT:
  3562. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3563. switch (loopMode) {
  3564. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3565. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3566. return floatValue;
  3567. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3568. return offsetValue * repeatCount + floatValue;
  3569. }
  3570. break;
  3571. // Quaternion
  3572. case Animation.ANIMATIONTYPE_QUATERNION:
  3573. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3574. switch (loopMode) {
  3575. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3576. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3577. return quatValue;
  3578. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3579. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3580. }
  3581. return quatValue;
  3582. // Vector3
  3583. case Animation.ANIMATIONTYPE_VECTOR3:
  3584. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3585. switch (loopMode) {
  3586. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3587. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3588. return vec3Value;
  3589. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3590. return vec3Value.add(offsetValue.scale(repeatCount));
  3591. }
  3592. // Vector2
  3593. case Animation.ANIMATIONTYPE_VECTOR2:
  3594. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3595. switch (loopMode) {
  3596. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3597. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3598. return vec2Value;
  3599. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3600. return vec2Value.add(offsetValue.scale(repeatCount));
  3601. }
  3602. // Size
  3603. case Animation.ANIMATIONTYPE_SIZE:
  3604. switch (loopMode) {
  3605. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3606. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3607. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3608. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3609. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3610. }
  3611. // Color3
  3612. case Animation.ANIMATIONTYPE_COLOR3:
  3613. switch (loopMode) {
  3614. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3615. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3616. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3617. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3618. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3619. }
  3620. // Matrix
  3621. case Animation.ANIMATIONTYPE_MATRIX:
  3622. switch (loopMode) {
  3623. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3624. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3625. if (Animation.AllowMatricesInterpolation) {
  3626. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3627. }
  3628. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3629. return startValue;
  3630. }
  3631. default:
  3632. break;
  3633. }
  3634. break;
  3635. }
  3636. }
  3637. return this._getKeyValue(keys[keys.length - 1].value);
  3638. };
  3639. /**
  3640. * Defines the function to use to interpolate matrices
  3641. * @param startValue defines the start matrix
  3642. * @param endValue defines the end matrix
  3643. * @param gradient defines the gradient between both matrices
  3644. * @param result defines an optional target matrix where to store the interpolation
  3645. * @returns the interpolated matrix
  3646. */
  3647. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3648. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3649. if (result) {
  3650. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3651. return result;
  3652. }
  3653. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3654. }
  3655. if (result) {
  3656. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3657. return result;
  3658. }
  3659. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3660. };
  3661. /**
  3662. * Makes a copy of the animation
  3663. * @returns Cloned animation
  3664. */
  3665. Animation.prototype.clone = function () {
  3666. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3667. clone.enableBlending = this.enableBlending;
  3668. clone.blendingSpeed = this.blendingSpeed;
  3669. if (this._keys) {
  3670. clone.setKeys(this._keys);
  3671. }
  3672. if (this._ranges) {
  3673. clone._ranges = {};
  3674. for (var name in this._ranges) {
  3675. var range = this._ranges[name];
  3676. if (!range) {
  3677. continue;
  3678. }
  3679. clone._ranges[name] = range.clone();
  3680. }
  3681. }
  3682. return clone;
  3683. };
  3684. /**
  3685. * Sets the key frames of the animation
  3686. * @param values The animation key frames to set
  3687. */
  3688. Animation.prototype.setKeys = function (values) {
  3689. this._keys = values.slice(0);
  3690. };
  3691. /**
  3692. * Serializes the animation to an object
  3693. * @returns Serialized object
  3694. */
  3695. Animation.prototype.serialize = function () {
  3696. var serializationObject = {};
  3697. serializationObject.name = this.name;
  3698. serializationObject.property = this.targetProperty;
  3699. serializationObject.framePerSecond = this.framePerSecond;
  3700. serializationObject.dataType = this.dataType;
  3701. serializationObject.loopBehavior = this.loopMode;
  3702. serializationObject.enableBlending = this.enableBlending;
  3703. serializationObject.blendingSpeed = this.blendingSpeed;
  3704. var dataType = this.dataType;
  3705. serializationObject.keys = [];
  3706. var keys = this.getKeys();
  3707. for (var index = 0; index < keys.length; index++) {
  3708. var animationKey = keys[index];
  3709. var key = {};
  3710. key.frame = animationKey.frame;
  3711. switch (dataType) {
  3712. case Animation.ANIMATIONTYPE_FLOAT:
  3713. key.values = [animationKey.value];
  3714. break;
  3715. case Animation.ANIMATIONTYPE_QUATERNION:
  3716. case Animation.ANIMATIONTYPE_MATRIX:
  3717. case Animation.ANIMATIONTYPE_VECTOR3:
  3718. case Animation.ANIMATIONTYPE_COLOR3:
  3719. key.values = animationKey.value.asArray();
  3720. break;
  3721. }
  3722. serializationObject.keys.push(key);
  3723. }
  3724. serializationObject.ranges = [];
  3725. for (var name in this._ranges) {
  3726. var source = this._ranges[name];
  3727. if (!source) {
  3728. continue;
  3729. }
  3730. var range = {};
  3731. range.name = name;
  3732. range.from = source.from;
  3733. range.to = source.to;
  3734. serializationObject.ranges.push(range);
  3735. }
  3736. return serializationObject;
  3737. };
  3738. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3739. /**
  3740. * Get the float animation type
  3741. */
  3742. get: function () {
  3743. return Animation._ANIMATIONTYPE_FLOAT;
  3744. },
  3745. enumerable: true,
  3746. configurable: true
  3747. });
  3748. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3749. /**
  3750. * Get the Vector3 animation type
  3751. */
  3752. get: function () {
  3753. return Animation._ANIMATIONTYPE_VECTOR3;
  3754. },
  3755. enumerable: true,
  3756. configurable: true
  3757. });
  3758. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3759. /**
  3760. * Get the Vector2 animation type
  3761. */
  3762. get: function () {
  3763. return Animation._ANIMATIONTYPE_VECTOR2;
  3764. },
  3765. enumerable: true,
  3766. configurable: true
  3767. });
  3768. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3769. /**
  3770. * Get the Size animation type
  3771. */
  3772. get: function () {
  3773. return Animation._ANIMATIONTYPE_SIZE;
  3774. },
  3775. enumerable: true,
  3776. configurable: true
  3777. });
  3778. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3779. /**
  3780. * Get the Quaternion animation type
  3781. */
  3782. get: function () {
  3783. return Animation._ANIMATIONTYPE_QUATERNION;
  3784. },
  3785. enumerable: true,
  3786. configurable: true
  3787. });
  3788. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3789. /**
  3790. * Get the Matrix animation type
  3791. */
  3792. get: function () {
  3793. return Animation._ANIMATIONTYPE_MATRIX;
  3794. },
  3795. enumerable: true,
  3796. configurable: true
  3797. });
  3798. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3799. /**
  3800. * Get the Color3 animation type
  3801. */
  3802. get: function () {
  3803. return Animation._ANIMATIONTYPE_COLOR3;
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3809. /**
  3810. * Get the Relative Loop Mode
  3811. */
  3812. get: function () {
  3813. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3814. },
  3815. enumerable: true,
  3816. configurable: true
  3817. });
  3818. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3819. /**
  3820. * Get the Cycle Loop Mode
  3821. */
  3822. get: function () {
  3823. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3824. },
  3825. enumerable: true,
  3826. configurable: true
  3827. });
  3828. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3829. /**
  3830. * Get the Constant Loop Mode
  3831. */
  3832. get: function () {
  3833. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3834. },
  3835. enumerable: true,
  3836. configurable: true
  3837. });
  3838. /** @hidden */
  3839. Animation._UniversalLerp = function (left, right, amount) {
  3840. var constructor = left.constructor;
  3841. if (constructor.Lerp) { // Lerp supported
  3842. return constructor.Lerp(left, right, amount);
  3843. }
  3844. else if (constructor.Slerp) { // Slerp supported
  3845. return constructor.Slerp(left, right, amount);
  3846. }
  3847. else if (left.toFixed) { // Number
  3848. return left * (1.0 - amount) + amount * right;
  3849. }
  3850. else { // Blending not supported
  3851. return right;
  3852. }
  3853. };
  3854. /**
  3855. * Parses an animation object and creates an animation
  3856. * @param parsedAnimation Parsed animation object
  3857. * @returns Animation object
  3858. */
  3859. Animation.Parse = function (parsedAnimation) {
  3860. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3861. var dataType = parsedAnimation.dataType;
  3862. var keys = [];
  3863. var data;
  3864. var index;
  3865. if (parsedAnimation.enableBlending) {
  3866. animation.enableBlending = parsedAnimation.enableBlending;
  3867. }
  3868. if (parsedAnimation.blendingSpeed) {
  3869. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3870. }
  3871. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3872. var key = parsedAnimation.keys[index];
  3873. var inTangent;
  3874. var outTangent;
  3875. switch (dataType) {
  3876. case Animation.ANIMATIONTYPE_FLOAT:
  3877. data = key.values[0];
  3878. if (key.values.length >= 1) {
  3879. inTangent = key.values[1];
  3880. }
  3881. if (key.values.length >= 2) {
  3882. outTangent = key.values[2];
  3883. }
  3884. break;
  3885. case Animation.ANIMATIONTYPE_QUATERNION:
  3886. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3887. if (key.values.length >= 8) {
  3888. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3889. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3890. inTangent = _inTangent;
  3891. }
  3892. }
  3893. if (key.values.length >= 12) {
  3894. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3895. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3896. outTangent = _outTangent;
  3897. }
  3898. }
  3899. break;
  3900. case Animation.ANIMATIONTYPE_MATRIX:
  3901. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3902. break;
  3903. case Animation.ANIMATIONTYPE_COLOR3:
  3904. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3905. break;
  3906. case Animation.ANIMATIONTYPE_VECTOR3:
  3907. default:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3909. break;
  3910. }
  3911. var keyData = {};
  3912. keyData.frame = key.frame;
  3913. keyData.value = data;
  3914. if (inTangent != undefined) {
  3915. keyData.inTangent = inTangent;
  3916. }
  3917. if (outTangent != undefined) {
  3918. keyData.outTangent = outTangent;
  3919. }
  3920. keys.push(keyData);
  3921. }
  3922. animation.setKeys(keys);
  3923. if (parsedAnimation.ranges) {
  3924. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3925. data = parsedAnimation.ranges[index];
  3926. animation.createRange(data.name, data.from, data.to);
  3927. }
  3928. }
  3929. return animation;
  3930. };
  3931. /**
  3932. * Appends the serialized animations from the source animations
  3933. * @param source Source containing the animations
  3934. * @param destination Target to store the animations
  3935. */
  3936. Animation.AppendSerializedAnimations = function (source, destination) {
  3937. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3938. };
  3939. /**
  3940. * Use matrix interpolation instead of using direct key value when animating matrices
  3941. */
  3942. Animation.AllowMatricesInterpolation = false;
  3943. /**
  3944. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3945. */
  3946. Animation.AllowMatrixDecomposeForInterpolation = true;
  3947. // Statics
  3948. /**
  3949. * Float animation type
  3950. */
  3951. Animation._ANIMATIONTYPE_FLOAT = 0;
  3952. /**
  3953. * Vector3 animation type
  3954. */
  3955. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3956. /**
  3957. * Quaternion animation type
  3958. */
  3959. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3960. /**
  3961. * Matrix animation type
  3962. */
  3963. Animation._ANIMATIONTYPE_MATRIX = 3;
  3964. /**
  3965. * Color3 animation type
  3966. */
  3967. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3968. /**
  3969. * Vector2 animation type
  3970. */
  3971. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3972. /**
  3973. * Size animation type
  3974. */
  3975. Animation._ANIMATIONTYPE_SIZE = 6;
  3976. /**
  3977. * Relative Loop Mode
  3978. */
  3979. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3980. /**
  3981. * Cycle Loop Mode
  3982. */
  3983. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3984. /**
  3985. * Constant Loop Mode
  3986. */
  3987. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3988. return Animation;
  3989. }());
  3990. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3991. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3992. /***/ }),
  3993. /***/ "./Animations/animationEvent.ts":
  3994. /*!**************************************!*\
  3995. !*** ./Animations/animationEvent.ts ***!
  3996. \**************************************/
  3997. /*! exports provided: AnimationEvent */
  3998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3999. "use strict";
  4000. __webpack_require__.r(__webpack_exports__);
  4001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4002. /**
  4003. * Composed of a frame, and an action function
  4004. */
  4005. var AnimationEvent = /** @class */ (function () {
  4006. /**
  4007. * Initializes the animation event
  4008. * @param frame The frame for which the event is triggered
  4009. * @param action The event to perform when triggered
  4010. * @param onlyOnce Specifies if the event should be triggered only once
  4011. */
  4012. function AnimationEvent(
  4013. /** The frame for which the event is triggered **/
  4014. frame,
  4015. /** The event to perform when triggered **/
  4016. action,
  4017. /** Specifies if the event should be triggered only once**/
  4018. onlyOnce) {
  4019. this.frame = frame;
  4020. this.action = action;
  4021. this.onlyOnce = onlyOnce;
  4022. /**
  4023. * Specifies if the animation event is done
  4024. */
  4025. this.isDone = false;
  4026. }
  4027. /** @hidden */
  4028. AnimationEvent.prototype._clone = function () {
  4029. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4030. };
  4031. return AnimationEvent;
  4032. }());
  4033. /***/ }),
  4034. /***/ "./Animations/animationGroup.ts":
  4035. /*!**************************************!*\
  4036. !*** ./Animations/animationGroup.ts ***!
  4037. \**************************************/
  4038. /*! exports provided: TargetedAnimation, AnimationGroup */
  4039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4040. "use strict";
  4041. __webpack_require__.r(__webpack_exports__);
  4042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4044. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4045. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4046. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4047. /**
  4048. * This class defines the direct association between an animation and a target
  4049. */
  4050. var TargetedAnimation = /** @class */ (function () {
  4051. function TargetedAnimation() {
  4052. }
  4053. return TargetedAnimation;
  4054. }());
  4055. /**
  4056. * Use this class to create coordinated animations on multiple targets
  4057. */
  4058. var AnimationGroup = /** @class */ (function () {
  4059. /**
  4060. * Instantiates a new Animation Group.
  4061. * This helps managing several animations at once.
  4062. * @see http://doc.babylonjs.com/how_to/group
  4063. * @param name Defines the name of the group
  4064. * @param scene Defines the scene the group belongs to
  4065. */
  4066. function AnimationGroup(
  4067. /** The name of the animation group */
  4068. name, scene) {
  4069. if (scene === void 0) { scene = null; }
  4070. this.name = name;
  4071. this._targetedAnimations = new Array();
  4072. this._animatables = new Array();
  4073. this._from = Number.MAX_VALUE;
  4074. this._to = -Number.MAX_VALUE;
  4075. this._speedRatio = 1;
  4076. /**
  4077. * This observable will notify when one animation have ended
  4078. */
  4079. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4080. /**
  4081. * Observer raised when one animation loops
  4082. */
  4083. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4084. /**
  4085. * This observable will notify when all animations have ended.
  4086. */
  4087. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4088. /**
  4089. * This observable will notify when all animations have paused.
  4090. */
  4091. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4092. /**
  4093. * This observable will notify when all animations are playing.
  4094. */
  4095. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4096. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4097. this.uniqueId = this._scene.getUniqueId();
  4098. this._scene.animationGroups.push(this);
  4099. }
  4100. Object.defineProperty(AnimationGroup.prototype, "from", {
  4101. /**
  4102. * Gets the first frame
  4103. */
  4104. get: function () {
  4105. return this._from;
  4106. },
  4107. enumerable: true,
  4108. configurable: true
  4109. });
  4110. Object.defineProperty(AnimationGroup.prototype, "to", {
  4111. /**
  4112. * Gets the last frame
  4113. */
  4114. get: function () {
  4115. return this._to;
  4116. },
  4117. enumerable: true,
  4118. configurable: true
  4119. });
  4120. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4121. /**
  4122. * Define if the animations are started
  4123. */
  4124. get: function () {
  4125. return this._isStarted;
  4126. },
  4127. enumerable: true,
  4128. configurable: true
  4129. });
  4130. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4131. /**
  4132. * Gets a value indicating that the current group is playing
  4133. */
  4134. get: function () {
  4135. return this._isStarted && !this._isPaused;
  4136. },
  4137. enumerable: true,
  4138. configurable: true
  4139. });
  4140. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4141. /**
  4142. * Gets or sets the speed ratio to use for all animations
  4143. */
  4144. get: function () {
  4145. return this._speedRatio;
  4146. },
  4147. /**
  4148. * Gets or sets the speed ratio to use for all animations
  4149. */
  4150. set: function (value) {
  4151. if (this._speedRatio === value) {
  4152. return;
  4153. }
  4154. this._speedRatio = value;
  4155. for (var index = 0; index < this._animatables.length; index++) {
  4156. var animatable = this._animatables[index];
  4157. animatable.speedRatio = this._speedRatio;
  4158. }
  4159. },
  4160. enumerable: true,
  4161. configurable: true
  4162. });
  4163. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4164. /**
  4165. * Gets the targeted animations for this animation group
  4166. */
  4167. get: function () {
  4168. return this._targetedAnimations;
  4169. },
  4170. enumerable: true,
  4171. configurable: true
  4172. });
  4173. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4174. /**
  4175. * returning the list of animatables controlled by this animation group.
  4176. */
  4177. get: function () {
  4178. return this._animatables;
  4179. },
  4180. enumerable: true,
  4181. configurable: true
  4182. });
  4183. /**
  4184. * Add an animation (with its target) in the group
  4185. * @param animation defines the animation we want to add
  4186. * @param target defines the target of the animation
  4187. * @returns the TargetedAnimation object
  4188. */
  4189. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4190. var targetedAnimation = {
  4191. animation: animation,
  4192. target: target
  4193. };
  4194. var keys = animation.getKeys();
  4195. if (this._from > keys[0].frame) {
  4196. this._from = keys[0].frame;
  4197. }
  4198. if (this._to < keys[keys.length - 1].frame) {
  4199. this._to = keys[keys.length - 1].frame;
  4200. }
  4201. this._targetedAnimations.push(targetedAnimation);
  4202. return targetedAnimation;
  4203. };
  4204. /**
  4205. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4206. * It can add constant keys at begin or end
  4207. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4208. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4209. * @returns the animation group
  4210. */
  4211. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4212. if (beginFrame === void 0) { beginFrame = null; }
  4213. if (endFrame === void 0) { endFrame = null; }
  4214. if (beginFrame == null) {
  4215. beginFrame = this._from;
  4216. }
  4217. if (endFrame == null) {
  4218. endFrame = this._to;
  4219. }
  4220. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4221. var targetedAnimation = this._targetedAnimations[index];
  4222. var keys = targetedAnimation.animation.getKeys();
  4223. var startKey = keys[0];
  4224. var endKey = keys[keys.length - 1];
  4225. if (startKey.frame > beginFrame) {
  4226. var newKey = {
  4227. frame: beginFrame,
  4228. value: startKey.value,
  4229. inTangent: startKey.inTangent,
  4230. outTangent: startKey.outTangent,
  4231. interpolation: startKey.interpolation
  4232. };
  4233. keys.splice(0, 0, newKey);
  4234. }
  4235. if (endKey.frame < endFrame) {
  4236. var newKey = {
  4237. frame: endFrame,
  4238. value: endKey.value,
  4239. inTangent: endKey.outTangent,
  4240. outTangent: endKey.outTangent,
  4241. interpolation: endKey.interpolation
  4242. };
  4243. keys.push(newKey);
  4244. }
  4245. }
  4246. this._from = beginFrame;
  4247. this._to = endFrame;
  4248. return this;
  4249. };
  4250. /**
  4251. * Start all animations on given targets
  4252. * @param loop defines if animations must loop
  4253. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4254. * @param from defines the from key (optional)
  4255. * @param to defines the to key (optional)
  4256. * @returns the current animation group
  4257. */
  4258. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4259. var _this = this;
  4260. if (loop === void 0) { loop = false; }
  4261. if (speedRatio === void 0) { speedRatio = 1; }
  4262. if (this._isStarted || this._targetedAnimations.length === 0) {
  4263. return this;
  4264. }
  4265. var _loop_1 = function (targetedAnimation) {
  4266. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4267. animatable.onAnimationEnd = function () {
  4268. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4269. _this._checkAnimationGroupEnded(animatable);
  4270. };
  4271. animatable.onAnimationLoop = function () {
  4272. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4273. };
  4274. this_1._animatables.push(animatable);
  4275. };
  4276. var this_1 = this;
  4277. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4278. var targetedAnimation = _a[_i];
  4279. _loop_1(targetedAnimation);
  4280. }
  4281. this._speedRatio = speedRatio;
  4282. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4283. this._speedRatio = -speedRatio;
  4284. }
  4285. this._isStarted = true;
  4286. this._isPaused = false;
  4287. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4288. return this;
  4289. };
  4290. /**
  4291. * Pause all animations
  4292. * @returns the animation group
  4293. */
  4294. AnimationGroup.prototype.pause = function () {
  4295. if (!this._isStarted) {
  4296. return this;
  4297. }
  4298. this._isPaused = true;
  4299. for (var index = 0; index < this._animatables.length; index++) {
  4300. var animatable = this._animatables[index];
  4301. animatable.pause();
  4302. }
  4303. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4304. return this;
  4305. };
  4306. /**
  4307. * Play all animations to initial state
  4308. * This function will start() the animations if they were not started or will restart() them if they were paused
  4309. * @param loop defines if animations must loop
  4310. * @returns the animation group
  4311. */
  4312. AnimationGroup.prototype.play = function (loop) {
  4313. // only if all animatables are ready and exist
  4314. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4315. if (loop !== undefined) {
  4316. for (var index = 0; index < this._animatables.length; index++) {
  4317. var animatable = this._animatables[index];
  4318. animatable.loopAnimation = loop;
  4319. }
  4320. }
  4321. this.restart();
  4322. }
  4323. else {
  4324. this.stop();
  4325. this.start(loop, this._speedRatio);
  4326. }
  4327. this._isPaused = false;
  4328. return this;
  4329. };
  4330. /**
  4331. * Reset all animations to initial state
  4332. * @returns the animation group
  4333. */
  4334. AnimationGroup.prototype.reset = function () {
  4335. if (!this._isStarted) {
  4336. return this;
  4337. }
  4338. for (var index = 0; index < this._animatables.length; index++) {
  4339. var animatable = this._animatables[index];
  4340. animatable.reset();
  4341. }
  4342. return this;
  4343. };
  4344. /**
  4345. * Restart animations from key 0
  4346. * @returns the animation group
  4347. */
  4348. AnimationGroup.prototype.restart = function () {
  4349. if (!this._isStarted) {
  4350. return this;
  4351. }
  4352. for (var index = 0; index < this._animatables.length; index++) {
  4353. var animatable = this._animatables[index];
  4354. animatable.restart();
  4355. }
  4356. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4357. return this;
  4358. };
  4359. /**
  4360. * Stop all animations
  4361. * @returns the animation group
  4362. */
  4363. AnimationGroup.prototype.stop = function () {
  4364. if (!this._isStarted) {
  4365. return this;
  4366. }
  4367. var list = this._animatables.slice();
  4368. for (var index = 0; index < list.length; index++) {
  4369. list[index].stop();
  4370. }
  4371. this._isStarted = false;
  4372. return this;
  4373. };
  4374. /**
  4375. * Set animation weight for all animatables
  4376. * @param weight defines the weight to use
  4377. * @return the animationGroup
  4378. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4379. */
  4380. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4381. for (var index = 0; index < this._animatables.length; index++) {
  4382. var animatable = this._animatables[index];
  4383. animatable.weight = weight;
  4384. }
  4385. return this;
  4386. };
  4387. /**
  4388. * Synchronize and normalize all animatables with a source animatable
  4389. * @param root defines the root animatable to synchronize with
  4390. * @return the animationGroup
  4391. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4392. */
  4393. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4394. for (var index = 0; index < this._animatables.length; index++) {
  4395. var animatable = this._animatables[index];
  4396. animatable.syncWith(root);
  4397. }
  4398. return this;
  4399. };
  4400. /**
  4401. * Goes to a specific frame in this animation group
  4402. * @param frame the frame number to go to
  4403. * @return the animationGroup
  4404. */
  4405. AnimationGroup.prototype.goToFrame = function (frame) {
  4406. if (!this._isStarted) {
  4407. return this;
  4408. }
  4409. for (var index = 0; index < this._animatables.length; index++) {
  4410. var animatable = this._animatables[index];
  4411. animatable.goToFrame(frame);
  4412. }
  4413. return this;
  4414. };
  4415. /**
  4416. * Dispose all associated resources
  4417. */
  4418. AnimationGroup.prototype.dispose = function () {
  4419. this._targetedAnimations = [];
  4420. this._animatables = [];
  4421. var index = this._scene.animationGroups.indexOf(this);
  4422. if (index > -1) {
  4423. this._scene.animationGroups.splice(index, 1);
  4424. }
  4425. this.onAnimationEndObservable.clear();
  4426. this.onAnimationGroupEndObservable.clear();
  4427. this.onAnimationGroupPauseObservable.clear();
  4428. this.onAnimationGroupPlayObservable.clear();
  4429. this.onAnimationLoopObservable.clear();
  4430. };
  4431. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4432. // animatable should be taken out of the array
  4433. var idx = this._animatables.indexOf(animatable);
  4434. if (idx > -1) {
  4435. this._animatables.splice(idx, 1);
  4436. }
  4437. // all animatables were removed? animation group ended!
  4438. if (this._animatables.length === 0) {
  4439. this._isStarted = false;
  4440. this.onAnimationGroupEndObservable.notifyObservers(this);
  4441. }
  4442. };
  4443. // Statics
  4444. /**
  4445. * Returns a new AnimationGroup object parsed from the source provided.
  4446. * @param parsedAnimationGroup defines the source
  4447. * @param scene defines the scene that will receive the animationGroup
  4448. * @returns a new AnimationGroup
  4449. */
  4450. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4451. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4452. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4453. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4454. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4455. var id = targetedAnimation.targetId;
  4456. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4457. var morphTarget = scene.getMorphTargetById(id);
  4458. if (morphTarget) {
  4459. animationGroup.addTargetedAnimation(animation, morphTarget);
  4460. }
  4461. }
  4462. else {
  4463. var targetNode = scene.getNodeByID(id);
  4464. if (targetNode != null) {
  4465. animationGroup.addTargetedAnimation(animation, targetNode);
  4466. }
  4467. }
  4468. }
  4469. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4470. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4471. }
  4472. return animationGroup;
  4473. };
  4474. /**
  4475. * Returns the string "AnimationGroup"
  4476. * @returns "AnimationGroup"
  4477. */
  4478. AnimationGroup.prototype.getClassName = function () {
  4479. return "AnimationGroup";
  4480. };
  4481. /**
  4482. * Creates a detailled string about the object
  4483. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4484. * @returns a string representing the object
  4485. */
  4486. AnimationGroup.prototype.toString = function (fullDetails) {
  4487. var ret = "Name: " + this.name;
  4488. ret += ", type: " + this.getClassName();
  4489. if (fullDetails) {
  4490. ret += ", from: " + this._from;
  4491. ret += ", to: " + this._to;
  4492. ret += ", isStarted: " + this._isStarted;
  4493. ret += ", speedRatio: " + this._speedRatio;
  4494. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4495. ret += ", animatables length: " + this._animatables;
  4496. }
  4497. return ret;
  4498. };
  4499. return AnimationGroup;
  4500. }());
  4501. /***/ }),
  4502. /***/ "./Animations/animationKey.ts":
  4503. /*!************************************!*\
  4504. !*** ./Animations/animationKey.ts ***!
  4505. \************************************/
  4506. /*! exports provided: AnimationKeyInterpolation */
  4507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4508. "use strict";
  4509. __webpack_require__.r(__webpack_exports__);
  4510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4511. /**
  4512. * Enum for the animation key frame interpolation type
  4513. */
  4514. var AnimationKeyInterpolation;
  4515. (function (AnimationKeyInterpolation) {
  4516. /**
  4517. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4518. */
  4519. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4520. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4521. /***/ }),
  4522. /***/ "./Animations/animationPropertiesOverride.ts":
  4523. /*!***************************************************!*\
  4524. !*** ./Animations/animationPropertiesOverride.ts ***!
  4525. \***************************************************/
  4526. /*! exports provided: AnimationPropertiesOverride */
  4527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4528. "use strict";
  4529. __webpack_require__.r(__webpack_exports__);
  4530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4531. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4532. /**
  4533. * Class used to override all child animations of a given target
  4534. */
  4535. var AnimationPropertiesOverride = /** @class */ (function () {
  4536. function AnimationPropertiesOverride() {
  4537. /**
  4538. * Gets or sets a value indicating if animation blending must be used
  4539. */
  4540. this.enableBlending = false;
  4541. /**
  4542. * Gets or sets the blending speed to use when enableBlending is true
  4543. */
  4544. this.blendingSpeed = 0.01;
  4545. /**
  4546. * Gets or sets the default loop mode to use
  4547. */
  4548. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4549. }
  4550. return AnimationPropertiesOverride;
  4551. }());
  4552. /***/ }),
  4553. /***/ "./Animations/animationRange.ts":
  4554. /*!**************************************!*\
  4555. !*** ./Animations/animationRange.ts ***!
  4556. \**************************************/
  4557. /*! exports provided: AnimationRange */
  4558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4559. "use strict";
  4560. __webpack_require__.r(__webpack_exports__);
  4561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4562. /**
  4563. * Represents the range of an animation
  4564. */
  4565. var AnimationRange = /** @class */ (function () {
  4566. /**
  4567. * Initializes the range of an animation
  4568. * @param name The name of the animation range
  4569. * @param from The starting frame of the animation
  4570. * @param to The ending frame of the animation
  4571. */
  4572. function AnimationRange(
  4573. /**The name of the animation range**/
  4574. name,
  4575. /**The starting frame of the animation */
  4576. from,
  4577. /**The ending frame of the animation*/
  4578. to) {
  4579. this.name = name;
  4580. this.from = from;
  4581. this.to = to;
  4582. }
  4583. /**
  4584. * Makes a copy of the animation range
  4585. * @returns A copy of the animation range
  4586. */
  4587. AnimationRange.prototype.clone = function () {
  4588. return new AnimationRange(this.name, this.from, this.to);
  4589. };
  4590. return AnimationRange;
  4591. }());
  4592. /***/ }),
  4593. /***/ "./Animations/easing.ts":
  4594. /*!******************************!*\
  4595. !*** ./Animations/easing.ts ***!
  4596. \******************************/
  4597. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4599. "use strict";
  4600. __webpack_require__.r(__webpack_exports__);
  4601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4615. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4616. /**
  4617. * Base class used for every default easing function.
  4618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4619. */
  4620. var EasingFunction = /** @class */ (function () {
  4621. function EasingFunction() {
  4622. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4623. }
  4624. /**
  4625. * Sets the easing mode of the current function.
  4626. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4627. */
  4628. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4629. var n = Math.min(Math.max(easingMode, 0), 2);
  4630. this._easingMode = n;
  4631. };
  4632. /**
  4633. * Gets the current easing mode.
  4634. * @returns the easing mode
  4635. */
  4636. EasingFunction.prototype.getEasingMode = function () {
  4637. return this._easingMode;
  4638. };
  4639. /**
  4640. * @hidden
  4641. */
  4642. EasingFunction.prototype.easeInCore = function (gradient) {
  4643. throw new Error('You must implement this method');
  4644. };
  4645. /**
  4646. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4647. * of the easing function.
  4648. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4649. * @returns the corresponding value on the curve defined by the easing function
  4650. */
  4651. EasingFunction.prototype.ease = function (gradient) {
  4652. switch (this._easingMode) {
  4653. case EasingFunction.EASINGMODE_EASEIN:
  4654. return this.easeInCore(gradient);
  4655. case EasingFunction.EASINGMODE_EASEOUT:
  4656. return (1 - this.easeInCore(1 - gradient));
  4657. }
  4658. if (gradient >= 0.5) {
  4659. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4660. }
  4661. return (this.easeInCore(gradient * 2) * 0.5);
  4662. };
  4663. /**
  4664. * Interpolation follows the mathematical formula associated with the easing function.
  4665. */
  4666. EasingFunction.EASINGMODE_EASEIN = 0;
  4667. /**
  4668. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4669. */
  4670. EasingFunction.EASINGMODE_EASEOUT = 1;
  4671. /**
  4672. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4673. */
  4674. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4675. return EasingFunction;
  4676. }());
  4677. /**
  4678. * Easing function with a circle shape (see link below).
  4679. * @see https://easings.net/#easeInCirc
  4680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4681. */
  4682. var CircleEase = /** @class */ (function (_super) {
  4683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4684. function CircleEase() {
  4685. return _super !== null && _super.apply(this, arguments) || this;
  4686. }
  4687. /** @hidden */
  4688. CircleEase.prototype.easeInCore = function (gradient) {
  4689. gradient = Math.max(0, Math.min(1, gradient));
  4690. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4691. };
  4692. return CircleEase;
  4693. }(EasingFunction));
  4694. /**
  4695. * Easing function with a ease back shape (see link below).
  4696. * @see https://easings.net/#easeInBack
  4697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4698. */
  4699. var BackEase = /** @class */ (function (_super) {
  4700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4701. /**
  4702. * Instantiates a back ease easing
  4703. * @see https://easings.net/#easeInBack
  4704. * @param amplitude Defines the amplitude of the function
  4705. */
  4706. function BackEase(
  4707. /** Defines the amplitude of the function */
  4708. amplitude) {
  4709. if (amplitude === void 0) { amplitude = 1; }
  4710. var _this = _super.call(this) || this;
  4711. _this.amplitude = amplitude;
  4712. return _this;
  4713. }
  4714. /** @hidden */
  4715. BackEase.prototype.easeInCore = function (gradient) {
  4716. var num = Math.max(0, this.amplitude);
  4717. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4718. };
  4719. return BackEase;
  4720. }(EasingFunction));
  4721. /**
  4722. * Easing function with a bouncing shape (see link below).
  4723. * @see https://easings.net/#easeInBounce
  4724. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4725. */
  4726. var BounceEase = /** @class */ (function (_super) {
  4727. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4728. /**
  4729. * Instantiates a bounce easing
  4730. * @see https://easings.net/#easeInBounce
  4731. * @param bounces Defines the number of bounces
  4732. * @param bounciness Defines the amplitude of the bounce
  4733. */
  4734. function BounceEase(
  4735. /** Defines the number of bounces */
  4736. bounces,
  4737. /** Defines the amplitude of the bounce */
  4738. bounciness) {
  4739. if (bounces === void 0) { bounces = 3; }
  4740. if (bounciness === void 0) { bounciness = 2; }
  4741. var _this = _super.call(this) || this;
  4742. _this.bounces = bounces;
  4743. _this.bounciness = bounciness;
  4744. return _this;
  4745. }
  4746. /** @hidden */
  4747. BounceEase.prototype.easeInCore = function (gradient) {
  4748. var y = Math.max(0.0, this.bounces);
  4749. var bounciness = this.bounciness;
  4750. if (bounciness <= 1.0) {
  4751. bounciness = 1.001;
  4752. }
  4753. var num9 = Math.pow(bounciness, y);
  4754. var num5 = 1.0 - bounciness;
  4755. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4756. var num15 = gradient * num4;
  4757. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4758. var num3 = Math.floor(num65);
  4759. var num13 = num3 + 1.0;
  4760. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4761. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4762. var num7 = (num8 + num12) * 0.5;
  4763. var num6 = gradient - num7;
  4764. var num2 = num7 - num8;
  4765. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4766. };
  4767. return BounceEase;
  4768. }(EasingFunction));
  4769. /**
  4770. * Easing function with a power of 3 shape (see link below).
  4771. * @see https://easings.net/#easeInCubic
  4772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4773. */
  4774. var CubicEase = /** @class */ (function (_super) {
  4775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4776. function CubicEase() {
  4777. return _super !== null && _super.apply(this, arguments) || this;
  4778. }
  4779. /** @hidden */
  4780. CubicEase.prototype.easeInCore = function (gradient) {
  4781. return (gradient * gradient * gradient);
  4782. };
  4783. return CubicEase;
  4784. }(EasingFunction));
  4785. /**
  4786. * Easing function with an elastic shape (see link below).
  4787. * @see https://easings.net/#easeInElastic
  4788. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4789. */
  4790. var ElasticEase = /** @class */ (function (_super) {
  4791. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4792. /**
  4793. * Instantiates an elastic easing function
  4794. * @see https://easings.net/#easeInElastic
  4795. * @param oscillations Defines the number of oscillations
  4796. * @param springiness Defines the amplitude of the oscillations
  4797. */
  4798. function ElasticEase(
  4799. /** Defines the number of oscillations*/
  4800. oscillations,
  4801. /** Defines the amplitude of the oscillations*/
  4802. springiness) {
  4803. if (oscillations === void 0) { oscillations = 3; }
  4804. if (springiness === void 0) { springiness = 3; }
  4805. var _this = _super.call(this) || this;
  4806. _this.oscillations = oscillations;
  4807. _this.springiness = springiness;
  4808. return _this;
  4809. }
  4810. /** @hidden */
  4811. ElasticEase.prototype.easeInCore = function (gradient) {
  4812. var num2;
  4813. var num3 = Math.max(0.0, this.oscillations);
  4814. var num = Math.max(0.0, this.springiness);
  4815. if (num == 0) {
  4816. num2 = gradient;
  4817. }
  4818. else {
  4819. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4820. }
  4821. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4822. };
  4823. return ElasticEase;
  4824. }(EasingFunction));
  4825. /**
  4826. * Easing function with an exponential shape (see link below).
  4827. * @see https://easings.net/#easeInExpo
  4828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4829. */
  4830. var ExponentialEase = /** @class */ (function (_super) {
  4831. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4832. /**
  4833. * Instantiates an exponential easing function
  4834. * @see https://easings.net/#easeInExpo
  4835. * @param exponent Defines the exponent of the function
  4836. */
  4837. function ExponentialEase(
  4838. /** Defines the exponent of the function */
  4839. exponent) {
  4840. if (exponent === void 0) { exponent = 2; }
  4841. var _this = _super.call(this) || this;
  4842. _this.exponent = exponent;
  4843. return _this;
  4844. }
  4845. /** @hidden */
  4846. ExponentialEase.prototype.easeInCore = function (gradient) {
  4847. if (this.exponent <= 0) {
  4848. return gradient;
  4849. }
  4850. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4851. };
  4852. return ExponentialEase;
  4853. }(EasingFunction));
  4854. /**
  4855. * Easing function with a power shape (see link below).
  4856. * @see https://easings.net/#easeInQuad
  4857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4858. */
  4859. var PowerEase = /** @class */ (function (_super) {
  4860. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4861. /**
  4862. * Instantiates an power base easing function
  4863. * @see https://easings.net/#easeInQuad
  4864. * @param power Defines the power of the function
  4865. */
  4866. function PowerEase(
  4867. /** Defines the power of the function */
  4868. power) {
  4869. if (power === void 0) { power = 2; }
  4870. var _this = _super.call(this) || this;
  4871. _this.power = power;
  4872. return _this;
  4873. }
  4874. /** @hidden */
  4875. PowerEase.prototype.easeInCore = function (gradient) {
  4876. var y = Math.max(0.0, this.power);
  4877. return Math.pow(gradient, y);
  4878. };
  4879. return PowerEase;
  4880. }(EasingFunction));
  4881. /**
  4882. * Easing function with a power of 2 shape (see link below).
  4883. * @see https://easings.net/#easeInQuad
  4884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4885. */
  4886. var QuadraticEase = /** @class */ (function (_super) {
  4887. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4888. function QuadraticEase() {
  4889. return _super !== null && _super.apply(this, arguments) || this;
  4890. }
  4891. /** @hidden */
  4892. QuadraticEase.prototype.easeInCore = function (gradient) {
  4893. return (gradient * gradient);
  4894. };
  4895. return QuadraticEase;
  4896. }(EasingFunction));
  4897. /**
  4898. * Easing function with a power of 4 shape (see link below).
  4899. * @see https://easings.net/#easeInQuart
  4900. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4901. */
  4902. var QuarticEase = /** @class */ (function (_super) {
  4903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4904. function QuarticEase() {
  4905. return _super !== null && _super.apply(this, arguments) || this;
  4906. }
  4907. /** @hidden */
  4908. QuarticEase.prototype.easeInCore = function (gradient) {
  4909. return (gradient * gradient * gradient * gradient);
  4910. };
  4911. return QuarticEase;
  4912. }(EasingFunction));
  4913. /**
  4914. * Easing function with a power of 5 shape (see link below).
  4915. * @see https://easings.net/#easeInQuint
  4916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4917. */
  4918. var QuinticEase = /** @class */ (function (_super) {
  4919. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4920. function QuinticEase() {
  4921. return _super !== null && _super.apply(this, arguments) || this;
  4922. }
  4923. /** @hidden */
  4924. QuinticEase.prototype.easeInCore = function (gradient) {
  4925. return (gradient * gradient * gradient * gradient * gradient);
  4926. };
  4927. return QuinticEase;
  4928. }(EasingFunction));
  4929. /**
  4930. * Easing function with a sin shape (see link below).
  4931. * @see https://easings.net/#easeInSine
  4932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4933. */
  4934. var SineEase = /** @class */ (function (_super) {
  4935. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4936. function SineEase() {
  4937. return _super !== null && _super.apply(this, arguments) || this;
  4938. }
  4939. /** @hidden */
  4940. SineEase.prototype.easeInCore = function (gradient) {
  4941. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4942. };
  4943. return SineEase;
  4944. }(EasingFunction));
  4945. /**
  4946. * Easing function with a bezier shape (see link below).
  4947. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4949. */
  4950. var BezierCurveEase = /** @class */ (function (_super) {
  4951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4952. /**
  4953. * Instantiates a bezier function
  4954. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4955. * @param x1 Defines the x component of the start tangent in the bezier curve
  4956. * @param y1 Defines the y component of the start tangent in the bezier curve
  4957. * @param x2 Defines the x component of the end tangent in the bezier curve
  4958. * @param y2 Defines the y component of the end tangent in the bezier curve
  4959. */
  4960. function BezierCurveEase(
  4961. /** Defines the x component of the start tangent in the bezier curve */
  4962. x1,
  4963. /** Defines the y component of the start tangent in the bezier curve */
  4964. y1,
  4965. /** Defines the x component of the end tangent in the bezier curve */
  4966. x2,
  4967. /** Defines the y component of the end tangent in the bezier curve */
  4968. y2) {
  4969. if (x1 === void 0) { x1 = 0; }
  4970. if (y1 === void 0) { y1 = 0; }
  4971. if (x2 === void 0) { x2 = 1; }
  4972. if (y2 === void 0) { y2 = 1; }
  4973. var _this = _super.call(this) || this;
  4974. _this.x1 = x1;
  4975. _this.y1 = y1;
  4976. _this.x2 = x2;
  4977. _this.y2 = y2;
  4978. return _this;
  4979. }
  4980. /** @hidden */
  4981. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4982. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  4983. };
  4984. return BezierCurveEase;
  4985. }(EasingFunction));
  4986. /***/ }),
  4987. /***/ "./Animations/index.ts":
  4988. /*!*****************************!*\
  4989. !*** ./Animations/index.ts ***!
  4990. \*****************************/
  4991. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  4992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4993. "use strict";
  4994. __webpack_require__.r(__webpack_exports__);
  4995. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  4997. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  4999. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5002. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5004. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5018. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5020. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5022. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5024. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5026. /***/ }),
  5027. /***/ "./Animations/runtimeAnimation.ts":
  5028. /*!****************************************!*\
  5029. !*** ./Animations/runtimeAnimation.ts ***!
  5030. \****************************************/
  5031. /*! exports provided: RuntimeAnimation */
  5032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5033. "use strict";
  5034. __webpack_require__.r(__webpack_exports__);
  5035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5037. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5038. // Static values to help the garbage collector
  5039. // Quaternion
  5040. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5041. // Vector3
  5042. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5043. // Vector2
  5044. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5045. // Size
  5046. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5047. // Color3
  5048. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5049. /**
  5050. * Defines a runtime animation
  5051. */
  5052. var RuntimeAnimation = /** @class */ (function () {
  5053. /**
  5054. * Create a new RuntimeAnimation object
  5055. * @param target defines the target of the animation
  5056. * @param animation defines the source animation object
  5057. * @param scene defines the hosting scene
  5058. * @param host defines the initiating Animatable
  5059. */
  5060. function RuntimeAnimation(target, animation, scene, host) {
  5061. var _this = this;
  5062. this._events = new Array();
  5063. /**
  5064. * The current frame of the runtime animation
  5065. */
  5066. this._currentFrame = 0;
  5067. /**
  5068. * The original value of the runtime animation
  5069. */
  5070. this._originalValue = new Array();
  5071. /**
  5072. * The offsets cache of the runtime animation
  5073. */
  5074. this._offsetsCache = {};
  5075. /**
  5076. * The high limits cache of the runtime animation
  5077. */
  5078. this._highLimitsCache = {};
  5079. /**
  5080. * Specifies if the runtime animation has been stopped
  5081. */
  5082. this._stopped = false;
  5083. /**
  5084. * The blending factor of the runtime animation
  5085. */
  5086. this._blendingFactor = 0;
  5087. /**
  5088. * The target path of the runtime animation
  5089. */
  5090. this._targetPath = "";
  5091. /**
  5092. * The weight of the runtime animation
  5093. */
  5094. this._weight = 1.0;
  5095. /**
  5096. * The ratio offset of the runtime animation
  5097. */
  5098. this._ratioOffset = 0;
  5099. /**
  5100. * The previous delay of the runtime animation
  5101. */
  5102. this._previousDelay = 0;
  5103. /**
  5104. * The previous ratio of the runtime animation
  5105. */
  5106. this._previousRatio = 0;
  5107. this._animation = animation;
  5108. this._target = target;
  5109. this._scene = scene;
  5110. this._host = host;
  5111. animation._runtimeAnimations.push(this);
  5112. // Cloning events locally
  5113. var events = animation.getEvents();
  5114. if (events && events.length > 0) {
  5115. events.forEach(function (e) {
  5116. _this._events.push(e._clone());
  5117. });
  5118. }
  5119. }
  5120. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5121. /**
  5122. * Gets the current frame of the runtime animation
  5123. */
  5124. get: function () {
  5125. return this._currentFrame;
  5126. },
  5127. enumerable: true,
  5128. configurable: true
  5129. });
  5130. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5131. /**
  5132. * Gets the weight of the runtime animation
  5133. */
  5134. get: function () {
  5135. return this._weight;
  5136. },
  5137. enumerable: true,
  5138. configurable: true
  5139. });
  5140. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5141. /**
  5142. * Gets the current value of the runtime animation
  5143. */
  5144. get: function () {
  5145. return this._currentValue;
  5146. },
  5147. enumerable: true,
  5148. configurable: true
  5149. });
  5150. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5151. /**
  5152. * Gets the target path of the runtime animation
  5153. */
  5154. get: function () {
  5155. return this._targetPath;
  5156. },
  5157. enumerable: true,
  5158. configurable: true
  5159. });
  5160. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5161. /**
  5162. * Gets the actual target of the runtime animation
  5163. */
  5164. get: function () {
  5165. return this._activeTarget;
  5166. },
  5167. enumerable: true,
  5168. configurable: true
  5169. });
  5170. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5171. /**
  5172. * Gets the animation from the runtime animation
  5173. */
  5174. get: function () {
  5175. return this._animation;
  5176. },
  5177. enumerable: true,
  5178. configurable: true
  5179. });
  5180. /**
  5181. * Resets the runtime animation to the beginning
  5182. * @param restoreOriginal defines whether to restore the target property to the original value
  5183. */
  5184. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5185. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5186. if (restoreOriginal) {
  5187. if (this._target instanceof Array) {
  5188. var index = 0;
  5189. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5190. var target = _a[_i];
  5191. if (this._originalValue[index] !== undefined) {
  5192. this._setValue(target, this._originalValue[index], -1);
  5193. }
  5194. index++;
  5195. }
  5196. }
  5197. else {
  5198. if (this._originalValue[0] !== undefined) {
  5199. this._setValue(this._target, this._originalValue[0], -1);
  5200. }
  5201. }
  5202. }
  5203. this._offsetsCache = {};
  5204. this._highLimitsCache = {};
  5205. this._currentFrame = 0;
  5206. this._blendingFactor = 0;
  5207. this._originalValue = new Array();
  5208. // Events
  5209. for (var index = 0; index < this._events.length; index++) {
  5210. this._events[index].isDone = false;
  5211. }
  5212. };
  5213. /**
  5214. * Specifies if the runtime animation is stopped
  5215. * @returns Boolean specifying if the runtime animation is stopped
  5216. */
  5217. RuntimeAnimation.prototype.isStopped = function () {
  5218. return this._stopped;
  5219. };
  5220. /**
  5221. * Disposes of the runtime animation
  5222. */
  5223. RuntimeAnimation.prototype.dispose = function () {
  5224. var index = this._animation.runtimeAnimations.indexOf(this);
  5225. if (index > -1) {
  5226. this._animation.runtimeAnimations.splice(index, 1);
  5227. }
  5228. };
  5229. /**
  5230. * Interpolates the animation from the current frame
  5231. * @param currentFrame The frame to interpolate the animation to
  5232. * @param repeatCount The number of times that the animation should loop
  5233. * @param loopMode The type of looping mode to use
  5234. * @param offsetValue Animation offset value
  5235. * @param highLimitValue The high limit value
  5236. * @returns The interpolated value
  5237. */
  5238. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5239. this._currentFrame = currentFrame;
  5240. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5241. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5242. }
  5243. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5244. };
  5245. /**
  5246. * Apply the interpolated value to the target
  5247. * @param currentValue defines the value computed by the animation
  5248. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5249. */
  5250. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5251. if (weight === void 0) { weight = 1.0; }
  5252. if (this._target instanceof Array) {
  5253. var index = 0;
  5254. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5255. var target = _a[_i];
  5256. this._setValue(target, currentValue, weight, index);
  5257. index++;
  5258. }
  5259. }
  5260. else {
  5261. this._setValue(this._target, currentValue, weight);
  5262. }
  5263. };
  5264. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5265. if (targetIndex === void 0) { targetIndex = 0; }
  5266. // Set value
  5267. var path;
  5268. var destination;
  5269. var targetPropertyPath = this._animation.targetPropertyPath;
  5270. if (targetPropertyPath.length > 1) {
  5271. var property = target[targetPropertyPath[0]];
  5272. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5273. property = property[targetPropertyPath[index]];
  5274. }
  5275. path = targetPropertyPath[targetPropertyPath.length - 1];
  5276. destination = property;
  5277. }
  5278. else {
  5279. path = targetPropertyPath[0];
  5280. destination = target;
  5281. }
  5282. this._targetPath = path;
  5283. this._activeTarget = destination;
  5284. this._weight = weight;
  5285. if (this._originalValue[targetIndex] === undefined) {
  5286. var originalValue = void 0;
  5287. if (destination.getRestPose && path === "_matrix") { // For bones
  5288. originalValue = destination.getRestPose();
  5289. }
  5290. else {
  5291. originalValue = destination[path];
  5292. }
  5293. if (originalValue && originalValue.clone) {
  5294. this._originalValue[targetIndex] = originalValue.clone();
  5295. }
  5296. else {
  5297. this._originalValue[targetIndex] = originalValue;
  5298. }
  5299. }
  5300. // Blending
  5301. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5302. if (enableBlending && this._blendingFactor <= 1.0) {
  5303. if (!this._originalBlendValue) {
  5304. var originalValue = destination[path];
  5305. if (originalValue.clone) {
  5306. this._originalBlendValue = originalValue.clone();
  5307. }
  5308. else {
  5309. this._originalBlendValue = originalValue;
  5310. }
  5311. }
  5312. if (this._originalBlendValue.m) { // Matrix
  5313. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5314. if (this._currentValue) {
  5315. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5316. }
  5317. else {
  5318. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5319. }
  5320. }
  5321. else {
  5322. if (this._currentValue) {
  5323. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5324. }
  5325. else {
  5326. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5327. }
  5328. }
  5329. }
  5330. else {
  5331. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5332. }
  5333. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5334. this._blendingFactor += blendingSpeed;
  5335. }
  5336. else {
  5337. this._currentValue = currentValue;
  5338. }
  5339. if (weight !== -1.0) {
  5340. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5341. }
  5342. else {
  5343. destination[path] = this._currentValue;
  5344. }
  5345. if (target.markAsDirty) {
  5346. target.markAsDirty(this._animation.targetProperty);
  5347. }
  5348. };
  5349. /**
  5350. * Gets the loop pmode of the runtime animation
  5351. * @returns Loop Mode
  5352. */
  5353. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5354. if (this._target && this._target.animationPropertiesOverride) {
  5355. return this._target.animationPropertiesOverride.loopMode;
  5356. }
  5357. return this._animation.loopMode;
  5358. };
  5359. /**
  5360. * Move the current animation to a given frame
  5361. * @param frame defines the frame to move to
  5362. */
  5363. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5364. var keys = this._animation.getKeys();
  5365. if (frame < keys[0].frame) {
  5366. frame = keys[0].frame;
  5367. }
  5368. else if (frame > keys[keys.length - 1].frame) {
  5369. frame = keys[keys.length - 1].frame;
  5370. }
  5371. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5372. this.setValue(currentValue, -1);
  5373. };
  5374. /**
  5375. * @hidden Internal use only
  5376. */
  5377. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5378. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5379. this._ratioOffset = this._previousRatio - newRatio;
  5380. };
  5381. /**
  5382. * Execute the current animation
  5383. * @param delay defines the delay to add to the current frame
  5384. * @param from defines the lower bound of the animation range
  5385. * @param to defines the upper bound of the animation range
  5386. * @param loop defines if the current animation must loop
  5387. * @param speedRatio defines the current speed ratio
  5388. * @param weight defines the weight of the animation (default is -1 so no weight)
  5389. * @param onLoop optional callback called when animation loops
  5390. * @returns a boolean indicating if the animation is running
  5391. */
  5392. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5393. if (weight === void 0) { weight = -1.0; }
  5394. var targetPropertyPath = this._animation.targetPropertyPath;
  5395. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5396. this._stopped = true;
  5397. return false;
  5398. }
  5399. var returnValue = true;
  5400. var keys = this._animation.getKeys();
  5401. // Adding a start key at frame 0 if missing
  5402. if (keys[0].frame !== 0) {
  5403. var newKey = { frame: 0, value: keys[0].value };
  5404. keys.splice(0, 0, newKey);
  5405. }
  5406. // Adding a duplicate key when there is only one key at frame zero
  5407. else if (keys.length === 1) {
  5408. var newKey = { frame: 0.001, value: keys[0].value };
  5409. keys.push(newKey);
  5410. }
  5411. // Check limits
  5412. if (from < keys[0].frame || from > keys[keys.length - 1].frame) {
  5413. from = keys[0].frame;
  5414. }
  5415. if (to < keys[0].frame || to > keys[keys.length - 1].frame) {
  5416. to = keys[keys.length - 1].frame;
  5417. }
  5418. //to and from cannot be the same key
  5419. if (from === to) {
  5420. if (from > keys[0].frame) {
  5421. from--;
  5422. }
  5423. else if (to < keys[keys.length - 1].frame) {
  5424. to++;
  5425. }
  5426. }
  5427. // Compute ratio
  5428. var range = to - from;
  5429. var offsetValue;
  5430. // ratio represents the frame delta between from and to
  5431. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5432. var highLimitValue = 0;
  5433. this._previousDelay = delay;
  5434. this._previousRatio = ratio;
  5435. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5436. returnValue = false;
  5437. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5438. }
  5439. else {
  5440. // Get max value if required
  5441. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5442. var keyOffset = to.toString() + from.toString();
  5443. if (!this._offsetsCache[keyOffset]) {
  5444. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5445. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5446. switch (this._animation.dataType) {
  5447. // Float
  5448. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5449. this._offsetsCache[keyOffset] = toValue - fromValue;
  5450. break;
  5451. // Quaternion
  5452. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5453. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5454. break;
  5455. // Vector3
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5457. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5458. // Vector2
  5459. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5460. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5461. // Size
  5462. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5463. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5464. // Color3
  5465. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5466. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5467. default:
  5468. break;
  5469. }
  5470. this._highLimitsCache[keyOffset] = toValue;
  5471. }
  5472. highLimitValue = this._highLimitsCache[keyOffset];
  5473. offsetValue = this._offsetsCache[keyOffset];
  5474. }
  5475. }
  5476. if (offsetValue === undefined) {
  5477. switch (this._animation.dataType) {
  5478. // Float
  5479. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5480. offsetValue = 0;
  5481. break;
  5482. // Quaternion
  5483. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5484. offsetValue = _staticOffsetValueQuaternion;
  5485. break;
  5486. // Vector3
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5488. offsetValue = _staticOffsetValueVector3;
  5489. break;
  5490. // Vector2
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5492. offsetValue = _staticOffsetValueVector2;
  5493. break;
  5494. // Size
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5496. offsetValue = _staticOffsetValueSize;
  5497. break;
  5498. // Color3
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5500. offsetValue = _staticOffsetValueColor3;
  5501. }
  5502. }
  5503. // Compute value
  5504. var repeatCount = (ratio / range) >> 0;
  5505. var currentFrame = returnValue ? from + ratio % range : to;
  5506. // Need to normalize?
  5507. if (this._host && this._host.syncRoot) {
  5508. var syncRoot = this._host.syncRoot;
  5509. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5510. currentFrame = from + (to - from) * hostNormalizedFrame;
  5511. }
  5512. // Reset events if looping
  5513. var events = this._events;
  5514. if (range > 0 && this.currentFrame > currentFrame ||
  5515. range < 0 && this.currentFrame < currentFrame) {
  5516. if (onLoop) {
  5517. onLoop();
  5518. }
  5519. // Need to reset animation events
  5520. for (var index = 0; index < events.length; index++) {
  5521. if (!events[index].onlyOnce) {
  5522. // reset event, the animation is looping
  5523. events[index].isDone = false;
  5524. }
  5525. }
  5526. }
  5527. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5528. // Set value
  5529. this.setValue(currentValue, weight);
  5530. // Check events
  5531. for (var index = 0; index < events.length; index++) {
  5532. // Make sure current frame has passed event frame and that event frame is within the current range
  5533. // Also, handle both forward and reverse animations
  5534. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5535. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5536. var event = events[index];
  5537. if (!event.isDone) {
  5538. // If event should be done only once, remove it.
  5539. if (event.onlyOnce) {
  5540. events.splice(index, 1);
  5541. index--;
  5542. }
  5543. event.isDone = true;
  5544. event.action(currentFrame);
  5545. } // Don't do anything if the event has already be done.
  5546. }
  5547. }
  5548. if (!returnValue) {
  5549. this._stopped = true;
  5550. }
  5551. return returnValue;
  5552. };
  5553. return RuntimeAnimation;
  5554. }());
  5555. /***/ }),
  5556. /***/ "./Audio/analyser.ts":
  5557. /*!***************************!*\
  5558. !*** ./Audio/analyser.ts ***!
  5559. \***************************/
  5560. /*! exports provided: Analyser */
  5561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5562. "use strict";
  5563. __webpack_require__.r(__webpack_exports__);
  5564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5565. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5566. /**
  5567. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5569. */
  5570. var Analyser = /** @class */ (function () {
  5571. /**
  5572. * Creates a new analyser
  5573. * @param scene defines hosting scene
  5574. */
  5575. function Analyser(scene) {
  5576. /**
  5577. * Gets or sets the smoothing
  5578. * @ignorenaming
  5579. */
  5580. this.SMOOTHING = 0.75;
  5581. /**
  5582. * Gets or sets the FFT table size
  5583. * @ignorenaming
  5584. */
  5585. this.FFT_SIZE = 512;
  5586. /**
  5587. * Gets or sets the bar graph amplitude
  5588. * @ignorenaming
  5589. */
  5590. this.BARGRAPHAMPLITUDE = 256;
  5591. /**
  5592. * Gets or sets the position of the debug canvas
  5593. * @ignorenaming
  5594. */
  5595. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5596. /**
  5597. * Gets or sets the debug canvas size
  5598. * @ignorenaming
  5599. */
  5600. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5601. this._scene = scene;
  5602. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5603. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5604. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5605. this._webAudioAnalyser.minDecibels = -140;
  5606. this._webAudioAnalyser.maxDecibels = 0;
  5607. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5608. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5609. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5610. }
  5611. }
  5612. /**
  5613. * Get the number of data values you will have to play with for the visualization
  5614. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5615. * @returns a number
  5616. */
  5617. Analyser.prototype.getFrequencyBinCount = function () {
  5618. if (this._audioEngine.canUseWebAudio) {
  5619. return this._webAudioAnalyser.frequencyBinCount;
  5620. }
  5621. else {
  5622. return 0;
  5623. }
  5624. };
  5625. /**
  5626. * Gets the current frequency data as a byte array
  5627. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5628. * @returns a Uint8Array
  5629. */
  5630. Analyser.prototype.getByteFrequencyData = function () {
  5631. if (this._audioEngine.canUseWebAudio) {
  5632. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5633. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5634. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5635. }
  5636. return this._byteFreqs;
  5637. };
  5638. /**
  5639. * Gets the current waveform as a byte array
  5640. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5641. * @returns a Uint8Array
  5642. */
  5643. Analyser.prototype.getByteTimeDomainData = function () {
  5644. if (this._audioEngine.canUseWebAudio) {
  5645. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5646. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5647. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5648. }
  5649. return this._byteTime;
  5650. };
  5651. /**
  5652. * Gets the current frequency data as a float array
  5653. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5654. * @returns a Float32Array
  5655. */
  5656. Analyser.prototype.getFloatFrequencyData = function () {
  5657. if (this._audioEngine.canUseWebAudio) {
  5658. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5659. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5660. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5661. }
  5662. return this._floatFreqs;
  5663. };
  5664. /**
  5665. * Renders the debug canvas
  5666. */
  5667. Analyser.prototype.drawDebugCanvas = function () {
  5668. var _this = this;
  5669. if (this._audioEngine.canUseWebAudio) {
  5670. if (!this._debugCanvas) {
  5671. this._debugCanvas = document.createElement("canvas");
  5672. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5673. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5674. this._debugCanvas.style.position = "absolute";
  5675. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5676. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5677. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5678. document.body.appendChild(this._debugCanvas);
  5679. this._registerFunc = function () {
  5680. _this.drawDebugCanvas();
  5681. };
  5682. this._scene.registerBeforeRender(this._registerFunc);
  5683. }
  5684. if (this._registerFunc && this._debugCanvasContext) {
  5685. var workingArray = this.getByteFrequencyData();
  5686. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5687. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5688. // Draw the frequency domain chart.
  5689. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5690. var value = workingArray[i];
  5691. var percent = value / this.BARGRAPHAMPLITUDE;
  5692. var height = this.DEBUGCANVASSIZE.height * percent;
  5693. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5694. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5695. var hue = i / this.getFrequencyBinCount() * 360;
  5696. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5697. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5698. }
  5699. }
  5700. }
  5701. };
  5702. /**
  5703. * Stops rendering the debug canvas and removes it
  5704. */
  5705. Analyser.prototype.stopDebugCanvas = function () {
  5706. if (this._debugCanvas) {
  5707. if (this._registerFunc) {
  5708. this._scene.unregisterBeforeRender(this._registerFunc);
  5709. this._registerFunc = null;
  5710. }
  5711. document.body.removeChild(this._debugCanvas);
  5712. this._debugCanvas = null;
  5713. this._debugCanvasContext = null;
  5714. }
  5715. };
  5716. /**
  5717. * Connects two audio nodes
  5718. * @param inputAudioNode defines first node to connect
  5719. * @param outputAudioNode defines second node to connect
  5720. */
  5721. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5722. if (this._audioEngine.canUseWebAudio) {
  5723. inputAudioNode.connect(this._webAudioAnalyser);
  5724. this._webAudioAnalyser.connect(outputAudioNode);
  5725. }
  5726. };
  5727. /**
  5728. * Releases all associated resources
  5729. */
  5730. Analyser.prototype.dispose = function () {
  5731. if (this._audioEngine.canUseWebAudio) {
  5732. this._webAudioAnalyser.disconnect();
  5733. }
  5734. };
  5735. return Analyser;
  5736. }());
  5737. /***/ }),
  5738. /***/ "./Audio/audioEngine.ts":
  5739. /*!******************************!*\
  5740. !*** ./Audio/audioEngine.ts ***!
  5741. \******************************/
  5742. /*! exports provided: AudioEngine */
  5743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5744. "use strict";
  5745. __webpack_require__.r(__webpack_exports__);
  5746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5747. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5748. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5749. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5750. // Sets the default audio engine to Babylon.js
  5751. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5752. /**
  5753. * This represents the default audio engine used in babylon.
  5754. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5756. */
  5757. var AudioEngine = /** @class */ (function () {
  5758. /**
  5759. * Instantiates a new audio engine.
  5760. *
  5761. * There should be only one per page as some browsers restrict the number
  5762. * of audio contexts you can create.
  5763. * @param hostElement defines the host element where to display the mute icon if necessary
  5764. */
  5765. function AudioEngine(hostElement) {
  5766. if (hostElement === void 0) { hostElement = null; }
  5767. var _this = this;
  5768. this._audioContext = null;
  5769. this._audioContextInitialized = false;
  5770. this._muteButton = null;
  5771. /**
  5772. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5773. */
  5774. this.canUseWebAudio = false;
  5775. /**
  5776. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5777. * @ignoreNaming
  5778. */
  5779. this.WarnedWebAudioUnsupported = false;
  5780. /**
  5781. * Gets whether or not mp3 are supported by your browser.
  5782. */
  5783. this.isMP3supported = false;
  5784. /**
  5785. * Gets whether or not ogg are supported by your browser.
  5786. */
  5787. this.isOGGsupported = false;
  5788. /**
  5789. * Gets whether audio has been unlocked on the device.
  5790. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5791. * a user interaction has happened.
  5792. */
  5793. this.unlocked = true;
  5794. /**
  5795. * Defines if the audio engine relies on a custom unlocked button.
  5796. * In this case, the embedded button will not be displayed.
  5797. */
  5798. this.useCustomUnlockedButton = false;
  5799. /**
  5800. * Event raised when audio has been unlocked on the browser.
  5801. */
  5802. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5803. /**
  5804. * Event raised when audio has been locked on the browser.
  5805. */
  5806. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5807. this._tryToRun = false;
  5808. this._onResize = function () {
  5809. _this._moveButtonToTopLeft();
  5810. };
  5811. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5812. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5813. this.canUseWebAudio = true;
  5814. }
  5815. var audioElem = document.createElement('audio');
  5816. this._hostElement = hostElement;
  5817. try {
  5818. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5819. this.isMP3supported = true;
  5820. }
  5821. }
  5822. catch (e) {
  5823. // protect error during capability check.
  5824. }
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5827. this.isOGGsupported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. }
  5834. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5835. /**
  5836. * Gets the current AudioContext if available.
  5837. */
  5838. get: function () {
  5839. if (!this._audioContextInitialized) {
  5840. this._initializeAudioContext();
  5841. }
  5842. else {
  5843. if (!this.unlocked && !this._muteButton) {
  5844. this._displayMuteButton();
  5845. }
  5846. }
  5847. return this._audioContext;
  5848. },
  5849. enumerable: true,
  5850. configurable: true
  5851. });
  5852. /**
  5853. * Flags the audio engine in Locked state.
  5854. * This happens due to new browser policies preventing audio to autoplay.
  5855. */
  5856. AudioEngine.prototype.lock = function () {
  5857. this._triggerSuspendedState();
  5858. };
  5859. /**
  5860. * Unlocks the audio engine once a user action has been done on the dom.
  5861. * This is helpful to resume play once browser policies have been satisfied.
  5862. */
  5863. AudioEngine.prototype.unlock = function () {
  5864. this._triggerRunningState();
  5865. };
  5866. AudioEngine.prototype._resumeAudioContext = function () {
  5867. var result;
  5868. if (this._audioContext.resume) {
  5869. result = this._audioContext.resume();
  5870. }
  5871. return result || Promise.resolve();
  5872. };
  5873. AudioEngine.prototype._initializeAudioContext = function () {
  5874. try {
  5875. if (this.canUseWebAudio) {
  5876. this._audioContext = new AudioContext();
  5877. // create a global volume gain node
  5878. this.masterGain = this._audioContext.createGain();
  5879. this.masterGain.gain.value = 1;
  5880. this.masterGain.connect(this._audioContext.destination);
  5881. this._audioContextInitialized = true;
  5882. if (this._audioContext.state === "running") {
  5883. // Do not wait for the promise to unlock.
  5884. this._triggerRunningState();
  5885. }
  5886. }
  5887. }
  5888. catch (e) {
  5889. this.canUseWebAudio = false;
  5890. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5891. }
  5892. };
  5893. AudioEngine.prototype._triggerRunningState = function () {
  5894. var _this = this;
  5895. if (this._tryToRun) {
  5896. return;
  5897. }
  5898. this._tryToRun = true;
  5899. this._resumeAudioContext()
  5900. .then(function () {
  5901. _this._tryToRun = false;
  5902. if (_this._muteButton) {
  5903. _this._hideMuteButton();
  5904. }
  5905. }).catch(function () {
  5906. _this._tryToRun = false;
  5907. _this.unlocked = false;
  5908. });
  5909. // Notify users that the audio stack is unlocked/unmuted
  5910. this.unlocked = true;
  5911. this.onAudioUnlockedObservable.notifyObservers(this);
  5912. };
  5913. AudioEngine.prototype._triggerSuspendedState = function () {
  5914. this.unlocked = false;
  5915. this.onAudioLockedObservable.notifyObservers(this);
  5916. this._displayMuteButton();
  5917. };
  5918. AudioEngine.prototype._displayMuteButton = function () {
  5919. var _this = this;
  5920. if (this.useCustomUnlockedButton || this._muteButton) {
  5921. return;
  5922. }
  5923. this._muteButton = document.createElement("BUTTON");
  5924. this._muteButton.className = "babylonUnmuteIcon";
  5925. this._muteButton.id = "babylonUnmuteIconBtn";
  5926. this._muteButton.title = "Unmute";
  5927. 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) }";
  5928. var style = document.createElement('style');
  5929. style.appendChild(document.createTextNode(css));
  5930. document.getElementsByTagName('head')[0].appendChild(style);
  5931. document.body.appendChild(this._muteButton);
  5932. this._moveButtonToTopLeft();
  5933. this._muteButton.addEventListener('touchend', function () {
  5934. _this._triggerRunningState();
  5935. }, true);
  5936. this._muteButton.addEventListener('click', function () {
  5937. _this._triggerRunningState();
  5938. }, true);
  5939. window.addEventListener("resize", this._onResize);
  5940. };
  5941. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5942. if (this._hostElement && this._muteButton) {
  5943. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5944. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5945. }
  5946. };
  5947. AudioEngine.prototype._hideMuteButton = function () {
  5948. if (this._muteButton) {
  5949. document.body.removeChild(this._muteButton);
  5950. this._muteButton = null;
  5951. }
  5952. };
  5953. /**
  5954. * Destroy and release the resources associated with the audio ccontext.
  5955. */
  5956. AudioEngine.prototype.dispose = function () {
  5957. if (this.canUseWebAudio && this._audioContextInitialized) {
  5958. if (this._connectedAnalyser && this._audioContext) {
  5959. this._connectedAnalyser.stopDebugCanvas();
  5960. this._connectedAnalyser.dispose();
  5961. this.masterGain.disconnect();
  5962. this.masterGain.connect(this._audioContext.destination);
  5963. this._connectedAnalyser = null;
  5964. }
  5965. this.masterGain.gain.value = 1;
  5966. }
  5967. this.WarnedWebAudioUnsupported = false;
  5968. this._hideMuteButton();
  5969. window.removeEventListener("resize", this._onResize);
  5970. this.onAudioUnlockedObservable.clear();
  5971. this.onAudioLockedObservable.clear();
  5972. };
  5973. /**
  5974. * Gets the global volume sets on the master gain.
  5975. * @returns the global volume if set or -1 otherwise
  5976. */
  5977. AudioEngine.prototype.getGlobalVolume = function () {
  5978. if (this.canUseWebAudio && this._audioContextInitialized) {
  5979. return this.masterGain.gain.value;
  5980. }
  5981. else {
  5982. return -1;
  5983. }
  5984. };
  5985. /**
  5986. * Sets the global volume of your experience (sets on the master gain).
  5987. * @param newVolume Defines the new global volume of the application
  5988. */
  5989. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5990. if (this.canUseWebAudio && this._audioContextInitialized) {
  5991. this.masterGain.gain.value = newVolume;
  5992. }
  5993. };
  5994. /**
  5995. * Connect the audio engine to an audio analyser allowing some amazing
  5996. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5998. * @param analyser The analyser to connect to the engine
  5999. */
  6000. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6001. if (this._connectedAnalyser) {
  6002. this._connectedAnalyser.stopDebugCanvas();
  6003. }
  6004. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6005. this._connectedAnalyser = analyser;
  6006. this.masterGain.disconnect();
  6007. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6008. }
  6009. };
  6010. return AudioEngine;
  6011. }());
  6012. /***/ }),
  6013. /***/ "./Audio/audioSceneComponent.ts":
  6014. /*!**************************************!*\
  6015. !*** ./Audio/audioSceneComponent.ts ***!
  6016. \**************************************/
  6017. /*! exports provided: AudioSceneComponent */
  6018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6019. "use strict";
  6020. __webpack_require__.r(__webpack_exports__);
  6021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6022. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6023. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6024. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6026. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6027. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6028. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6029. // Adds the parser to the scene parsers.
  6030. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6031. // TODO: add sound
  6032. var loadedSounds = [];
  6033. var loadedSound;
  6034. container.sounds = container.sounds || [];
  6035. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6036. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6037. var parsedSound = parsedData.sounds[index];
  6038. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6039. if (!parsedSound.url) {
  6040. parsedSound.url = parsedSound.name;
  6041. }
  6042. if (!loadedSounds[parsedSound.url]) {
  6043. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6044. loadedSounds[parsedSound.url] = loadedSound;
  6045. container.sounds.push(loadedSound);
  6046. }
  6047. else {
  6048. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6049. }
  6050. }
  6051. else {
  6052. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6053. }
  6054. }
  6055. }
  6056. loadedSounds = [];
  6057. });
  6058. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6059. get: function () {
  6060. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6061. if (!compo) {
  6062. compo = new AudioSceneComponent(this);
  6063. this._addComponent(compo);
  6064. }
  6065. if (!this._mainSoundTrack) {
  6066. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6067. }
  6068. return this._mainSoundTrack;
  6069. },
  6070. enumerable: true,
  6071. configurable: true
  6072. });
  6073. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6074. var index;
  6075. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6076. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6077. return this.mainSoundTrack.soundCollection[index];
  6078. }
  6079. }
  6080. if (this.soundTracks) {
  6081. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6082. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6083. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6084. return this.soundTracks[sdIndex].soundCollection[index];
  6085. }
  6086. }
  6087. }
  6088. }
  6089. return null;
  6090. };
  6091. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6092. get: function () {
  6093. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6094. if (!compo) {
  6095. compo = new AudioSceneComponent(this);
  6096. this._addComponent(compo);
  6097. }
  6098. return compo.audioEnabled;
  6099. },
  6100. set: function (value) {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. if (value) {
  6107. compo.enableAudio();
  6108. }
  6109. else {
  6110. compo.disableAudio();
  6111. }
  6112. },
  6113. enumerable: true,
  6114. configurable: true
  6115. });
  6116. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6117. get: function () {
  6118. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6119. if (!compo) {
  6120. compo = new AudioSceneComponent(this);
  6121. this._addComponent(compo);
  6122. }
  6123. return compo.headphone;
  6124. },
  6125. set: function (value) {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. if (value) {
  6132. compo.switchAudioModeForHeadphones();
  6133. }
  6134. else {
  6135. compo.switchAudioModeForNormalSpeakers();
  6136. }
  6137. },
  6138. enumerable: true,
  6139. configurable: true
  6140. });
  6141. /**
  6142. * Defines the sound scene component responsible to manage any sounds
  6143. * in a given scene.
  6144. */
  6145. var AudioSceneComponent = /** @class */ (function () {
  6146. /**
  6147. * Creates a new instance of the component for the given scene
  6148. * @param scene Defines the scene to register the component in
  6149. */
  6150. function AudioSceneComponent(scene) {
  6151. /**
  6152. * The component name helpfull to identify the component in the list of scene components.
  6153. */
  6154. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6155. this._audioEnabled = true;
  6156. this._headphone = false;
  6157. this.scene = scene;
  6158. scene.soundTracks = new Array();
  6159. scene.sounds = new Array();
  6160. }
  6161. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6162. /**
  6163. * Gets whether audio is enabled or not.
  6164. * Please use related enable/disable method to switch state.
  6165. */
  6166. get: function () {
  6167. return this._audioEnabled;
  6168. },
  6169. enumerable: true,
  6170. configurable: true
  6171. });
  6172. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6173. /**
  6174. * Gets whether audio is outputing to headphone or not.
  6175. * Please use the according Switch methods to change output.
  6176. */
  6177. get: function () {
  6178. return this._headphone;
  6179. },
  6180. enumerable: true,
  6181. configurable: true
  6182. });
  6183. /**
  6184. * Registers the component in a given scene
  6185. */
  6186. AudioSceneComponent.prototype.register = function () {
  6187. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6188. };
  6189. /**
  6190. * Rebuilds the elements related to this component in case of
  6191. * context lost for instance.
  6192. */
  6193. AudioSceneComponent.prototype.rebuild = function () {
  6194. // Nothing to do here. (Not rendering related)
  6195. };
  6196. /**
  6197. * Serializes the component data to the specified json object
  6198. * @param serializationObject The object to serialize to
  6199. */
  6200. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6201. serializationObject.sounds = [];
  6202. if (this.scene.soundTracks) {
  6203. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6204. var soundtrack = this.scene.soundTracks[index];
  6205. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6206. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6207. }
  6208. }
  6209. }
  6210. };
  6211. /**
  6212. * Adds all the element from the container to the scene
  6213. * @param container the container holding the elements
  6214. */
  6215. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6216. var _this = this;
  6217. if (!container.sounds) {
  6218. return;
  6219. }
  6220. container.sounds.forEach(function (sound) {
  6221. sound.play();
  6222. sound.autoplay = true;
  6223. _this.scene.mainSoundTrack.AddSound(sound);
  6224. });
  6225. };
  6226. /**
  6227. * Removes all the elements in the container from the scene
  6228. * @param container contains the elements to remove
  6229. */
  6230. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6231. var _this = this;
  6232. if (!container.sounds) {
  6233. return;
  6234. }
  6235. container.sounds.forEach(function (sound) {
  6236. sound.stop();
  6237. sound.autoplay = false;
  6238. _this.scene.mainSoundTrack.RemoveSound(sound);
  6239. });
  6240. };
  6241. /**
  6242. * Disposes the component and the associated ressources.
  6243. */
  6244. AudioSceneComponent.prototype.dispose = function () {
  6245. var scene = this.scene;
  6246. if (scene._mainSoundTrack) {
  6247. scene.mainSoundTrack.dispose();
  6248. }
  6249. if (scene.soundTracks) {
  6250. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6251. scene.soundTracks[scIndex].dispose();
  6252. }
  6253. }
  6254. };
  6255. /**
  6256. * Disables audio in the associated scene.
  6257. */
  6258. AudioSceneComponent.prototype.disableAudio = function () {
  6259. var scene = this.scene;
  6260. this._audioEnabled = false;
  6261. var i;
  6262. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6263. scene.mainSoundTrack.soundCollection[i].pause();
  6264. }
  6265. if (scene.soundTracks) {
  6266. for (i = 0; i < scene.soundTracks.length; i++) {
  6267. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6268. scene.soundTracks[i].soundCollection[j].pause();
  6269. }
  6270. }
  6271. }
  6272. };
  6273. /**
  6274. * Enables audio in the associated scene.
  6275. */
  6276. AudioSceneComponent.prototype.enableAudio = function () {
  6277. var scene = this.scene;
  6278. this._audioEnabled = true;
  6279. var i;
  6280. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6281. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6282. scene.mainSoundTrack.soundCollection[i].play();
  6283. }
  6284. }
  6285. if (scene.soundTracks) {
  6286. for (i = 0; i < scene.soundTracks.length; i++) {
  6287. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6288. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6289. scene.soundTracks[i].soundCollection[j].play();
  6290. }
  6291. }
  6292. }
  6293. }
  6294. };
  6295. /**
  6296. * Switch audio to headphone output.
  6297. */
  6298. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6299. var scene = this.scene;
  6300. this._headphone = true;
  6301. scene.mainSoundTrack.switchPanningModelToHRTF();
  6302. if (scene.soundTracks) {
  6303. for (var i = 0; i < scene.soundTracks.length; i++) {
  6304. scene.soundTracks[i].switchPanningModelToHRTF();
  6305. }
  6306. }
  6307. };
  6308. /**
  6309. * Switch audio to normal speakers.
  6310. */
  6311. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6312. var scene = this.scene;
  6313. this._headphone = false;
  6314. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6315. if (scene.soundTracks) {
  6316. for (var i = 0; i < scene.soundTracks.length; i++) {
  6317. scene.soundTracks[i].switchPanningModelToEqualPower();
  6318. }
  6319. }
  6320. };
  6321. AudioSceneComponent.prototype._afterRender = function () {
  6322. var scene = this.scene;
  6323. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6324. return;
  6325. }
  6326. var listeningCamera;
  6327. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6328. if (scene.activeCameras.length > 0) {
  6329. listeningCamera = scene.activeCameras[0];
  6330. }
  6331. else {
  6332. listeningCamera = scene.activeCamera;
  6333. }
  6334. if (listeningCamera && audioEngine.audioContext) {
  6335. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6336. // for VR cameras
  6337. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6338. listeningCamera = listeningCamera.rigCameras[0];
  6339. }
  6340. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6341. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6342. cameraDirection.normalize();
  6343. // To avoid some errors on GearVR
  6344. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6345. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6346. }
  6347. var i;
  6348. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6349. var sound = scene.mainSoundTrack.soundCollection[i];
  6350. if (sound.useCustomAttenuation) {
  6351. sound.updateDistanceFromListener();
  6352. }
  6353. }
  6354. if (scene.soundTracks) {
  6355. for (i = 0; i < scene.soundTracks.length; i++) {
  6356. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6357. sound = scene.soundTracks[i].soundCollection[j];
  6358. if (sound.useCustomAttenuation) {
  6359. sound.updateDistanceFromListener();
  6360. }
  6361. }
  6362. }
  6363. }
  6364. }
  6365. };
  6366. return AudioSceneComponent;
  6367. }());
  6368. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6369. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6370. if (!compo) {
  6371. compo = new AudioSceneComponent(scene);
  6372. scene._addComponent(compo);
  6373. }
  6374. };
  6375. /***/ }),
  6376. /***/ "./Audio/index.ts":
  6377. /*!************************!*\
  6378. !*** ./Audio/index.ts ***!
  6379. \************************/
  6380. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6382. "use strict";
  6383. __webpack_require__.r(__webpack_exports__);
  6384. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6386. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6388. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6390. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6392. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6394. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6396. /***/ }),
  6397. /***/ "./Audio/sound.ts":
  6398. /*!************************!*\
  6399. !*** ./Audio/sound.ts ***!
  6400. \************************/
  6401. /*! exports provided: Sound */
  6402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6403. "use strict";
  6404. __webpack_require__.r(__webpack_exports__);
  6405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6406. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6408. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6409. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6410. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6411. /**
  6412. * Defines a sound that can be played in the application.
  6413. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6415. */
  6416. var Sound = /** @class */ (function () {
  6417. /**
  6418. * Create a sound and attach it to a scene
  6419. * @param name Name of your sound
  6420. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6421. * @param scene defines the scene the sound belongs to
  6422. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6423. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6424. */
  6425. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6426. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6427. var _this = this;
  6428. /**
  6429. * Does the sound autoplay once loaded.
  6430. */
  6431. this.autoplay = false;
  6432. /**
  6433. * Does the sound loop after it finishes playing once.
  6434. */
  6435. this.loop = false;
  6436. /**
  6437. * Does the sound use a custom attenuation curve to simulate the falloff
  6438. * happening when the source gets further away from the camera.
  6439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6440. */
  6441. this.useCustomAttenuation = false;
  6442. /**
  6443. * Is this sound currently played.
  6444. */
  6445. this.isPlaying = false;
  6446. /**
  6447. * Is this sound currently paused.
  6448. */
  6449. this.isPaused = false;
  6450. /**
  6451. * Does this sound enables spatial sound.
  6452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6453. */
  6454. this.spatialSound = false;
  6455. /**
  6456. * Define the reference distance the sound should be heard perfectly.
  6457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6458. */
  6459. this.refDistance = 1;
  6460. /**
  6461. * Define the roll off factor of spatial sounds.
  6462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6463. */
  6464. this.rolloffFactor = 1;
  6465. /**
  6466. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6468. */
  6469. this.maxDistance = 100;
  6470. /**
  6471. * Define the distance attenuation model the sound will follow.
  6472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6473. */
  6474. this.distanceModel = "linear";
  6475. /**
  6476. * Observable event when the current playing sound finishes.
  6477. */
  6478. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6479. this._panningModel = "equalpower";
  6480. this._playbackRate = 1;
  6481. this._streaming = false;
  6482. this._startTime = 0;
  6483. this._startOffset = 0;
  6484. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6485. /** @hidden */
  6486. this._positionInEmitterSpace = false;
  6487. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6488. this._volume = 1;
  6489. this._isReadyToPlay = false;
  6490. this._isDirectional = false;
  6491. // Used if you'd like to create a directional sound.
  6492. // If not set, the sound will be omnidirectional
  6493. this._coneInnerAngle = 360;
  6494. this._coneOuterAngle = 360;
  6495. this._coneOuterGain = 0;
  6496. this._isOutputConnected = false;
  6497. this._urlType = "Unknown";
  6498. this.name = name;
  6499. this._scene = scene;
  6500. Sound._SceneComponentInitialization(scene);
  6501. this._readyToPlayCallback = readyToPlayCallback;
  6502. // Default custom attenuation function is a linear attenuation
  6503. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6504. if (currentDistance < maxDistance) {
  6505. return currentVolume * (1 - currentDistance / maxDistance);
  6506. }
  6507. else {
  6508. return 0;
  6509. }
  6510. };
  6511. if (options) {
  6512. this.autoplay = options.autoplay || false;
  6513. this.loop = options.loop || false;
  6514. // if volume === 0, we need another way to check this option
  6515. if (options.volume !== undefined) {
  6516. this._volume = options.volume;
  6517. }
  6518. this.spatialSound = options.spatialSound || false;
  6519. this.maxDistance = options.maxDistance || 100;
  6520. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6521. this.rolloffFactor = options.rolloffFactor || 1;
  6522. this.refDistance = options.refDistance || 1;
  6523. this.distanceModel = options.distanceModel || "linear";
  6524. this._playbackRate = options.playbackRate || 1;
  6525. this._streaming = options.streaming || false;
  6526. }
  6527. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6528. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6529. this._soundGain.gain.value = this._volume;
  6530. this._inputAudioNode = this._soundGain;
  6531. this._outputAudioNode = this._soundGain;
  6532. if (this.spatialSound) {
  6533. this._createSpatialParameters();
  6534. }
  6535. this._scene.mainSoundTrack.AddSound(this);
  6536. var validParameter = true;
  6537. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6538. if (urlOrArrayBuffer) {
  6539. try {
  6540. if (typeof (urlOrArrayBuffer) === "string") {
  6541. this._urlType = "String";
  6542. }
  6543. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6544. this._urlType = "ArrayBuffer";
  6545. }
  6546. else if (urlOrArrayBuffer instanceof MediaStream) {
  6547. this._urlType = "MediaStream";
  6548. }
  6549. else if (Array.isArray(urlOrArrayBuffer)) {
  6550. this._urlType = "Array";
  6551. }
  6552. var urls = [];
  6553. var codecSupportedFound = false;
  6554. switch (this._urlType) {
  6555. case "MediaStream":
  6556. this._streaming = true;
  6557. this._isReadyToPlay = true;
  6558. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6559. if (this.autoplay) {
  6560. this.play();
  6561. }
  6562. if (this._readyToPlayCallback) {
  6563. this._readyToPlayCallback();
  6564. }
  6565. break;
  6566. case "ArrayBuffer":
  6567. if (urlOrArrayBuffer.byteLength > 0) {
  6568. codecSupportedFound = true;
  6569. this._soundLoaded(urlOrArrayBuffer);
  6570. }
  6571. break;
  6572. case "String":
  6573. urls.push(urlOrArrayBuffer);
  6574. case "Array":
  6575. if (urls.length === 0) {
  6576. urls = urlOrArrayBuffer;
  6577. }
  6578. // If we found a supported format, we load it immediately and stop the loop
  6579. for (var i = 0; i < urls.length; i++) {
  6580. var url = urls[i];
  6581. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6582. codecSupportedFound = true;
  6583. }
  6584. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6585. codecSupportedFound = true;
  6586. }
  6587. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6588. codecSupportedFound = true;
  6589. }
  6590. if (url.indexOf("blob:") !== -1) {
  6591. codecSupportedFound = true;
  6592. }
  6593. if (codecSupportedFound) {
  6594. // Loading sound using XHR2
  6595. if (!this._streaming) {
  6596. this._scene._loadFile(url, function (data) {
  6597. _this._soundLoaded(data);
  6598. }, undefined, true, true, function (exception) {
  6599. if (exception) {
  6600. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6601. }
  6602. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6603. _this._scene.mainSoundTrack.RemoveSound(_this);
  6604. });
  6605. }
  6606. // Streaming sound using HTML5 Audio tag
  6607. else {
  6608. this._htmlAudioElement = new Audio(url);
  6609. this._htmlAudioElement.controls = false;
  6610. this._htmlAudioElement.loop = this.loop;
  6611. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6612. this._htmlAudioElement.preload = "auto";
  6613. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6614. _this._isReadyToPlay = true;
  6615. if (_this.autoplay) {
  6616. _this.play();
  6617. }
  6618. if (_this._readyToPlayCallback) {
  6619. _this._readyToPlayCallback();
  6620. }
  6621. });
  6622. document.body.appendChild(this._htmlAudioElement);
  6623. this._htmlAudioElement.load();
  6624. }
  6625. break;
  6626. }
  6627. }
  6628. break;
  6629. default:
  6630. validParameter = false;
  6631. break;
  6632. }
  6633. if (!validParameter) {
  6634. _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.");
  6635. }
  6636. else {
  6637. if (!codecSupportedFound) {
  6638. this._isReadyToPlay = true;
  6639. // Simulating a ready to play event to avoid breaking code path
  6640. if (this._readyToPlayCallback) {
  6641. window.setTimeout(function () {
  6642. if (_this._readyToPlayCallback) {
  6643. _this._readyToPlayCallback();
  6644. }
  6645. }, 1000);
  6646. }
  6647. }
  6648. }
  6649. }
  6650. catch (ex) {
  6651. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6652. this._scene.mainSoundTrack.RemoveSound(this);
  6653. }
  6654. }
  6655. }
  6656. else {
  6657. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6658. this._scene.mainSoundTrack.AddSound(this);
  6659. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6660. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6661. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6662. }
  6663. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6664. if (this._readyToPlayCallback) {
  6665. window.setTimeout(function () {
  6666. if (_this._readyToPlayCallback) {
  6667. _this._readyToPlayCallback();
  6668. }
  6669. }, 1000);
  6670. }
  6671. }
  6672. }
  6673. /**
  6674. * Release the sound and its associated resources
  6675. */
  6676. Sound.prototype.dispose = function () {
  6677. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6678. if (this.isPlaying) {
  6679. this.stop();
  6680. }
  6681. this._isReadyToPlay = false;
  6682. if (this.soundTrackId === -1) {
  6683. this._scene.mainSoundTrack.RemoveSound(this);
  6684. }
  6685. else if (this._scene.soundTracks) {
  6686. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6687. }
  6688. if (this._soundGain) {
  6689. this._soundGain.disconnect();
  6690. this._soundGain = null;
  6691. }
  6692. if (this._soundPanner) {
  6693. this._soundPanner.disconnect();
  6694. this._soundPanner = null;
  6695. }
  6696. if (this._soundSource) {
  6697. this._soundSource.disconnect();
  6698. this._soundSource = null;
  6699. }
  6700. this._audioBuffer = null;
  6701. if (this._htmlAudioElement) {
  6702. this._htmlAudioElement.pause();
  6703. this._htmlAudioElement.src = "";
  6704. document.body.removeChild(this._htmlAudioElement);
  6705. }
  6706. if (this._streamingSource) {
  6707. this._streamingSource.disconnect();
  6708. }
  6709. if (this._connectedTransformNode && this._registerFunc) {
  6710. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6711. this._connectedTransformNode = null;
  6712. }
  6713. }
  6714. };
  6715. /**
  6716. * Gets if the sounds is ready to be played or not.
  6717. * @returns true if ready, otherwise false
  6718. */
  6719. Sound.prototype.isReady = function () {
  6720. return this._isReadyToPlay;
  6721. };
  6722. Sound.prototype._soundLoaded = function (audioData) {
  6723. var _this = this;
  6724. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6725. return;
  6726. }
  6727. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6728. _this._audioBuffer = buffer;
  6729. _this._isReadyToPlay = true;
  6730. if (_this.autoplay) {
  6731. _this.play();
  6732. }
  6733. if (_this._readyToPlayCallback) {
  6734. _this._readyToPlayCallback();
  6735. }
  6736. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6737. };
  6738. /**
  6739. * Sets the data of the sound from an audiobuffer
  6740. * @param audioBuffer The audioBuffer containing the data
  6741. */
  6742. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6743. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6744. this._audioBuffer = audioBuffer;
  6745. this._isReadyToPlay = true;
  6746. }
  6747. };
  6748. /**
  6749. * Updates the current sounds options such as maxdistance, loop...
  6750. * @param options A JSON object containing values named as the object properties
  6751. */
  6752. Sound.prototype.updateOptions = function (options) {
  6753. if (options) {
  6754. this.loop = options.loop || this.loop;
  6755. this.maxDistance = options.maxDistance || this.maxDistance;
  6756. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6757. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6758. this.refDistance = options.refDistance || this.refDistance;
  6759. this.distanceModel = options.distanceModel || this.distanceModel;
  6760. this._playbackRate = options.playbackRate || this._playbackRate;
  6761. this._updateSpatialParameters();
  6762. if (this.isPlaying) {
  6763. if (this._streaming && this._htmlAudioElement) {
  6764. this._htmlAudioElement.playbackRate = this._playbackRate;
  6765. }
  6766. else {
  6767. if (this._soundSource) {
  6768. this._soundSource.playbackRate.value = this._playbackRate;
  6769. }
  6770. }
  6771. }
  6772. }
  6773. };
  6774. Sound.prototype._createSpatialParameters = function () {
  6775. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6776. if (this._scene.headphone) {
  6777. this._panningModel = "HRTF";
  6778. }
  6779. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6780. this._updateSpatialParameters();
  6781. this._soundPanner.connect(this._outputAudioNode);
  6782. this._inputAudioNode = this._soundPanner;
  6783. }
  6784. };
  6785. Sound.prototype._updateSpatialParameters = function () {
  6786. if (this.spatialSound && this._soundPanner) {
  6787. if (this.useCustomAttenuation) {
  6788. // Tricks to disable in a way embedded Web Audio attenuation
  6789. this._soundPanner.distanceModel = "linear";
  6790. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6791. this._soundPanner.refDistance = 1;
  6792. this._soundPanner.rolloffFactor = 1;
  6793. this._soundPanner.panningModel = this._panningModel;
  6794. }
  6795. else {
  6796. this._soundPanner.distanceModel = this.distanceModel;
  6797. this._soundPanner.maxDistance = this.maxDistance;
  6798. this._soundPanner.refDistance = this.refDistance;
  6799. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6800. this._soundPanner.panningModel = this._panningModel;
  6801. }
  6802. }
  6803. };
  6804. /**
  6805. * Switch the panning model to HRTF:
  6806. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6808. */
  6809. Sound.prototype.switchPanningModelToHRTF = function () {
  6810. this._panningModel = "HRTF";
  6811. this._switchPanningModel();
  6812. };
  6813. /**
  6814. * Switch the panning model to Equal Power:
  6815. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6817. */
  6818. Sound.prototype.switchPanningModelToEqualPower = function () {
  6819. this._panningModel = "equalpower";
  6820. this._switchPanningModel();
  6821. };
  6822. Sound.prototype._switchPanningModel = function () {
  6823. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6824. this._soundPanner.panningModel = this._panningModel;
  6825. }
  6826. };
  6827. /**
  6828. * Connect this sound to a sound track audio node like gain...
  6829. * @param soundTrackAudioNode the sound track audio node to connect to
  6830. */
  6831. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6832. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6833. if (this._isOutputConnected) {
  6834. this._outputAudioNode.disconnect();
  6835. }
  6836. this._outputAudioNode.connect(soundTrackAudioNode);
  6837. this._isOutputConnected = true;
  6838. }
  6839. };
  6840. /**
  6841. * Transform this sound into a directional source
  6842. * @param coneInnerAngle Size of the inner cone in degree
  6843. * @param coneOuterAngle Size of the outer cone in degree
  6844. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6845. */
  6846. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6847. if (coneOuterAngle < coneInnerAngle) {
  6848. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6849. return;
  6850. }
  6851. this._coneInnerAngle = coneInnerAngle;
  6852. this._coneOuterAngle = coneOuterAngle;
  6853. this._coneOuterGain = coneOuterGain;
  6854. this._isDirectional = true;
  6855. if (this.isPlaying && this.loop) {
  6856. this.stop();
  6857. this.play();
  6858. }
  6859. };
  6860. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6861. /**
  6862. * Gets or sets the inner angle for the directional cone.
  6863. */
  6864. get: function () {
  6865. return this._coneInnerAngle;
  6866. },
  6867. /**
  6868. * Gets or sets the inner angle for the directional cone.
  6869. */
  6870. set: function (value) {
  6871. if (value != this._coneInnerAngle) {
  6872. if (this._coneOuterAngle < value) {
  6873. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6874. return;
  6875. }
  6876. this._coneInnerAngle = value;
  6877. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6878. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6879. }
  6880. }
  6881. },
  6882. enumerable: true,
  6883. configurable: true
  6884. });
  6885. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6886. /**
  6887. * Gets or sets the outer angle for the directional cone.
  6888. */
  6889. get: function () {
  6890. return this._coneOuterAngle;
  6891. },
  6892. /**
  6893. * Gets or sets the outer angle for the directional cone.
  6894. */
  6895. set: function (value) {
  6896. if (value != this._coneOuterAngle) {
  6897. if (value < this._coneInnerAngle) {
  6898. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6899. return;
  6900. }
  6901. this._coneOuterAngle = value;
  6902. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6903. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6904. }
  6905. }
  6906. },
  6907. enumerable: true,
  6908. configurable: true
  6909. });
  6910. /**
  6911. * Sets the position of the emitter if spatial sound is enabled
  6912. * @param newPosition Defines the new posisiton
  6913. */
  6914. Sound.prototype.setPosition = function (newPosition) {
  6915. this._position = newPosition;
  6916. 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)) {
  6917. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6918. }
  6919. };
  6920. /**
  6921. * Sets the local direction of the emitter if spatial sound is enabled
  6922. * @param newLocalDirection Defines the new local direction
  6923. */
  6924. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6925. this._localDirection = newLocalDirection;
  6926. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6927. this._updateDirection();
  6928. }
  6929. };
  6930. Sound.prototype._updateDirection = function () {
  6931. if (!this._connectedTransformNode || !this._soundPanner) {
  6932. return;
  6933. }
  6934. var mat = this._connectedTransformNode.getWorldMatrix();
  6935. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6936. direction.normalize();
  6937. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6938. };
  6939. /** @hidden */
  6940. Sound.prototype.updateDistanceFromListener = function () {
  6941. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6942. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6943. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6944. }
  6945. };
  6946. /**
  6947. * Sets a new custom attenuation function for the sound.
  6948. * @param callback Defines the function used for the attenuation
  6949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6950. */
  6951. Sound.prototype.setAttenuationFunction = function (callback) {
  6952. this._customAttenuationFunction = callback;
  6953. };
  6954. /**
  6955. * Play the sound
  6956. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6957. * @param offset (optional) Start the sound setting it at a specific time
  6958. */
  6959. Sound.prototype.play = function (time, offset) {
  6960. var _this = this;
  6961. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6962. try {
  6963. if (this._startOffset < 0) {
  6964. time = -this._startOffset;
  6965. this._startOffset = 0;
  6966. }
  6967. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6968. if (!this._soundSource || !this._streamingSource) {
  6969. if (this.spatialSound && this._soundPanner) {
  6970. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6971. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6972. }
  6973. if (this._isDirectional) {
  6974. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6975. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6976. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6977. if (this._connectedTransformNode) {
  6978. this._updateDirection();
  6979. }
  6980. else {
  6981. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6982. }
  6983. }
  6984. }
  6985. }
  6986. if (this._streaming) {
  6987. if (!this._streamingSource) {
  6988. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6989. this._htmlAudioElement.onended = function () { _this._onended(); };
  6990. this._htmlAudioElement.playbackRate = this._playbackRate;
  6991. }
  6992. this._streamingSource.disconnect();
  6993. this._streamingSource.connect(this._inputAudioNode);
  6994. if (this._htmlAudioElement) {
  6995. // required to manage properly the new suspended default state of Chrome
  6996. // When the option 'streaming: true' is used, we need first to wait for
  6997. // the audio engine to be unlocked by a user gesture before trying to play
  6998. // an HTML Audio elememt
  6999. var tryToPlay = function () {
  7000. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7001. var playPromise = _this._htmlAudioElement.play();
  7002. // In browsers that don’t yet support this functionality,
  7003. // playPromise won’t be defined.
  7004. if (playPromise !== undefined) {
  7005. playPromise.catch(function (error) {
  7006. // Automatic playback failed.
  7007. // Waiting for the audio engine to be unlocked by user click on unmute
  7008. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7009. if (_this.loop || _this.autoplay) {
  7010. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7011. }
  7012. });
  7013. }
  7014. }
  7015. else {
  7016. if (_this.loop || _this.autoplay) {
  7017. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7018. }
  7019. }
  7020. };
  7021. tryToPlay();
  7022. }
  7023. }
  7024. else {
  7025. var tryToPlay = function () {
  7026. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7027. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7028. _this._soundSource.buffer = _this._audioBuffer;
  7029. _this._soundSource.connect(_this._inputAudioNode);
  7030. _this._soundSource.loop = _this.loop;
  7031. _this._soundSource.playbackRate.value = _this._playbackRate;
  7032. _this._soundSource.onended = function () { _this._onended(); };
  7033. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7034. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7035. }
  7036. };
  7037. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7038. // Wait a bit for FF as context seems late to be ready.
  7039. setTimeout(function () {
  7040. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7041. // Automatic playback failed.
  7042. // Waiting for the audio engine to be unlocked by user click on unmute
  7043. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7044. if (_this.loop || _this.autoplay) {
  7045. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7046. }
  7047. }
  7048. else {
  7049. tryToPlay();
  7050. }
  7051. }, 500);
  7052. }
  7053. else {
  7054. tryToPlay();
  7055. }
  7056. }
  7057. this._startTime = startTime;
  7058. this.isPlaying = true;
  7059. this.isPaused = false;
  7060. }
  7061. catch (ex) {
  7062. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7063. }
  7064. }
  7065. };
  7066. Sound.prototype._onended = function () {
  7067. this.isPlaying = false;
  7068. if (this.onended) {
  7069. this.onended();
  7070. }
  7071. this.onEndedObservable.notifyObservers(this);
  7072. };
  7073. /**
  7074. * Stop the sound
  7075. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7076. */
  7077. Sound.prototype.stop = function (time) {
  7078. if (this.isPlaying) {
  7079. if (this._streaming) {
  7080. if (this._htmlAudioElement) {
  7081. this._htmlAudioElement.pause();
  7082. // Test needed for Firefox or it will generate an Invalid State Error
  7083. if (this._htmlAudioElement.currentTime > 0) {
  7084. this._htmlAudioElement.currentTime = 0;
  7085. }
  7086. }
  7087. else {
  7088. this._streamingSource.disconnect();
  7089. }
  7090. }
  7091. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7092. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7093. this._soundSource.stop(stopTime);
  7094. this._soundSource.onended = function () { };
  7095. if (!this.isPaused) {
  7096. this._startOffset = 0;
  7097. }
  7098. }
  7099. this.isPlaying = false;
  7100. }
  7101. };
  7102. /**
  7103. * Put the sound in pause
  7104. */
  7105. Sound.prototype.pause = function () {
  7106. if (this.isPlaying) {
  7107. this.isPaused = true;
  7108. if (this._streaming) {
  7109. if (this._htmlAudioElement) {
  7110. this._htmlAudioElement.pause();
  7111. }
  7112. else {
  7113. this._streamingSource.disconnect();
  7114. }
  7115. }
  7116. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7117. this.stop(0);
  7118. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7119. }
  7120. }
  7121. };
  7122. /**
  7123. * Sets a dedicated volume for this sounds
  7124. * @param newVolume Define the new volume of the sound
  7125. * @param time Define in how long the sound should be at this value
  7126. */
  7127. Sound.prototype.setVolume = function (newVolume, time) {
  7128. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7129. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7130. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7131. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7132. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7133. }
  7134. else {
  7135. this._soundGain.gain.value = newVolume;
  7136. }
  7137. }
  7138. this._volume = newVolume;
  7139. };
  7140. /**
  7141. * Set the sound play back rate
  7142. * @param newPlaybackRate Define the playback rate the sound should be played at
  7143. */
  7144. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7145. this._playbackRate = newPlaybackRate;
  7146. if (this.isPlaying) {
  7147. if (this._streaming && this._htmlAudioElement) {
  7148. this._htmlAudioElement.playbackRate = this._playbackRate;
  7149. }
  7150. else if (this._soundSource) {
  7151. this._soundSource.playbackRate.value = this._playbackRate;
  7152. }
  7153. }
  7154. };
  7155. /**
  7156. * Gets the volume of the sound.
  7157. * @returns the volume of the sound
  7158. */
  7159. Sound.prototype.getVolume = function () {
  7160. return this._volume;
  7161. };
  7162. /**
  7163. * Attach the sound to a dedicated mesh
  7164. * @param transformNode The transform node to connect the sound with
  7165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7166. */
  7167. Sound.prototype.attachToMesh = function (transformNode) {
  7168. var _this = this;
  7169. if (this._connectedTransformNode && this._registerFunc) {
  7170. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7171. this._registerFunc = null;
  7172. }
  7173. this._connectedTransformNode = transformNode;
  7174. if (!this.spatialSound) {
  7175. this.spatialSound = true;
  7176. this._createSpatialParameters();
  7177. if (this.isPlaying && this.loop) {
  7178. this.stop();
  7179. this.play();
  7180. }
  7181. }
  7182. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7183. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7184. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7185. };
  7186. /**
  7187. * Detach the sound from the previously attached mesh
  7188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7189. */
  7190. Sound.prototype.detachFromMesh = function () {
  7191. if (this._connectedTransformNode && this._registerFunc) {
  7192. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7193. this._registerFunc = null;
  7194. this._connectedTransformNode = null;
  7195. }
  7196. };
  7197. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7198. if (!node.getBoundingInfo) {
  7199. return;
  7200. }
  7201. var mesh = node;
  7202. if (this._positionInEmitterSpace) {
  7203. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7204. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7205. }
  7206. else {
  7207. var boundingInfo = mesh.getBoundingInfo();
  7208. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7209. }
  7210. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7211. this._updateDirection();
  7212. }
  7213. };
  7214. /**
  7215. * Clone the current sound in the scene.
  7216. * @returns the new sound clone
  7217. */
  7218. Sound.prototype.clone = function () {
  7219. var _this = this;
  7220. if (!this._streaming) {
  7221. var setBufferAndRun = function () {
  7222. if (_this._isReadyToPlay) {
  7223. clonedSound._audioBuffer = _this.getAudioBuffer();
  7224. clonedSound._isReadyToPlay = true;
  7225. if (clonedSound.autoplay) {
  7226. clonedSound.play();
  7227. }
  7228. }
  7229. else {
  7230. window.setTimeout(setBufferAndRun, 300);
  7231. }
  7232. };
  7233. var currentOptions = {
  7234. autoplay: this.autoplay, loop: this.loop,
  7235. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7236. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7237. refDistance: this.refDistance, distanceModel: this.distanceModel
  7238. };
  7239. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7240. if (this.useCustomAttenuation) {
  7241. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7242. }
  7243. clonedSound.setPosition(this._position);
  7244. clonedSound.setPlaybackRate(this._playbackRate);
  7245. setBufferAndRun();
  7246. return clonedSound;
  7247. }
  7248. // Can't clone a streaming sound
  7249. else {
  7250. return null;
  7251. }
  7252. };
  7253. /**
  7254. * Gets the current underlying audio buffer containing the data
  7255. * @returns the audio buffer
  7256. */
  7257. Sound.prototype.getAudioBuffer = function () {
  7258. return this._audioBuffer;
  7259. };
  7260. /**
  7261. * Serializes the Sound in a JSON representation
  7262. * @returns the JSON representation of the sound
  7263. */
  7264. Sound.prototype.serialize = function () {
  7265. var serializationObject = {
  7266. name: this.name,
  7267. url: this.name,
  7268. autoplay: this.autoplay,
  7269. loop: this.loop,
  7270. volume: this._volume,
  7271. spatialSound: this.spatialSound,
  7272. maxDistance: this.maxDistance,
  7273. rolloffFactor: this.rolloffFactor,
  7274. refDistance: this.refDistance,
  7275. distanceModel: this.distanceModel,
  7276. playbackRate: this._playbackRate,
  7277. panningModel: this._panningModel,
  7278. soundTrackId: this.soundTrackId
  7279. };
  7280. if (this.spatialSound) {
  7281. if (this._connectedTransformNode) {
  7282. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7283. }
  7284. serializationObject.position = this._position.asArray();
  7285. serializationObject.refDistance = this.refDistance;
  7286. serializationObject.distanceModel = this.distanceModel;
  7287. serializationObject.isDirectional = this._isDirectional;
  7288. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7289. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7290. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7291. serializationObject.coneOuterGain = this._coneOuterGain;
  7292. }
  7293. return serializationObject;
  7294. };
  7295. /**
  7296. * Parse a JSON representation of a sound to innstantiate in a given scene
  7297. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7298. * @param scene Define the scene the new parsed sound should be created in
  7299. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7300. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7301. * @returns the newly parsed sound
  7302. */
  7303. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7304. var soundName = parsedSound.name;
  7305. var soundUrl;
  7306. if (parsedSound.url) {
  7307. soundUrl = rootUrl + parsedSound.url;
  7308. }
  7309. else {
  7310. soundUrl = rootUrl + soundName;
  7311. }
  7312. var options = {
  7313. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7314. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7315. rolloffFactor: parsedSound.rolloffFactor,
  7316. refDistance: parsedSound.refDistance,
  7317. distanceModel: parsedSound.distanceModel,
  7318. playbackRate: parsedSound.playbackRate
  7319. };
  7320. var newSound;
  7321. if (!sourceSound) {
  7322. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7323. scene._addPendingData(newSound);
  7324. }
  7325. else {
  7326. var setBufferAndRun = function () {
  7327. if (sourceSound._isReadyToPlay) {
  7328. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7329. newSound._isReadyToPlay = true;
  7330. if (newSound.autoplay) {
  7331. newSound.play();
  7332. }
  7333. }
  7334. else {
  7335. window.setTimeout(setBufferAndRun, 300);
  7336. }
  7337. };
  7338. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7339. setBufferAndRun();
  7340. }
  7341. if (parsedSound.position) {
  7342. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7343. newSound.setPosition(soundPosition);
  7344. }
  7345. if (parsedSound.isDirectional) {
  7346. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7347. if (parsedSound.localDirectionToMesh) {
  7348. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7349. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7350. }
  7351. }
  7352. if (parsedSound.connectedMeshId) {
  7353. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7354. if (connectedMesh) {
  7355. newSound.attachToMesh(connectedMesh);
  7356. }
  7357. }
  7358. return newSound;
  7359. };
  7360. /** @hidden */
  7361. Sound._SceneComponentInitialization = function (_) {
  7362. throw "Import AudioSceneComponent before creating sound.";
  7363. };
  7364. return Sound;
  7365. }());
  7366. /***/ }),
  7367. /***/ "./Audio/soundTrack.ts":
  7368. /*!*****************************!*\
  7369. !*** ./Audio/soundTrack.ts ***!
  7370. \*****************************/
  7371. /*! exports provided: SoundTrack */
  7372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7373. "use strict";
  7374. __webpack_require__.r(__webpack_exports__);
  7375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7376. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7377. /**
  7378. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7379. * It will be also used in a future release to apply effects on a specific track.
  7380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7381. */
  7382. var SoundTrack = /** @class */ (function () {
  7383. /**
  7384. * Creates a new sound track.
  7385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7386. * @param scene Define the scene the sound track belongs to
  7387. * @param options
  7388. */
  7389. function SoundTrack(scene, options) {
  7390. if (options === void 0) { options = {}; }
  7391. /**
  7392. * The unique identifier of the sound track in the scene.
  7393. */
  7394. this.id = -1;
  7395. this._isMainTrack = false;
  7396. this._isInitialized = false;
  7397. this._scene = scene;
  7398. this.soundCollection = new Array();
  7399. this._options = options;
  7400. if (!this._isMainTrack && this._scene.soundTracks) {
  7401. this._scene.soundTracks.push(this);
  7402. this.id = this._scene.soundTracks.length - 1;
  7403. }
  7404. }
  7405. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7406. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7407. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7408. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7409. if (this._options) {
  7410. if (this._options.volume) {
  7411. this._outputAudioNode.gain.value = this._options.volume;
  7412. }
  7413. if (this._options.mainTrack) {
  7414. this._isMainTrack = this._options.mainTrack;
  7415. }
  7416. }
  7417. this._isInitialized = true;
  7418. }
  7419. };
  7420. /**
  7421. * Release the sound track and its associated resources
  7422. */
  7423. SoundTrack.prototype.dispose = function () {
  7424. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7425. if (this._connectedAnalyser) {
  7426. this._connectedAnalyser.stopDebugCanvas();
  7427. }
  7428. while (this.soundCollection.length) {
  7429. this.soundCollection[0].dispose();
  7430. }
  7431. if (this._outputAudioNode) {
  7432. this._outputAudioNode.disconnect();
  7433. }
  7434. this._outputAudioNode = null;
  7435. }
  7436. };
  7437. /**
  7438. * Adds a sound to this sound track
  7439. * @param sound define the cound to add
  7440. * @ignoreNaming
  7441. */
  7442. SoundTrack.prototype.AddSound = function (sound) {
  7443. if (!this._isInitialized) {
  7444. this._initializeSoundTrackAudioGraph();
  7445. }
  7446. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7447. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7448. }
  7449. if (sound.soundTrackId) {
  7450. if (sound.soundTrackId === -1) {
  7451. this._scene.mainSoundTrack.RemoveSound(sound);
  7452. }
  7453. else if (this._scene.soundTracks) {
  7454. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7455. }
  7456. }
  7457. this.soundCollection.push(sound);
  7458. sound.soundTrackId = this.id;
  7459. };
  7460. /**
  7461. * Removes a sound to this sound track
  7462. * @param sound define the cound to remove
  7463. * @ignoreNaming
  7464. */
  7465. SoundTrack.prototype.RemoveSound = function (sound) {
  7466. var index = this.soundCollection.indexOf(sound);
  7467. if (index !== -1) {
  7468. this.soundCollection.splice(index, 1);
  7469. }
  7470. };
  7471. /**
  7472. * Set a global volume for the full sound track.
  7473. * @param newVolume Define the new volume of the sound track
  7474. */
  7475. SoundTrack.prototype.setVolume = function (newVolume) {
  7476. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7477. this._outputAudioNode.gain.value = newVolume;
  7478. }
  7479. };
  7480. /**
  7481. * Switch the panning model to HRTF:
  7482. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7484. */
  7485. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7486. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7487. for (var i = 0; i < this.soundCollection.length; i++) {
  7488. this.soundCollection[i].switchPanningModelToHRTF();
  7489. }
  7490. }
  7491. };
  7492. /**
  7493. * Switch the panning model to Equal Power:
  7494. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7496. */
  7497. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7498. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7499. for (var i = 0; i < this.soundCollection.length; i++) {
  7500. this.soundCollection[i].switchPanningModelToEqualPower();
  7501. }
  7502. }
  7503. };
  7504. /**
  7505. * Connect the sound track to an audio analyser allowing some amazing
  7506. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7508. * @param analyser The analyser to connect to the engine
  7509. */
  7510. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7511. if (this._connectedAnalyser) {
  7512. this._connectedAnalyser.stopDebugCanvas();
  7513. }
  7514. this._connectedAnalyser = analyser;
  7515. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7516. this._outputAudioNode.disconnect();
  7517. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7518. }
  7519. };
  7520. return SoundTrack;
  7521. }());
  7522. /***/ }),
  7523. /***/ "./Audio/weightedsound.ts":
  7524. /*!********************************!*\
  7525. !*** ./Audio/weightedsound.ts ***!
  7526. \********************************/
  7527. /*! exports provided: WeightedSound */
  7528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7529. "use strict";
  7530. __webpack_require__.r(__webpack_exports__);
  7531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7532. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7533. /**
  7534. * Wraps one or more Sound objects and selects one with random weight for playback.
  7535. */
  7536. var WeightedSound = /** @class */ (function () {
  7537. /**
  7538. * Creates a new WeightedSound from the list of sounds given.
  7539. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7540. * @param sounds Array of Sounds that will be selected from.
  7541. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7542. */
  7543. function WeightedSound(loop, sounds, weights) {
  7544. var _this = this;
  7545. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7546. this.loop = false;
  7547. this._coneInnerAngle = 360;
  7548. this._coneOuterAngle = 360;
  7549. this._volume = 1;
  7550. /** A Sound is currently playing. */
  7551. this.isPlaying = false;
  7552. /** A Sound is currently paused. */
  7553. this.isPaused = false;
  7554. this._sounds = [];
  7555. this._weights = [];
  7556. if (sounds.length !== weights.length) {
  7557. throw new Error('Sounds length does not equal weights length');
  7558. }
  7559. this.loop = loop;
  7560. this._weights = weights;
  7561. // Normalize the weights
  7562. var weightSum = 0;
  7563. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7564. var weight = weights_1[_i];
  7565. weightSum += weight;
  7566. }
  7567. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7568. for (var i = 0; i < this._weights.length; i++) {
  7569. this._weights[i] *= invWeightSum;
  7570. }
  7571. this._sounds = sounds;
  7572. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7573. var sound = _b[_a];
  7574. sound.onEndedObservable.add(function () { _this._onended(); });
  7575. }
  7576. }
  7577. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7578. /**
  7579. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7580. */
  7581. get: function () {
  7582. return this._coneInnerAngle;
  7583. },
  7584. /**
  7585. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7586. */
  7587. set: function (value) {
  7588. if (value !== this._coneInnerAngle) {
  7589. if (this._coneOuterAngle < value) {
  7590. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7591. return;
  7592. }
  7593. this._coneInnerAngle = value;
  7594. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7595. var sound = _a[_i];
  7596. sound.directionalConeInnerAngle = value;
  7597. }
  7598. }
  7599. },
  7600. enumerable: true,
  7601. configurable: true
  7602. });
  7603. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7604. /**
  7605. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7606. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7607. */
  7608. get: function () {
  7609. return this._coneOuterAngle;
  7610. },
  7611. /**
  7612. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7613. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7614. */
  7615. set: function (value) {
  7616. if (value !== this._coneOuterAngle) {
  7617. if (value < this._coneInnerAngle) {
  7618. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7619. return;
  7620. }
  7621. this._coneOuterAngle = value;
  7622. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7623. var sound = _a[_i];
  7624. sound.directionalConeOuterAngle = value;
  7625. }
  7626. }
  7627. },
  7628. enumerable: true,
  7629. configurable: true
  7630. });
  7631. Object.defineProperty(WeightedSound.prototype, "volume", {
  7632. /**
  7633. * Playback volume.
  7634. */
  7635. get: function () {
  7636. return this._volume;
  7637. },
  7638. /**
  7639. * Playback volume.
  7640. */
  7641. set: function (value) {
  7642. if (value !== this._volume) {
  7643. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7644. var sound = _a[_i];
  7645. sound.setVolume(value);
  7646. }
  7647. }
  7648. },
  7649. enumerable: true,
  7650. configurable: true
  7651. });
  7652. WeightedSound.prototype._onended = function () {
  7653. if (this._currentIndex !== undefined) {
  7654. this._sounds[this._currentIndex].autoplay = false;
  7655. }
  7656. if (this.loop && this.isPlaying) {
  7657. this.play();
  7658. }
  7659. else {
  7660. this.isPlaying = false;
  7661. }
  7662. };
  7663. /**
  7664. * Suspend playback
  7665. */
  7666. WeightedSound.prototype.pause = function () {
  7667. this.isPaused = true;
  7668. if (this._currentIndex !== undefined) {
  7669. this._sounds[this._currentIndex].pause();
  7670. }
  7671. };
  7672. /**
  7673. * Stop playback
  7674. */
  7675. WeightedSound.prototype.stop = function () {
  7676. this.isPlaying = false;
  7677. if (this._currentIndex !== undefined) {
  7678. this._sounds[this._currentIndex].stop();
  7679. }
  7680. };
  7681. /**
  7682. * Start playback.
  7683. * @param startOffset Position the clip head at a specific time in seconds.
  7684. */
  7685. WeightedSound.prototype.play = function (startOffset) {
  7686. if (!this.isPaused) {
  7687. this.stop();
  7688. var randomValue = Math.random();
  7689. var total = 0;
  7690. for (var i = 0; i < this._weights.length; i++) {
  7691. total += this._weights[i];
  7692. if (randomValue <= total) {
  7693. this._currentIndex = i;
  7694. break;
  7695. }
  7696. }
  7697. }
  7698. var sound = this._sounds[this._currentIndex];
  7699. if (sound.isReady()) {
  7700. sound.play(0, this.isPaused ? undefined : startOffset);
  7701. }
  7702. else {
  7703. sound.autoplay = true;
  7704. }
  7705. this.isPlaying = true;
  7706. this.isPaused = false;
  7707. };
  7708. return WeightedSound;
  7709. }());
  7710. /***/ }),
  7711. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7712. /*!***************************************************!*\
  7713. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7714. \***************************************************/
  7715. /*! exports provided: AutoRotationBehavior */
  7716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7717. "use strict";
  7718. __webpack_require__.r(__webpack_exports__);
  7719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7720. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7721. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7722. /**
  7723. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7724. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7725. */
  7726. var AutoRotationBehavior = /** @class */ (function () {
  7727. function AutoRotationBehavior() {
  7728. this._zoomStopsAnimation = false;
  7729. this._idleRotationSpeed = 0.05;
  7730. this._idleRotationWaitTime = 2000;
  7731. this._idleRotationSpinupTime = 2000;
  7732. this._isPointerDown = false;
  7733. this._lastFrameTime = null;
  7734. this._lastInteractionTime = -Infinity;
  7735. this._cameraRotationSpeed = 0;
  7736. this._lastFrameRadius = 0;
  7737. }
  7738. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7739. /**
  7740. * Gets the name of the behavior.
  7741. */
  7742. get: function () {
  7743. return "AutoRotation";
  7744. },
  7745. enumerable: true,
  7746. configurable: true
  7747. });
  7748. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7749. /**
  7750. * Gets the flag that indicates if user zooming should stop animation.
  7751. */
  7752. get: function () {
  7753. return this._zoomStopsAnimation;
  7754. },
  7755. /**
  7756. * Sets the flag that indicates if user zooming should stop animation.
  7757. */
  7758. set: function (flag) {
  7759. this._zoomStopsAnimation = flag;
  7760. },
  7761. enumerable: true,
  7762. configurable: true
  7763. });
  7764. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7765. /**
  7766. * Gets the default speed at which the camera rotates around the model.
  7767. */
  7768. get: function () {
  7769. return this._idleRotationSpeed;
  7770. },
  7771. /**
  7772. * Sets the default speed at which the camera rotates around the model.
  7773. */
  7774. set: function (speed) {
  7775. this._idleRotationSpeed = speed;
  7776. },
  7777. enumerable: true,
  7778. configurable: true
  7779. });
  7780. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7781. /**
  7782. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7783. */
  7784. get: function () {
  7785. return this._idleRotationWaitTime;
  7786. },
  7787. /**
  7788. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7789. */
  7790. set: function (time) {
  7791. this._idleRotationWaitTime = time;
  7792. },
  7793. enumerable: true,
  7794. configurable: true
  7795. });
  7796. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7797. /**
  7798. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7799. */
  7800. get: function () {
  7801. return this._idleRotationSpinupTime;
  7802. },
  7803. /**
  7804. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7805. */
  7806. set: function (time) {
  7807. this._idleRotationSpinupTime = time;
  7808. },
  7809. enumerable: true,
  7810. configurable: true
  7811. });
  7812. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7813. /**
  7814. * Gets a value indicating if the camera is currently rotating because of this behavior
  7815. */
  7816. get: function () {
  7817. return Math.abs(this._cameraRotationSpeed) > 0;
  7818. },
  7819. enumerable: true,
  7820. configurable: true
  7821. });
  7822. /**
  7823. * Initializes the behavior.
  7824. */
  7825. AutoRotationBehavior.prototype.init = function () {
  7826. // Do notihng
  7827. };
  7828. /**
  7829. * Attaches the behavior to its arc rotate camera.
  7830. * @param camera Defines the camera to attach the behavior to
  7831. */
  7832. AutoRotationBehavior.prototype.attach = function (camera) {
  7833. var _this = this;
  7834. this._attachedCamera = camera;
  7835. var scene = this._attachedCamera.getScene();
  7836. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7837. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7838. _this._isPointerDown = true;
  7839. return;
  7840. }
  7841. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7842. _this._isPointerDown = false;
  7843. }
  7844. });
  7845. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7846. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7847. var dt = 0;
  7848. if (_this._lastFrameTime != null) {
  7849. dt = now - _this._lastFrameTime;
  7850. }
  7851. _this._lastFrameTime = now;
  7852. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7853. _this._applyUserInteraction();
  7854. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7855. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7856. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7857. // Step camera rotation by rotation speed
  7858. if (_this._attachedCamera) {
  7859. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7860. }
  7861. });
  7862. };
  7863. /**
  7864. * Detaches the behavior from its current arc rotate camera.
  7865. */
  7866. AutoRotationBehavior.prototype.detach = function () {
  7867. if (!this._attachedCamera) {
  7868. return;
  7869. }
  7870. var scene = this._attachedCamera.getScene();
  7871. if (this._onPrePointerObservableObserver) {
  7872. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7873. }
  7874. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7875. this._attachedCamera = null;
  7876. };
  7877. /**
  7878. * Returns true if user is scrolling.
  7879. * @return true if user is scrolling.
  7880. */
  7881. AutoRotationBehavior.prototype._userIsZooming = function () {
  7882. if (!this._attachedCamera) {
  7883. return false;
  7884. }
  7885. return this._attachedCamera.inertialRadiusOffset !== 0;
  7886. };
  7887. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7888. if (!this._attachedCamera) {
  7889. return false;
  7890. }
  7891. var zoomHasHitLimit = false;
  7892. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7893. zoomHasHitLimit = true;
  7894. }
  7895. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7896. this._lastFrameRadius = this._attachedCamera.radius;
  7897. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7898. };
  7899. /**
  7900. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7901. */
  7902. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7903. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7904. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7905. }
  7906. };
  7907. // Tools
  7908. AutoRotationBehavior.prototype._userIsMoving = function () {
  7909. if (!this._attachedCamera) {
  7910. return false;
  7911. }
  7912. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7913. this._attachedCamera.inertialBetaOffset !== 0 ||
  7914. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7915. this._attachedCamera.inertialPanningX !== 0 ||
  7916. this._attachedCamera.inertialPanningY !== 0 ||
  7917. this._isPointerDown;
  7918. };
  7919. return AutoRotationBehavior;
  7920. }());
  7921. /***/ }),
  7922. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7923. /*!***********************************************!*\
  7924. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7925. \***********************************************/
  7926. /*! exports provided: BouncingBehavior */
  7927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7928. "use strict";
  7929. __webpack_require__.r(__webpack_exports__);
  7930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7931. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7932. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7933. /**
  7934. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7935. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7936. */
  7937. var BouncingBehavior = /** @class */ (function () {
  7938. function BouncingBehavior() {
  7939. /**
  7940. * The duration of the animation, in milliseconds
  7941. */
  7942. this.transitionDuration = 450;
  7943. /**
  7944. * Length of the distance animated by the transition when lower radius is reached
  7945. */
  7946. this.lowerRadiusTransitionRange = 2;
  7947. /**
  7948. * Length of the distance animated by the transition when upper radius is reached
  7949. */
  7950. this.upperRadiusTransitionRange = -2;
  7951. this._autoTransitionRange = false;
  7952. // Animations
  7953. this._radiusIsAnimating = false;
  7954. this._radiusBounceTransition = null;
  7955. this._animatables = new Array();
  7956. }
  7957. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7958. /**
  7959. * Gets the name of the behavior.
  7960. */
  7961. get: function () {
  7962. return "Bouncing";
  7963. },
  7964. enumerable: true,
  7965. configurable: true
  7966. });
  7967. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7968. /**
  7969. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7970. */
  7971. get: function () {
  7972. return this._autoTransitionRange;
  7973. },
  7974. /**
  7975. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7976. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7977. */
  7978. set: function (value) {
  7979. var _this = this;
  7980. if (this._autoTransitionRange === value) {
  7981. return;
  7982. }
  7983. this._autoTransitionRange = value;
  7984. var camera = this._attachedCamera;
  7985. if (!camera) {
  7986. return;
  7987. }
  7988. if (value) {
  7989. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7990. if (!mesh) {
  7991. return;
  7992. }
  7993. mesh.computeWorldMatrix(true);
  7994. var diagonal = mesh.getBoundingInfo().diagonalLength;
  7995. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  7996. _this.upperRadiusTransitionRange = diagonal * 0.05;
  7997. });
  7998. }
  7999. else if (this._onMeshTargetChangedObserver) {
  8000. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8001. }
  8002. },
  8003. enumerable: true,
  8004. configurable: true
  8005. });
  8006. /**
  8007. * Initializes the behavior.
  8008. */
  8009. BouncingBehavior.prototype.init = function () {
  8010. // Do notihng
  8011. };
  8012. /**
  8013. * Attaches the behavior to its arc rotate camera.
  8014. * @param camera Defines the camera to attach the behavior to
  8015. */
  8016. BouncingBehavior.prototype.attach = function (camera) {
  8017. var _this = this;
  8018. this._attachedCamera = camera;
  8019. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8020. if (!_this._attachedCamera) {
  8021. return;
  8022. }
  8023. // Add the bounce animation to the lower radius limit
  8024. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8025. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8026. }
  8027. // Add the bounce animation to the upper radius limit
  8028. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8029. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8030. }
  8031. });
  8032. };
  8033. /**
  8034. * Detaches the behavior from its current arc rotate camera.
  8035. */
  8036. BouncingBehavior.prototype.detach = function () {
  8037. if (!this._attachedCamera) {
  8038. return;
  8039. }
  8040. if (this._onAfterCheckInputsObserver) {
  8041. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8042. }
  8043. if (this._onMeshTargetChangedObserver) {
  8044. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8045. }
  8046. this._attachedCamera = null;
  8047. };
  8048. /**
  8049. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8050. * @param radiusLimit The limit to check against.
  8051. * @return Bool to indicate if at limit.
  8052. */
  8053. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8054. if (!this._attachedCamera) {
  8055. return false;
  8056. }
  8057. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8058. return true;
  8059. }
  8060. return false;
  8061. };
  8062. /**
  8063. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8064. * @param radiusDelta The delta by which to animate to. Can be negative.
  8065. */
  8066. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8067. var _this = this;
  8068. if (!this._attachedCamera) {
  8069. return;
  8070. }
  8071. if (!this._radiusBounceTransition) {
  8072. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8073. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8074. }
  8075. // Prevent zoom until bounce has completed
  8076. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8077. this._attachedCamera.wheelPrecision = Infinity;
  8078. this._attachedCamera.inertialRadiusOffset = 0;
  8079. // Animate to the radius limit
  8080. this.stopAllAnimations();
  8081. this._radiusIsAnimating = true;
  8082. 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(); });
  8083. if (animatable) {
  8084. this._animatables.push(animatable);
  8085. }
  8086. };
  8087. /**
  8088. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8089. */
  8090. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8091. this._radiusIsAnimating = false;
  8092. if (this._attachedCamera) {
  8093. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8094. }
  8095. };
  8096. /**
  8097. * Stops and removes all animations that have been applied to the camera
  8098. */
  8099. BouncingBehavior.prototype.stopAllAnimations = function () {
  8100. if (this._attachedCamera) {
  8101. this._attachedCamera.animations = [];
  8102. }
  8103. while (this._animatables.length) {
  8104. this._animatables[0].onAnimationEnd = null;
  8105. this._animatables[0].stop();
  8106. this._animatables.shift();
  8107. }
  8108. };
  8109. /**
  8110. * The easing function used by animations
  8111. */
  8112. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8113. /**
  8114. * The easing mode used by animations
  8115. */
  8116. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8117. return BouncingBehavior;
  8118. }());
  8119. /***/ }),
  8120. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8121. /*!**********************************************!*\
  8122. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8123. \**********************************************/
  8124. /*! exports provided: FramingBehavior */
  8125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8126. "use strict";
  8127. __webpack_require__.r(__webpack_exports__);
  8128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8129. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8130. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8131. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8132. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8133. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8134. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8135. /**
  8136. * 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.
  8137. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8138. */
  8139. var FramingBehavior = /** @class */ (function () {
  8140. function FramingBehavior() {
  8141. this._mode = FramingBehavior.FitFrustumSidesMode;
  8142. this._radiusScale = 1.0;
  8143. this._positionScale = 0.5;
  8144. this._defaultElevation = 0.3;
  8145. this._elevationReturnTime = 1500;
  8146. this._elevationReturnWaitTime = 1000;
  8147. this._zoomStopsAnimation = false;
  8148. this._framingTime = 1500;
  8149. /**
  8150. * Define if the behavior should automatically change the configured
  8151. * camera limits and sensibilities.
  8152. */
  8153. this.autoCorrectCameraLimitsAndSensibility = true;
  8154. this._isPointerDown = false;
  8155. this._lastInteractionTime = -Infinity;
  8156. // Framing control
  8157. this._animatables = new Array();
  8158. this._betaIsAnimating = false;
  8159. }
  8160. Object.defineProperty(FramingBehavior.prototype, "name", {
  8161. /**
  8162. * Gets the name of the behavior.
  8163. */
  8164. get: function () {
  8165. return "Framing";
  8166. },
  8167. enumerable: true,
  8168. configurable: true
  8169. });
  8170. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8171. /**
  8172. * Gets current mode used by the behavior.
  8173. */
  8174. get: function () {
  8175. return this._mode;
  8176. },
  8177. /**
  8178. * Sets the current mode used by the behavior
  8179. */
  8180. set: function (mode) {
  8181. this._mode = mode;
  8182. },
  8183. enumerable: true,
  8184. configurable: true
  8185. });
  8186. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8187. /**
  8188. * Gets the scale applied to the radius
  8189. */
  8190. get: function () {
  8191. return this._radiusScale;
  8192. },
  8193. /**
  8194. * Sets the scale applied to the radius (1 by default)
  8195. */
  8196. set: function (radius) {
  8197. this._radiusScale = radius;
  8198. },
  8199. enumerable: true,
  8200. configurable: true
  8201. });
  8202. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8203. /**
  8204. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8205. */
  8206. get: function () {
  8207. return this._positionScale;
  8208. },
  8209. /**
  8210. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8211. */
  8212. set: function (scale) {
  8213. this._positionScale = scale;
  8214. },
  8215. enumerable: true,
  8216. configurable: true
  8217. });
  8218. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8219. /**
  8220. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8221. * behaviour is triggered, in radians.
  8222. */
  8223. get: function () {
  8224. return this._defaultElevation;
  8225. },
  8226. /**
  8227. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8228. * behaviour is triggered, in radians.
  8229. */
  8230. set: function (elevation) {
  8231. this._defaultElevation = elevation;
  8232. },
  8233. enumerable: true,
  8234. configurable: true
  8235. });
  8236. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8237. /**
  8238. * Gets the time (in milliseconds) taken to return to the default beta position.
  8239. * Negative value indicates camera should not return to default.
  8240. */
  8241. get: function () {
  8242. return this._elevationReturnTime;
  8243. },
  8244. /**
  8245. * Sets the time (in milliseconds) taken to return to the default beta position.
  8246. * Negative value indicates camera should not return to default.
  8247. */
  8248. set: function (speed) {
  8249. this._elevationReturnTime = speed;
  8250. },
  8251. enumerable: true,
  8252. configurable: true
  8253. });
  8254. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8255. /**
  8256. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8257. */
  8258. get: function () {
  8259. return this._elevationReturnWaitTime;
  8260. },
  8261. /**
  8262. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8263. */
  8264. set: function (time) {
  8265. this._elevationReturnWaitTime = time;
  8266. },
  8267. enumerable: true,
  8268. configurable: true
  8269. });
  8270. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8271. /**
  8272. * Gets the flag that indicates if user zooming should stop animation.
  8273. */
  8274. get: function () {
  8275. return this._zoomStopsAnimation;
  8276. },
  8277. /**
  8278. * Sets the flag that indicates if user zooming should stop animation.
  8279. */
  8280. set: function (flag) {
  8281. this._zoomStopsAnimation = flag;
  8282. },
  8283. enumerable: true,
  8284. configurable: true
  8285. });
  8286. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8287. /**
  8288. * Gets the transition time when framing the mesh, in milliseconds
  8289. */
  8290. get: function () {
  8291. return this._framingTime;
  8292. },
  8293. /**
  8294. * Sets the transition time when framing the mesh, in milliseconds
  8295. */
  8296. set: function (time) {
  8297. this._framingTime = time;
  8298. },
  8299. enumerable: true,
  8300. configurable: true
  8301. });
  8302. /**
  8303. * Initializes the behavior.
  8304. */
  8305. FramingBehavior.prototype.init = function () {
  8306. // Do notihng
  8307. };
  8308. /**
  8309. * Attaches the behavior to its arc rotate camera.
  8310. * @param camera Defines the camera to attach the behavior to
  8311. */
  8312. FramingBehavior.prototype.attach = function (camera) {
  8313. var _this = this;
  8314. this._attachedCamera = camera;
  8315. var scene = this._attachedCamera.getScene();
  8316. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8317. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8318. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8319. _this._isPointerDown = true;
  8320. return;
  8321. }
  8322. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8323. _this._isPointerDown = false;
  8324. }
  8325. });
  8326. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8327. if (mesh) {
  8328. _this.zoomOnMesh(mesh);
  8329. }
  8330. });
  8331. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8332. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8333. _this._applyUserInteraction();
  8334. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8335. // back to the default position after a given timeout
  8336. _this._maintainCameraAboveGround();
  8337. });
  8338. };
  8339. /**
  8340. * Detaches the behavior from its current arc rotate camera.
  8341. */
  8342. FramingBehavior.prototype.detach = function () {
  8343. if (!this._attachedCamera) {
  8344. return;
  8345. }
  8346. var scene = this._attachedCamera.getScene();
  8347. if (this._onPrePointerObservableObserver) {
  8348. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8349. }
  8350. if (this._onAfterCheckInputsObserver) {
  8351. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8352. }
  8353. if (this._onMeshTargetChangedObserver) {
  8354. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8355. }
  8356. this._attachedCamera = null;
  8357. };
  8358. /**
  8359. * Targets the given mesh and updates zoom level accordingly.
  8360. * @param mesh The mesh to target.
  8361. * @param radius Optional. If a cached radius position already exists, overrides default.
  8362. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8363. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8364. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8365. */
  8366. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8367. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8368. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8369. mesh.computeWorldMatrix(true);
  8370. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8371. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8372. };
  8373. /**
  8374. * Targets the given mesh with its children and updates zoom level accordingly.
  8375. * @param mesh The mesh to target.
  8376. * @param radius Optional. If a cached radius position already exists, overrides default.
  8377. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8380. */
  8381. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8382. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8383. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8384. mesh.computeWorldMatrix(true);
  8385. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8386. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8387. };
  8388. /**
  8389. * Targets the given meshes with their children and updates zoom level accordingly.
  8390. * @param meshes The mesh to target.
  8391. * @param radius Optional. If a cached radius position already exists, overrides default.
  8392. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8395. */
  8396. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8397. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8398. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8399. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8400. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8401. for (var i = 0; i < meshes.length; i++) {
  8402. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8403. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8404. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8405. }
  8406. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8407. };
  8408. /**
  8409. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8410. * @param minimumWorld Determines the smaller position of the bounding box extend
  8411. * @param maximumWorld Determines the bigger position of the bounding box extend
  8412. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8413. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8414. */
  8415. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8416. var _this = this;
  8417. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8418. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8419. var zoomTarget;
  8420. if (!this._attachedCamera) {
  8421. return;
  8422. }
  8423. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8424. var bottom = minimumWorld.y;
  8425. var top = maximumWorld.y;
  8426. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8427. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8428. if (focusOnOriginXZ) {
  8429. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8430. }
  8431. else {
  8432. var centerWorld = minimumWorld.add(radiusWorld);
  8433. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8434. }
  8435. if (!this._vectorTransition) {
  8436. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8437. }
  8438. this._betaIsAnimating = true;
  8439. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8440. if (animatable) {
  8441. this._animatables.push(animatable);
  8442. }
  8443. // sets the radius and lower radius bounds
  8444. // Small delta ensures camera is not always at lower zoom limit.
  8445. var radius = 0;
  8446. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8447. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8448. if (this.autoCorrectCameraLimitsAndSensibility) {
  8449. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8450. }
  8451. radius = position;
  8452. }
  8453. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8454. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8455. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8456. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8457. }
  8458. }
  8459. // Set sensibilities
  8460. if (this.autoCorrectCameraLimitsAndSensibility) {
  8461. var extend = maximumWorld.subtract(minimumWorld).length();
  8462. this._attachedCamera.panningSensibility = 5000 / extend;
  8463. this._attachedCamera.wheelPrecision = 100 / radius;
  8464. }
  8465. // transition to new radius
  8466. if (!this._radiusTransition) {
  8467. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8468. }
  8469. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8470. _this.stopAllAnimations();
  8471. if (onAnimationEnd) {
  8472. onAnimationEnd();
  8473. }
  8474. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8475. _this._attachedCamera.storeState();
  8476. }
  8477. });
  8478. if (animatable) {
  8479. this._animatables.push(animatable);
  8480. }
  8481. };
  8482. /**
  8483. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8484. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8485. * frustum width.
  8486. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8487. * to fully enclose the mesh in the viewing frustum.
  8488. */
  8489. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8490. var size = maximumWorld.subtract(minimumWorld);
  8491. var boxVectorGlobalDiagonal = size.length();
  8492. var frustumSlope = this._getFrustumSlope();
  8493. // Formula for setting distance
  8494. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8495. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8496. // Horizon distance
  8497. var radius = radiusWithoutFraming * this._radiusScale;
  8498. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8499. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8500. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8501. var camera = this._attachedCamera;
  8502. if (!camera) {
  8503. return 0;
  8504. }
  8505. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8506. // Don't exceed the requested limit
  8507. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8508. }
  8509. // Don't exceed the upper radius limit
  8510. if (camera.upperRadiusLimit) {
  8511. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8512. }
  8513. return distance;
  8514. };
  8515. /**
  8516. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8517. * is automatically returned to its default position (expected to be above ground plane).
  8518. */
  8519. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8520. var _this = this;
  8521. if (this._elevationReturnTime < 0) {
  8522. return;
  8523. }
  8524. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8525. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8526. var limitBeta = Math.PI * 0.5;
  8527. // Bring the camera back up if below the ground plane
  8528. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8529. this._betaIsAnimating = true;
  8530. //Transition to new position
  8531. this.stopAllAnimations();
  8532. if (!this._betaTransition) {
  8533. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8534. }
  8535. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8536. _this._clearAnimationLocks();
  8537. _this.stopAllAnimations();
  8538. });
  8539. if (animatabe) {
  8540. this._animatables.push(animatabe);
  8541. }
  8542. }
  8543. };
  8544. /**
  8545. * Returns the frustum slope based on the canvas ratio and camera FOV
  8546. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8547. */
  8548. FramingBehavior.prototype._getFrustumSlope = function () {
  8549. // Calculate the viewport ratio
  8550. // Aspect Ratio is Height/Width.
  8551. var camera = this._attachedCamera;
  8552. if (!camera) {
  8553. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8554. }
  8555. var engine = camera.getScene().getEngine();
  8556. var aspectRatio = engine.getAspectRatio(camera);
  8557. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8558. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8559. var frustumSlopeY = Math.tan(camera.fov / 2);
  8560. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8561. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8562. // along the forward vector.
  8563. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8564. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8565. };
  8566. /**
  8567. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8568. */
  8569. FramingBehavior.prototype._clearAnimationLocks = function () {
  8570. this._betaIsAnimating = false;
  8571. };
  8572. /**
  8573. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8574. */
  8575. FramingBehavior.prototype._applyUserInteraction = function () {
  8576. if (this.isUserIsMoving) {
  8577. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8578. this.stopAllAnimations();
  8579. this._clearAnimationLocks();
  8580. }
  8581. };
  8582. /**
  8583. * Stops and removes all animations that have been applied to the camera
  8584. */
  8585. FramingBehavior.prototype.stopAllAnimations = function () {
  8586. if (this._attachedCamera) {
  8587. this._attachedCamera.animations = [];
  8588. }
  8589. while (this._animatables.length) {
  8590. if (this._animatables[0]) {
  8591. this._animatables[0].onAnimationEnd = null;
  8592. this._animatables[0].stop();
  8593. }
  8594. this._animatables.shift();
  8595. }
  8596. };
  8597. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8598. /**
  8599. * Gets a value indicating if the user is moving the camera
  8600. */
  8601. get: function () {
  8602. if (!this._attachedCamera) {
  8603. return false;
  8604. }
  8605. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8606. this._attachedCamera.inertialBetaOffset !== 0 ||
  8607. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8608. this._attachedCamera.inertialPanningX !== 0 ||
  8609. this._attachedCamera.inertialPanningY !== 0 ||
  8610. this._isPointerDown;
  8611. },
  8612. enumerable: true,
  8613. configurable: true
  8614. });
  8615. /**
  8616. * The easing function used by animations
  8617. */
  8618. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8619. /**
  8620. * The easing mode used by animations
  8621. */
  8622. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8623. // Statics
  8624. /**
  8625. * The camera can move all the way towards the mesh.
  8626. */
  8627. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8628. /**
  8629. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8630. */
  8631. FramingBehavior.FitFrustumSidesMode = 1;
  8632. return FramingBehavior;
  8633. }());
  8634. /***/ }),
  8635. /***/ "./Behaviors/Cameras/index.ts":
  8636. /*!************************************!*\
  8637. !*** ./Behaviors/Cameras/index.ts ***!
  8638. \************************************/
  8639. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8641. "use strict";
  8642. __webpack_require__.r(__webpack_exports__);
  8643. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8645. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8647. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8649. /***/ }),
  8650. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8651. /*!*************************************************!*\
  8652. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8653. \*************************************************/
  8654. /*! exports provided: AttachToBoxBehavior */
  8655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8656. "use strict";
  8657. __webpack_require__.r(__webpack_exports__);
  8658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8659. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8660. /**
  8661. * @hidden
  8662. */
  8663. var FaceDirectionInfo = /** @class */ (function () {
  8664. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8665. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8666. if (diff === void 0) { diff = 0; }
  8667. if (ignore === void 0) { ignore = false; }
  8668. this.direction = direction;
  8669. this.rotatedDirection = rotatedDirection;
  8670. this.diff = diff;
  8671. this.ignore = ignore;
  8672. }
  8673. return FaceDirectionInfo;
  8674. }());
  8675. /**
  8676. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8677. */
  8678. var AttachToBoxBehavior = /** @class */ (function () {
  8679. /**
  8680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8681. * @param ui The transform node that should be attched to the mesh
  8682. */
  8683. function AttachToBoxBehavior(ui) {
  8684. this.ui = ui;
  8685. /**
  8686. * The name of the behavior
  8687. */
  8688. this.name = "AttachToBoxBehavior";
  8689. /**
  8690. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8691. */
  8692. this.distanceAwayFromFace = 0.15;
  8693. /**
  8694. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8695. */
  8696. this.distanceAwayFromBottomOfFace = 0.15;
  8697. 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))];
  8698. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8699. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8700. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8701. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8702. /* Does nothing */
  8703. }
  8704. /**
  8705. * Initializes the behavior
  8706. */
  8707. AttachToBoxBehavior.prototype.init = function () {
  8708. /* Does nothing */
  8709. };
  8710. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8711. var _this = this;
  8712. // Go over each face and calculate the angle between the face's normal and targetDirection
  8713. this._faceVectors.forEach(function (v) {
  8714. if (!_this._target.rotationQuaternion) {
  8715. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8716. }
  8717. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8718. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8719. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8720. });
  8721. // Return the face information of the one with the normal closeset to target direction
  8722. return this._faceVectors.reduce(function (min, p) {
  8723. if (min.ignore) {
  8724. return p;
  8725. }
  8726. else if (p.ignore) {
  8727. return min;
  8728. }
  8729. else {
  8730. return min.diff < p.diff ? min : p;
  8731. }
  8732. }, this._faceVectors[0]);
  8733. };
  8734. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8735. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8736. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8737. this._lookAtTmpMatrix.invert();
  8738. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8739. };
  8740. /**
  8741. * Attaches the AttachToBoxBehavior to the passed in mesh
  8742. * @param target The mesh that the specified node will be attached to
  8743. */
  8744. AttachToBoxBehavior.prototype.attach = function (target) {
  8745. var _this = this;
  8746. this._target = target;
  8747. this._scene = this._target.getScene();
  8748. // Every frame, update the app bars position
  8749. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8750. if (!_this._scene.activeCamera) {
  8751. return;
  8752. }
  8753. // Find the face closest to the cameras position
  8754. var cameraPos = _this._scene.activeCamera.position;
  8755. if (_this._scene.activeCamera.devicePosition) {
  8756. cameraPos = _this._scene.activeCamera.devicePosition;
  8757. }
  8758. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8759. if (_this._scene.activeCamera.leftCamera) {
  8760. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8761. }
  8762. else {
  8763. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8764. }
  8765. // Get camera up direction
  8766. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8767. // Ignore faces to not select a parrelel face for the up vector of the UI
  8768. _this._faceVectors.forEach(function (v) {
  8769. if (facing.direction.x && v.direction.x) {
  8770. v.ignore = true;
  8771. }
  8772. if (facing.direction.y && v.direction.y) {
  8773. v.ignore = true;
  8774. }
  8775. if (facing.direction.z && v.direction.z) {
  8776. v.ignore = true;
  8777. }
  8778. });
  8779. var facingUp = _this._closestFace(_this._tmpVector);
  8780. // Unignore faces
  8781. _this._faceVectors.forEach(function (v) {
  8782. v.ignore = false;
  8783. });
  8784. // Position the app bar on that face
  8785. _this.ui.position.copyFrom(target.position);
  8786. if (facing.direction.x) {
  8787. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8788. _this.ui.position.addInPlace(_this._tmpVector);
  8789. }
  8790. if (facing.direction.y) {
  8791. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8792. _this.ui.position.addInPlace(_this._tmpVector);
  8793. }
  8794. if (facing.direction.z) {
  8795. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8796. _this.ui.position.addInPlace(_this._tmpVector);
  8797. }
  8798. // Rotate to be oriented properly to the camera
  8799. if (!_this.ui.rotationQuaternion) {
  8800. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8801. }
  8802. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8803. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8804. // Place ui the correct distance from the bottom of the mesh
  8805. if (facingUp.direction.x) {
  8806. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8807. }
  8808. if (facingUp.direction.y) {
  8809. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8810. }
  8811. if (facingUp.direction.z) {
  8812. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8813. }
  8814. _this.ui.position.addInPlace(_this._tmpVector);
  8815. });
  8816. };
  8817. /**
  8818. * Detaches the behavior from the mesh
  8819. */
  8820. AttachToBoxBehavior.prototype.detach = function () {
  8821. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8822. };
  8823. return AttachToBoxBehavior;
  8824. }());
  8825. /***/ }),
  8826. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8827. /*!***********************************************!*\
  8828. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8829. \***********************************************/
  8830. /*! exports provided: FadeInOutBehavior */
  8831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8832. "use strict";
  8833. __webpack_require__.r(__webpack_exports__);
  8834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8835. /**
  8836. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8837. */
  8838. var FadeInOutBehavior = /** @class */ (function () {
  8839. /**
  8840. * Instatiates the FadeInOutBehavior
  8841. */
  8842. function FadeInOutBehavior() {
  8843. var _this = this;
  8844. /**
  8845. * Time in milliseconds to delay before fading in (Default: 0)
  8846. */
  8847. this.delay = 0;
  8848. /**
  8849. * Time in milliseconds for the mesh to fade in (Default: 300)
  8850. */
  8851. this.fadeInTime = 300;
  8852. this._millisecondsPerFrame = 1000 / 60;
  8853. this._hovered = false;
  8854. this._hoverValue = 0;
  8855. this._ownerNode = null;
  8856. this._update = function () {
  8857. if (_this._ownerNode) {
  8858. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8859. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8860. if (_this._ownerNode.visibility > 1) {
  8861. _this._setAllVisibility(_this._ownerNode, 1);
  8862. _this._hoverValue = _this.fadeInTime + _this.delay;
  8863. return;
  8864. }
  8865. else if (_this._ownerNode.visibility < 0) {
  8866. _this._setAllVisibility(_this._ownerNode, 0);
  8867. if (_this._hoverValue < 0) {
  8868. _this._hoverValue = 0;
  8869. return;
  8870. }
  8871. }
  8872. setTimeout(_this._update, _this._millisecondsPerFrame);
  8873. }
  8874. };
  8875. }
  8876. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8877. /**
  8878. * The name of the behavior
  8879. */
  8880. get: function () {
  8881. return "FadeInOut";
  8882. },
  8883. enumerable: true,
  8884. configurable: true
  8885. });
  8886. /**
  8887. * Initializes the behavior
  8888. */
  8889. FadeInOutBehavior.prototype.init = function () {
  8890. };
  8891. /**
  8892. * Attaches the fade behavior on the passed in mesh
  8893. * @param ownerNode The mesh that will be faded in/out once attached
  8894. */
  8895. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8896. this._ownerNode = ownerNode;
  8897. this._setAllVisibility(this._ownerNode, 0);
  8898. };
  8899. /**
  8900. * Detaches the behavior from the mesh
  8901. */
  8902. FadeInOutBehavior.prototype.detach = function () {
  8903. this._ownerNode = null;
  8904. };
  8905. /**
  8906. * Triggers the mesh to begin fading in or out
  8907. * @param value if the object should fade in or out (true to fade in)
  8908. */
  8909. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8910. this._hovered = value;
  8911. this._update();
  8912. };
  8913. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8914. var _this = this;
  8915. mesh.visibility = value;
  8916. mesh.getChildMeshes().forEach(function (c) {
  8917. _this._setAllVisibility(c, value);
  8918. });
  8919. };
  8920. return FadeInOutBehavior;
  8921. }());
  8922. /***/ }),
  8923. /***/ "./Behaviors/Meshes/index.ts":
  8924. /*!***********************************!*\
  8925. !*** ./Behaviors/Meshes/index.ts ***!
  8926. \***********************************/
  8927. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8929. "use strict";
  8930. __webpack_require__.r(__webpack_exports__);
  8931. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8933. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8935. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8937. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8939. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8941. /***/ }),
  8942. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8943. /*!*******************************************************!*\
  8944. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8945. \*******************************************************/
  8946. /*! exports provided: MultiPointerScaleBehavior */
  8947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8948. "use strict";
  8949. __webpack_require__.r(__webpack_exports__);
  8950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8951. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8953. /**
  8954. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8955. */
  8956. var MultiPointerScaleBehavior = /** @class */ (function () {
  8957. /**
  8958. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8959. */
  8960. function MultiPointerScaleBehavior() {
  8961. this._startDistance = 0;
  8962. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8963. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8964. this._sceneRenderObserver = null;
  8965. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8966. this._dragBehaviorA.moveAttached = false;
  8967. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8968. this._dragBehaviorB.moveAttached = false;
  8969. }
  8970. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8971. /**
  8972. * The name of the behavior
  8973. */
  8974. get: function () {
  8975. return "MultiPointerScale";
  8976. },
  8977. enumerable: true,
  8978. configurable: true
  8979. });
  8980. /**
  8981. * Initializes the behavior
  8982. */
  8983. MultiPointerScaleBehavior.prototype.init = function () { };
  8984. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8985. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8986. };
  8987. /**
  8988. * Attaches the scale behavior the passed in mesh
  8989. * @param ownerNode The mesh that will be scaled around once attached
  8990. */
  8991. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8992. var _this = this;
  8993. this._ownerNode = ownerNode;
  8994. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  8995. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  8996. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8997. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8998. _this._dragBehaviorA.releaseDrag();
  8999. }
  9000. else {
  9001. _this._initialScale.copyFrom(ownerNode.scaling);
  9002. _this._startDistance = _this._getCurrentDistance();
  9003. }
  9004. }
  9005. });
  9006. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9007. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9008. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9009. _this._dragBehaviorB.releaseDrag();
  9010. }
  9011. else {
  9012. _this._initialScale.copyFrom(ownerNode.scaling);
  9013. _this._startDistance = _this._getCurrentDistance();
  9014. }
  9015. }
  9016. });
  9017. // Once both drag behaviors are active scale based on the distance between the two pointers
  9018. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9019. behavior.onDragObservable.add(function () {
  9020. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9021. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9022. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9023. }
  9024. });
  9025. });
  9026. ownerNode.addBehavior(this._dragBehaviorA);
  9027. ownerNode.addBehavior(this._dragBehaviorB);
  9028. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9029. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9030. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9031. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9032. if (change.length() > 0.01) {
  9033. ownerNode.scaling.addInPlace(change);
  9034. }
  9035. }
  9036. });
  9037. };
  9038. /**
  9039. * Detaches the behavior from the mesh
  9040. */
  9041. MultiPointerScaleBehavior.prototype.detach = function () {
  9042. var _this = this;
  9043. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9044. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9045. behavior.onDragStartObservable.clear();
  9046. behavior.onDragObservable.clear();
  9047. _this._ownerNode.removeBehavior(behavior);
  9048. });
  9049. };
  9050. return MultiPointerScaleBehavior;
  9051. }());
  9052. /***/ }),
  9053. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9054. /*!*************************************************!*\
  9055. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9056. \*************************************************/
  9057. /*! exports provided: PointerDragBehavior */
  9058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9059. "use strict";
  9060. __webpack_require__.r(__webpack_exports__);
  9061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9062. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9063. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9064. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9065. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9066. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9067. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9068. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9069. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9070. /**
  9071. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9072. */
  9073. var PointerDragBehavior = /** @class */ (function () {
  9074. /**
  9075. * Creates a pointer drag behavior that can be attached to a mesh
  9076. * @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)
  9077. */
  9078. function PointerDragBehavior(options) {
  9079. /**
  9080. * 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)
  9081. */
  9082. this.maxDragAngle = 0;
  9083. /**
  9084. * @hidden
  9085. */
  9086. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9087. /**
  9088. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9089. */
  9090. this.currentDraggingPointerID = -1;
  9091. /**
  9092. * If the behavior is currently in a dragging state
  9093. */
  9094. this.dragging = false;
  9095. /**
  9096. * 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)
  9097. */
  9098. this.dragDeltaRatio = 0.2;
  9099. /**
  9100. * If the drag plane orientation should be updated during the dragging (Default: true)
  9101. */
  9102. this.updateDragPlane = true;
  9103. // Debug mode will display drag planes to help visualize behavior
  9104. this._debugMode = false;
  9105. this._moving = false;
  9106. /**
  9107. * Fires each time the attached mesh is dragged with the pointer
  9108. * * delta between last drag position and current drag position in world space
  9109. * * dragDistance along the drag axis
  9110. * * dragPlaneNormal normal of the current drag plane used during the drag
  9111. * * dragPlanePoint in world space where the drag intersects the drag plane
  9112. */
  9113. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9114. /**
  9115. * Fires each time a drag begins (eg. mouse down on mesh)
  9116. */
  9117. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9118. /**
  9119. * Fires each time a drag ends (eg. mouse release after drag)
  9120. */
  9121. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9122. /**
  9123. * If the attached mesh should be moved when dragged
  9124. */
  9125. this.moveAttached = true;
  9126. /**
  9127. * If the drag behavior will react to drag events (Default: true)
  9128. */
  9129. this.enabled = true;
  9130. /**
  9131. * If camera controls should be detached during the drag
  9132. */
  9133. this.detachCameraControls = true;
  9134. /**
  9135. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9136. */
  9137. this.useObjectOrienationForDragging = true;
  9138. /**
  9139. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9140. */
  9141. this.validateDrag = function (targetPosition) { return true; };
  9142. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9143. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9144. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9145. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9146. this._attachedElement = null;
  9147. 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"]());
  9148. this._lastPointerRay = {};
  9149. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9150. // Variables to avoid instantiation in the below method
  9151. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9152. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9153. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9154. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9155. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9156. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9157. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9158. this._options = options ? options : {};
  9159. var optionCount = 0;
  9160. if (this._options.dragAxis) {
  9161. optionCount++;
  9162. }
  9163. if (this._options.dragPlaneNormal) {
  9164. optionCount++;
  9165. }
  9166. if (optionCount > 1) {
  9167. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9168. }
  9169. }
  9170. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9171. /**
  9172. * The name of the behavior
  9173. */
  9174. get: function () {
  9175. return "PointerDrag";
  9176. },
  9177. enumerable: true,
  9178. configurable: true
  9179. });
  9180. /**
  9181. * Initializes the behavior
  9182. */
  9183. PointerDragBehavior.prototype.init = function () { };
  9184. /**
  9185. * Attaches the drag behavior the passed in mesh
  9186. * @param ownerNode The mesh that will be dragged around once attached
  9187. */
  9188. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9189. var _this = this;
  9190. this._scene = ownerNode.getScene();
  9191. this._attachedNode = ownerNode;
  9192. // Initialize drag plane to not interfere with existing scene
  9193. if (!PointerDragBehavior._planeScene) {
  9194. if (this._debugMode) {
  9195. PointerDragBehavior._planeScene = this._scene;
  9196. }
  9197. else {
  9198. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9199. PointerDragBehavior._planeScene.detachControl();
  9200. this._scene.getEngine().scenes.pop();
  9201. this._scene.onDisposeObservable.addOnce(function () {
  9202. PointerDragBehavior._planeScene.dispose();
  9203. PointerDragBehavior._planeScene = null;
  9204. });
  9205. }
  9206. }
  9207. 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);
  9208. // State of the drag
  9209. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9210. var pickPredicate = function (m) {
  9211. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9212. };
  9213. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9214. if (!_this.enabled) {
  9215. return;
  9216. }
  9217. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9218. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9219. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9220. }
  9221. }
  9222. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9223. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9224. _this.releaseDrag();
  9225. }
  9226. }
  9227. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9228. var pointerId = pointerInfo.event.pointerId;
  9229. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9230. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9231. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9232. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9233. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9234. }
  9235. _this.currentDraggingPointerID = pointerId;
  9236. }
  9237. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9238. if (!_this._lastPointerRay[pointerId]) {
  9239. _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"]());
  9240. }
  9241. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9242. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9243. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9244. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9245. _this._moveDrag(pointerInfo.pickInfo.ray);
  9246. }
  9247. }
  9248. }
  9249. });
  9250. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9251. if (_this._moving && _this.moveAttached) {
  9252. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9253. // Slowly move mesh to avoid jitter
  9254. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9255. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9256. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9257. if (_this.validateDrag(_this._tmpVector)) {
  9258. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9259. }
  9260. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9261. }
  9262. });
  9263. };
  9264. /**
  9265. * Force relase the drag action by code.
  9266. */
  9267. PointerDragBehavior.prototype.releaseDrag = function () {
  9268. this.dragging = false;
  9269. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9270. this.currentDraggingPointerID = -1;
  9271. this._moving = false;
  9272. // Reattach camera controls
  9273. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9274. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9275. }
  9276. };
  9277. /**
  9278. * Simulates the start of a pointer drag event on the behavior
  9279. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9280. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9281. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9282. */
  9283. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9284. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9285. this._startDrag(pointerId, fromRay, startPickedPoint);
  9286. var lastRay = this._lastPointerRay[pointerId];
  9287. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9288. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9289. }
  9290. if (lastRay) {
  9291. // if there was a last pointer ray drag the object there
  9292. this._moveDrag(lastRay);
  9293. }
  9294. };
  9295. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9296. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9297. return;
  9298. }
  9299. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9300. // Create start ray from the camera to the object
  9301. if (fromRay) {
  9302. this._startDragRay.direction.copyFrom(fromRay.direction);
  9303. this._startDragRay.origin.copyFrom(fromRay.origin);
  9304. }
  9305. else {
  9306. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9307. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9308. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9309. }
  9310. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9311. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9312. if (pickedPoint) {
  9313. this.dragging = true;
  9314. this.currentDraggingPointerID = pointerId;
  9315. this.lastDragPosition.copyFrom(pickedPoint);
  9316. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9317. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9318. // Detatch camera controls
  9319. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9320. if (this._scene.activeCamera.inputs.attachedElement) {
  9321. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9322. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9323. }
  9324. else {
  9325. this._attachedElement = null;
  9326. }
  9327. }
  9328. }
  9329. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9330. };
  9331. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9332. this._moving = true;
  9333. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9334. if (pickedPoint) {
  9335. if (this.updateDragPlane) {
  9336. this._updateDragPlanePosition(ray, pickedPoint);
  9337. }
  9338. var dragLength = 0;
  9339. // depending on the drag mode option drag accordingly
  9340. if (this._options.dragAxis) {
  9341. // Convert local drag axis to world
  9342. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9343. // Project delta drag from the drag plane onto the drag axis
  9344. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9345. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9346. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9347. }
  9348. else {
  9349. dragLength = this._dragDelta.length();
  9350. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9351. }
  9352. this._targetPosition.addInPlace(this._dragDelta);
  9353. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9354. this.lastDragPosition.copyFrom(pickedPoint);
  9355. }
  9356. };
  9357. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9358. var _this = this;
  9359. if (!ray) {
  9360. return null;
  9361. }
  9362. // Calculate angle between plane normal and ray
  9363. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9364. // Correct if ray is casted from oposite side
  9365. if (angle > Math.PI / 2) {
  9366. angle = Math.PI - angle;
  9367. }
  9368. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9369. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9370. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9371. // Invert ray direction along the towards object axis
  9372. this._tmpVector.copyFrom(ray.direction);
  9373. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9374. this._alternatePickedPoint.normalize();
  9375. this._alternatePickedPoint.scaleInPlace(-2 * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9376. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9377. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9378. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9379. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9380. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9381. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9382. return this._alternatePickedPoint;
  9383. }
  9384. else {
  9385. return null;
  9386. }
  9387. }
  9388. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9389. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9390. return pickResult.pickedPoint;
  9391. }
  9392. else {
  9393. return null;
  9394. }
  9395. };
  9396. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9397. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9398. this._pointA.copyFrom(dragPlanePosition);
  9399. if (this._options.dragAxis) {
  9400. 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);
  9401. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9402. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9403. ray.origin.subtractToRef(this._pointA, this._pointC);
  9404. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9405. // Get perpendicular line from direction to camera and drag axis
  9406. this._pointB.subtractToRef(this._pointA, this._lineA);
  9407. this._pointC.subtractToRef(this._pointA, this._lineB);
  9408. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9409. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9410. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9411. this._lookAt.normalize();
  9412. this._dragPlane.position.copyFrom(this._pointA);
  9413. this._pointA.addToRef(this._lookAt, this._lookAt);
  9414. this._dragPlane.lookAt(this._lookAt);
  9415. }
  9416. else if (this._options.dragPlaneNormal) {
  9417. 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);
  9418. this._dragPlane.position.copyFrom(this._pointA);
  9419. this._pointA.addToRef(this._localAxis, this._lookAt);
  9420. this._dragPlane.lookAt(this._lookAt);
  9421. }
  9422. else {
  9423. this._dragPlane.position.copyFrom(this._pointA);
  9424. this._dragPlane.lookAt(ray.origin);
  9425. }
  9426. this._dragPlane.computeWorldMatrix(true);
  9427. };
  9428. /**
  9429. * Detaches the behavior from the mesh
  9430. */
  9431. PointerDragBehavior.prototype.detach = function () {
  9432. if (this._pointerObserver) {
  9433. this._scene.onPointerObservable.remove(this._pointerObserver);
  9434. }
  9435. if (this._beforeRenderObserver) {
  9436. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9437. }
  9438. };
  9439. PointerDragBehavior._AnyMouseID = -2;
  9440. return PointerDragBehavior;
  9441. }());
  9442. /***/ }),
  9443. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9444. /*!************************************************!*\
  9445. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9446. \************************************************/
  9447. /*! exports provided: SixDofDragBehavior */
  9448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9449. "use strict";
  9450. __webpack_require__.r(__webpack_exports__);
  9451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9452. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9453. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9454. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9455. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9456. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9457. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9458. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9459. /**
  9460. * 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
  9461. */
  9462. var SixDofDragBehavior = /** @class */ (function () {
  9463. /**
  9464. * 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
  9465. */
  9466. function SixDofDragBehavior() {
  9467. this._sceneRenderObserver = null;
  9468. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9469. this._moving = false;
  9470. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9471. /**
  9472. * 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)
  9473. */
  9474. this.zDragFactor = 3;
  9475. /**
  9476. * If the object should rotate to face the drag origin
  9477. */
  9478. this.rotateDraggedObject = true;
  9479. /**
  9480. * If the behavior is currently in a dragging state
  9481. */
  9482. this.dragging = false;
  9483. /**
  9484. * 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)
  9485. */
  9486. this.dragDeltaRatio = 0.2;
  9487. /**
  9488. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9489. */
  9490. this.currentDraggingPointerID = -1;
  9491. /**
  9492. * If camera controls should be detached during the drag
  9493. */
  9494. this.detachCameraControls = true;
  9495. /**
  9496. * Fires each time a drag starts
  9497. */
  9498. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9499. /**
  9500. * Fires each time a drag ends (eg. mouse release after drag)
  9501. */
  9502. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9503. }
  9504. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9505. /**
  9506. * The name of the behavior
  9507. */
  9508. get: function () {
  9509. return "SixDofDrag";
  9510. },
  9511. enumerable: true,
  9512. configurable: true
  9513. });
  9514. /**
  9515. * Initializes the behavior
  9516. */
  9517. SixDofDragBehavior.prototype.init = function () { };
  9518. /**
  9519. * Attaches the scale behavior the passed in mesh
  9520. * @param ownerNode The mesh that will be scaled around once attached
  9521. */
  9522. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9523. var _this = this;
  9524. this._ownerNode = ownerNode;
  9525. this._scene = this._ownerNode.getScene();
  9526. if (!SixDofDragBehavior._virtualScene) {
  9527. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9528. SixDofDragBehavior._virtualScene.detachControl();
  9529. this._scene.getEngine().scenes.pop();
  9530. }
  9531. var pickedMesh = null;
  9532. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9533. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9534. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9535. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9536. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9537. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9538. var pickPredicate = function (m) {
  9539. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9540. };
  9541. var attachedElement = null;
  9542. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9543. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9544. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9545. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9546. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9547. }
  9548. pickedMesh = _this._ownerNode;
  9549. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9550. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9551. // Set position and orientation of the controller
  9552. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9553. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9554. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9555. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9556. pickedMesh.computeWorldMatrix();
  9557. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9558. if (!pickedMesh.rotationQuaternion) {
  9559. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9560. }
  9561. var oldParent = pickedMesh.parent;
  9562. pickedMesh.setParent(null);
  9563. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9564. pickedMesh.setParent(oldParent);
  9565. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9566. // Update state
  9567. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9568. _this.dragging = true;
  9569. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9570. // Detatch camera controls
  9571. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9572. if (_this._scene.activeCamera.inputs.attachedElement) {
  9573. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9574. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9575. }
  9576. else {
  9577. attachedElement = null;
  9578. }
  9579. }
  9580. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9581. _this.onDragStartObservable.notifyObservers({});
  9582. }
  9583. }
  9584. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9585. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9586. _this.dragging = false;
  9587. _this._moving = false;
  9588. _this.currentDraggingPointerID = -1;
  9589. pickedMesh = null;
  9590. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9591. // Reattach camera controls
  9592. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9593. _this._scene.activeCamera.attachControl(attachedElement, true);
  9594. }
  9595. _this.onDragEndObservable.notifyObservers({});
  9596. }
  9597. }
  9598. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9599. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9600. var zDragFactor = _this.zDragFactor;
  9601. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9602. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9603. zDragFactor = 0;
  9604. }
  9605. // Calculate controller drag distance in controller space
  9606. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9607. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9608. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9609. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9610. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9611. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9612. if (_this._virtualDragMesh.position.z < 0) {
  9613. _this._virtualDragMesh.position.z = 0;
  9614. }
  9615. // Update the controller position
  9616. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9617. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9618. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9619. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9620. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9621. if (pickedMesh.parent) {
  9622. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9623. }
  9624. if (!_this._moving) {
  9625. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9626. }
  9627. _this._moving = true;
  9628. }
  9629. }
  9630. });
  9631. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9632. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9633. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9634. if (_this.dragging && _this._moving && pickedMesh) {
  9635. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9636. // Slowly move mesh to avoid jitter
  9637. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9638. if (_this.rotateDraggedObject) {
  9639. // Get change in rotation
  9640. tmpQuaternion.copyFrom(_this._startingOrientation);
  9641. tmpQuaternion.x = -tmpQuaternion.x;
  9642. tmpQuaternion.y = -tmpQuaternion.y;
  9643. tmpQuaternion.z = -tmpQuaternion.z;
  9644. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9645. // Convert change in rotation to only y axis rotation
  9646. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9647. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9648. // Slowly move mesh to avoid jitter
  9649. var oldParent = pickedMesh.parent;
  9650. // Only rotate the mesh if it's parent has uniform scaling
  9651. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9652. pickedMesh.setParent(null);
  9653. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9654. pickedMesh.setParent(oldParent);
  9655. }
  9656. }
  9657. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9658. }
  9659. });
  9660. };
  9661. /**
  9662. * Detaches the behavior from the mesh
  9663. */
  9664. SixDofDragBehavior.prototype.detach = function () {
  9665. if (this._scene) {
  9666. this._scene.onPointerObservable.remove(this._pointerObserver);
  9667. }
  9668. if (this._ownerNode) {
  9669. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9670. }
  9671. if (this._virtualOriginMesh) {
  9672. this._virtualOriginMesh.dispose();
  9673. }
  9674. if (this._virtualDragMesh) {
  9675. this._virtualDragMesh.dispose();
  9676. }
  9677. this.onDragEndObservable.clear();
  9678. this.onDragStartObservable.clear();
  9679. };
  9680. return SixDofDragBehavior;
  9681. }());
  9682. /***/ }),
  9683. /***/ "./Behaviors/index.ts":
  9684. /*!****************************!*\
  9685. !*** ./Behaviors/index.ts ***!
  9686. \****************************/
  9687. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9689. "use strict";
  9690. __webpack_require__.r(__webpack_exports__);
  9691. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9695. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9701. /***/ }),
  9702. /***/ "./Bones/bone.ts":
  9703. /*!***********************!*\
  9704. !*** ./Bones/bone.ts ***!
  9705. \***********************/
  9706. /*! exports provided: Bone */
  9707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9708. "use strict";
  9709. __webpack_require__.r(__webpack_exports__);
  9710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9712. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9713. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9714. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9715. /**
  9716. * Class used to store bone information
  9717. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9718. */
  9719. var Bone = /** @class */ (function (_super) {
  9720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9721. /**
  9722. * Create a new bone
  9723. * @param name defines the bone name
  9724. * @param skeleton defines the parent skeleton
  9725. * @param parentBone defines the parent (can be null if the bone is the root)
  9726. * @param localMatrix defines the local matrix
  9727. * @param restPose defines the rest pose matrix
  9728. * @param baseMatrix defines the base matrix
  9729. * @param index defines index of the bone in the hiearchy
  9730. */
  9731. function Bone(
  9732. /**
  9733. * defines the bone name
  9734. */
  9735. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9736. if (parentBone === void 0) { parentBone = null; }
  9737. if (localMatrix === void 0) { localMatrix = null; }
  9738. if (restPose === void 0) { restPose = null; }
  9739. if (baseMatrix === void 0) { baseMatrix = null; }
  9740. if (index === void 0) { index = null; }
  9741. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9742. _this.name = name;
  9743. /**
  9744. * Gets the list of child bones
  9745. */
  9746. _this.children = new Array();
  9747. /** Gets the animations associated with this bone */
  9748. _this.animations = new Array();
  9749. /**
  9750. * @hidden Internal only
  9751. * Set this value to map this bone to a different index in the transform matrices
  9752. * Set this value to -1 to exclude the bone from the transform matrices
  9753. */
  9754. _this._index = null;
  9755. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9756. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9757. _this._scalingDeterminant = 1;
  9758. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9759. _this._needToDecompose = true;
  9760. _this._needToCompose = false;
  9761. /** @hidden */
  9762. _this._linkedTransformNode = null;
  9763. _this._skeleton = skeleton;
  9764. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9765. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9766. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9767. _this._index = index;
  9768. skeleton.bones.push(_this);
  9769. _this.setParent(parentBone, false);
  9770. if (baseMatrix || localMatrix) {
  9771. _this._updateDifferenceMatrix();
  9772. }
  9773. return _this;
  9774. }
  9775. Object.defineProperty(Bone.prototype, "_matrix", {
  9776. /** @hidden */
  9777. get: function () {
  9778. this._compose();
  9779. return this._localMatrix;
  9780. },
  9781. /** @hidden */
  9782. set: function (value) {
  9783. this._localMatrix.copyFrom(value);
  9784. this._needToDecompose = true;
  9785. },
  9786. enumerable: true,
  9787. configurable: true
  9788. });
  9789. // Members
  9790. /**
  9791. * Gets the parent skeleton
  9792. * @returns a skeleton
  9793. */
  9794. Bone.prototype.getSkeleton = function () {
  9795. return this._skeleton;
  9796. };
  9797. /**
  9798. * Gets parent bone
  9799. * @returns a bone or null if the bone is the root of the bone hierarchy
  9800. */
  9801. Bone.prototype.getParent = function () {
  9802. return this._parent;
  9803. };
  9804. /**
  9805. * Sets the parent bone
  9806. * @param parent defines the parent (can be null if the bone is the root)
  9807. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9808. */
  9809. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9810. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9811. if (this._parent === parent) {
  9812. return;
  9813. }
  9814. if (this._parent) {
  9815. var index = this._parent.children.indexOf(this);
  9816. if (index !== -1) {
  9817. this._parent.children.splice(index, 1);
  9818. }
  9819. }
  9820. this._parent = parent;
  9821. if (this._parent) {
  9822. this._parent.children.push(this);
  9823. }
  9824. if (updateDifferenceMatrix) {
  9825. this._updateDifferenceMatrix();
  9826. }
  9827. this.markAsDirty();
  9828. };
  9829. /**
  9830. * Gets the local matrix
  9831. * @returns a matrix
  9832. */
  9833. Bone.prototype.getLocalMatrix = function () {
  9834. this._compose();
  9835. return this._localMatrix;
  9836. };
  9837. /**
  9838. * Gets the base matrix (initial matrix which remains unchanged)
  9839. * @returns a matrix
  9840. */
  9841. Bone.prototype.getBaseMatrix = function () {
  9842. return this._baseMatrix;
  9843. };
  9844. /**
  9845. * Gets the rest pose matrix
  9846. * @returns a matrix
  9847. */
  9848. Bone.prototype.getRestPose = function () {
  9849. return this._restPose;
  9850. };
  9851. /**
  9852. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9853. */
  9854. Bone.prototype.getWorldMatrix = function () {
  9855. return this._worldTransform;
  9856. };
  9857. /**
  9858. * Sets the local matrix to rest pose matrix
  9859. */
  9860. Bone.prototype.returnToRest = function () {
  9861. this.updateMatrix(this._restPose.clone());
  9862. };
  9863. /**
  9864. * Gets the inverse of the absolute transform matrix.
  9865. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9866. * @returns a matrix
  9867. */
  9868. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9869. return this._invertedAbsoluteTransform;
  9870. };
  9871. /**
  9872. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9873. * @returns a matrix
  9874. */
  9875. Bone.prototype.getAbsoluteTransform = function () {
  9876. return this._absoluteTransform;
  9877. };
  9878. /**
  9879. * Links with the given transform node.
  9880. * The local matrix of this bone is copied from the transform node every frame.
  9881. * @param transformNode defines the transform node to link to
  9882. */
  9883. Bone.prototype.linkTransformNode = function (transformNode) {
  9884. if (this._linkedTransformNode) {
  9885. this._skeleton._numBonesWithLinkedTransformNode--;
  9886. }
  9887. this._linkedTransformNode = transformNode;
  9888. if (this._linkedTransformNode) {
  9889. this._skeleton._numBonesWithLinkedTransformNode++;
  9890. }
  9891. };
  9892. Object.defineProperty(Bone.prototype, "position", {
  9893. // Properties (matches AbstractMesh properties)
  9894. /** Gets or sets current position (in local space) */
  9895. get: function () {
  9896. this._decompose();
  9897. return this._localPosition;
  9898. },
  9899. set: function (newPosition) {
  9900. this._decompose();
  9901. this._localPosition.copyFrom(newPosition);
  9902. this._markAsDirtyAndCompose();
  9903. },
  9904. enumerable: true,
  9905. configurable: true
  9906. });
  9907. Object.defineProperty(Bone.prototype, "rotation", {
  9908. /** Gets or sets current rotation (in local space) */
  9909. get: function () {
  9910. return this.getRotation();
  9911. },
  9912. set: function (newRotation) {
  9913. this.setRotation(newRotation);
  9914. },
  9915. enumerable: true,
  9916. configurable: true
  9917. });
  9918. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9919. /** Gets or sets current rotation quaternion (in local space) */
  9920. get: function () {
  9921. this._decompose();
  9922. return this._localRotation;
  9923. },
  9924. set: function (newRotation) {
  9925. this.setRotationQuaternion(newRotation);
  9926. },
  9927. enumerable: true,
  9928. configurable: true
  9929. });
  9930. Object.defineProperty(Bone.prototype, "scaling", {
  9931. /** Gets or sets current scaling (in local space) */
  9932. get: function () {
  9933. return this.getScale();
  9934. },
  9935. set: function (newScaling) {
  9936. this.setScale(newScaling);
  9937. },
  9938. enumerable: true,
  9939. configurable: true
  9940. });
  9941. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9942. /**
  9943. * Gets the animation properties override
  9944. */
  9945. get: function () {
  9946. return this._skeleton.animationPropertiesOverride;
  9947. },
  9948. enumerable: true,
  9949. configurable: true
  9950. });
  9951. // Methods
  9952. Bone.prototype._decompose = function () {
  9953. if (!this._needToDecompose) {
  9954. return;
  9955. }
  9956. this._needToDecompose = false;
  9957. if (!this._localScaling) {
  9958. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9959. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9960. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9961. }
  9962. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9963. };
  9964. Bone.prototype._compose = function () {
  9965. if (!this._needToCompose) {
  9966. return;
  9967. }
  9968. this._needToCompose = false;
  9969. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9970. };
  9971. /**
  9972. * Update the base and local matrices
  9973. * @param matrix defines the new base or local matrix
  9974. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9975. * @param updateLocalMatrix defines if the local matrix should be updated
  9976. */
  9977. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9978. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9979. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9980. this._baseMatrix.copyFrom(matrix);
  9981. if (updateDifferenceMatrix) {
  9982. this._updateDifferenceMatrix();
  9983. }
  9984. if (updateLocalMatrix) {
  9985. this._localMatrix.copyFrom(matrix);
  9986. this._markAsDirtyAndDecompose();
  9987. }
  9988. else {
  9989. this.markAsDirty();
  9990. }
  9991. };
  9992. /** @hidden */
  9993. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  9994. if (updateChildren === void 0) { updateChildren = true; }
  9995. if (!rootMatrix) {
  9996. rootMatrix = this._baseMatrix;
  9997. }
  9998. if (this._parent) {
  9999. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10000. }
  10001. else {
  10002. this._absoluteTransform.copyFrom(rootMatrix);
  10003. }
  10004. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10005. if (updateChildren) {
  10006. for (var index = 0; index < this.children.length; index++) {
  10007. this.children[index]._updateDifferenceMatrix();
  10008. }
  10009. }
  10010. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10011. };
  10012. /**
  10013. * Flag the bone as dirty (Forcing it to update everything)
  10014. */
  10015. Bone.prototype.markAsDirty = function () {
  10016. this._currentRenderId++;
  10017. this._childRenderId++;
  10018. this._skeleton._markAsDirty();
  10019. };
  10020. Bone.prototype._markAsDirtyAndCompose = function () {
  10021. this.markAsDirty();
  10022. this._needToCompose = true;
  10023. };
  10024. Bone.prototype._markAsDirtyAndDecompose = function () {
  10025. this.markAsDirty();
  10026. this._needToDecompose = true;
  10027. };
  10028. /**
  10029. * Translate the bone in local or world space
  10030. * @param vec The amount to translate the bone
  10031. * @param space The space that the translation is in
  10032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10033. */
  10034. Bone.prototype.translate = function (vec, space, mesh) {
  10035. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10036. var lm = this.getLocalMatrix();
  10037. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10038. lm.addAtIndex(12, vec.x);
  10039. lm.addAtIndex(13, vec.y);
  10040. lm.addAtIndex(14, vec.z);
  10041. }
  10042. else {
  10043. var wm = null;
  10044. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10045. if (mesh) {
  10046. wm = mesh.getWorldMatrix();
  10047. }
  10048. this._skeleton.computeAbsoluteTransforms();
  10049. var tmat = Bone._tmpMats[0];
  10050. var tvec = Bone._tmpVecs[0];
  10051. if (this._parent) {
  10052. if (mesh && wm) {
  10053. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10054. tmat.multiplyToRef(wm, tmat);
  10055. }
  10056. else {
  10057. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10058. }
  10059. }
  10060. tmat.setTranslationFromFloats(0, 0, 0);
  10061. tmat.invert();
  10062. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10063. lm.addAtIndex(12, tvec.x);
  10064. lm.addAtIndex(13, tvec.y);
  10065. lm.addAtIndex(14, tvec.z);
  10066. }
  10067. this._markAsDirtyAndDecompose();
  10068. };
  10069. /**
  10070. * Set the postion of the bone in local or world space
  10071. * @param position The position to set the bone
  10072. * @param space The space that the position is in
  10073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10074. */
  10075. Bone.prototype.setPosition = function (position, space, mesh) {
  10076. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10077. var lm = this.getLocalMatrix();
  10078. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10079. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10080. }
  10081. else {
  10082. var wm = null;
  10083. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10084. if (mesh) {
  10085. wm = mesh.getWorldMatrix();
  10086. }
  10087. this._skeleton.computeAbsoluteTransforms();
  10088. var tmat = Bone._tmpMats[0];
  10089. var vec = Bone._tmpVecs[0];
  10090. if (this._parent) {
  10091. if (mesh && wm) {
  10092. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10093. tmat.multiplyToRef(wm, tmat);
  10094. }
  10095. else {
  10096. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10097. }
  10098. }
  10099. tmat.invert();
  10100. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10101. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10102. }
  10103. this._markAsDirtyAndDecompose();
  10104. };
  10105. /**
  10106. * Set the absolute position of the bone (world space)
  10107. * @param position The position to set the bone
  10108. * @param mesh The mesh that this bone is attached to
  10109. */
  10110. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10111. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10112. };
  10113. /**
  10114. * Scale the bone on the x, y and z axes (in local space)
  10115. * @param x The amount to scale the bone on the x axis
  10116. * @param y The amount to scale the bone on the y axis
  10117. * @param z The amount to scale the bone on the z axis
  10118. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10119. */
  10120. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10121. if (scaleChildren === void 0) { scaleChildren = false; }
  10122. var locMat = this.getLocalMatrix();
  10123. // Apply new scaling on top of current local matrix
  10124. var scaleMat = Bone._tmpMats[0];
  10125. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10126. scaleMat.multiplyToRef(locMat, locMat);
  10127. // Invert scaling matrix and apply the inverse to all children
  10128. scaleMat.invert();
  10129. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10130. var child = _a[_i];
  10131. var cm = child.getLocalMatrix();
  10132. cm.multiplyToRef(scaleMat, cm);
  10133. cm.multiplyAtIndex(12, x);
  10134. cm.multiplyAtIndex(13, y);
  10135. cm.multiplyAtIndex(14, z);
  10136. child._markAsDirtyAndDecompose();
  10137. }
  10138. this._markAsDirtyAndDecompose();
  10139. if (scaleChildren) {
  10140. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10141. var child = _c[_b];
  10142. child.scale(x, y, z, scaleChildren);
  10143. }
  10144. }
  10145. };
  10146. /**
  10147. * Set the bone scaling in local space
  10148. * @param scale defines the scaling vector
  10149. */
  10150. Bone.prototype.setScale = function (scale) {
  10151. this._decompose();
  10152. this._localScaling.copyFrom(scale);
  10153. this._markAsDirtyAndCompose();
  10154. };
  10155. /**
  10156. * Gets the current scaling in local space
  10157. * @returns the current scaling vector
  10158. */
  10159. Bone.prototype.getScale = function () {
  10160. this._decompose();
  10161. return this._localScaling;
  10162. };
  10163. /**
  10164. * Gets the current scaling in local space and stores it in a target vector
  10165. * @param result defines the target vector
  10166. */
  10167. Bone.prototype.getScaleToRef = function (result) {
  10168. this._decompose();
  10169. result.copyFrom(this._localScaling);
  10170. };
  10171. /**
  10172. * Set the yaw, pitch, and roll of the bone in local or world space
  10173. * @param yaw The rotation of the bone on the y axis
  10174. * @param pitch The rotation of the bone on the x axis
  10175. * @param roll The rotation of the bone on the z axis
  10176. * @param space The space that the axes of rotation are in
  10177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10178. */
  10179. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10180. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10181. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10182. var quat = Bone._tmpQuat;
  10183. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10184. this.setRotationQuaternion(quat, space, mesh);
  10185. return;
  10186. }
  10187. var rotMatInv = Bone._tmpMats[0];
  10188. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10189. return;
  10190. }
  10191. var rotMat = Bone._tmpMats[1];
  10192. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10193. rotMatInv.multiplyToRef(rotMat, rotMat);
  10194. this._rotateWithMatrix(rotMat, space, mesh);
  10195. };
  10196. /**
  10197. * Add a rotation to the bone on an axis in local or world space
  10198. * @param axis The axis to rotate the bone on
  10199. * @param amount The amount to rotate the bone
  10200. * @param space The space that the axis is in
  10201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10202. */
  10203. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10204. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10205. var rmat = Bone._tmpMats[0];
  10206. rmat.setTranslationFromFloats(0, 0, 0);
  10207. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10208. this._rotateWithMatrix(rmat, space, mesh);
  10209. };
  10210. /**
  10211. * Set the rotation of the bone to a particular axis angle in local or world space
  10212. * @param axis The axis to rotate the bone on
  10213. * @param angle The angle that the bone should be rotated to
  10214. * @param space The space that the axis is in
  10215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10216. */
  10217. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10218. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10219. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10220. var quat = Bone._tmpQuat;
  10221. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10222. this.setRotationQuaternion(quat, space, mesh);
  10223. return;
  10224. }
  10225. var rotMatInv = Bone._tmpMats[0];
  10226. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10227. return;
  10228. }
  10229. var rotMat = Bone._tmpMats[1];
  10230. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10231. rotMatInv.multiplyToRef(rotMat, rotMat);
  10232. this._rotateWithMatrix(rotMat, space, mesh);
  10233. };
  10234. /**
  10235. * Set the euler rotation of the bone in local of world space
  10236. * @param rotation The euler rotation that the bone should be set to
  10237. * @param space The space that the rotation is in
  10238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10239. */
  10240. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10241. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10242. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10243. };
  10244. /**
  10245. * Set the quaternion rotation of the bone in local of world space
  10246. * @param quat The quaternion rotation that the bone should be set to
  10247. * @param space The space that the rotation is in
  10248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10249. */
  10250. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10251. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10252. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10253. this._decompose();
  10254. this._localRotation.copyFrom(quat);
  10255. this._markAsDirtyAndCompose();
  10256. return;
  10257. }
  10258. var rotMatInv = Bone._tmpMats[0];
  10259. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10260. return;
  10261. }
  10262. var rotMat = Bone._tmpMats[1];
  10263. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10264. rotMatInv.multiplyToRef(rotMat, rotMat);
  10265. this._rotateWithMatrix(rotMat, space, mesh);
  10266. };
  10267. /**
  10268. * Set the rotation matrix of the bone in local of world space
  10269. * @param rotMat The rotation matrix that the bone should be set to
  10270. * @param space The space that the rotation is in
  10271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10272. */
  10273. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10274. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10275. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10276. var quat = Bone._tmpQuat;
  10277. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10278. this.setRotationQuaternion(quat, space, mesh);
  10279. return;
  10280. }
  10281. var rotMatInv = Bone._tmpMats[0];
  10282. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10283. return;
  10284. }
  10285. var rotMat2 = Bone._tmpMats[1];
  10286. rotMat2.copyFrom(rotMat);
  10287. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10288. this._rotateWithMatrix(rotMat2, space, mesh);
  10289. };
  10290. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10291. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10292. var lmat = this.getLocalMatrix();
  10293. var lx = lmat.m[12];
  10294. var ly = lmat.m[13];
  10295. var lz = lmat.m[14];
  10296. var parent = this.getParent();
  10297. var parentScale = Bone._tmpMats[3];
  10298. var parentScaleInv = Bone._tmpMats[4];
  10299. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10300. if (mesh) {
  10301. parentScale.copyFrom(mesh.getWorldMatrix());
  10302. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10303. }
  10304. else {
  10305. parentScale.copyFrom(parent.getAbsoluteTransform());
  10306. }
  10307. parentScaleInv.copyFrom(parentScale);
  10308. parentScaleInv.invert();
  10309. lmat.multiplyToRef(parentScale, lmat);
  10310. lmat.multiplyToRef(rmat, lmat);
  10311. lmat.multiplyToRef(parentScaleInv, lmat);
  10312. }
  10313. else {
  10314. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10315. parentScale.copyFrom(mesh.getWorldMatrix());
  10316. parentScaleInv.copyFrom(parentScale);
  10317. parentScaleInv.invert();
  10318. lmat.multiplyToRef(parentScale, lmat);
  10319. lmat.multiplyToRef(rmat, lmat);
  10320. lmat.multiplyToRef(parentScaleInv, lmat);
  10321. }
  10322. else {
  10323. lmat.multiplyToRef(rmat, lmat);
  10324. }
  10325. }
  10326. lmat.setTranslationFromFloats(lx, ly, lz);
  10327. this.computeAbsoluteTransforms();
  10328. this._markAsDirtyAndDecompose();
  10329. };
  10330. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10331. var scaleMatrix = Bone._tmpMats[2];
  10332. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10333. if (mesh) {
  10334. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10335. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10336. }
  10337. rotMatInv.invert();
  10338. if (isNaN(rotMatInv.m[0])) {
  10339. // Matrix failed to invert.
  10340. // This can happen if scale is zero for example.
  10341. return false;
  10342. }
  10343. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10344. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10345. return true;
  10346. };
  10347. /**
  10348. * Get the position of the bone in local or world space
  10349. * @param space The space that the returned position is in
  10350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10351. * @returns The position of the bone
  10352. */
  10353. Bone.prototype.getPosition = function (space, mesh) {
  10354. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10355. if (mesh === void 0) { mesh = null; }
  10356. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10357. this.getPositionToRef(space, mesh, pos);
  10358. return pos;
  10359. };
  10360. /**
  10361. * Copy the position of the bone to a vector3 in local or world space
  10362. * @param space The space that the returned position is in
  10363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10364. * @param result The vector3 to copy the position to
  10365. */
  10366. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10367. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10368. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10369. var lm = this.getLocalMatrix();
  10370. result.x = lm.m[12];
  10371. result.y = lm.m[13];
  10372. result.z = lm.m[14];
  10373. }
  10374. else {
  10375. var wm = null;
  10376. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10377. if (mesh) {
  10378. wm = mesh.getWorldMatrix();
  10379. }
  10380. this._skeleton.computeAbsoluteTransforms();
  10381. var tmat = Bone._tmpMats[0];
  10382. if (mesh && wm) {
  10383. tmat.copyFrom(this.getAbsoluteTransform());
  10384. tmat.multiplyToRef(wm, tmat);
  10385. }
  10386. else {
  10387. tmat = this.getAbsoluteTransform();
  10388. }
  10389. result.x = tmat.m[12];
  10390. result.y = tmat.m[13];
  10391. result.z = tmat.m[14];
  10392. }
  10393. };
  10394. /**
  10395. * Get the absolute position of the bone (world space)
  10396. * @param mesh The mesh that this bone is attached to
  10397. * @returns The absolute position of the bone
  10398. */
  10399. Bone.prototype.getAbsolutePosition = function (mesh) {
  10400. if (mesh === void 0) { mesh = null; }
  10401. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10402. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10403. return pos;
  10404. };
  10405. /**
  10406. * Copy the absolute position of the bone (world space) to the result param
  10407. * @param mesh The mesh that this bone is attached to
  10408. * @param result The vector3 to copy the absolute position to
  10409. */
  10410. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10411. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10412. };
  10413. /**
  10414. * Compute the absolute transforms of this bone and its children
  10415. */
  10416. Bone.prototype.computeAbsoluteTransforms = function () {
  10417. this._compose();
  10418. if (this._parent) {
  10419. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10420. }
  10421. else {
  10422. this._absoluteTransform.copyFrom(this._localMatrix);
  10423. var poseMatrix = this._skeleton.getPoseMatrix();
  10424. if (poseMatrix) {
  10425. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10426. }
  10427. }
  10428. var children = this.children;
  10429. var len = children.length;
  10430. for (var i = 0; i < len; i++) {
  10431. children[i].computeAbsoluteTransforms();
  10432. }
  10433. };
  10434. /**
  10435. * Get the world direction from an axis that is in the local space of the bone
  10436. * @param localAxis The local direction that is used to compute the world direction
  10437. * @param mesh The mesh that this bone is attached to
  10438. * @returns The world direction
  10439. */
  10440. Bone.prototype.getDirection = function (localAxis, mesh) {
  10441. if (mesh === void 0) { mesh = null; }
  10442. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10443. this.getDirectionToRef(localAxis, mesh, result);
  10444. return result;
  10445. };
  10446. /**
  10447. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10448. * @param localAxis The local direction that is used to compute the world direction
  10449. * @param mesh The mesh that this bone is attached to
  10450. * @param result The vector3 that the world direction will be copied to
  10451. */
  10452. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10453. if (mesh === void 0) { mesh = null; }
  10454. var wm = null;
  10455. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10456. if (mesh) {
  10457. wm = mesh.getWorldMatrix();
  10458. }
  10459. this._skeleton.computeAbsoluteTransforms();
  10460. var mat = Bone._tmpMats[0];
  10461. mat.copyFrom(this.getAbsoluteTransform());
  10462. if (mesh && wm) {
  10463. mat.multiplyToRef(wm, mat);
  10464. }
  10465. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10466. result.normalize();
  10467. };
  10468. /**
  10469. * Get the euler rotation of the bone in local or world space
  10470. * @param space The space that the rotation should be in
  10471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10472. * @returns The euler rotation
  10473. */
  10474. Bone.prototype.getRotation = function (space, mesh) {
  10475. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10476. if (mesh === void 0) { mesh = null; }
  10477. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10478. this.getRotationToRef(space, mesh, result);
  10479. return result;
  10480. };
  10481. /**
  10482. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10483. * @param space The space that the rotation should be in
  10484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10485. * @param result The vector3 that the rotation should be copied to
  10486. */
  10487. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10488. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10489. if (mesh === void 0) { mesh = null; }
  10490. var quat = Bone._tmpQuat;
  10491. this.getRotationQuaternionToRef(space, mesh, quat);
  10492. quat.toEulerAnglesToRef(result);
  10493. };
  10494. /**
  10495. * Get the quaternion rotation of the bone in either local or world space
  10496. * @param space The space that the rotation should be in
  10497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10498. * @returns The quaternion rotation
  10499. */
  10500. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10501. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10502. if (mesh === void 0) { mesh = null; }
  10503. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10504. this.getRotationQuaternionToRef(space, mesh, result);
  10505. return result;
  10506. };
  10507. /**
  10508. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10509. * @param space The space that the rotation should be in
  10510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10511. * @param result The quaternion that the rotation should be copied to
  10512. */
  10513. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10514. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10515. if (mesh === void 0) { mesh = null; }
  10516. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10517. this._decompose();
  10518. result.copyFrom(this._localRotation);
  10519. }
  10520. else {
  10521. var mat = Bone._tmpMats[0];
  10522. var amat = this.getAbsoluteTransform();
  10523. if (mesh) {
  10524. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10525. }
  10526. else {
  10527. mat.copyFrom(amat);
  10528. }
  10529. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10530. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10531. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10532. mat.decompose(undefined, result, undefined);
  10533. }
  10534. };
  10535. /**
  10536. * Get the rotation matrix of the bone in local or world space
  10537. * @param space The space that the rotation should be in
  10538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10539. * @returns The rotation matrix
  10540. */
  10541. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10542. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10543. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10544. this.getRotationMatrixToRef(space, mesh, result);
  10545. return result;
  10546. };
  10547. /**
  10548. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10549. * @param space The space that the rotation should be in
  10550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10551. * @param result The quaternion that the rotation should be copied to
  10552. */
  10553. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10554. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10555. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10556. this.getLocalMatrix().getRotationMatrixToRef(result);
  10557. }
  10558. else {
  10559. var mat = Bone._tmpMats[0];
  10560. var amat = this.getAbsoluteTransform();
  10561. if (mesh) {
  10562. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10563. }
  10564. else {
  10565. mat.copyFrom(amat);
  10566. }
  10567. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10568. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10569. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10570. mat.getRotationMatrixToRef(result);
  10571. }
  10572. };
  10573. /**
  10574. * Get the world position of a point that is in the local space of the bone
  10575. * @param position The local position
  10576. * @param mesh The mesh that this bone is attached to
  10577. * @returns The world position
  10578. */
  10579. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10580. if (mesh === void 0) { mesh = null; }
  10581. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10582. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10583. return result;
  10584. };
  10585. /**
  10586. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10587. * @param position The local position
  10588. * @param mesh The mesh that this bone is attached to
  10589. * @param result The vector3 that the world position should be copied to
  10590. */
  10591. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10592. if (mesh === void 0) { mesh = null; }
  10593. var wm = null;
  10594. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10595. if (mesh) {
  10596. wm = mesh.getWorldMatrix();
  10597. }
  10598. this._skeleton.computeAbsoluteTransforms();
  10599. var tmat = Bone._tmpMats[0];
  10600. if (mesh && wm) {
  10601. tmat.copyFrom(this.getAbsoluteTransform());
  10602. tmat.multiplyToRef(wm, tmat);
  10603. }
  10604. else {
  10605. tmat = this.getAbsoluteTransform();
  10606. }
  10607. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10608. };
  10609. /**
  10610. * Get the local position of a point that is in world space
  10611. * @param position The world position
  10612. * @param mesh The mesh that this bone is attached to
  10613. * @returns The local position
  10614. */
  10615. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10616. if (mesh === void 0) { mesh = null; }
  10617. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10618. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10619. return result;
  10620. };
  10621. /**
  10622. * Get the local position of a point that is in world space and copy it to the result param
  10623. * @param position The world position
  10624. * @param mesh The mesh that this bone is attached to
  10625. * @param result The vector3 that the local position should be copied to
  10626. */
  10627. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10628. if (mesh === void 0) { mesh = null; }
  10629. var wm = null;
  10630. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10631. if (mesh) {
  10632. wm = mesh.getWorldMatrix();
  10633. }
  10634. this._skeleton.computeAbsoluteTransforms();
  10635. var tmat = Bone._tmpMats[0];
  10636. tmat.copyFrom(this.getAbsoluteTransform());
  10637. if (mesh && wm) {
  10638. tmat.multiplyToRef(wm, tmat);
  10639. }
  10640. tmat.invert();
  10641. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10642. };
  10643. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10644. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10645. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10646. return Bone;
  10647. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10648. /***/ }),
  10649. /***/ "./Bones/boneIKController.ts":
  10650. /*!***********************************!*\
  10651. !*** ./Bones/boneIKController.ts ***!
  10652. \***********************************/
  10653. /*! exports provided: BoneIKController */
  10654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10655. "use strict";
  10656. __webpack_require__.r(__webpack_exports__);
  10657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10659. /**
  10660. * Class used to apply inverse kinematics to bones
  10661. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10662. */
  10663. var BoneIKController = /** @class */ (function () {
  10664. /**
  10665. * Creates a new BoneIKController
  10666. * @param mesh defines the mesh to control
  10667. * @param bone defines the bone to control
  10668. * @param options defines options to set up the controller
  10669. */
  10670. function BoneIKController(mesh, bone, options) {
  10671. /**
  10672. * Gets or sets the target position
  10673. */
  10674. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10675. /**
  10676. * Gets or sets the pole target position
  10677. */
  10678. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10679. /**
  10680. * Gets or sets the pole target local offset
  10681. */
  10682. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10683. /**
  10684. * Gets or sets the pole angle
  10685. */
  10686. this.poleAngle = 0;
  10687. /**
  10688. * 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)
  10689. */
  10690. this.slerpAmount = 1;
  10691. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10692. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10693. this._bone2Ang = Math.PI;
  10694. this._maxAngle = Math.PI;
  10695. this._rightHandedSystem = false;
  10696. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10697. this._slerping = false;
  10698. this._adjustRoll = 0;
  10699. this._bone2 = bone;
  10700. this._bone1 = bone.getParent();
  10701. if (!this._bone1) {
  10702. return;
  10703. }
  10704. this.mesh = mesh;
  10705. var bonePos = bone.getPosition();
  10706. if (bone.getAbsoluteTransform().determinant() > 0) {
  10707. this._rightHandedSystem = true;
  10708. this._bendAxis.x = 0;
  10709. this._bendAxis.y = 0;
  10710. this._bendAxis.z = -1;
  10711. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10712. this._adjustRoll = Math.PI * .5;
  10713. this._bendAxis.z = 1;
  10714. }
  10715. }
  10716. if (this._bone1.length) {
  10717. var boneScale1 = this._bone1.getScale();
  10718. var boneScale2 = this._bone2.getScale();
  10719. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10720. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10721. }
  10722. else if (this._bone1.children[0]) {
  10723. mesh.computeWorldMatrix(true);
  10724. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10725. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10726. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10727. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10728. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10729. }
  10730. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10731. this.maxAngle = Math.PI;
  10732. if (options) {
  10733. if (options.targetMesh) {
  10734. this.targetMesh = options.targetMesh;
  10735. this.targetMesh.computeWorldMatrix(true);
  10736. }
  10737. if (options.poleTargetMesh) {
  10738. this.poleTargetMesh = options.poleTargetMesh;
  10739. this.poleTargetMesh.computeWorldMatrix(true);
  10740. }
  10741. else if (options.poleTargetBone) {
  10742. this.poleTargetBone = options.poleTargetBone;
  10743. }
  10744. else if (this._bone1.getParent()) {
  10745. this.poleTargetBone = this._bone1.getParent();
  10746. }
  10747. if (options.poleTargetLocalOffset) {
  10748. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10749. }
  10750. if (options.poleAngle) {
  10751. this.poleAngle = options.poleAngle;
  10752. }
  10753. if (options.bendAxis) {
  10754. this._bendAxis.copyFrom(options.bendAxis);
  10755. }
  10756. if (options.maxAngle) {
  10757. this.maxAngle = options.maxAngle;
  10758. }
  10759. if (options.slerpAmount) {
  10760. this.slerpAmount = options.slerpAmount;
  10761. }
  10762. }
  10763. }
  10764. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10765. /**
  10766. * Gets or sets maximum allowed angle
  10767. */
  10768. get: function () {
  10769. return this._maxAngle;
  10770. },
  10771. set: function (value) {
  10772. this._setMaxAngle(value);
  10773. },
  10774. enumerable: true,
  10775. configurable: true
  10776. });
  10777. BoneIKController.prototype._setMaxAngle = function (ang) {
  10778. if (ang < 0) {
  10779. ang = 0;
  10780. }
  10781. if (ang > Math.PI || ang == undefined) {
  10782. ang = Math.PI;
  10783. }
  10784. this._maxAngle = ang;
  10785. var a = this._bone1Length;
  10786. var b = this._bone2Length;
  10787. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10788. };
  10789. /**
  10790. * Force the controller to update the bones
  10791. */
  10792. BoneIKController.prototype.update = function () {
  10793. var bone1 = this._bone1;
  10794. if (!bone1) {
  10795. return;
  10796. }
  10797. var target = this.targetPosition;
  10798. var poleTarget = this.poleTargetPosition;
  10799. var mat1 = BoneIKController._tmpMats[0];
  10800. var mat2 = BoneIKController._tmpMats[1];
  10801. if (this.targetMesh) {
  10802. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10803. }
  10804. if (this.poleTargetBone) {
  10805. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10806. }
  10807. else if (this.poleTargetMesh) {
  10808. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10809. }
  10810. var bonePos = BoneIKController._tmpVecs[0];
  10811. var zaxis = BoneIKController._tmpVecs[1];
  10812. var xaxis = BoneIKController._tmpVecs[2];
  10813. var yaxis = BoneIKController._tmpVecs[3];
  10814. var upAxis = BoneIKController._tmpVecs[4];
  10815. var _tmpQuat = BoneIKController._tmpQuat;
  10816. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10817. poleTarget.subtractToRef(bonePos, upAxis);
  10818. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10819. upAxis.y = 1;
  10820. }
  10821. else {
  10822. upAxis.normalize();
  10823. }
  10824. target.subtractToRef(bonePos, yaxis);
  10825. yaxis.normalize();
  10826. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10827. zaxis.normalize();
  10828. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10829. xaxis.normalize();
  10830. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10831. var a = this._bone1Length;
  10832. var b = this._bone2Length;
  10833. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10834. if (this._maxReach > 0) {
  10835. c = Math.min(this._maxReach, c);
  10836. }
  10837. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10838. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10839. if (acosa > 1) {
  10840. acosa = 1;
  10841. }
  10842. if (acosb > 1) {
  10843. acosb = 1;
  10844. }
  10845. if (acosa < -1) {
  10846. acosa = -1;
  10847. }
  10848. if (acosb < -1) {
  10849. acosb = -1;
  10850. }
  10851. var angA = Math.acos(acosa);
  10852. var angB = Math.acos(acosb);
  10853. var angC = -angA - angB;
  10854. if (this._rightHandedSystem) {
  10855. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10856. mat2.multiplyToRef(mat1, mat1);
  10857. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10858. mat2.multiplyToRef(mat1, mat1);
  10859. }
  10860. else {
  10861. var _tmpVec = BoneIKController._tmpVecs[5];
  10862. _tmpVec.copyFrom(this._bendAxis);
  10863. _tmpVec.x *= -1;
  10864. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10865. mat2.multiplyToRef(mat1, mat1);
  10866. }
  10867. if (this.poleAngle) {
  10868. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10869. mat1.multiplyToRef(mat2, mat1);
  10870. }
  10871. if (this._bone1) {
  10872. if (this.slerpAmount < 1) {
  10873. if (!this._slerping) {
  10874. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10875. }
  10876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10877. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10878. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10879. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10880. this._slerping = true;
  10881. }
  10882. else {
  10883. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10884. this._bone1Mat.copyFrom(mat1);
  10885. this._slerping = false;
  10886. }
  10887. }
  10888. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10889. this._bone2Ang = angC;
  10890. };
  10891. 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()];
  10892. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10893. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10894. return BoneIKController;
  10895. }());
  10896. /***/ }),
  10897. /***/ "./Bones/boneLookController.ts":
  10898. /*!*************************************!*\
  10899. !*** ./Bones/boneLookController.ts ***!
  10900. \*************************************/
  10901. /*! exports provided: BoneLookController */
  10902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10903. "use strict";
  10904. __webpack_require__.r(__webpack_exports__);
  10905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10906. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10907. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10908. /**
  10909. * Class used to make a bone look toward a point in space
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10911. */
  10912. var BoneLookController = /** @class */ (function () {
  10913. /**
  10914. * Create a BoneLookController
  10915. * @param mesh the mesh that the bone belongs to
  10916. * @param bone the bone that will be looking to the target
  10917. * @param target the target Vector3 to look at
  10918. * @param options optional settings:
  10919. * * maxYaw: the maximum angle the bone will yaw to
  10920. * * minYaw: the minimum angle the bone will yaw to
  10921. * * maxPitch: the maximum angle the bone will pitch to
  10922. * * minPitch: the minimum angle the bone will yaw to
  10923. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10924. * * upAxis: the up axis of the coordinate system
  10925. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10926. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10927. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10928. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10929. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10930. * * adjustRoll: used to make an adjustment to the roll of the bone
  10931. **/
  10932. function BoneLookController(mesh, bone, target, options) {
  10933. /**
  10934. * The up axis of the coordinate system that is used when the bone is rotated
  10935. */
  10936. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10937. /**
  10938. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10939. */
  10940. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10941. /**
  10942. * Used to make an adjustment to the yaw of the bone
  10943. */
  10944. this.adjustYaw = 0;
  10945. /**
  10946. * Used to make an adjustment to the pitch of the bone
  10947. */
  10948. this.adjustPitch = 0;
  10949. /**
  10950. * Used to make an adjustment to the roll of the bone
  10951. */
  10952. this.adjustRoll = 0;
  10953. /**
  10954. * 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)
  10955. */
  10956. this.slerpAmount = 1;
  10957. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10958. this._slerping = false;
  10959. this._firstFrameSkipped = false;
  10960. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10961. this.mesh = mesh;
  10962. this.bone = bone;
  10963. this.target = target;
  10964. if (options) {
  10965. if (options.adjustYaw) {
  10966. this.adjustYaw = options.adjustYaw;
  10967. }
  10968. if (options.adjustPitch) {
  10969. this.adjustPitch = options.adjustPitch;
  10970. }
  10971. if (options.adjustRoll) {
  10972. this.adjustRoll = options.adjustRoll;
  10973. }
  10974. if (options.maxYaw != null) {
  10975. this.maxYaw = options.maxYaw;
  10976. }
  10977. else {
  10978. this.maxYaw = Math.PI;
  10979. }
  10980. if (options.minYaw != null) {
  10981. this.minYaw = options.minYaw;
  10982. }
  10983. else {
  10984. this.minYaw = -Math.PI;
  10985. }
  10986. if (options.maxPitch != null) {
  10987. this.maxPitch = options.maxPitch;
  10988. }
  10989. else {
  10990. this.maxPitch = Math.PI;
  10991. }
  10992. if (options.minPitch != null) {
  10993. this.minPitch = options.minPitch;
  10994. }
  10995. else {
  10996. this.minPitch = -Math.PI;
  10997. }
  10998. if (options.slerpAmount != null) {
  10999. this.slerpAmount = options.slerpAmount;
  11000. }
  11001. if (options.upAxis != null) {
  11002. this.upAxis = options.upAxis;
  11003. }
  11004. if (options.upAxisSpace != null) {
  11005. this.upAxisSpace = options.upAxisSpace;
  11006. }
  11007. if (options.yawAxis != null || options.pitchAxis != null) {
  11008. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11009. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11010. if (options.yawAxis != null) {
  11011. newYawAxis = options.yawAxis.clone();
  11012. newYawAxis.normalize();
  11013. }
  11014. if (options.pitchAxis != null) {
  11015. newPitchAxis = options.pitchAxis.clone();
  11016. newPitchAxis.normalize();
  11017. }
  11018. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11019. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11020. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11021. this._transformYawPitchInv = this._transformYawPitch.clone();
  11022. this._transformYawPitch.invert();
  11023. }
  11024. }
  11025. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11026. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11027. }
  11028. }
  11029. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11030. /**
  11031. * Gets or sets the minimum yaw angle that the bone can look to
  11032. */
  11033. get: function () {
  11034. return this._minYaw;
  11035. },
  11036. set: function (value) {
  11037. this._minYaw = value;
  11038. this._minYawSin = Math.sin(value);
  11039. this._minYawCos = Math.cos(value);
  11040. if (this._maxYaw != null) {
  11041. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11042. this._yawRange = this._maxYaw - this._minYaw;
  11043. }
  11044. },
  11045. enumerable: true,
  11046. configurable: true
  11047. });
  11048. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11049. /**
  11050. * Gets or sets the maximum yaw angle that the bone can look to
  11051. */
  11052. get: function () {
  11053. return this._maxYaw;
  11054. },
  11055. set: function (value) {
  11056. this._maxYaw = value;
  11057. this._maxYawSin = Math.sin(value);
  11058. this._maxYawCos = Math.cos(value);
  11059. if (this._minYaw != null) {
  11060. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11061. this._yawRange = this._maxYaw - this._minYaw;
  11062. }
  11063. },
  11064. enumerable: true,
  11065. configurable: true
  11066. });
  11067. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11068. /**
  11069. * Gets or sets the minimum pitch angle that the bone can look to
  11070. */
  11071. get: function () {
  11072. return this._minPitch;
  11073. },
  11074. set: function (value) {
  11075. this._minPitch = value;
  11076. this._minPitchTan = Math.tan(value);
  11077. },
  11078. enumerable: true,
  11079. configurable: true
  11080. });
  11081. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11082. /**
  11083. * Gets or sets the maximum pitch angle that the bone can look to
  11084. */
  11085. get: function () {
  11086. return this._maxPitch;
  11087. },
  11088. set: function (value) {
  11089. this._maxPitch = value;
  11090. this._maxPitchTan = Math.tan(value);
  11091. },
  11092. enumerable: true,
  11093. configurable: true
  11094. });
  11095. /**
  11096. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11097. */
  11098. BoneLookController.prototype.update = function () {
  11099. //skip the first frame when slerping so that the mesh rotation is correct
  11100. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11101. this._firstFrameSkipped = true;
  11102. return;
  11103. }
  11104. var bone = this.bone;
  11105. var bonePos = BoneLookController._tmpVecs[0];
  11106. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11107. var target = this.target;
  11108. var _tmpMat1 = BoneLookController._tmpMats[0];
  11109. var _tmpMat2 = BoneLookController._tmpMats[1];
  11110. var mesh = this.mesh;
  11111. var parentBone = bone.getParent();
  11112. var upAxis = BoneLookController._tmpVecs[1];
  11113. upAxis.copyFrom(this.upAxis);
  11114. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11115. if (this._transformYawPitch) {
  11116. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11117. }
  11118. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11119. }
  11120. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11121. mesh.getDirectionToRef(upAxis, upAxis);
  11122. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11123. upAxis.normalize();
  11124. }
  11125. }
  11126. var checkYaw = false;
  11127. var checkPitch = false;
  11128. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11129. checkYaw = true;
  11130. }
  11131. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11132. checkPitch = true;
  11133. }
  11134. if (checkYaw || checkPitch) {
  11135. var spaceMat = BoneLookController._tmpMats[2];
  11136. var spaceMatInv = BoneLookController._tmpMats[3];
  11137. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11138. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11139. }
  11140. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11141. spaceMat.copyFrom(mesh.getWorldMatrix());
  11142. }
  11143. else {
  11144. var forwardAxis = BoneLookController._tmpVecs[2];
  11145. forwardAxis.copyFrom(this._fowardAxis);
  11146. if (this._transformYawPitch) {
  11147. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11148. }
  11149. if (parentBone) {
  11150. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11151. }
  11152. else {
  11153. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11154. }
  11155. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11156. rightAxis.normalize();
  11157. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11158. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11159. }
  11160. spaceMat.invertToRef(spaceMatInv);
  11161. var xzlen = null;
  11162. if (checkPitch) {
  11163. var localTarget = BoneLookController._tmpVecs[3];
  11164. target.subtractToRef(bonePos, localTarget);
  11165. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11166. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11167. var pitch = Math.atan2(localTarget.y, xzlen);
  11168. var newPitch = pitch;
  11169. if (pitch > this._maxPitch) {
  11170. localTarget.y = this._maxPitchTan * xzlen;
  11171. newPitch = this._maxPitch;
  11172. }
  11173. else if (pitch < this._minPitch) {
  11174. localTarget.y = this._minPitchTan * xzlen;
  11175. newPitch = this._minPitch;
  11176. }
  11177. if (pitch != newPitch) {
  11178. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11179. localTarget.addInPlace(bonePos);
  11180. target = localTarget;
  11181. }
  11182. }
  11183. if (checkYaw) {
  11184. var localTarget = BoneLookController._tmpVecs[4];
  11185. target.subtractToRef(bonePos, localTarget);
  11186. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11187. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11188. var newYaw = yaw;
  11189. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11190. if (xzlen == null) {
  11191. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11192. }
  11193. if (this._yawRange > Math.PI) {
  11194. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11195. localTarget.z = this._maxYawCos * xzlen;
  11196. localTarget.x = this._maxYawSin * xzlen;
  11197. newYaw = this._maxYaw;
  11198. }
  11199. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11200. localTarget.z = this._minYawCos * xzlen;
  11201. localTarget.x = this._minYawSin * xzlen;
  11202. newYaw = this._minYaw;
  11203. }
  11204. }
  11205. else {
  11206. if (yaw > this._maxYaw) {
  11207. localTarget.z = this._maxYawCos * xzlen;
  11208. localTarget.x = this._maxYawSin * xzlen;
  11209. newYaw = this._maxYaw;
  11210. }
  11211. else if (yaw < this._minYaw) {
  11212. localTarget.z = this._minYawCos * xzlen;
  11213. localTarget.x = this._minYawSin * xzlen;
  11214. newYaw = this._minYaw;
  11215. }
  11216. }
  11217. }
  11218. if (this._slerping && this._yawRange > Math.PI) {
  11219. //are we going to be crossing into the min/max region?
  11220. var boneFwd = BoneLookController._tmpVecs[8];
  11221. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11222. if (this._transformYawPitch) {
  11223. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11224. }
  11225. var boneRotMat = BoneLookController._tmpMats[4];
  11226. this._boneQuat.toRotationMatrix(boneRotMat);
  11227. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11228. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11229. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11230. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11231. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11232. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11233. if (angBtwTar > angBtwMidYaw) {
  11234. if (xzlen == null) {
  11235. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11236. }
  11237. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11238. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11239. if (angBtwMin < angBtwMax) {
  11240. newYaw = boneYaw + Math.PI * .75;
  11241. localTarget.z = Math.cos(newYaw) * xzlen;
  11242. localTarget.x = Math.sin(newYaw) * xzlen;
  11243. }
  11244. else {
  11245. newYaw = boneYaw - Math.PI * .75;
  11246. localTarget.z = Math.cos(newYaw) * xzlen;
  11247. localTarget.x = Math.sin(newYaw) * xzlen;
  11248. }
  11249. }
  11250. }
  11251. if (yaw != newYaw) {
  11252. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11253. localTarget.addInPlace(bonePos);
  11254. target = localTarget;
  11255. }
  11256. }
  11257. }
  11258. var zaxis = BoneLookController._tmpVecs[5];
  11259. var xaxis = BoneLookController._tmpVecs[6];
  11260. var yaxis = BoneLookController._tmpVecs[7];
  11261. var _tmpQuat = BoneLookController._tmpQuat;
  11262. target.subtractToRef(bonePos, zaxis);
  11263. zaxis.normalize();
  11264. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11265. xaxis.normalize();
  11266. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11267. yaxis.normalize();
  11268. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11269. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11270. return;
  11271. }
  11272. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11273. return;
  11274. }
  11275. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11276. return;
  11277. }
  11278. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11279. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11280. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11281. }
  11282. if (this.slerpAmount < 1) {
  11283. if (!this._slerping) {
  11284. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11285. }
  11286. if (this._transformYawPitch) {
  11287. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11288. }
  11289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11291. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11292. this._slerping = true;
  11293. }
  11294. else {
  11295. if (this._transformYawPitch) {
  11296. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11297. }
  11298. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11299. this._slerping = false;
  11300. }
  11301. };
  11302. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11303. var angDiff = ang2 - ang1;
  11304. angDiff %= Math.PI * 2;
  11305. if (angDiff > Math.PI) {
  11306. angDiff -= Math.PI * 2;
  11307. }
  11308. else if (angDiff < -Math.PI) {
  11309. angDiff += Math.PI * 2;
  11310. }
  11311. return angDiff;
  11312. };
  11313. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11314. ang1 %= (2 * Math.PI);
  11315. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11316. ang2 %= (2 * Math.PI);
  11317. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11318. var ab = 0;
  11319. if (ang1 < ang2) {
  11320. ab = ang2 - ang1;
  11321. }
  11322. else {
  11323. ab = ang1 - ang2;
  11324. }
  11325. if (ab > Math.PI) {
  11326. ab = Math.PI * 2 - ab;
  11327. }
  11328. return ab;
  11329. };
  11330. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11331. ang %= (2 * Math.PI);
  11332. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11333. ang1 %= (2 * Math.PI);
  11334. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11335. ang2 %= (2 * Math.PI);
  11336. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11337. if (ang1 < ang2) {
  11338. if (ang > ang1 && ang < ang2) {
  11339. return true;
  11340. }
  11341. }
  11342. else {
  11343. if (ang > ang2 && ang < ang1) {
  11344. return true;
  11345. }
  11346. }
  11347. return false;
  11348. };
  11349. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11350. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11351. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11352. return BoneLookController;
  11353. }());
  11354. /***/ }),
  11355. /***/ "./Bones/index.ts":
  11356. /*!************************!*\
  11357. !*** ./Bones/index.ts ***!
  11358. \************************/
  11359. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11361. "use strict";
  11362. __webpack_require__.r(__webpack_exports__);
  11363. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11365. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11367. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11369. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11371. /***/ }),
  11372. /***/ "./Bones/skeleton.ts":
  11373. /*!***************************!*\
  11374. !*** ./Bones/skeleton.ts ***!
  11375. \***************************/
  11376. /*! exports provided: Skeleton */
  11377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11378. "use strict";
  11379. __webpack_require__.r(__webpack_exports__);
  11380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11381. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11382. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11383. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11384. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11385. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11386. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11387. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11388. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11389. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11390. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11391. /**
  11392. * Class used to handle skinning animations
  11393. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11394. */
  11395. var Skeleton = /** @class */ (function () {
  11396. /**
  11397. * Creates a new skeleton
  11398. * @param name defines the skeleton name
  11399. * @param id defines the skeleton Id
  11400. * @param scene defines the hosting scene
  11401. */
  11402. function Skeleton(
  11403. /** defines the skeleton name */
  11404. name,
  11405. /** defines the skeleton Id */
  11406. id, scene) {
  11407. this.name = name;
  11408. this.id = id;
  11409. /**
  11410. * Defines the list of child bones
  11411. */
  11412. this.bones = new Array();
  11413. /**
  11414. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11415. */
  11416. this.needInitialSkinMatrix = false;
  11417. /**
  11418. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11419. */
  11420. this.overrideMesh = null;
  11421. this._isDirty = true;
  11422. this._meshesWithPoseMatrix = new Array();
  11423. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11424. this._ranges = {};
  11425. this._lastAbsoluteTransformsUpdateId = -1;
  11426. this._canUseTextureForBones = false;
  11427. /** @hidden */
  11428. this._numBonesWithLinkedTransformNode = 0;
  11429. /**
  11430. * Specifies if the skeleton should be serialized
  11431. */
  11432. this.doNotSerialize = false;
  11433. /**
  11434. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11435. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11436. */
  11437. this.useTextureToStoreBoneMatrices = true;
  11438. this._animationPropertiesOverride = null;
  11439. // Events
  11440. /**
  11441. * An observable triggered before computing the skeleton's matrices
  11442. */
  11443. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11444. this.bones = [];
  11445. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11446. this._scene.skeletons.push(this);
  11447. //make sure it will recalculate the matrix next time prepare is called.
  11448. this._isDirty = true;
  11449. var engineCaps = this._scene.getEngine().getCaps();
  11450. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11451. }
  11452. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11453. /**
  11454. * Gets or sets the animation properties override
  11455. */
  11456. get: function () {
  11457. if (!this._animationPropertiesOverride) {
  11458. return this._scene.animationPropertiesOverride;
  11459. }
  11460. return this._animationPropertiesOverride;
  11461. },
  11462. set: function (value) {
  11463. this._animationPropertiesOverride = value;
  11464. },
  11465. enumerable: true,
  11466. configurable: true
  11467. });
  11468. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11469. /**
  11470. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11471. */
  11472. get: function () {
  11473. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11474. },
  11475. enumerable: true,
  11476. configurable: true
  11477. });
  11478. // Members
  11479. /**
  11480. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11481. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11482. * @returns a Float32Array containing matrices data
  11483. */
  11484. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11485. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11486. return mesh._bonesTransformMatrices;
  11487. }
  11488. if (!this._transformMatrices) {
  11489. this.prepare();
  11490. }
  11491. return this._transformMatrices;
  11492. };
  11493. /**
  11494. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11495. * @returns a raw texture containing the data
  11496. */
  11497. Skeleton.prototype.getTransformMatrixTexture = function () {
  11498. return this._transformMatrixTexture;
  11499. };
  11500. /**
  11501. * Gets the current hosting scene
  11502. * @returns a scene object
  11503. */
  11504. Skeleton.prototype.getScene = function () {
  11505. return this._scene;
  11506. };
  11507. // Methods
  11508. /**
  11509. * Gets a string representing the current skeleton data
  11510. * @param fullDetails defines a boolean indicating if we want a verbose version
  11511. * @returns a string representing the current skeleton data
  11512. */
  11513. Skeleton.prototype.toString = function (fullDetails) {
  11514. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11515. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11516. if (fullDetails) {
  11517. ret += ", Ranges: {";
  11518. var first = true;
  11519. for (var name_1 in this._ranges) {
  11520. if (first) {
  11521. ret += ", ";
  11522. first = false;
  11523. }
  11524. ret += name_1;
  11525. }
  11526. ret += "}";
  11527. }
  11528. return ret;
  11529. };
  11530. /**
  11531. * Get bone's index searching by name
  11532. * @param name defines bone's name to search for
  11533. * @return the indice of the bone. Returns -1 if not found
  11534. */
  11535. Skeleton.prototype.getBoneIndexByName = function (name) {
  11536. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11537. if (this.bones[boneIndex].name === name) {
  11538. return boneIndex;
  11539. }
  11540. }
  11541. return -1;
  11542. };
  11543. /**
  11544. * Creater a new animation range
  11545. * @param name defines the name of the range
  11546. * @param from defines the start key
  11547. * @param to defines the end key
  11548. */
  11549. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11550. // check name not already in use
  11551. if (!this._ranges[name]) {
  11552. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11553. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11554. if (this.bones[i].animations[0]) {
  11555. this.bones[i].animations[0].createRange(name, from, to);
  11556. }
  11557. }
  11558. }
  11559. };
  11560. /**
  11561. * Delete a specific animation range
  11562. * @param name defines the name of the range
  11563. * @param deleteFrames defines if frames must be removed as well
  11564. */
  11565. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11566. if (deleteFrames === void 0) { deleteFrames = true; }
  11567. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11568. if (this.bones[i].animations[0]) {
  11569. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11570. }
  11571. }
  11572. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11573. };
  11574. /**
  11575. * Gets a specific animation range
  11576. * @param name defines the name of the range to look for
  11577. * @returns the requested animation range or null if not found
  11578. */
  11579. Skeleton.prototype.getAnimationRange = function (name) {
  11580. return this._ranges[name];
  11581. };
  11582. /**
  11583. * Gets the list of all animation ranges defined on this skeleton
  11584. * @returns an array
  11585. */
  11586. Skeleton.prototype.getAnimationRanges = function () {
  11587. var animationRanges = [];
  11588. var name;
  11589. var i = 0;
  11590. for (name in this._ranges) {
  11591. animationRanges[i] = this._ranges[name];
  11592. i++;
  11593. }
  11594. return animationRanges;
  11595. };
  11596. /**
  11597. * Copy animation range from a source skeleton.
  11598. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11599. * @param source defines the source skeleton
  11600. * @param name defines the name of the range to copy
  11601. * @param rescaleAsRequired defines if rescaling must be applied if required
  11602. * @returns true if operation was successful
  11603. */
  11604. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11605. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11606. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11607. return false;
  11608. }
  11609. var ret = true;
  11610. var frameOffset = this._getHighestAnimationFrame() + 1;
  11611. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11612. var boneDict = {};
  11613. var sourceBones = source.bones;
  11614. var nBones;
  11615. var i;
  11616. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11617. boneDict[sourceBones[i].name] = sourceBones[i];
  11618. }
  11619. if (this.bones.length !== sourceBones.length) {
  11620. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11621. ret = false;
  11622. }
  11623. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11624. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11625. var boneName = this.bones[i].name;
  11626. var sourceBone = boneDict[boneName];
  11627. if (sourceBone) {
  11628. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11629. }
  11630. else {
  11631. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11632. ret = false;
  11633. }
  11634. }
  11635. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11636. var range = source.getAnimationRange(name);
  11637. if (range) {
  11638. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11639. }
  11640. return ret;
  11641. };
  11642. /**
  11643. * Forces the skeleton to go to rest pose
  11644. */
  11645. Skeleton.prototype.returnToRest = function () {
  11646. for (var index = 0; index < this.bones.length; index++) {
  11647. this.bones[index].returnToRest();
  11648. }
  11649. };
  11650. Skeleton.prototype._getHighestAnimationFrame = function () {
  11651. var ret = 0;
  11652. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11653. if (this.bones[i].animations[0]) {
  11654. var highest = this.bones[i].animations[0].getHighestFrame();
  11655. if (ret < highest) {
  11656. ret = highest;
  11657. }
  11658. }
  11659. }
  11660. return ret;
  11661. };
  11662. /**
  11663. * Begin a specific animation range
  11664. * @param name defines the name of the range to start
  11665. * @param loop defines if looping must be turned on (false by default)
  11666. * @param speedRatio defines the speed ratio to apply (1 by default)
  11667. * @param onAnimationEnd defines a callback which will be called when animation will end
  11668. * @returns a new animatable
  11669. */
  11670. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11671. var range = this.getAnimationRange(name);
  11672. if (!range) {
  11673. return null;
  11674. }
  11675. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11676. };
  11677. /** @hidden */
  11678. Skeleton.prototype._markAsDirty = function () {
  11679. this._isDirty = true;
  11680. };
  11681. /** @hidden */
  11682. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11683. this._meshesWithPoseMatrix.push(mesh);
  11684. };
  11685. /** @hidden */
  11686. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11687. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11688. if (index > -1) {
  11689. this._meshesWithPoseMatrix.splice(index, 1);
  11690. }
  11691. };
  11692. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11693. this.onBeforeComputeObservable.notifyObservers(this);
  11694. for (var index = 0; index < this.bones.length; index++) {
  11695. var bone = this.bones[index];
  11696. var parentBone = bone.getParent();
  11697. if (parentBone) {
  11698. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11699. }
  11700. else {
  11701. if (initialSkinMatrix) {
  11702. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11703. }
  11704. else {
  11705. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11706. }
  11707. }
  11708. if (bone._index !== -1) {
  11709. var mappedIndex = bone._index === null ? index : bone._index;
  11710. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11711. }
  11712. }
  11713. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11714. };
  11715. /**
  11716. * Build all resources required to render a skeleton
  11717. */
  11718. Skeleton.prototype.prepare = function () {
  11719. // Update the local matrix of bones with linked transform nodes.
  11720. if (this._numBonesWithLinkedTransformNode > 0) {
  11721. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11722. var bone_1 = _a[_i];
  11723. if (bone_1._linkedTransformNode) {
  11724. // Computing the world matrix also computes the local matrix.
  11725. bone_1._linkedTransformNode.computeWorldMatrix();
  11726. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11727. bone_1.markAsDirty();
  11728. }
  11729. }
  11730. }
  11731. if (!this._isDirty) {
  11732. return;
  11733. }
  11734. if (this.needInitialSkinMatrix) {
  11735. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11736. var mesh = this._meshesWithPoseMatrix[index];
  11737. var poseMatrix = mesh.getPoseMatrix();
  11738. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11739. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11740. }
  11741. if (this._synchronizedWithMesh !== mesh) {
  11742. this._synchronizedWithMesh = mesh;
  11743. // Prepare bones
  11744. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11745. var bone = this.bones[boneIndex];
  11746. if (!bone.getParent()) {
  11747. var matrix = bone.getBaseMatrix();
  11748. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11749. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11750. }
  11751. }
  11752. }
  11753. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11754. }
  11755. }
  11756. else {
  11757. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11758. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11759. if (this.isUsingTextureForMatrices) {
  11760. if (this._transformMatrixTexture) {
  11761. this._transformMatrixTexture.dispose();
  11762. }
  11763. 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);
  11764. }
  11765. }
  11766. this._computeTransformMatrices(this._transformMatrices, null);
  11767. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11768. this._transformMatrixTexture.update(this._transformMatrices);
  11769. }
  11770. }
  11771. this._isDirty = false;
  11772. this._scene._activeBones.addCount(this.bones.length, false);
  11773. };
  11774. /**
  11775. * Gets the list of animatables currently running for this skeleton
  11776. * @returns an array of animatables
  11777. */
  11778. Skeleton.prototype.getAnimatables = function () {
  11779. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11780. this._animatables = [];
  11781. for (var index = 0; index < this.bones.length; index++) {
  11782. this._animatables.push(this.bones[index]);
  11783. }
  11784. }
  11785. return this._animatables;
  11786. };
  11787. /**
  11788. * Clone the current skeleton
  11789. * @param name defines the name of the new skeleton
  11790. * @param id defines the id of the enw skeleton
  11791. * @returns the new skeleton
  11792. */
  11793. Skeleton.prototype.clone = function (name, id) {
  11794. var result = new Skeleton(name, id || name, this._scene);
  11795. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11796. for (var index = 0; index < this.bones.length; index++) {
  11797. var source = this.bones[index];
  11798. var parentBone = null;
  11799. var parent_1 = source.getParent();
  11800. if (parent_1) {
  11801. var parentIndex = this.bones.indexOf(parent_1);
  11802. parentBone = result.bones[parentIndex];
  11803. }
  11804. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11805. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11806. }
  11807. if (this._ranges) {
  11808. result._ranges = {};
  11809. for (var rangeName in this._ranges) {
  11810. var range = this._ranges[rangeName];
  11811. if (range) {
  11812. result._ranges[rangeName] = range.clone();
  11813. }
  11814. }
  11815. }
  11816. this._isDirty = true;
  11817. return result;
  11818. };
  11819. /**
  11820. * Enable animation blending for this skeleton
  11821. * @param blendingSpeed defines the blending speed to apply
  11822. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11823. */
  11824. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11825. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11826. this.bones.forEach(function (bone) {
  11827. bone.animations.forEach(function (animation) {
  11828. animation.enableBlending = true;
  11829. animation.blendingSpeed = blendingSpeed;
  11830. });
  11831. });
  11832. };
  11833. /**
  11834. * Releases all resources associated with the current skeleton
  11835. */
  11836. Skeleton.prototype.dispose = function () {
  11837. this._meshesWithPoseMatrix = [];
  11838. // Animations
  11839. this.getScene().stopAnimation(this);
  11840. // Remove from scene
  11841. this.getScene().removeSkeleton(this);
  11842. if (this._transformMatrixTexture) {
  11843. this._transformMatrixTexture.dispose();
  11844. this._transformMatrixTexture = null;
  11845. }
  11846. };
  11847. /**
  11848. * Serialize the skeleton in a JSON object
  11849. * @returns a JSON object
  11850. */
  11851. Skeleton.prototype.serialize = function () {
  11852. var serializationObject = {};
  11853. serializationObject.name = this.name;
  11854. serializationObject.id = this.id;
  11855. if (this.dimensionsAtRest) {
  11856. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11857. }
  11858. serializationObject.bones = [];
  11859. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11860. for (var index = 0; index < this.bones.length; index++) {
  11861. var bone = this.bones[index];
  11862. var parent_2 = bone.getParent();
  11863. var serializedBone = {
  11864. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11865. name: bone.name,
  11866. matrix: bone.getBaseMatrix().toArray(),
  11867. rest: bone.getRestPose().toArray()
  11868. };
  11869. serializationObject.bones.push(serializedBone);
  11870. if (bone.length) {
  11871. serializedBone.length = bone.length;
  11872. }
  11873. if (bone.metadata) {
  11874. serializedBone.metadata = bone.metadata;
  11875. }
  11876. if (bone.animations && bone.animations.length > 0) {
  11877. serializedBone.animation = bone.animations[0].serialize();
  11878. }
  11879. serializationObject.ranges = [];
  11880. for (var name in this._ranges) {
  11881. var source = this._ranges[name];
  11882. if (!source) {
  11883. continue;
  11884. }
  11885. var range = {};
  11886. range.name = name;
  11887. range.from = source.from;
  11888. range.to = source.to;
  11889. serializationObject.ranges.push(range);
  11890. }
  11891. }
  11892. return serializationObject;
  11893. };
  11894. /**
  11895. * Creates a new skeleton from serialized data
  11896. * @param parsedSkeleton defines the serialized data
  11897. * @param scene defines the hosting scene
  11898. * @returns a new skeleton
  11899. */
  11900. Skeleton.Parse = function (parsedSkeleton, scene) {
  11901. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11902. if (parsedSkeleton.dimensionsAtRest) {
  11903. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11904. }
  11905. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11906. var index;
  11907. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11908. var parsedBone = parsedSkeleton.bones[index];
  11909. var parentBone = null;
  11910. if (parsedBone.parentBoneIndex > -1) {
  11911. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11912. }
  11913. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11914. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11915. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11916. bone.id = parsedBone.id;
  11917. }
  11918. if (parsedBone.length) {
  11919. bone.length = parsedBone.length;
  11920. }
  11921. if (parsedBone.metadata) {
  11922. bone.metadata = parsedBone.metadata;
  11923. }
  11924. if (parsedBone.animation) {
  11925. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11926. }
  11927. }
  11928. // placed after bones, so createAnimationRange can cascade down
  11929. if (parsedSkeleton.ranges) {
  11930. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11931. var data = parsedSkeleton.ranges[index];
  11932. skeleton.createAnimationRange(data.name, data.from, data.to);
  11933. }
  11934. }
  11935. return skeleton;
  11936. };
  11937. /**
  11938. * Compute all node absolute transforms
  11939. * @param forceUpdate defines if computation must be done even if cache is up to date
  11940. */
  11941. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11942. if (forceUpdate === void 0) { forceUpdate = false; }
  11943. var renderId = this._scene.getRenderId();
  11944. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11945. this.bones[0].computeAbsoluteTransforms();
  11946. this._lastAbsoluteTransformsUpdateId = renderId;
  11947. }
  11948. };
  11949. /**
  11950. * Gets the root pose matrix
  11951. * @returns a matrix
  11952. */
  11953. Skeleton.prototype.getPoseMatrix = function () {
  11954. var poseMatrix = null;
  11955. if (this._meshesWithPoseMatrix.length > 0) {
  11956. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11957. }
  11958. return poseMatrix;
  11959. };
  11960. /**
  11961. * Sorts bones per internal index
  11962. */
  11963. Skeleton.prototype.sortBones = function () {
  11964. var bones = new Array();
  11965. var visited = new Array(this.bones.length);
  11966. for (var index = 0; index < this.bones.length; index++) {
  11967. this._sortBones(index, bones, visited);
  11968. }
  11969. this.bones = bones;
  11970. };
  11971. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11972. if (visited[index]) {
  11973. return;
  11974. }
  11975. visited[index] = true;
  11976. var bone = this.bones[index];
  11977. if (bone._index === undefined) {
  11978. bone._index = index;
  11979. }
  11980. var parentBone = bone.getParent();
  11981. if (parentBone) {
  11982. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11983. }
  11984. bones.push(bone);
  11985. };
  11986. return Skeleton;
  11987. }());
  11988. /***/ }),
  11989. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11990. /*!*******************************************************!*\
  11991. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  11992. \*******************************************************/
  11993. /*! exports provided: ArcRotateCameraGamepadInput */
  11994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11995. "use strict";
  11996. __webpack_require__.r(__webpack_exports__);
  11997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  11998. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11999. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12000. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12001. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12002. /**
  12003. * Manage the gamepad inputs to control an arc rotate camera.
  12004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12005. */
  12006. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12007. function ArcRotateCameraGamepadInput() {
  12008. /**
  12009. * Defines the gamepad rotation sensiblity.
  12010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12011. */
  12012. this.gamepadRotationSensibility = 80;
  12013. /**
  12014. * Defines the gamepad move sensiblity.
  12015. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12016. */
  12017. this.gamepadMoveSensibility = 40;
  12018. }
  12019. /**
  12020. * Attach the input controls to a specific dom element to get the input from.
  12021. * @param element Defines the element the controls should be listened from
  12022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12023. */
  12024. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12025. var _this = this;
  12026. var manager = this.camera.getScene().gamepadManager;
  12027. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12028. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12029. // prioritize XBOX gamepads.
  12030. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12031. _this.gamepad = gamepad;
  12032. }
  12033. }
  12034. });
  12035. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12036. if (_this.gamepad === gamepad) {
  12037. _this.gamepad = null;
  12038. }
  12039. });
  12040. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12041. };
  12042. /**
  12043. * Detach the current controls from the specified dom element.
  12044. * @param element Defines the element to stop listening the inputs from
  12045. */
  12046. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12047. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12048. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12049. this.gamepad = null;
  12050. };
  12051. /**
  12052. * Update the current camera state depending on the inputs that have been used this frame.
  12053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12054. */
  12055. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12056. if (this.gamepad) {
  12057. var camera = this.camera;
  12058. var RSValues = this.gamepad.rightStick;
  12059. if (RSValues) {
  12060. if (RSValues.x != 0) {
  12061. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12062. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12063. camera.inertialAlphaOffset += normalizedRX;
  12064. }
  12065. }
  12066. if (RSValues.y != 0) {
  12067. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12068. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12069. camera.inertialBetaOffset += normalizedRY;
  12070. }
  12071. }
  12072. }
  12073. var LSValues = this.gamepad.leftStick;
  12074. if (LSValues && LSValues.y != 0) {
  12075. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12076. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12077. this.camera.inertialRadiusOffset -= normalizedLY;
  12078. }
  12079. }
  12080. }
  12081. };
  12082. /**
  12083. * Gets the class name of the current intput.
  12084. * @returns the class name
  12085. */
  12086. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12087. return "ArcRotateCameraGamepadInput";
  12088. };
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12094. return "gamepad";
  12095. };
  12096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12098. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12101. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12102. return ArcRotateCameraGamepadInput;
  12103. }());
  12104. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12105. /***/ }),
  12106. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12107. /*!************************************************************!*\
  12108. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12109. \************************************************************/
  12110. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12112. "use strict";
  12113. __webpack_require__.r(__webpack_exports__);
  12114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12115. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12116. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12117. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12118. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12119. /**
  12120. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12122. */
  12123. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12124. function ArcRotateCameraKeyboardMoveInput() {
  12125. /**
  12126. * Defines the list of key codes associated with the up action (increase alpha)
  12127. */
  12128. this.keysUp = [38];
  12129. /**
  12130. * Defines the list of key codes associated with the down action (decrease alpha)
  12131. */
  12132. this.keysDown = [40];
  12133. /**
  12134. * Defines the list of key codes associated with the left action (increase beta)
  12135. */
  12136. this.keysLeft = [37];
  12137. /**
  12138. * Defines the list of key codes associated with the right action (decrease beta)
  12139. */
  12140. this.keysRight = [39];
  12141. /**
  12142. * Defines the list of key codes associated with the reset action.
  12143. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12144. */
  12145. this.keysReset = [220];
  12146. /**
  12147. * Defines the panning sensibility of the inputs.
  12148. * (How fast is the camera paning)
  12149. */
  12150. this.panningSensibility = 50.0;
  12151. /**
  12152. * Defines the zooming sensibility of the inputs.
  12153. * (How fast is the camera zooming)
  12154. */
  12155. this.zoomingSensibility = 25.0;
  12156. /**
  12157. * Defines wether maintaining the alt key down switch the movement mode from
  12158. * orientation to zoom.
  12159. */
  12160. this.useAltToZoom = true;
  12161. /**
  12162. * Rotation speed of the camera
  12163. */
  12164. this.angularSpeed = 0.01;
  12165. this._keys = new Array();
  12166. }
  12167. /**
  12168. * Attach the input controls to a specific dom element to get the input from.
  12169. * @param element Defines the element the controls should be listened from
  12170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12171. */
  12172. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12173. var _this = this;
  12174. if (this._onCanvasBlurObserver) {
  12175. return;
  12176. }
  12177. this._scene = this.camera.getScene();
  12178. this._engine = this._scene.getEngine();
  12179. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12180. _this._keys = [];
  12181. });
  12182. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12183. var evt = info.event;
  12184. if (!evt.metaKey) {
  12185. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12186. _this._ctrlPressed = evt.ctrlKey;
  12187. _this._altPressed = evt.altKey;
  12188. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12189. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12190. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12191. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12192. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12193. var index = _this._keys.indexOf(evt.keyCode);
  12194. if (index === -1) {
  12195. _this._keys.push(evt.keyCode);
  12196. }
  12197. if (evt.preventDefault) {
  12198. if (!noPreventDefault) {
  12199. evt.preventDefault();
  12200. }
  12201. }
  12202. }
  12203. }
  12204. else {
  12205. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12206. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12207. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12208. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12209. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12210. var index = _this._keys.indexOf(evt.keyCode);
  12211. if (index >= 0) {
  12212. _this._keys.splice(index, 1);
  12213. }
  12214. if (evt.preventDefault) {
  12215. if (!noPreventDefault) {
  12216. evt.preventDefault();
  12217. }
  12218. }
  12219. }
  12220. }
  12221. }
  12222. });
  12223. };
  12224. /**
  12225. * Detach the current controls from the specified dom element.
  12226. * @param element Defines the element to stop listening the inputs from
  12227. */
  12228. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12229. if (this._scene) {
  12230. if (this._onKeyboardObserver) {
  12231. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12232. }
  12233. if (this._onCanvasBlurObserver) {
  12234. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12235. }
  12236. this._onKeyboardObserver = null;
  12237. this._onCanvasBlurObserver = null;
  12238. }
  12239. this._keys = [];
  12240. };
  12241. /**
  12242. * Update the current camera state depending on the inputs that have been used this frame.
  12243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12244. */
  12245. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12246. if (this._onKeyboardObserver) {
  12247. var camera = this.camera;
  12248. for (var index = 0; index < this._keys.length; index++) {
  12249. var keyCode = this._keys[index];
  12250. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12251. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12252. camera.inertialPanningX -= 1 / this.panningSensibility;
  12253. }
  12254. else {
  12255. camera.inertialAlphaOffset -= this.angularSpeed;
  12256. }
  12257. }
  12258. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12259. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12260. camera.inertialPanningY += 1 / this.panningSensibility;
  12261. }
  12262. else if (this._altPressed && this.useAltToZoom) {
  12263. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12264. }
  12265. else {
  12266. camera.inertialBetaOffset -= this.angularSpeed;
  12267. }
  12268. }
  12269. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12270. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12271. camera.inertialPanningX += 1 / this.panningSensibility;
  12272. }
  12273. else {
  12274. camera.inertialAlphaOffset += this.angularSpeed;
  12275. }
  12276. }
  12277. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12278. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12279. camera.inertialPanningY -= 1 / this.panningSensibility;
  12280. }
  12281. else if (this._altPressed && this.useAltToZoom) {
  12282. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12283. }
  12284. else {
  12285. camera.inertialBetaOffset += this.angularSpeed;
  12286. }
  12287. }
  12288. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12289. if (camera.useInputToRestoreState) {
  12290. camera.restoreState();
  12291. }
  12292. }
  12293. }
  12294. }
  12295. };
  12296. /**
  12297. * Gets the class name of the current intput.
  12298. * @returns the class name
  12299. */
  12300. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12301. return "ArcRotateCameraKeyboardMoveInput";
  12302. };
  12303. /**
  12304. * Get the friendly name associated with the input class.
  12305. * @returns the input friendly name
  12306. */
  12307. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12308. return "keyboard";
  12309. };
  12310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12312. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12315. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12318. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12321. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12324. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12327. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12330. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12333. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12336. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12337. return ArcRotateCameraKeyboardMoveInput;
  12338. }());
  12339. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12340. /***/ }),
  12341. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12342. /*!**********************************************************!*\
  12343. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12344. \**********************************************************/
  12345. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12347. "use strict";
  12348. __webpack_require__.r(__webpack_exports__);
  12349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12350. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12351. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12352. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12353. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12354. /**
  12355. * Manage the mouse wheel inputs to control an arc rotate camera.
  12356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12357. */
  12358. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12359. function ArcRotateCameraMouseWheelInput() {
  12360. /**
  12361. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12362. */
  12363. this.wheelPrecision = 3.0;
  12364. /**
  12365. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12366. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12367. */
  12368. this.wheelDeltaPercentage = 0;
  12369. }
  12370. /**
  12371. * Attach the input controls to a specific dom element to get the input from.
  12372. * @param element Defines the element the controls should be listened from
  12373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12374. */
  12375. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12376. var _this = this;
  12377. this._wheel = function (p, s) {
  12378. //sanity check - this should be a PointerWheel event.
  12379. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12380. return;
  12381. }
  12382. var event = p.event;
  12383. var delta = 0;
  12384. var mouseWheelLegacyEvent = event;
  12385. if (mouseWheelLegacyEvent.wheelDelta) {
  12386. if (_this.wheelDeltaPercentage) {
  12387. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12388. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12389. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12390. }
  12391. else {
  12392. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12393. }
  12394. }
  12395. else {
  12396. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12397. }
  12398. }
  12399. else {
  12400. var deltaValue = event.deltaY || event.detail;
  12401. delta = -deltaValue / _this.wheelPrecision;
  12402. }
  12403. if (delta) {
  12404. _this.camera.inertialRadiusOffset += delta;
  12405. }
  12406. if (event.preventDefault) {
  12407. if (!noPreventDefault) {
  12408. event.preventDefault();
  12409. }
  12410. }
  12411. };
  12412. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12413. };
  12414. /**
  12415. * Detach the current controls from the specified dom element.
  12416. * @param element Defines the element to stop listening the inputs from
  12417. */
  12418. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12419. if (this._observer && element) {
  12420. this.camera.getScene().onPointerObservable.remove(this._observer);
  12421. this._observer = null;
  12422. this._wheel = null;
  12423. }
  12424. };
  12425. /**
  12426. * Gets the class name of the current intput.
  12427. * @returns the class name
  12428. */
  12429. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12430. return "ArcRotateCameraMouseWheelInput";
  12431. };
  12432. /**
  12433. * Get the friendly name associated with the input class.
  12434. * @returns the input friendly name
  12435. */
  12436. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12437. return "mousewheel";
  12438. };
  12439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12441. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12444. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12445. return ArcRotateCameraMouseWheelInput;
  12446. }());
  12447. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12448. /***/ }),
  12449. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12450. /*!********************************************************!*\
  12451. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12452. \********************************************************/
  12453. /*! exports provided: ArcRotateCameraPointersInput */
  12454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12455. "use strict";
  12456. __webpack_require__.r(__webpack_exports__);
  12457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12459. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12460. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12461. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12462. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12463. /**
  12464. * Manage the pointers inputs to control an arc rotate camera.
  12465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12466. */
  12467. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12468. function ArcRotateCameraPointersInput() {
  12469. /**
  12470. * Defines the buttons associated with the input to handle camera move.
  12471. */
  12472. this.buttons = [0, 1, 2];
  12473. /**
  12474. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12475. */
  12476. this.angularSensibilityX = 1000.0;
  12477. /**
  12478. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12479. */
  12480. this.angularSensibilityY = 1000.0;
  12481. /**
  12482. * Defines the pointer pinch precision or how fast is the camera zooming.
  12483. */
  12484. this.pinchPrecision = 12.0;
  12485. /**
  12486. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12487. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12488. */
  12489. this.pinchDeltaPercentage = 0;
  12490. /**
  12491. * Defines the pointer panning sensibility or how fast is the camera moving.
  12492. */
  12493. this.panningSensibility = 1000.0;
  12494. /**
  12495. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12496. */
  12497. this.multiTouchPanning = true;
  12498. /**
  12499. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12500. */
  12501. this.multiTouchPanAndZoom = true;
  12502. /**
  12503. * Revers pinch action direction.
  12504. */
  12505. this.pinchInwards = true;
  12506. this._isPanClick = false;
  12507. }
  12508. /**
  12509. * Attach the input controls to a specific dom element to get the input from.
  12510. * @param element Defines the element the controls should be listened from
  12511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12512. */
  12513. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12514. var _this = this;
  12515. var engine = this.camera.getEngine();
  12516. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12517. var pointA = null;
  12518. var pointB = null;
  12519. var previousPinchSquaredDistance = 0;
  12520. var initialDistance = 0;
  12521. var twoFingerActivityCount = 0;
  12522. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12523. this._pointerInput = function (p, s) {
  12524. var evt = p.event;
  12525. var isTouch = p.event.pointerType === "touch";
  12526. if (engine.isInVRExclusivePointerMode) {
  12527. return;
  12528. }
  12529. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12530. return;
  12531. }
  12532. var srcElement = (evt.srcElement || evt.target);
  12533. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12534. try {
  12535. srcElement.setPointerCapture(evt.pointerId);
  12536. }
  12537. catch (e) {
  12538. //Nothing to do with the error. Execution will continue.
  12539. }
  12540. // Manage panning with pan button click
  12541. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12542. // manage pointers
  12543. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12544. if (pointA === null) {
  12545. pointA = cacheSoloPointer;
  12546. }
  12547. else if (pointB === null) {
  12548. pointB = cacheSoloPointer;
  12549. }
  12550. if (!noPreventDefault) {
  12551. evt.preventDefault();
  12552. element.focus();
  12553. }
  12554. }
  12555. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12556. if (_this.camera.useInputToRestoreState) {
  12557. _this.camera.restoreState();
  12558. }
  12559. }
  12560. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12561. try {
  12562. srcElement.releasePointerCapture(evt.pointerId);
  12563. }
  12564. catch (e) {
  12565. //Nothing to do with the error.
  12566. }
  12567. cacheSoloPointer = null;
  12568. previousPinchSquaredDistance = 0;
  12569. previousMultiTouchPanPosition.isPaning = false;
  12570. previousMultiTouchPanPosition.isPinching = false;
  12571. twoFingerActivityCount = 0;
  12572. initialDistance = 0;
  12573. if (!isTouch) {
  12574. pointB = null; // Mouse and pen are mono pointer
  12575. }
  12576. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12577. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12578. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12579. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12580. if (engine._badOS) {
  12581. pointA = pointB = null;
  12582. }
  12583. else {
  12584. //only remove the impacted pointer in case of multitouch allowing on most
  12585. //platforms switching from rotate to zoom and pan seamlessly.
  12586. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12587. pointA = pointB;
  12588. pointB = null;
  12589. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12590. }
  12591. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12592. pointB = null;
  12593. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12594. }
  12595. else {
  12596. pointA = pointB = null;
  12597. }
  12598. }
  12599. if (!noPreventDefault) {
  12600. evt.preventDefault();
  12601. }
  12602. }
  12603. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12604. if (!noPreventDefault) {
  12605. evt.preventDefault();
  12606. }
  12607. // One button down
  12608. if (pointA && pointB === null && cacheSoloPointer) {
  12609. if (_this.panningSensibility !== 0 &&
  12610. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12611. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12612. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12613. }
  12614. else {
  12615. var offsetX = evt.clientX - cacheSoloPointer.x;
  12616. var offsetY = evt.clientY - cacheSoloPointer.y;
  12617. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12618. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12619. }
  12620. cacheSoloPointer.x = evt.clientX;
  12621. cacheSoloPointer.y = evt.clientY;
  12622. }
  12623. // Two buttons down: pinch/pan
  12624. else if (pointA && pointB) {
  12625. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12626. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12627. ed.x = evt.clientX;
  12628. ed.y = evt.clientY;
  12629. var direction = _this.pinchInwards ? 1 : -1;
  12630. var distX = pointA.x - pointB.x;
  12631. var distY = pointA.y - pointB.y;
  12632. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12633. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12634. if (previousPinchSquaredDistance === 0) {
  12635. initialDistance = pinchDistance;
  12636. previousPinchSquaredDistance = pinchSquaredDistance;
  12637. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12638. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12639. return;
  12640. }
  12641. if (_this.multiTouchPanAndZoom) {
  12642. if (_this.pinchDeltaPercentage) {
  12643. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12644. }
  12645. else {
  12646. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12647. (_this.pinchPrecision *
  12648. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12649. direction);
  12650. }
  12651. if (_this.panningSensibility !== 0) {
  12652. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12653. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12654. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12655. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12656. previousMultiTouchPanPosition.x = pointersCenterX;
  12657. previousMultiTouchPanPosition.y = pointersCenterY;
  12658. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12659. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12660. }
  12661. }
  12662. else {
  12663. twoFingerActivityCount++;
  12664. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12665. if (_this.pinchDeltaPercentage) {
  12666. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12667. }
  12668. else {
  12669. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12670. (_this.pinchPrecision *
  12671. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12672. direction);
  12673. }
  12674. previousMultiTouchPanPosition.isPaning = false;
  12675. previousMultiTouchPanPosition.isPinching = true;
  12676. }
  12677. else {
  12678. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12679. if (!previousMultiTouchPanPosition.isPaning) {
  12680. previousMultiTouchPanPosition.isPaning = true;
  12681. previousMultiTouchPanPosition.isPinching = false;
  12682. previousMultiTouchPanPosition.x = ed.x;
  12683. previousMultiTouchPanPosition.y = ed.y;
  12684. return;
  12685. }
  12686. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12687. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12688. }
  12689. }
  12690. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12691. previousMultiTouchPanPosition.x = ed.x;
  12692. previousMultiTouchPanPosition.y = ed.y;
  12693. }
  12694. }
  12695. previousPinchSquaredDistance = pinchSquaredDistance;
  12696. }
  12697. }
  12698. };
  12699. 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 | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP);
  12700. this._onContextMenu = function (evt) {
  12701. evt.preventDefault();
  12702. };
  12703. if (!this.camera._useCtrlForPanning) {
  12704. element.addEventListener("contextmenu", this._onContextMenu, false);
  12705. }
  12706. this._onLostFocus = function () {
  12707. //this._keys = [];
  12708. pointA = pointB = null;
  12709. previousPinchSquaredDistance = 0;
  12710. previousMultiTouchPanPosition.isPaning = false;
  12711. previousMultiTouchPanPosition.isPinching = false;
  12712. twoFingerActivityCount = 0;
  12713. cacheSoloPointer = null;
  12714. initialDistance = 0;
  12715. };
  12716. this._onMouseMove = function (evt) {
  12717. if (!engine.isPointerLock) {
  12718. return;
  12719. }
  12720. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12721. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12722. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12723. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12724. if (!noPreventDefault) {
  12725. evt.preventDefault();
  12726. }
  12727. };
  12728. this._onGestureStart = function (e) {
  12729. if (window.MSGesture === undefined) {
  12730. return;
  12731. }
  12732. if (!_this._MSGestureHandler) {
  12733. _this._MSGestureHandler = new MSGesture();
  12734. _this._MSGestureHandler.target = element;
  12735. }
  12736. _this._MSGestureHandler.addPointer(e.pointerId);
  12737. };
  12738. this._onGesture = function (e) {
  12739. _this.camera.radius *= e.scale;
  12740. if (e.preventDefault) {
  12741. if (!noPreventDefault) {
  12742. e.stopPropagation();
  12743. e.preventDefault();
  12744. }
  12745. }
  12746. };
  12747. element.addEventListener("mousemove", this._onMouseMove, false);
  12748. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12749. element.addEventListener("MSGestureChange", this._onGesture, false);
  12750. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12751. { name: "blur", handler: this._onLostFocus }
  12752. ]);
  12753. };
  12754. /**
  12755. * Detach the current controls from the specified dom element.
  12756. * @param element Defines the element to stop listening the inputs from
  12757. */
  12758. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12759. if (this._onLostFocus) {
  12760. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12761. { name: "blur", handler: this._onLostFocus }
  12762. ]);
  12763. }
  12764. if (element && this._observer) {
  12765. this.camera.getScene().onPointerObservable.remove(this._observer);
  12766. this._observer = null;
  12767. if (this._onContextMenu) {
  12768. element.removeEventListener("contextmenu", this._onContextMenu);
  12769. }
  12770. if (this._onMouseMove) {
  12771. element.removeEventListener("mousemove", this._onMouseMove);
  12772. }
  12773. if (this._onGestureStart) {
  12774. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12775. }
  12776. if (this._onGesture) {
  12777. element.removeEventListener("MSGestureChange", this._onGesture);
  12778. }
  12779. this._isPanClick = false;
  12780. this.pinchInwards = true;
  12781. this._onMouseMove = null;
  12782. this._onGestureStart = null;
  12783. this._onGesture = null;
  12784. this._MSGestureHandler = null;
  12785. this._onLostFocus = null;
  12786. this._onContextMenu = null;
  12787. }
  12788. };
  12789. /**
  12790. * Gets the class name of the current intput.
  12791. * @returns the class name
  12792. */
  12793. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12794. return "ArcRotateCameraPointersInput";
  12795. };
  12796. /**
  12797. * Get the friendly name associated with the input class.
  12798. * @returns the input friendly name
  12799. */
  12800. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12801. return "pointers";
  12802. };
  12803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12805. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12808. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12811. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12814. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12817. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12820. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12823. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12826. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12827. return ArcRotateCameraPointersInput;
  12828. }());
  12829. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12830. /***/ }),
  12831. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12832. /*!*******************************************************************!*\
  12833. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12834. \*******************************************************************/
  12835. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12837. "use strict";
  12838. __webpack_require__.r(__webpack_exports__);
  12839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12840. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12841. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12842. /**
  12843. * Add orientation input support to the input manager.
  12844. * @returns the current input manager
  12845. */
  12846. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12847. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12848. return this;
  12849. };
  12850. /**
  12851. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12853. */
  12854. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12855. /**
  12856. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12857. */
  12858. function ArcRotateCameraVRDeviceOrientationInput() {
  12859. /**
  12860. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12861. */
  12862. this.alphaCorrection = 1;
  12863. /**
  12864. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12865. */
  12866. this.gammaCorrection = 1;
  12867. this._alpha = 0;
  12868. this._gamma = 0;
  12869. this._dirty = false;
  12870. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12871. }
  12872. /**
  12873. * Attach the input controls to a specific dom element to get the input from.
  12874. * @param element Defines the element the controls should be listened from
  12875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12876. */
  12877. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12878. this.camera.attachControl(element, noPreventDefault);
  12879. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12880. };
  12881. /** @hidden */
  12882. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12883. if (evt.alpha !== null) {
  12884. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12885. }
  12886. if (evt.gamma !== null) {
  12887. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12888. }
  12889. this._dirty = true;
  12890. };
  12891. /**
  12892. * Update the current camera state depending on the inputs that have been used this frame.
  12893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12894. */
  12895. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12896. if (this._dirty) {
  12897. this._dirty = false;
  12898. if (this._gamma < 0) {
  12899. this._gamma = 180 + this._gamma;
  12900. }
  12901. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12902. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12903. }
  12904. };
  12905. /**
  12906. * Detach the current controls from the specified dom element.
  12907. * @param element Defines the element to stop listening the inputs from
  12908. */
  12909. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12910. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12911. };
  12912. /**
  12913. * Gets the class name of the current intput.
  12914. * @returns the class name
  12915. */
  12916. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12917. return "ArcRotateCameraVRDeviceOrientationInput";
  12918. };
  12919. /**
  12920. * Get the friendly name associated with the input class.
  12921. * @returns the input friendly name
  12922. */
  12923. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12924. return "VRDeviceOrientation";
  12925. };
  12926. return ArcRotateCameraVRDeviceOrientationInput;
  12927. }());
  12928. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12929. /***/ }),
  12930. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12931. /*!**************************************************!*\
  12932. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12933. \**************************************************/
  12934. /*! exports provided: FlyCameraKeyboardInput */
  12935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12936. "use strict";
  12937. __webpack_require__.r(__webpack_exports__);
  12938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12940. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12941. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12942. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12943. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12944. /**
  12945. * Listen to keyboard events to control the camera.
  12946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12947. */
  12948. var FlyCameraKeyboardInput = /** @class */ (function () {
  12949. function FlyCameraKeyboardInput() {
  12950. /**
  12951. * The list of keyboard keys used to control the forward move of the camera.
  12952. */
  12953. this.keysForward = [87];
  12954. /**
  12955. * The list of keyboard keys used to control the backward move of the camera.
  12956. */
  12957. this.keysBackward = [83];
  12958. /**
  12959. * The list of keyboard keys used to control the forward move of the camera.
  12960. */
  12961. this.keysUp = [69];
  12962. /**
  12963. * The list of keyboard keys used to control the backward move of the camera.
  12964. */
  12965. this.keysDown = [81];
  12966. /**
  12967. * The list of keyboard keys used to control the right strafe move of the camera.
  12968. */
  12969. this.keysRight = [68];
  12970. /**
  12971. * The list of keyboard keys used to control the left strafe move of the camera.
  12972. */
  12973. this.keysLeft = [65];
  12974. this._keys = new Array();
  12975. }
  12976. /**
  12977. * Attach the input controls to a specific dom element to get the input from.
  12978. * @param element Defines the element the controls should be listened from
  12979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12980. */
  12981. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12982. var _this = this;
  12983. if (this._onCanvasBlurObserver) {
  12984. return;
  12985. }
  12986. this._scene = this.camera.getScene();
  12987. this._engine = this._scene.getEngine();
  12988. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12989. _this._keys = [];
  12990. });
  12991. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12992. var evt = info.event;
  12993. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12994. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12995. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12996. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12997. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12998. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12999. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13000. var index = _this._keys.indexOf(evt.keyCode);
  13001. if (index === -1) {
  13002. _this._keys.push(evt.keyCode);
  13003. }
  13004. if (!noPreventDefault) {
  13005. evt.preventDefault();
  13006. }
  13007. }
  13008. }
  13009. else {
  13010. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13011. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13012. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13013. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13014. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13015. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13016. var index = _this._keys.indexOf(evt.keyCode);
  13017. if (index >= 0) {
  13018. _this._keys.splice(index, 1);
  13019. }
  13020. if (!noPreventDefault) {
  13021. evt.preventDefault();
  13022. }
  13023. }
  13024. }
  13025. });
  13026. };
  13027. /**
  13028. * Detach the current controls from the specified dom element.
  13029. * @param element Defines the element to stop listening the inputs from
  13030. */
  13031. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13032. if (this._scene) {
  13033. if (this._onKeyboardObserver) {
  13034. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13035. }
  13036. if (this._onCanvasBlurObserver) {
  13037. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13038. }
  13039. this._onKeyboardObserver = null;
  13040. this._onCanvasBlurObserver = null;
  13041. }
  13042. this._keys = [];
  13043. };
  13044. /**
  13045. * Gets the class name of the current intput.
  13046. * @returns the class name
  13047. */
  13048. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13049. return "FlyCameraKeyboardInput";
  13050. };
  13051. /** @hidden */
  13052. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13053. this._keys = [];
  13054. };
  13055. /**
  13056. * Get the friendly name associated with the input class.
  13057. * @returns the input friendly name
  13058. */
  13059. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13060. return "keyboard";
  13061. };
  13062. /**
  13063. * Update the current camera state depending on the inputs that have been used this frame.
  13064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13065. */
  13066. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13067. if (this._onKeyboardObserver) {
  13068. var camera = this.camera;
  13069. // Keyboard
  13070. for (var index = 0; index < this._keys.length; index++) {
  13071. var keyCode = this._keys[index];
  13072. var speed = camera._computeLocalCameraSpeed();
  13073. if (this.keysForward.indexOf(keyCode) !== -1) {
  13074. camera._localDirection.copyFromFloats(0, 0, speed);
  13075. }
  13076. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13077. camera._localDirection.copyFromFloats(0, 0, -speed);
  13078. }
  13079. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13080. camera._localDirection.copyFromFloats(0, speed, 0);
  13081. }
  13082. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13083. camera._localDirection.copyFromFloats(0, -speed, 0);
  13084. }
  13085. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13086. camera._localDirection.copyFromFloats(speed, 0, 0);
  13087. }
  13088. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13089. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13090. }
  13091. if (camera.getScene().useRightHandedSystem) {
  13092. camera._localDirection.z *= -1;
  13093. }
  13094. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13095. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13096. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13097. }
  13098. }
  13099. };
  13100. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13101. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13102. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13103. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13105. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13108. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13111. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13114. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13117. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13118. return FlyCameraKeyboardInput;
  13119. }());
  13120. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13121. /***/ }),
  13122. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13123. /*!***********************************************!*\
  13124. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13125. \***********************************************/
  13126. /*! exports provided: FlyCameraMouseInput */
  13127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13128. "use strict";
  13129. __webpack_require__.r(__webpack_exports__);
  13130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13132. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13133. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13134. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13136. /**
  13137. * Listen to mouse events to control the camera.
  13138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13139. */
  13140. var FlyCameraMouseInput = /** @class */ (function () {
  13141. /**
  13142. * Listen to mouse events to control the camera.
  13143. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13145. */
  13146. function FlyCameraMouseInput(touchEnabled) {
  13147. if (touchEnabled === void 0) { touchEnabled = true; }
  13148. /**
  13149. * Defines the buttons associated with the input to handle camera rotation.
  13150. */
  13151. this.buttons = [0, 1, 2];
  13152. /**
  13153. * Assign buttons for Yaw control.
  13154. */
  13155. this.buttonsYaw = [-1, 0, 1];
  13156. /**
  13157. * Assign buttons for Pitch control.
  13158. */
  13159. this.buttonsPitch = [-1, 0, 1];
  13160. /**
  13161. * Assign buttons for Roll control.
  13162. */
  13163. this.buttonsRoll = [2];
  13164. /**
  13165. * Detect if any button is being pressed while mouse is moved.
  13166. * -1 = Mouse locked.
  13167. * 0 = Left button.
  13168. * 1 = Middle Button.
  13169. * 2 = Right Button.
  13170. */
  13171. this.activeButton = -1;
  13172. /**
  13173. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13174. * Higher values reduce its sensitivity.
  13175. */
  13176. this.angularSensibility = 1000.0;
  13177. this.previousPosition = null;
  13178. }
  13179. /**
  13180. * Attach the mouse control to the HTML DOM element.
  13181. * @param element Defines the element that listens to the input events.
  13182. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13183. */
  13184. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13185. var _this = this;
  13186. this.element = element;
  13187. this.noPreventDefault = noPreventDefault;
  13188. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13189. _this._pointerInput(p, s);
  13190. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13191. // Correct Roll by rate, if enabled.
  13192. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13193. if (_this.camera.rollCorrect) {
  13194. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13195. }
  13196. });
  13197. // Helper function to keep 'this'.
  13198. this._mousemoveCallback = function (e) {
  13199. _this._onMouseMove(e);
  13200. };
  13201. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13202. };
  13203. /**
  13204. * Detach the current controls from the specified dom element.
  13205. * @param element Defines the element to stop listening the inputs from
  13206. */
  13207. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13208. if (this._observer && element) {
  13209. this.camera.getScene().onPointerObservable.remove(this._observer);
  13210. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13211. if (this._mousemoveCallback) {
  13212. element.removeEventListener("mousemove", this._mousemoveCallback);
  13213. }
  13214. this._observer = null;
  13215. this._rollObserver = null;
  13216. this.previousPosition = null;
  13217. this.noPreventDefault = undefined;
  13218. }
  13219. };
  13220. /**
  13221. * Gets the class name of the current input.
  13222. * @returns the class name.
  13223. */
  13224. FlyCameraMouseInput.prototype.getClassName = function () {
  13225. return "FlyCameraMouseInput";
  13226. };
  13227. /**
  13228. * Get the friendly name associated with the input class.
  13229. * @returns the input's friendly name.
  13230. */
  13231. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13232. return "mouse";
  13233. };
  13234. // Track mouse movement, when the pointer is not locked.
  13235. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13236. var e = p.event;
  13237. var camera = this.camera;
  13238. var engine = camera.getEngine();
  13239. if (engine.isInVRExclusivePointerMode) {
  13240. return;
  13241. }
  13242. if (!this.touchEnabled && e.pointerType === "touch") {
  13243. return;
  13244. }
  13245. // Mouse is moved but an unknown mouse button is pressed.
  13246. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13247. return;
  13248. }
  13249. var srcElement = (e.srcElement || e.target);
  13250. // Mouse down.
  13251. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13252. try {
  13253. srcElement.setPointerCapture(e.pointerId);
  13254. }
  13255. catch (e) {
  13256. // Nothing to do with the error. Execution continues.
  13257. }
  13258. this.previousPosition = {
  13259. x: e.clientX,
  13260. y: e.clientY
  13261. };
  13262. this.activeButton = e.button;
  13263. if (!this.noPreventDefault) {
  13264. e.preventDefault();
  13265. this.element.focus();
  13266. }
  13267. }
  13268. else
  13269. // Mouse up.
  13270. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13271. try {
  13272. srcElement.releasePointerCapture(e.pointerId);
  13273. }
  13274. catch (e) {
  13275. // Nothing to do with the error. Execution continues.
  13276. }
  13277. this.activeButton = -1;
  13278. this.previousPosition = null;
  13279. if (!this.noPreventDefault) {
  13280. e.preventDefault();
  13281. }
  13282. }
  13283. else
  13284. // Mouse move.
  13285. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13286. if (!this.previousPosition || engine.isPointerLock) {
  13287. return;
  13288. }
  13289. var offsetX = e.clientX - this.previousPosition.x;
  13290. var offsetY = e.clientY - this.previousPosition.y;
  13291. this.rotateCamera(offsetX, offsetY);
  13292. this.previousPosition = {
  13293. x: e.clientX,
  13294. y: e.clientY
  13295. };
  13296. if (!this.noPreventDefault) {
  13297. e.preventDefault();
  13298. }
  13299. }
  13300. };
  13301. // Track mouse movement, when pointer is locked.
  13302. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13303. var camera = this.camera;
  13304. var engine = camera.getEngine();
  13305. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13306. return;
  13307. }
  13308. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13309. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13310. this.rotateCamera(offsetX, offsetY);
  13311. this.previousPosition = null;
  13312. if (!this.noPreventDefault) {
  13313. e.preventDefault();
  13314. }
  13315. };
  13316. /**
  13317. * Rotate camera by mouse offset.
  13318. */
  13319. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13320. var _this = this;
  13321. var camera = this.camera;
  13322. var scene = this.camera.getScene();
  13323. if (scene.useRightHandedSystem) {
  13324. offsetX *= -1;
  13325. }
  13326. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13327. offsetX *= -1;
  13328. }
  13329. var x = offsetX / this.angularSensibility;
  13330. var y = offsetY / this.angularSensibility;
  13331. // Initialize to current rotation.
  13332. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13333. var rotationChange;
  13334. // Pitch.
  13335. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13336. // Apply change in Radians to vector Angle.
  13337. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13338. // Apply Pitch to quaternion.
  13339. currentRotation.multiplyInPlace(rotationChange);
  13340. }
  13341. // Yaw.
  13342. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13343. // Apply change in Radians to vector Angle.
  13344. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13345. // Apply Yaw to quaternion.
  13346. currentRotation.multiplyInPlace(rotationChange);
  13347. // Add Roll, if banked turning is enabled, within Roll limit.
  13348. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13349. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13350. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13351. // Apply change in Radians to vector Angle.
  13352. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13353. // Apply Yaw to quaternion.
  13354. currentRotation.multiplyInPlace(rotationChange);
  13355. }
  13356. }
  13357. // Roll.
  13358. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13359. // Apply change in Radians to vector Angle.
  13360. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13361. // Track Rolling.
  13362. camera._trackRoll -= x;
  13363. // Apply Pitch to quaternion.
  13364. currentRotation.multiplyInPlace(rotationChange);
  13365. }
  13366. // Apply rotationQuaternion to Euler camera.rotation.
  13367. currentRotation.toEulerAnglesToRef(camera.rotation);
  13368. };
  13369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13371. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13374. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13375. return FlyCameraMouseInput;
  13376. }());
  13377. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13378. /***/ }),
  13379. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13380. /*!*********************************************************!*\
  13381. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13382. \*********************************************************/
  13383. /*! exports provided: FollowCameraKeyboardMoveInput */
  13384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13385. "use strict";
  13386. __webpack_require__.r(__webpack_exports__);
  13387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13388. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13389. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13390. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13391. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13392. /**
  13393. * Manage the keyboard inputs to control the movement of a follow camera.
  13394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13395. */
  13396. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13397. function FollowCameraKeyboardMoveInput() {
  13398. /**
  13399. * Defines the list of key codes associated with the up action (increase heightOffset)
  13400. */
  13401. this.keysHeightOffsetIncr = [38];
  13402. /**
  13403. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13404. */
  13405. this.keysHeightOffsetDecr = [40];
  13406. /**
  13407. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13408. */
  13409. this.keysHeightOffsetModifierAlt = false;
  13410. /**
  13411. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13412. */
  13413. this.keysHeightOffsetModifierCtrl = false;
  13414. /**
  13415. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13416. */
  13417. this.keysHeightOffsetModifierShift = false;
  13418. /**
  13419. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13420. */
  13421. this.keysRotationOffsetIncr = [37];
  13422. /**
  13423. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13424. */
  13425. this.keysRotationOffsetDecr = [39];
  13426. /**
  13427. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13428. */
  13429. this.keysRotationOffsetModifierAlt = false;
  13430. /**
  13431. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13432. */
  13433. this.keysRotationOffsetModifierCtrl = false;
  13434. /**
  13435. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13436. */
  13437. this.keysRotationOffsetModifierShift = false;
  13438. /**
  13439. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13440. */
  13441. this.keysRadiusIncr = [40];
  13442. /**
  13443. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13444. */
  13445. this.keysRadiusDecr = [38];
  13446. /**
  13447. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13448. */
  13449. this.keysRadiusModifierAlt = true;
  13450. /**
  13451. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13452. */
  13453. this.keysRadiusModifierCtrl = false;
  13454. /**
  13455. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13456. */
  13457. this.keysRadiusModifierShift = false;
  13458. /**
  13459. * Defines the rate of change of heightOffset.
  13460. */
  13461. this.heightSensibility = 1;
  13462. /**
  13463. * Defines the rate of change of rotationOffset.
  13464. */
  13465. this.rotationSensibility = 1;
  13466. /**
  13467. * Defines the rate of change of radius.
  13468. */
  13469. this.radiusSensibility = 1;
  13470. this._keys = new Array();
  13471. }
  13472. /**
  13473. * Attach the input controls to a specific dom element to get the input from.
  13474. * @param element Defines the element the controls should be listened from
  13475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13476. */
  13477. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13478. var _this = this;
  13479. if (this._onCanvasBlurObserver) {
  13480. return;
  13481. }
  13482. this._scene = this.camera.getScene();
  13483. this._engine = this._scene.getEngine();
  13484. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13485. _this._keys = [];
  13486. });
  13487. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13488. var evt = info.event;
  13489. if (!evt.metaKey) {
  13490. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13491. _this._ctrlPressed = evt.ctrlKey;
  13492. _this._altPressed = evt.altKey;
  13493. _this._shiftPressed = evt.shiftKey;
  13494. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13495. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13496. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13497. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13498. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13499. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13500. var index = _this._keys.indexOf(evt.keyCode);
  13501. if (index === -1) {
  13502. _this._keys.push(evt.keyCode);
  13503. }
  13504. if (evt.preventDefault) {
  13505. if (!noPreventDefault) {
  13506. evt.preventDefault();
  13507. }
  13508. }
  13509. }
  13510. }
  13511. else {
  13512. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13513. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13514. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13515. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13516. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13517. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13518. var index = _this._keys.indexOf(evt.keyCode);
  13519. if (index >= 0) {
  13520. _this._keys.splice(index, 1);
  13521. }
  13522. if (evt.preventDefault) {
  13523. if (!noPreventDefault) {
  13524. evt.preventDefault();
  13525. }
  13526. }
  13527. }
  13528. }
  13529. }
  13530. });
  13531. };
  13532. /**
  13533. * Detach the current controls from the specified dom element.
  13534. * @param element Defines the element to stop listening the inputs from
  13535. */
  13536. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13537. if (this._scene) {
  13538. if (this._onKeyboardObserver) {
  13539. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13540. }
  13541. if (this._onCanvasBlurObserver) {
  13542. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13543. }
  13544. this._onKeyboardObserver = null;
  13545. this._onCanvasBlurObserver = null;
  13546. }
  13547. this._keys = [];
  13548. };
  13549. /**
  13550. * Update the current camera state depending on the inputs that have been used this frame.
  13551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13552. */
  13553. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13554. var _this = this;
  13555. if (this._onKeyboardObserver) {
  13556. this._keys.forEach(function (keyCode) {
  13557. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13558. _this._modifierHeightOffset()) {
  13559. _this.camera.heightOffset += _this.heightSensibility;
  13560. }
  13561. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13562. _this._modifierHeightOffset()) {
  13563. _this.camera.heightOffset -= _this.heightSensibility;
  13564. }
  13565. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13566. _this._modifierRotationOffset()) {
  13567. _this.camera.rotationOffset += _this.rotationSensibility;
  13568. _this.camera.rotationOffset %= 360;
  13569. }
  13570. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13571. _this._modifierRotationOffset()) {
  13572. _this.camera.rotationOffset -= _this.rotationSensibility;
  13573. _this.camera.rotationOffset %= 360;
  13574. }
  13575. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13576. _this._modifierRadius()) {
  13577. _this.camera.radius += _this.radiusSensibility;
  13578. }
  13579. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13580. _this._modifierRadius()) {
  13581. _this.camera.radius -= _this.radiusSensibility;
  13582. }
  13583. });
  13584. }
  13585. };
  13586. /**
  13587. * Gets the class name of the current input.
  13588. * @returns the class name
  13589. */
  13590. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13591. return "FollowCameraKeyboardMoveInput";
  13592. };
  13593. /**
  13594. * Get the friendly name associated with the input class.
  13595. * @returns the input friendly name
  13596. */
  13597. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13598. return "keyboard";
  13599. };
  13600. /**
  13601. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13602. * allow modification of the heightOffset value.
  13603. */
  13604. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13605. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13606. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13607. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13608. };
  13609. /**
  13610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13611. * allow modification of the rotationOffset value.
  13612. */
  13613. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13614. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13615. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13616. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13617. };
  13618. /**
  13619. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13620. * allow modification of the radius value.
  13621. */
  13622. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13623. return (this.keysRadiusModifierAlt === this._altPressed &&
  13624. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13625. this.keysRadiusModifierShift === this._shiftPressed);
  13626. };
  13627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13629. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13632. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13635. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13638. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13641. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13644. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13647. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13650. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13653. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13656. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13659. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13662. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13665. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13668. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13671. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13674. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13677. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13680. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13681. return FollowCameraKeyboardMoveInput;
  13682. }());
  13683. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13684. /***/ }),
  13685. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13686. /*!*******************************************************!*\
  13687. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13688. \*******************************************************/
  13689. /*! exports provided: FollowCameraMouseWheelInput */
  13690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13691. "use strict";
  13692. __webpack_require__.r(__webpack_exports__);
  13693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13694. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13695. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13696. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13697. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13698. /**
  13699. * Manage the mouse wheel inputs to control a follow camera.
  13700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13701. */
  13702. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13703. function FollowCameraMouseWheelInput() {
  13704. /**
  13705. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13706. */
  13707. this.axisControlRadius = true;
  13708. /**
  13709. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13710. */
  13711. this.axisControlHeight = false;
  13712. /**
  13713. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13714. */
  13715. this.axisControlRotation = false;
  13716. /**
  13717. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13718. * relation to mouseWheel events.
  13719. */
  13720. this.wheelPrecision = 3.0;
  13721. /**
  13722. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13723. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13724. */
  13725. this.wheelDeltaPercentage = 0;
  13726. }
  13727. /**
  13728. * Attach the input controls to a specific dom element to get the input from.
  13729. * @param element Defines the element the controls should be listened from
  13730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13731. */
  13732. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13733. var _this = this;
  13734. this._wheel = function (p, s) {
  13735. // sanity check - this should be a PointerWheel event.
  13736. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13737. return;
  13738. }
  13739. var event = p.event;
  13740. var delta = 0;
  13741. // Chrome, Safari: event.deltaY
  13742. // IE: event.wheelDelta
  13743. // Firefox: event.detail (inverted)
  13744. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13745. if (_this.wheelDeltaPercentage) {
  13746. console.assert((_this.axisControlRadius +
  13747. _this.axisControlHeight +
  13748. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13749. "controlls ONE axis. " +
  13750. "Currently enabled: " +
  13751. "axisControlRadius: " + _this.axisControlRadius +
  13752. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13753. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13754. if (_this.axisControlRadius) {
  13755. delta =
  13756. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13757. _this.camera.radius;
  13758. }
  13759. else if (_this.axisControlHeight) {
  13760. delta =
  13761. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13762. _this.camera.heightOffset;
  13763. }
  13764. else if (_this.axisControlRotation) {
  13765. delta =
  13766. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13767. _this.camera.rotationOffset;
  13768. }
  13769. }
  13770. else {
  13771. delta = wheelDelta * _this.wheelPrecision;
  13772. }
  13773. if (delta) {
  13774. if (_this.axisControlRadius) {
  13775. _this.camera.radius += delta;
  13776. }
  13777. else if (_this.axisControlHeight) {
  13778. _this.camera.heightOffset -= delta;
  13779. }
  13780. else if (_this.axisControlRotation) {
  13781. _this.camera.rotationOffset -= delta;
  13782. }
  13783. }
  13784. if (event.preventDefault) {
  13785. if (!noPreventDefault) {
  13786. event.preventDefault();
  13787. }
  13788. }
  13789. };
  13790. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13791. };
  13792. /**
  13793. * Detach the current controls from the specified dom element.
  13794. * @param element Defines the element to stop listening the inputs from
  13795. */
  13796. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13797. if (this._observer && element) {
  13798. this.camera.getScene().onPointerObservable.remove(this._observer);
  13799. this._observer = null;
  13800. this._wheel = null;
  13801. }
  13802. };
  13803. /**
  13804. * Gets the class name of the current intput.
  13805. * @returns the class name
  13806. */
  13807. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13808. return "ArcRotateCameraMouseWheelInput";
  13809. };
  13810. /**
  13811. * Get the friendly name associated with the input class.
  13812. * @returns the input friendly name
  13813. */
  13814. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13815. return "mousewheel";
  13816. };
  13817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13819. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13822. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13825. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13828. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13831. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13832. return FollowCameraMouseWheelInput;
  13833. }());
  13834. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13835. /***/ }),
  13836. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13837. /*!************************************************************!*\
  13838. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13839. \************************************************************/
  13840. /*! exports provided: FreeCameraDeviceOrientationInput */
  13841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13842. "use strict";
  13843. __webpack_require__.r(__webpack_exports__);
  13844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13845. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13846. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13847. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13848. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13849. /**
  13850. * Add orientation input support to the input manager.
  13851. * @returns the current input manager
  13852. */
  13853. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13854. this.add(new FreeCameraDeviceOrientationInput());
  13855. return this;
  13856. };
  13857. /**
  13858. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13859. * Screen rotation is taken into account.
  13860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13861. */
  13862. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13863. /**
  13864. * Instantiates a new input
  13865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13866. */
  13867. function FreeCameraDeviceOrientationInput() {
  13868. var _this = this;
  13869. this._screenOrientationAngle = 0;
  13870. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13871. this._alpha = 0;
  13872. this._beta = 0;
  13873. this._gamma = 0;
  13874. this._orientationChanged = function () {
  13875. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13876. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13877. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13878. };
  13879. this._deviceOrientation = function (evt) {
  13880. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13881. _this._beta = evt.beta !== null ? evt.beta : 0;
  13882. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13883. };
  13884. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13885. this._orientationChanged();
  13886. }
  13887. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13888. /**
  13889. * Define the camera controlled by the input.
  13890. */
  13891. get: function () {
  13892. return this._camera;
  13893. },
  13894. set: function (camera) {
  13895. this._camera = camera;
  13896. if (this._camera != null && !this._camera.rotationQuaternion) {
  13897. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13898. }
  13899. },
  13900. enumerable: true,
  13901. configurable: true
  13902. });
  13903. /**
  13904. * Attach the input controls to a specific dom element to get the input from.
  13905. * @param element Defines the element the controls should be listened from
  13906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13907. */
  13908. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13909. window.addEventListener("orientationchange", this._orientationChanged);
  13910. window.addEventListener("deviceorientation", this._deviceOrientation);
  13911. //In certain cases, the attach control is called AFTER orientation was changed,
  13912. //So this is needed.
  13913. this._orientationChanged();
  13914. };
  13915. /**
  13916. * Detach the current controls from the specified dom element.
  13917. * @param element Defines the element to stop listening the inputs from
  13918. */
  13919. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13920. window.removeEventListener("orientationchange", this._orientationChanged);
  13921. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13922. };
  13923. /**
  13924. * Update the current camera state depending on the inputs that have been used this frame.
  13925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13926. */
  13927. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13928. //if no device orientation provided, don't update the rotation.
  13929. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13930. if (!this._alpha) {
  13931. return;
  13932. }
  13933. _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);
  13934. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13935. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13936. //Mirror on XY Plane
  13937. this._camera.rotationQuaternion.z *= -1;
  13938. this._camera.rotationQuaternion.w *= -1;
  13939. };
  13940. /**
  13941. * Gets the class name of the current intput.
  13942. * @returns the class name
  13943. */
  13944. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13945. return "FreeCameraDeviceOrientationInput";
  13946. };
  13947. /**
  13948. * Get the friendly name associated with the input class.
  13949. * @returns the input friendly name
  13950. */
  13951. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13952. return "deviceOrientation";
  13953. };
  13954. return FreeCameraDeviceOrientationInput;
  13955. }());
  13956. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13957. /***/ }),
  13958. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13959. /*!**************************************************!*\
  13960. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13961. \**************************************************/
  13962. /*! exports provided: FreeCameraGamepadInput */
  13963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13964. "use strict";
  13965. __webpack_require__.r(__webpack_exports__);
  13966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13967. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13968. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13969. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13970. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13971. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13972. /**
  13973. * Manage the gamepad inputs to control a free camera.
  13974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13975. */
  13976. var FreeCameraGamepadInput = /** @class */ (function () {
  13977. function FreeCameraGamepadInput() {
  13978. /**
  13979. * Defines the gamepad rotation sensiblity.
  13980. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13981. */
  13982. this.gamepadAngularSensibility = 200;
  13983. /**
  13984. * Defines the gamepad move sensiblity.
  13985. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13986. */
  13987. this.gamepadMoveSensibility = 40;
  13988. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13989. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13990. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13991. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  13992. }
  13993. /**
  13994. * Attach the input controls to a specific dom element to get the input from.
  13995. * @param element Defines the element the controls should be listened from
  13996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13997. */
  13998. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  13999. var _this = this;
  14000. var manager = this.camera.getScene().gamepadManager;
  14001. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14002. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14003. // prioritize XBOX gamepads.
  14004. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14005. _this.gamepad = gamepad;
  14006. }
  14007. }
  14008. });
  14009. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14010. if (_this.gamepad === gamepad) {
  14011. _this.gamepad = null;
  14012. }
  14013. });
  14014. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14015. };
  14016. /**
  14017. * Detach the current controls from the specified dom element.
  14018. * @param element Defines the element to stop listening the inputs from
  14019. */
  14020. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14021. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14022. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14023. this.gamepad = null;
  14024. };
  14025. /**
  14026. * Update the current camera state depending on the inputs that have been used this frame.
  14027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14028. */
  14029. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14030. if (this.gamepad && this.gamepad.leftStick) {
  14031. var camera = this.camera;
  14032. var LSValues = this.gamepad.leftStick;
  14033. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14034. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14035. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14036. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14037. var RSValues = this.gamepad.rightStick;
  14038. if (RSValues) {
  14039. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14040. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14041. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14042. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14043. }
  14044. else {
  14045. RSValues = { x: 0, y: 0 };
  14046. }
  14047. if (!camera.rotationQuaternion) {
  14048. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14049. }
  14050. else {
  14051. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14052. }
  14053. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14054. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14055. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14056. camera.cameraDirection.addInPlace(this._deltaTransform);
  14057. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14058. camera.cameraRotation.addInPlace(this._vector2);
  14059. }
  14060. };
  14061. /**
  14062. * Gets the class name of the current intput.
  14063. * @returns the class name
  14064. */
  14065. FreeCameraGamepadInput.prototype.getClassName = function () {
  14066. return "FreeCameraGamepadInput";
  14067. };
  14068. /**
  14069. * Get the friendly name associated with the input class.
  14070. * @returns the input friendly name
  14071. */
  14072. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14073. return "gamepad";
  14074. };
  14075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14077. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14080. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14081. return FreeCameraGamepadInput;
  14082. }());
  14083. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14084. /***/ }),
  14085. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14086. /*!*******************************************************!*\
  14087. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14088. \*******************************************************/
  14089. /*! exports provided: FreeCameraKeyboardMoveInput */
  14090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14091. "use strict";
  14092. __webpack_require__.r(__webpack_exports__);
  14093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14095. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14096. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14097. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14099. /**
  14100. * Manage the keyboard inputs to control the movement of a free camera.
  14101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14102. */
  14103. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14104. function FreeCameraKeyboardMoveInput() {
  14105. /**
  14106. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14107. */
  14108. this.keysUp = [38];
  14109. /**
  14110. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14111. */
  14112. this.keysDown = [40];
  14113. /**
  14114. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14115. */
  14116. this.keysLeft = [37];
  14117. /**
  14118. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14119. */
  14120. this.keysRight = [39];
  14121. this._keys = new Array();
  14122. }
  14123. /**
  14124. * Attach the input controls to a specific dom element to get the input from.
  14125. * @param element Defines the element the controls should be listened from
  14126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14127. */
  14128. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14129. var _this = this;
  14130. if (this._onCanvasBlurObserver) {
  14131. return;
  14132. }
  14133. this._scene = this.camera.getScene();
  14134. this._engine = this._scene.getEngine();
  14135. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14136. _this._keys = [];
  14137. });
  14138. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14139. var evt = info.event;
  14140. if (!evt.metaKey) {
  14141. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14142. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14143. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14144. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14145. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14146. var index = _this._keys.indexOf(evt.keyCode);
  14147. if (index === -1) {
  14148. _this._keys.push(evt.keyCode);
  14149. }
  14150. if (!noPreventDefault) {
  14151. evt.preventDefault();
  14152. }
  14153. }
  14154. }
  14155. else {
  14156. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14157. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14158. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14159. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14160. var index = _this._keys.indexOf(evt.keyCode);
  14161. if (index >= 0) {
  14162. _this._keys.splice(index, 1);
  14163. }
  14164. if (!noPreventDefault) {
  14165. evt.preventDefault();
  14166. }
  14167. }
  14168. }
  14169. }
  14170. });
  14171. };
  14172. /**
  14173. * Detach the current controls from the specified dom element.
  14174. * @param element Defines the element to stop listening the inputs from
  14175. */
  14176. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14177. if (this._scene) {
  14178. if (this._onKeyboardObserver) {
  14179. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14180. }
  14181. if (this._onCanvasBlurObserver) {
  14182. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14183. }
  14184. this._onKeyboardObserver = null;
  14185. this._onCanvasBlurObserver = null;
  14186. }
  14187. this._keys = [];
  14188. };
  14189. /**
  14190. * Update the current camera state depending on the inputs that have been used this frame.
  14191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14192. */
  14193. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14194. if (this._onKeyboardObserver) {
  14195. var camera = this.camera;
  14196. // Keyboard
  14197. for (var index = 0; index < this._keys.length; index++) {
  14198. var keyCode = this._keys[index];
  14199. var speed = camera._computeLocalCameraSpeed();
  14200. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14201. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14202. }
  14203. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14204. camera._localDirection.copyFromFloats(0, 0, speed);
  14205. }
  14206. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14207. camera._localDirection.copyFromFloats(speed, 0, 0);
  14208. }
  14209. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14210. camera._localDirection.copyFromFloats(0, 0, -speed);
  14211. }
  14212. if (camera.getScene().useRightHandedSystem) {
  14213. camera._localDirection.z *= -1;
  14214. }
  14215. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14216. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14217. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14218. }
  14219. }
  14220. };
  14221. /**
  14222. * Gets the class name of the current intput.
  14223. * @returns the class name
  14224. */
  14225. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14226. return "FreeCameraKeyboardMoveInput";
  14227. };
  14228. /** @hidden */
  14229. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14230. this._keys = [];
  14231. };
  14232. /**
  14233. * Get the friendly name associated with the input class.
  14234. * @returns the input friendly name
  14235. */
  14236. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14237. return "keyboard";
  14238. };
  14239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14241. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14244. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14247. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14250. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14251. return FreeCameraKeyboardMoveInput;
  14252. }());
  14253. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14254. /***/ }),
  14255. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14256. /*!************************************************!*\
  14257. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14258. \************************************************/
  14259. /*! exports provided: FreeCameraMouseInput */
  14260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14261. "use strict";
  14262. __webpack_require__.r(__webpack_exports__);
  14263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14264. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14265. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14266. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14267. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14268. /**
  14269. * Manage the mouse inputs to control the movement of a free camera.
  14270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14271. */
  14272. var FreeCameraMouseInput = /** @class */ (function () {
  14273. /**
  14274. * Manage the mouse inputs to control the movement of a free camera.
  14275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14276. * @param touchEnabled Defines if touch is enabled or not
  14277. */
  14278. function FreeCameraMouseInput(
  14279. /**
  14280. * Define if touch is enabled in the mouse input
  14281. */
  14282. touchEnabled) {
  14283. if (touchEnabled === void 0) { touchEnabled = true; }
  14284. this.touchEnabled = touchEnabled;
  14285. /**
  14286. * Defines the buttons associated with the input to handle camera move.
  14287. */
  14288. this.buttons = [0, 1, 2];
  14289. /**
  14290. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14291. */
  14292. this.angularSensibility = 2000.0;
  14293. this.previousPosition = null;
  14294. }
  14295. /**
  14296. * Attach the input controls to a specific dom element to get the input from.
  14297. * @param element Defines the element the controls should be listened from
  14298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14299. */
  14300. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14301. var _this = this;
  14302. var engine = this.camera.getEngine();
  14303. if (!this._pointerInput) {
  14304. this._pointerInput = function (p) {
  14305. var evt = p.event;
  14306. if (engine.isInVRExclusivePointerMode) {
  14307. return;
  14308. }
  14309. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14310. return;
  14311. }
  14312. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14313. return;
  14314. }
  14315. var srcElement = (evt.srcElement || evt.target);
  14316. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14317. try {
  14318. srcElement.setPointerCapture(evt.pointerId);
  14319. }
  14320. catch (e) {
  14321. //Nothing to do with the error. Execution will continue.
  14322. }
  14323. _this.previousPosition = {
  14324. x: evt.clientX,
  14325. y: evt.clientY
  14326. };
  14327. if (!noPreventDefault) {
  14328. evt.preventDefault();
  14329. element.focus();
  14330. }
  14331. }
  14332. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14333. try {
  14334. srcElement.releasePointerCapture(evt.pointerId);
  14335. }
  14336. catch (e) {
  14337. //Nothing to do with the error.
  14338. }
  14339. _this.previousPosition = null;
  14340. if (!noPreventDefault) {
  14341. evt.preventDefault();
  14342. }
  14343. }
  14344. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14345. if (!_this.previousPosition || engine.isPointerLock) {
  14346. return;
  14347. }
  14348. var offsetX = evt.clientX - _this.previousPosition.x;
  14349. if (_this.camera.getScene().useRightHandedSystem) {
  14350. offsetX *= -1;
  14351. }
  14352. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14353. offsetX *= -1;
  14354. }
  14355. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14356. var offsetY = evt.clientY - _this.previousPosition.y;
  14357. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14358. _this.previousPosition = {
  14359. x: evt.clientX,
  14360. y: evt.clientY
  14361. };
  14362. if (!noPreventDefault) {
  14363. evt.preventDefault();
  14364. }
  14365. }
  14366. };
  14367. }
  14368. this._onMouseMove = function (evt) {
  14369. if (!engine.isPointerLock) {
  14370. return;
  14371. }
  14372. if (engine.isInVRExclusivePointerMode) {
  14373. return;
  14374. }
  14375. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14376. if (_this.camera.getScene().useRightHandedSystem) {
  14377. offsetX *= -1;
  14378. }
  14379. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14380. offsetX *= -1;
  14381. }
  14382. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14383. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14384. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14385. _this.previousPosition = null;
  14386. if (!noPreventDefault) {
  14387. evt.preventDefault();
  14388. }
  14389. };
  14390. 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);
  14391. element.addEventListener("mousemove", this._onMouseMove, false);
  14392. };
  14393. /**
  14394. * Detach the current controls from the specified dom element.
  14395. * @param element Defines the element to stop listening the inputs from
  14396. */
  14397. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14398. if (this._observer && element) {
  14399. this.camera.getScene().onPointerObservable.remove(this._observer);
  14400. if (this._onMouseMove) {
  14401. element.removeEventListener("mousemove", this._onMouseMove);
  14402. }
  14403. this._observer = null;
  14404. this._onMouseMove = null;
  14405. this.previousPosition = null;
  14406. }
  14407. };
  14408. /**
  14409. * Gets the class name of the current intput.
  14410. * @returns the class name
  14411. */
  14412. FreeCameraMouseInput.prototype.getClassName = function () {
  14413. return "FreeCameraMouseInput";
  14414. };
  14415. /**
  14416. * Get the friendly name associated with the input class.
  14417. * @returns the input friendly name
  14418. */
  14419. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14420. return "mouse";
  14421. };
  14422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14424. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14427. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14428. return FreeCameraMouseInput;
  14429. }());
  14430. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14431. /***/ }),
  14432. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14433. /*!************************************************!*\
  14434. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14435. \************************************************/
  14436. /*! exports provided: FreeCameraTouchInput */
  14437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14438. "use strict";
  14439. __webpack_require__.r(__webpack_exports__);
  14440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14441. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14442. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14443. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14444. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14446. /**
  14447. * Manage the touch inputs to control the movement of a free camera.
  14448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14449. */
  14450. var FreeCameraTouchInput = /** @class */ (function () {
  14451. function FreeCameraTouchInput() {
  14452. /**
  14453. * Defines the touch sensibility for rotation.
  14454. * The higher the faster.
  14455. */
  14456. this.touchAngularSensibility = 200000.0;
  14457. /**
  14458. * Defines the touch sensibility for move.
  14459. * The higher the faster.
  14460. */
  14461. this.touchMoveSensibility = 250.0;
  14462. this._offsetX = null;
  14463. this._offsetY = null;
  14464. this._pointerPressed = new Array();
  14465. }
  14466. /**
  14467. * Attach the input controls to a specific dom element to get the input from.
  14468. * @param element Defines the element the controls should be listened from
  14469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14470. */
  14471. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14472. var _this = this;
  14473. var previousPosition = null;
  14474. if (this._pointerInput === undefined) {
  14475. this._onLostFocus = function () {
  14476. _this._offsetX = null;
  14477. _this._offsetY = null;
  14478. };
  14479. this._pointerInput = function (p) {
  14480. var evt = p.event;
  14481. if (evt.pointerType === "mouse") {
  14482. return;
  14483. }
  14484. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14485. if (!noPreventDefault) {
  14486. evt.preventDefault();
  14487. }
  14488. _this._pointerPressed.push(evt.pointerId);
  14489. if (_this._pointerPressed.length !== 1) {
  14490. return;
  14491. }
  14492. previousPosition = {
  14493. x: evt.clientX,
  14494. y: evt.clientY
  14495. };
  14496. }
  14497. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14498. if (!noPreventDefault) {
  14499. evt.preventDefault();
  14500. }
  14501. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14502. if (index === -1) {
  14503. return;
  14504. }
  14505. _this._pointerPressed.splice(index, 1);
  14506. if (index != 0) {
  14507. return;
  14508. }
  14509. previousPosition = null;
  14510. _this._offsetX = null;
  14511. _this._offsetY = null;
  14512. }
  14513. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14514. if (!noPreventDefault) {
  14515. evt.preventDefault();
  14516. }
  14517. if (!previousPosition) {
  14518. return;
  14519. }
  14520. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14521. if (index != 0) {
  14522. return;
  14523. }
  14524. _this._offsetX = evt.clientX - previousPosition.x;
  14525. _this._offsetY = -(evt.clientY - previousPosition.y);
  14526. }
  14527. };
  14528. }
  14529. 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);
  14530. if (this._onLostFocus) {
  14531. element.addEventListener("blur", this._onLostFocus);
  14532. }
  14533. };
  14534. /**
  14535. * Detach the current controls from the specified dom element.
  14536. * @param element Defines the element to stop listening the inputs from
  14537. */
  14538. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14539. if (this._pointerInput && element) {
  14540. if (this._observer) {
  14541. this.camera.getScene().onPointerObservable.remove(this._observer);
  14542. this._observer = null;
  14543. }
  14544. if (this._onLostFocus) {
  14545. element.removeEventListener("blur", this._onLostFocus);
  14546. this._onLostFocus = null;
  14547. }
  14548. this._pointerPressed = [];
  14549. this._offsetX = null;
  14550. this._offsetY = null;
  14551. }
  14552. };
  14553. /**
  14554. * Update the current camera state depending on the inputs that have been used this frame.
  14555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14556. */
  14557. FreeCameraTouchInput.prototype.checkInputs = function () {
  14558. if (this._offsetX && this._offsetY) {
  14559. var camera = this.camera;
  14560. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14561. if (this._pointerPressed.length > 1) {
  14562. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14563. }
  14564. else {
  14565. var speed = camera._computeLocalCameraSpeed();
  14566. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14567. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14568. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14569. }
  14570. }
  14571. };
  14572. /**
  14573. * Gets the class name of the current intput.
  14574. * @returns the class name
  14575. */
  14576. FreeCameraTouchInput.prototype.getClassName = function () {
  14577. return "FreeCameraTouchInput";
  14578. };
  14579. /**
  14580. * Get the friendly name associated with the input class.
  14581. * @returns the input friendly name
  14582. */
  14583. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14584. return "touch";
  14585. };
  14586. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14588. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14591. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14592. return FreeCameraTouchInput;
  14593. }());
  14594. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14595. /***/ }),
  14596. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14597. /*!**********************************************************!*\
  14598. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14599. \**********************************************************/
  14600. /*! exports provided: FreeCameraVirtualJoystickInput */
  14601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14602. "use strict";
  14603. __webpack_require__.r(__webpack_exports__);
  14604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14605. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14606. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14607. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14608. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14609. /**
  14610. * Add virtual joystick input support to the input manager.
  14611. * @returns the current input manager
  14612. */
  14613. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14614. this.add(new FreeCameraVirtualJoystickInput());
  14615. return this;
  14616. };
  14617. /**
  14618. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14620. */
  14621. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14622. function FreeCameraVirtualJoystickInput() {
  14623. }
  14624. /**
  14625. * Gets the left stick of the virtual joystick.
  14626. * @returns The virtual Joystick
  14627. */
  14628. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14629. return this._leftjoystick;
  14630. };
  14631. /**
  14632. * Gets the right stick of the virtual joystick.
  14633. * @returns The virtual Joystick
  14634. */
  14635. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14636. return this._rightjoystick;
  14637. };
  14638. /**
  14639. * Update the current camera state depending on the inputs that have been used this frame.
  14640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14641. */
  14642. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14643. if (this._leftjoystick) {
  14644. var camera = this.camera;
  14645. var speed = camera._computeLocalCameraSpeed() * 50;
  14646. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14647. 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);
  14648. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14649. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14650. if (!this._leftjoystick.pressed) {
  14651. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14652. }
  14653. if (!this._rightjoystick.pressed) {
  14654. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14655. }
  14656. }
  14657. };
  14658. /**
  14659. * Attach the input controls to a specific dom element to get the input from.
  14660. * @param element Defines the element the controls should be listened from
  14661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14662. */
  14663. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14664. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14665. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14666. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14667. this._leftjoystick.setJoystickSensibility(0.15);
  14668. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14669. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14670. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14671. this._rightjoystick.reverseUpDown = true;
  14672. this._rightjoystick.setJoystickSensibility(0.05);
  14673. this._rightjoystick.setJoystickColor("yellow");
  14674. };
  14675. /**
  14676. * Detach the current controls from the specified dom element.
  14677. * @param element Defines the element to stop listening the inputs from
  14678. */
  14679. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14680. this._leftjoystick.releaseCanvas();
  14681. this._rightjoystick.releaseCanvas();
  14682. };
  14683. /**
  14684. * Gets the class name of the current intput.
  14685. * @returns the class name
  14686. */
  14687. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14688. return "FreeCameraVirtualJoystickInput";
  14689. };
  14690. /**
  14691. * Get the friendly name associated with the input class.
  14692. * @returns the input friendly name
  14693. */
  14694. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14695. return "virtualJoystick";
  14696. };
  14697. return FreeCameraVirtualJoystickInput;
  14698. }());
  14699. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14700. /***/ }),
  14701. /***/ "./Cameras/Inputs/index.ts":
  14702. /*!*********************************!*\
  14703. !*** ./Cameras/Inputs/index.ts ***!
  14704. \*********************************/
  14705. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14707. "use strict";
  14708. __webpack_require__.r(__webpack_exports__);
  14709. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14711. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14713. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14715. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14717. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14719. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14721. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14723. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14725. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14727. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14729. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14731. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14733. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14735. /***/ }),
  14736. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14737. /*!*********************************************************!*\
  14738. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14739. \*********************************************************/
  14740. /*! no exports provided */
  14741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14742. "use strict";
  14743. __webpack_require__.r(__webpack_exports__);
  14744. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14745. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14746. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14747. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14748. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14749. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14750. };
  14751. /***/ }),
  14752. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14753. /*!*************************************************!*\
  14754. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14755. \*************************************************/
  14756. /*! no exports provided */
  14757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14758. "use strict";
  14759. __webpack_require__.r(__webpack_exports__);
  14760. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14761. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14762. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14763. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14764. 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;
  14765. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14766. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14767. };
  14768. /***/ }),
  14769. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14770. /*!***************************************!*\
  14771. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14772. \***************************************/
  14773. /*! no exports provided */
  14774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14775. "use strict";
  14776. __webpack_require__.r(__webpack_exports__);
  14777. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14779. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14780. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14781. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14782. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14783. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14784. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14785. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14786. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14787. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14788. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14789. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14790. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14791. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14792. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14793. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14794. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14795. if (metrics.compensateDistortion) {
  14796. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14797. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14798. }
  14799. };
  14800. /***/ }),
  14801. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14802. /*!******************************************!*\
  14803. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14804. \******************************************/
  14805. /*! no exports provided */
  14806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14807. "use strict";
  14808. __webpack_require__.r(__webpack_exports__);
  14809. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14810. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14811. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14812. if (rigParams.vrDisplay) {
  14813. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14814. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14815. //Left eye
  14816. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14817. camera._rigCameras[0].setCameraRigParameter("left", true);
  14818. //leaving this for future reference
  14819. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14820. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14821. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14822. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14823. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14824. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14825. camera._rigCameras[0].parent = camera;
  14826. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14827. //Right eye
  14828. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14829. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14830. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14831. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14832. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14833. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14834. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14835. camera._rigCameras[1].parent = camera;
  14836. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14837. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14838. camera._rigCameras[1]._skipRendering = true;
  14839. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14840. }
  14841. }
  14842. };
  14843. /***/ }),
  14844. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14845. /*!*********************************************************!*\
  14846. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14847. \*********************************************************/
  14848. /*! exports provided: AnaglyphArcRotateCamera */
  14849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14850. "use strict";
  14851. __webpack_require__.r(__webpack_exports__);
  14852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14853. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14854. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14855. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14856. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14857. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14858. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14859. // Side effect import to define the stereoscopic mode.
  14860. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14861. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14862. });
  14863. /**
  14864. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14865. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14866. */
  14867. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14869. /**
  14870. * Creates a new AnaglyphArcRotateCamera
  14871. * @param name defines camera name
  14872. * @param alpha defines alpha angle (in radians)
  14873. * @param beta defines beta angle (in radians)
  14874. * @param radius defines radius
  14875. * @param target defines camera target
  14876. * @param interaxialDistance defines distance between each color axis
  14877. * @param scene defines the hosting scene
  14878. */
  14879. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14880. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14881. _this.interaxialDistance = interaxialDistance;
  14882. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14883. return _this;
  14884. }
  14885. /**
  14886. * Gets camera class name
  14887. * @returns AnaglyphArcRotateCamera
  14888. */
  14889. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14890. return "AnaglyphArcRotateCamera";
  14891. };
  14892. return AnaglyphArcRotateCamera;
  14893. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14894. /***/ }),
  14895. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14896. /*!****************************************************!*\
  14897. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14898. \****************************************************/
  14899. /*! exports provided: AnaglyphFreeCamera */
  14900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14901. "use strict";
  14902. __webpack_require__.r(__webpack_exports__);
  14903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14905. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14906. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14907. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14908. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14909. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14910. // Side effect import to define the stereoscopic mode.
  14911. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14912. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14913. });
  14914. /**
  14915. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14916. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14917. */
  14918. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14919. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14920. /**
  14921. * Creates a new AnaglyphFreeCamera
  14922. * @param name defines camera name
  14923. * @param position defines initial position
  14924. * @param interaxialDistance defines distance between each color axis
  14925. * @param scene defines the hosting scene
  14926. */
  14927. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14928. var _this = _super.call(this, name, position, scene) || this;
  14929. _this.interaxialDistance = interaxialDistance;
  14930. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14931. return _this;
  14932. }
  14933. /**
  14934. * Gets camera class name
  14935. * @returns AnaglyphFreeCamera
  14936. */
  14937. AnaglyphFreeCamera.prototype.getClassName = function () {
  14938. return "AnaglyphFreeCamera";
  14939. };
  14940. return AnaglyphFreeCamera;
  14941. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14942. /***/ }),
  14943. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14944. /*!*******************************************************!*\
  14945. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14946. \*******************************************************/
  14947. /*! exports provided: AnaglyphGamepadCamera */
  14948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14949. "use strict";
  14950. __webpack_require__.r(__webpack_exports__);
  14951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14952. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14953. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14954. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14955. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14956. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14957. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14958. // Side effect import to define the stereoscopic mode.
  14959. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14960. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14961. });
  14962. /**
  14963. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14964. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14965. */
  14966. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14967. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14968. /**
  14969. * Creates a new AnaglyphGamepadCamera
  14970. * @param name defines camera name
  14971. * @param position defines initial position
  14972. * @param interaxialDistance defines distance between each color axis
  14973. * @param scene defines the hosting scene
  14974. */
  14975. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14976. var _this = _super.call(this, name, position, scene) || this;
  14977. _this.interaxialDistance = interaxialDistance;
  14978. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14979. return _this;
  14980. }
  14981. /**
  14982. * Gets camera class name
  14983. * @returns AnaglyphGamepadCamera
  14984. */
  14985. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14986. return "AnaglyphGamepadCamera";
  14987. };
  14988. return AnaglyphGamepadCamera;
  14989. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14990. /***/ }),
  14991. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  14992. /*!*********************************************************!*\
  14993. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  14994. \*********************************************************/
  14995. /*! exports provided: AnaglyphUniversalCamera */
  14996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14997. "use strict";
  14998. __webpack_require__.r(__webpack_exports__);
  14999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15001. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15002. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15003. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15004. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15005. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15006. // Side effect import to define the stereoscopic mode.
  15007. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15008. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15009. });
  15010. /**
  15011. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15012. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15013. */
  15014. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15015. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15016. /**
  15017. * Creates a new AnaglyphUniversalCamera
  15018. * @param name defines camera name
  15019. * @param position defines initial position
  15020. * @param interaxialDistance defines distance between each color axis
  15021. * @param scene defines the hosting scene
  15022. */
  15023. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15024. var _this = _super.call(this, name, position, scene) || this;
  15025. _this.interaxialDistance = interaxialDistance;
  15026. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15027. return _this;
  15028. }
  15029. /**
  15030. * Gets camera class name
  15031. * @returns AnaglyphUniversalCamera
  15032. */
  15033. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15034. return "AnaglyphUniversalCamera";
  15035. };
  15036. return AnaglyphUniversalCamera;
  15037. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15038. /***/ }),
  15039. /***/ "./Cameras/Stereoscopic/index.ts":
  15040. /*!***************************************!*\
  15041. !*** ./Cameras/Stereoscopic/index.ts ***!
  15042. \***************************************/
  15043. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15045. "use strict";
  15046. __webpack_require__.r(__webpack_exports__);
  15047. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15049. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15051. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15053. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15055. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15057. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15059. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15061. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15063. /***/ }),
  15064. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15065. /*!*************************************************************!*\
  15066. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15067. \*************************************************************/
  15068. /*! exports provided: StereoscopicArcRotateCamera */
  15069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15070. "use strict";
  15071. __webpack_require__.r(__webpack_exports__);
  15072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15073. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15074. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15075. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15076. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15077. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15078. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15079. // Side effect import to define the stereoscopic mode.
  15080. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15081. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15082. });
  15083. /**
  15084. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15085. * @see http://doc.babylonjs.com/features/cameras
  15086. */
  15087. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15088. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15089. /**
  15090. * Creates a new StereoscopicArcRotateCamera
  15091. * @param name defines camera name
  15092. * @param alpha defines alpha angle (in radians)
  15093. * @param beta defines beta angle (in radians)
  15094. * @param radius defines radius
  15095. * @param target defines camera target
  15096. * @param interaxialDistance defines distance between each color axis
  15097. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15098. * @param scene defines the hosting scene
  15099. */
  15100. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15101. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15102. _this.interaxialDistance = interaxialDistance;
  15103. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15104. _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 });
  15105. return _this;
  15106. }
  15107. /**
  15108. * Gets camera class name
  15109. * @returns StereoscopicArcRotateCamera
  15110. */
  15111. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15112. return "StereoscopicArcRotateCamera";
  15113. };
  15114. return StereoscopicArcRotateCamera;
  15115. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15116. /***/ }),
  15117. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15118. /*!********************************************************!*\
  15119. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15120. \********************************************************/
  15121. /*! exports provided: StereoscopicFreeCamera */
  15122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15123. "use strict";
  15124. __webpack_require__.r(__webpack_exports__);
  15125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15127. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15128. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15129. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15130. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15131. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15132. // Side effect import to define the stereoscopic mode.
  15133. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15134. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15135. });
  15136. /**
  15137. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15138. * @see http://doc.babylonjs.com/features/cameras
  15139. */
  15140. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15142. /**
  15143. * Creates a new StereoscopicFreeCamera
  15144. * @param name defines camera name
  15145. * @param position defines initial position
  15146. * @param interaxialDistance defines distance between each color axis
  15147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15148. * @param scene defines the hosting scene
  15149. */
  15150. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15151. var _this = _super.call(this, name, position, scene) || this;
  15152. _this.interaxialDistance = interaxialDistance;
  15153. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15154. _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 });
  15155. return _this;
  15156. }
  15157. /**
  15158. * Gets camera class name
  15159. * @returns StereoscopicFreeCamera
  15160. */
  15161. StereoscopicFreeCamera.prototype.getClassName = function () {
  15162. return "StereoscopicFreeCamera";
  15163. };
  15164. return StereoscopicFreeCamera;
  15165. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15166. /***/ }),
  15167. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15168. /*!***********************************************************!*\
  15169. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15170. \***********************************************************/
  15171. /*! exports provided: StereoscopicGamepadCamera */
  15172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15173. "use strict";
  15174. __webpack_require__.r(__webpack_exports__);
  15175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15177. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15178. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15179. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15180. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15181. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15182. // Side effect import to define the stereoscopic mode.
  15183. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15184. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15185. });
  15186. /**
  15187. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15188. * @see http://doc.babylonjs.com/features/cameras
  15189. */
  15190. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15191. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15192. /**
  15193. * Creates a new StereoscopicGamepadCamera
  15194. * @param name defines camera name
  15195. * @param position defines initial position
  15196. * @param interaxialDistance defines distance between each color axis
  15197. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15198. * @param scene defines the hosting scene
  15199. */
  15200. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15201. var _this = _super.call(this, name, position, scene) || this;
  15202. _this.interaxialDistance = interaxialDistance;
  15203. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15204. _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 });
  15205. return _this;
  15206. }
  15207. /**
  15208. * Gets camera class name
  15209. * @returns StereoscopicGamepadCamera
  15210. */
  15211. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15212. return "StereoscopicGamepadCamera";
  15213. };
  15214. return StereoscopicGamepadCamera;
  15215. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15216. /***/ }),
  15217. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15218. /*!*************************************************************!*\
  15219. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15220. \*************************************************************/
  15221. /*! exports provided: StereoscopicUniversalCamera */
  15222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15223. "use strict";
  15224. __webpack_require__.r(__webpack_exports__);
  15225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15226. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15227. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15228. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15229. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15230. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15231. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15232. // Side effect import to define the stereoscopic mode.
  15233. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15234. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15235. });
  15236. /**
  15237. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15238. * @see http://doc.babylonjs.com/features/cameras
  15239. */
  15240. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15242. /**
  15243. * Creates a new StereoscopicUniversalCamera
  15244. * @param name defines camera name
  15245. * @param position defines initial position
  15246. * @param interaxialDistance defines distance between each color axis
  15247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15248. * @param scene defines the hosting scene
  15249. */
  15250. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15251. var _this = _super.call(this, name, position, scene) || this;
  15252. _this.interaxialDistance = interaxialDistance;
  15253. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15254. _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 });
  15255. return _this;
  15256. }
  15257. /**
  15258. * Gets camera class name
  15259. * @returns StereoscopicUniversalCamera
  15260. */
  15261. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15262. return "StereoscopicUniversalCamera";
  15263. };
  15264. return StereoscopicUniversalCamera;
  15265. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15266. /***/ }),
  15267. /***/ "./Cameras/VR/index.ts":
  15268. /*!*****************************!*\
  15269. !*** ./Cameras/VR/index.ts ***!
  15270. \*****************************/
  15271. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  15272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15273. "use strict";
  15274. __webpack_require__.r(__webpack_exports__);
  15275. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15277. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15279. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15281. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15283. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15285. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15287. /***/ }),
  15288. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15289. /*!***************************************!*\
  15290. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15291. \***************************************/
  15292. /*! exports provided: VRCameraMetrics */
  15293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15294. "use strict";
  15295. __webpack_require__.r(__webpack_exports__);
  15296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15298. /**
  15299. * This represents all the required metrics to create a VR camera.
  15300. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15301. */
  15302. var VRCameraMetrics = /** @class */ (function () {
  15303. function VRCameraMetrics() {
  15304. /**
  15305. * Define if the current vr camera should compensate the distortion of the lense or not.
  15306. */
  15307. this.compensateDistortion = true;
  15308. }
  15309. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15310. /**
  15311. * Gets the rendering aspect ratio based on the provided resolutions.
  15312. */
  15313. get: function () {
  15314. return this.hResolution / (2 * this.vResolution);
  15315. },
  15316. enumerable: true,
  15317. configurable: true
  15318. });
  15319. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15320. /**
  15321. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15322. */
  15323. get: function () {
  15324. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15325. },
  15326. enumerable: true,
  15327. configurable: true
  15328. });
  15329. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15330. /**
  15331. * @hidden
  15332. */
  15333. get: function () {
  15334. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15335. var h = (4 * meters) / this.hScreenSize;
  15336. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15337. },
  15338. enumerable: true,
  15339. configurable: true
  15340. });
  15341. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15342. /**
  15343. * @hidden
  15344. */
  15345. get: function () {
  15346. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15347. var h = (4 * meters) / this.hScreenSize;
  15348. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15349. },
  15350. enumerable: true,
  15351. configurable: true
  15352. });
  15353. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15354. /**
  15355. * @hidden
  15356. */
  15357. get: function () {
  15358. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15359. },
  15360. enumerable: true,
  15361. configurable: true
  15362. });
  15363. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15364. /**
  15365. * @hidden
  15366. */
  15367. get: function () {
  15368. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15369. },
  15370. enumerable: true,
  15371. configurable: true
  15372. });
  15373. /**
  15374. * Get the default VRMetrics based on the most generic setup.
  15375. * @returns the default vr metrics
  15376. */
  15377. VRCameraMetrics.GetDefault = function () {
  15378. var result = new VRCameraMetrics();
  15379. result.hResolution = 1280;
  15380. result.vResolution = 800;
  15381. result.hScreenSize = 0.149759993;
  15382. result.vScreenSize = 0.0935999975;
  15383. result.vScreenCenter = 0.0467999987;
  15384. result.eyeToScreenDistance = 0.0410000011;
  15385. result.lensSeparationDistance = 0.0635000020;
  15386. result.interpupillaryDistance = 0.0640000030;
  15387. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15388. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15389. result.postProcessScaleFactor = 1.714605507808412;
  15390. result.lensCenterOffset = 0.151976421;
  15391. return result;
  15392. };
  15393. return VRCameraMetrics;
  15394. }());
  15395. /***/ }),
  15396. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15397. /*!**********************************************************!*\
  15398. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15399. \**********************************************************/
  15400. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15402. "use strict";
  15403. __webpack_require__.r(__webpack_exports__);
  15404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15406. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15407. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15408. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15409. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15410. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15411. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15412. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15413. // Side effect import to define the stereoscopic mode.
  15414. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15415. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15416. });
  15417. /**
  15418. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15419. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15420. */
  15421. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15423. /**
  15424. * Creates a new VRDeviceOrientationArcRotateCamera
  15425. * @param name defines camera name
  15426. * @param alpha defines the camera rotation along the logitudinal axis
  15427. * @param beta defines the camera rotation along the latitudinal axis
  15428. * @param radius defines the camera distance from its target
  15429. * @param target defines the camera target
  15430. * @param scene defines the scene the camera belongs to
  15431. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15432. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15433. */
  15434. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15435. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15436. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15437. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15438. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15439. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15440. _this.inputs.addVRDeviceOrientation();
  15441. return _this;
  15442. }
  15443. /**
  15444. * Gets camera class name
  15445. * @returns VRDeviceOrientationArcRotateCamera
  15446. */
  15447. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15448. return "VRDeviceOrientationArcRotateCamera";
  15449. };
  15450. return VRDeviceOrientationArcRotateCamera;
  15451. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15452. /***/ }),
  15453. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15454. /*!*****************************************************!*\
  15455. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15456. \*****************************************************/
  15457. /*! exports provided: VRDeviceOrientationFreeCamera */
  15458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15459. "use strict";
  15460. __webpack_require__.r(__webpack_exports__);
  15461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15462. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15463. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15464. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15465. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15466. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15467. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15468. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15469. // Side effect import to define the stereoscopic mode.
  15470. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15471. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15472. });
  15473. /**
  15474. * Camera used to simulate VR rendering (based on FreeCamera)
  15475. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15476. */
  15477. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15478. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15479. /**
  15480. * Creates a new VRDeviceOrientationFreeCamera
  15481. * @param name defines camera name
  15482. * @param position defines the start position of the camera
  15483. * @param scene defines the scene the camera belongs to
  15484. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15485. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15486. */
  15487. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15488. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15489. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15490. var _this = _super.call(this, name, position, scene) || this;
  15491. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15492. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15493. return _this;
  15494. }
  15495. /**
  15496. * Gets camera class name
  15497. * @returns VRDeviceOrientationFreeCamera
  15498. */
  15499. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15500. return "VRDeviceOrientationFreeCamera";
  15501. };
  15502. return VRDeviceOrientationFreeCamera;
  15503. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15504. /***/ }),
  15505. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15506. /*!********************************************************!*\
  15507. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15508. \********************************************************/
  15509. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15511. "use strict";
  15512. __webpack_require__.r(__webpack_exports__);
  15513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15515. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15516. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15517. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15518. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15519. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15520. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15521. });
  15522. /**
  15523. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15524. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15525. */
  15526. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15527. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15528. /**
  15529. * Creates a new VRDeviceOrientationGamepadCamera
  15530. * @param name defines camera name
  15531. * @param position defines the start position of the camera
  15532. * @param scene defines the scene the camera belongs to
  15533. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15534. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15535. */
  15536. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15537. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15538. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15539. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15540. _this.inputs.addGamepad();
  15541. return _this;
  15542. }
  15543. /**
  15544. * Gets camera class name
  15545. * @returns VRDeviceOrientationGamepadCamera
  15546. */
  15547. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15548. return "VRDeviceOrientationGamepadCamera";
  15549. };
  15550. return VRDeviceOrientationGamepadCamera;
  15551. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15552. /***/ }),
  15553. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15554. /*!******************************************!*\
  15555. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15556. \******************************************/
  15557. /*! exports provided: VRExperienceHelper */
  15558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15559. "use strict";
  15560. __webpack_require__.r(__webpack_exports__);
  15561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15562. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15563. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15564. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15565. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15566. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15567. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15568. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15569. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15570. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15571. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15572. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15573. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15574. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15575. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15576. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15577. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15578. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15579. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15580. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15581. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15582. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15583. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15584. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15585. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15586. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15587. var VRExperienceHelperGazer = /** @class */ (function () {
  15588. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15589. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15590. this.scene = scene;
  15591. /** @hidden */
  15592. this._pointerDownOnMeshAsked = false;
  15593. /** @hidden */
  15594. this._isActionableMesh = false;
  15595. /** @hidden */
  15596. this._teleportationRequestInitiated = false;
  15597. /** @hidden */
  15598. this._teleportationBackRequestInitiated = false;
  15599. /** @hidden */
  15600. this._rotationRightAsked = false;
  15601. /** @hidden */
  15602. this._rotationLeftAsked = false;
  15603. /** @hidden */
  15604. this._dpadPressed = true;
  15605. /** @hidden */
  15606. this._activePointer = false;
  15607. this._id = VRExperienceHelperGazer._idCounter++;
  15608. // Gaze tracker
  15609. if (!gazeTrackerToClone) {
  15610. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15611. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15612. this._gazeTracker.isPickable = false;
  15613. this._gazeTracker.isVisible = false;
  15614. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15615. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15616. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15617. targetMat.backFaceCulling = false;
  15618. this._gazeTracker.material = targetMat;
  15619. }
  15620. else {
  15621. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15622. }
  15623. }
  15624. /** @hidden */
  15625. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15626. 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));
  15627. };
  15628. /** @hidden */
  15629. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15630. this._pointerDownOnMeshAsked = true;
  15631. if (this._currentHit) {
  15632. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15633. }
  15634. };
  15635. /** @hidden */
  15636. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15637. if (this._currentHit) {
  15638. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15639. }
  15640. this._pointerDownOnMeshAsked = false;
  15641. };
  15642. /** @hidden */
  15643. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15644. this._activePointer = true;
  15645. };
  15646. /** @hidden */
  15647. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15648. this._activePointer = false;
  15649. };
  15650. /** @hidden */
  15651. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15652. if (distance === void 0) { distance = 100; }
  15653. };
  15654. VRExperienceHelperGazer.prototype.dispose = function () {
  15655. this._interactionsEnabled = false;
  15656. this._teleportationEnabled = false;
  15657. if (this._gazeTracker) {
  15658. this._gazeTracker.dispose();
  15659. }
  15660. };
  15661. VRExperienceHelperGazer._idCounter = 0;
  15662. return VRExperienceHelperGazer;
  15663. }());
  15664. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15666. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15667. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15668. _this.webVRController = webVRController;
  15669. // Laser pointer
  15670. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15671. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15672. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15673. laserPointerMaterial.alpha = 0.6;
  15674. _this._laserPointer.material = laserPointerMaterial;
  15675. _this._laserPointer.rotation.x = Math.PI / 2;
  15676. _this._laserPointer.position.z = -0.5;
  15677. _this._laserPointer.isVisible = false;
  15678. _this._laserPointer.isPickable = false;
  15679. if (!webVRController.mesh) {
  15680. // Create an empty mesh that is used prior to loading the high quality model
  15681. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15682. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15683. preloadPointerPose.rotation.x = -0.7;
  15684. preloadMesh.addChild(preloadPointerPose);
  15685. webVRController.attachToMesh(preloadMesh);
  15686. }
  15687. _this._setLaserPointerParent(webVRController.mesh);
  15688. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15689. _this._setLaserPointerParent(mesh);
  15690. });
  15691. return _this;
  15692. }
  15693. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15694. return this.webVRController.getForwardRay(length);
  15695. };
  15696. /** @hidden */
  15697. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15698. _super.prototype._activatePointer.call(this);
  15699. this._laserPointer.isVisible = true;
  15700. };
  15701. /** @hidden */
  15702. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15703. _super.prototype._deactivatePointer.call(this);
  15704. this._laserPointer.isVisible = false;
  15705. };
  15706. /** @hidden */
  15707. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15708. this._laserPointer.material.emissiveColor = color;
  15709. };
  15710. /** @hidden */
  15711. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15712. var makeNotPick = function (root) {
  15713. root.isPickable = false;
  15714. root.getChildMeshes().forEach(function (c) {
  15715. makeNotPick(c);
  15716. });
  15717. };
  15718. makeNotPick(mesh);
  15719. var meshChildren = mesh.getChildren(undefined, false);
  15720. var laserParent = mesh;
  15721. this.webVRController._pointingPoseNode = null;
  15722. for (var i = 0; i < meshChildren.length; i++) {
  15723. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15724. laserParent = meshChildren[i];
  15725. this.webVRController._pointingPoseNode = laserParent;
  15726. break;
  15727. }
  15728. }
  15729. this._laserPointer.parent = laserParent;
  15730. };
  15731. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15732. if (distance === void 0) { distance = 100; }
  15733. this._laserPointer.scaling.y = distance;
  15734. this._laserPointer.position.z = -distance / 2;
  15735. };
  15736. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15737. _super.prototype.dispose.call(this);
  15738. this._laserPointer.dispose();
  15739. if (this._meshAttachedObserver) {
  15740. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15741. }
  15742. };
  15743. return VRExperienceHelperControllerGazer;
  15744. }(VRExperienceHelperGazer));
  15745. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15747. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15748. var _this = _super.call(this, scene) || this;
  15749. _this.getCamera = getCamera;
  15750. return _this;
  15751. }
  15752. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15753. var camera = this.getCamera();
  15754. if (camera) {
  15755. return camera.getForwardRay(length);
  15756. }
  15757. else {
  15758. 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());
  15759. }
  15760. };
  15761. return VRExperienceHelperCameraGazer;
  15762. }(VRExperienceHelperGazer));
  15763. /**
  15764. * Helps to quickly add VR support to an existing scene.
  15765. * See http://doc.babylonjs.com/how_to/webvr_helper
  15766. */
  15767. var VRExperienceHelper = /** @class */ (function () {
  15768. /**
  15769. * Instantiates a VRExperienceHelper.
  15770. * Helps to quickly add VR support to an existing scene.
  15771. * @param scene The scene the VRExperienceHelper belongs to.
  15772. * @param webVROptions Options to modify the vr experience helper's behavior.
  15773. */
  15774. function VRExperienceHelper(scene,
  15775. /** Options to modify the vr experience helper's behavior. */
  15776. webVROptions) {
  15777. if (webVROptions === void 0) { webVROptions = {}; }
  15778. var _this = this;
  15779. this.webVROptions = webVROptions;
  15780. // Can the system support WebVR, even if a headset isn't plugged in?
  15781. this._webVRsupported = false;
  15782. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15783. this._webVRready = false;
  15784. // Are we waiting for the requestPresent callback to complete?
  15785. this._webVRrequesting = false;
  15786. // Are we presenting to the headset right now? (this is the vrDevice state)
  15787. this._webVRpresenting = false;
  15788. // Are we presenting in the fullscreen fallback?
  15789. this._fullscreenVRpresenting = false;
  15790. /**
  15791. * Observable raised when entering VR.
  15792. */
  15793. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15794. /**
  15795. * Observable raised when exiting VR.
  15796. */
  15797. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15798. /**
  15799. * Observable raised when controller mesh is loaded.
  15800. */
  15801. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15802. this._useCustomVRButton = false;
  15803. this._teleportationRequested = false;
  15804. this._teleportActive = false;
  15805. this._floorMeshesCollection = [];
  15806. this._rotationAllowed = true;
  15807. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15808. this._isDefaultTeleportationTarget = true;
  15809. this._teleportationFillColor = "#444444";
  15810. this._teleportationBorderColor = "#FFFFFF";
  15811. this._rotationAngle = 0;
  15812. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15813. this._padSensibilityUp = 0.65;
  15814. this._padSensibilityDown = 0.35;
  15815. this._leftController = null;
  15816. this._rightController = null;
  15817. /**
  15818. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15819. */
  15820. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15821. /**
  15822. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15823. */
  15824. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15825. /**
  15826. * Observable raised before camera teleportation
  15827. */
  15828. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15829. /**
  15830. * Observable raised after camera teleportation
  15831. */
  15832. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15833. /**
  15834. * Observable raised when current selected mesh gets unselected
  15835. */
  15836. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15837. /**
  15838. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15839. */
  15840. this.teleportationEnabled = true;
  15841. this._teleportationInitialized = false;
  15842. this._interactionsEnabled = false;
  15843. this._interactionsRequested = false;
  15844. this._displayGaze = true;
  15845. this._displayLaserPointer = true;
  15846. /**
  15847. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15848. */
  15849. this.updateGazeTrackerScale = true;
  15850. /**
  15851. * If the gaze trackers color should be updated when selecting meshes
  15852. */
  15853. this.updateGazeTrackerColor = true;
  15854. this._onResize = function () {
  15855. _this.moveButtonToBottomRight();
  15856. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15857. _this.exitVR();
  15858. }
  15859. };
  15860. this._onFullscreenChange = function () {
  15861. if (document.fullscreen !== undefined) {
  15862. _this._fullscreenVRpresenting = document.fullscreen;
  15863. }
  15864. else if (document.mozFullScreen !== undefined) {
  15865. _this._fullscreenVRpresenting = document.mozFullScreen;
  15866. }
  15867. else if (document.webkitIsFullScreen !== undefined) {
  15868. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15869. }
  15870. else if (document.msIsFullScreen !== undefined) {
  15871. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15872. }
  15873. else if (document.msFullscreenElement !== undefined) {
  15874. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15875. }
  15876. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15877. _this.exitVR();
  15878. if (!_this._useCustomVRButton) {
  15879. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15880. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15881. }
  15882. }
  15883. };
  15884. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15885. this.beforeRender = function () {
  15886. if (_this._leftController && _this._leftController._activePointer) {
  15887. _this._castRayAndSelectObject(_this._leftController);
  15888. }
  15889. if (_this._rightController && _this._rightController._activePointer) {
  15890. _this._castRayAndSelectObject(_this._rightController);
  15891. }
  15892. if (_this._noControllerIsActive) {
  15893. _this._castRayAndSelectObject(_this._cameraGazer);
  15894. }
  15895. else {
  15896. _this._cameraGazer._gazeTracker.isVisible = false;
  15897. }
  15898. };
  15899. this._onNewGamepadConnected = function (gamepad) {
  15900. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15901. if (gamepad.leftStick) {
  15902. gamepad.onleftstickchanged(function (stickValues) {
  15903. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15904. // Listening to classic/xbox gamepad only if no VR controller is active
  15905. if ((!_this._leftController && !_this._rightController) ||
  15906. ((_this._leftController && !_this._leftController._activePointer) &&
  15907. (_this._rightController && !_this._rightController._activePointer))) {
  15908. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15909. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15910. }
  15911. }
  15912. });
  15913. }
  15914. if (gamepad.rightStick) {
  15915. gamepad.onrightstickchanged(function (stickValues) {
  15916. if (_this._teleportationInitialized) {
  15917. _this._checkRotate(stickValues, _this._cameraGazer);
  15918. }
  15919. });
  15920. }
  15921. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15922. gamepad.onbuttondown(function (buttonPressed) {
  15923. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15924. _this._cameraGazer._selectionPointerDown();
  15925. }
  15926. });
  15927. gamepad.onbuttonup(function (buttonPressed) {
  15928. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15929. _this._cameraGazer._selectionPointerUp();
  15930. }
  15931. });
  15932. }
  15933. }
  15934. else {
  15935. var webVRController = gamepad;
  15936. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15937. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15938. _this._rightController = controller;
  15939. }
  15940. else {
  15941. _this._leftController = controller;
  15942. }
  15943. _this._tryEnableInteractionOnController(controller);
  15944. }
  15945. };
  15946. // 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
  15947. this._tryEnableInteractionOnController = function (controller) {
  15948. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15949. _this._enableInteractionOnController(controller);
  15950. }
  15951. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15952. _this._enableTeleportationOnController(controller);
  15953. }
  15954. };
  15955. this._onNewGamepadDisconnected = function (gamepad) {
  15956. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15957. if (gamepad.hand === "left" && _this._leftController != null) {
  15958. _this._leftController.dispose();
  15959. _this._leftController = null;
  15960. }
  15961. if (gamepad.hand === "right" && _this._rightController != null) {
  15962. _this._rightController.dispose();
  15963. _this._rightController = null;
  15964. }
  15965. }
  15966. };
  15967. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15968. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15969. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15970. this._scene = scene;
  15971. this._canvas = scene.getEngine().getRenderingCanvas();
  15972. // Parse options
  15973. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15974. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15975. }
  15976. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15977. webVROptions.createDeviceOrientationCamera = true;
  15978. }
  15979. if (webVROptions.laserToggle === undefined) {
  15980. webVROptions.laserToggle = true;
  15981. }
  15982. if (webVROptions.defaultHeight === undefined) {
  15983. webVROptions.defaultHeight = 1.7;
  15984. }
  15985. if (webVROptions.useCustomVRButton) {
  15986. this._useCustomVRButton = true;
  15987. if (webVROptions.customVRButton) {
  15988. this._btnVR = webVROptions.customVRButton;
  15989. }
  15990. }
  15991. if (webVROptions.rayLength) {
  15992. this._rayLength = webVROptions.rayLength;
  15993. }
  15994. this._defaultHeight = webVROptions.defaultHeight;
  15995. if (webVROptions.positionScale) {
  15996. this._rayLength *= webVROptions.positionScale;
  15997. this._defaultHeight *= webVROptions.positionScale;
  15998. }
  15999. this._hasEnteredVR = false;
  16000. // Set position
  16001. if (this._scene.activeCamera) {
  16002. this._position = this._scene.activeCamera.position.clone();
  16003. }
  16004. else {
  16005. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16006. }
  16007. // Set non-vr camera
  16008. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16009. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16010. // Copy data from existing camera
  16011. if (this._scene.activeCamera) {
  16012. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16013. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16014. // Set rotation from previous camera
  16015. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16016. var targetCamera = this._scene.activeCamera;
  16017. if (targetCamera.rotationQuaternion) {
  16018. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16019. }
  16020. else {
  16021. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16022. }
  16023. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16024. }
  16025. }
  16026. this._scene.activeCamera = this._deviceOrientationCamera;
  16027. if (this._canvas) {
  16028. this._scene.activeCamera.attachControl(this._canvas);
  16029. }
  16030. }
  16031. else {
  16032. this._existingCamera = this._scene.activeCamera;
  16033. }
  16034. // Create VR cameras
  16035. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16036. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene);
  16037. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16038. }
  16039. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16040. this._webVRCamera.useStandingMatrix();
  16041. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16042. // Create default button
  16043. if (!this._useCustomVRButton) {
  16044. this._btnVR = document.createElement("BUTTON");
  16045. this._btnVR.className = "babylonVRicon";
  16046. this._btnVR.id = "babylonVRiconbtn";
  16047. this._btnVR.title = "Click to switch to VR";
  16048. 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) }";
  16049. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16050. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16051. // css += ".babylonVRicon.vrdisplaysupported { }";
  16052. // css += ".babylonVRicon.vrdisplayready { }";
  16053. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16054. var style = document.createElement('style');
  16055. style.appendChild(document.createTextNode(css));
  16056. document.getElementsByTagName('head')[0].appendChild(style);
  16057. this.moveButtonToBottomRight();
  16058. }
  16059. // VR button click event
  16060. if (this._btnVR) {
  16061. this._btnVR.addEventListener("click", function () {
  16062. if (!_this.isInVRMode) {
  16063. _this.enterVR();
  16064. }
  16065. else {
  16066. _this.exitVR();
  16067. }
  16068. });
  16069. }
  16070. // Window events
  16071. window.addEventListener("resize", this._onResize);
  16072. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16073. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16074. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16075. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16076. document.onmsfullscreenchange = this._onFullscreenChange;
  16077. // Display vr button when headset is connected
  16078. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16079. this.displayVRButton();
  16080. }
  16081. else {
  16082. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16083. if (e.vrDisplay) {
  16084. _this.displayVRButton();
  16085. }
  16086. });
  16087. }
  16088. // Exiting VR mode using 'ESC' key on desktop
  16089. this._onKeyDown = function (event) {
  16090. if (event.keyCode === 27 && _this.isInVRMode) {
  16091. _this.exitVR();
  16092. }
  16093. };
  16094. document.addEventListener("keydown", this._onKeyDown);
  16095. // Exiting VR mode double tapping the touch screen
  16096. this._scene.onPrePointerObservable.add(function () {
  16097. if (_this.isInVRMode) {
  16098. _this.exitVR();
  16099. if (_this._fullscreenVRpresenting) {
  16100. _this._scene.getEngine().switchFullscreen(true);
  16101. }
  16102. }
  16103. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16104. // Listen for WebVR display changes
  16105. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16106. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16107. this._onVRRequestPresentStart = function () {
  16108. _this._webVRrequesting = true;
  16109. _this.updateButtonVisibility();
  16110. };
  16111. this._onVRRequestPresentComplete = function () {
  16112. _this._webVRrequesting = false;
  16113. _this.updateButtonVisibility();
  16114. };
  16115. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16116. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16117. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16118. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16119. scene.onDisposeObservable.add(function () {
  16120. _this.dispose();
  16121. });
  16122. // Gamepad connection events
  16123. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16124. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16125. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16126. this.updateButtonVisibility();
  16127. //create easing functions
  16128. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16129. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16130. if (this.webVROptions.floorMeshes) {
  16131. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16132. }
  16133. }
  16134. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16135. /** Return this.onEnteringVRObservable
  16136. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16137. */
  16138. get: function () {
  16139. return this.onEnteringVRObservable;
  16140. },
  16141. enumerable: true,
  16142. configurable: true
  16143. });
  16144. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16145. /** Return this.onExitingVRObservable
  16146. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16147. */
  16148. get: function () {
  16149. return this.onExitingVRObservable;
  16150. },
  16151. enumerable: true,
  16152. configurable: true
  16153. });
  16154. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16155. /** Return this.onControllerMeshLoadedObservable
  16156. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16157. */
  16158. get: function () {
  16159. return this.onControllerMeshLoadedObservable;
  16160. },
  16161. enumerable: true,
  16162. configurable: true
  16163. });
  16164. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16165. /**
  16166. * The mesh used to display where the user is going to teleport.
  16167. */
  16168. get: function () {
  16169. return this._teleportationTarget;
  16170. },
  16171. /**
  16172. * Sets the mesh to be used to display where the user is going to teleport.
  16173. */
  16174. set: function (value) {
  16175. if (value) {
  16176. value.name = "teleportationTarget";
  16177. this._isDefaultTeleportationTarget = false;
  16178. this._teleportationTarget = value;
  16179. }
  16180. },
  16181. enumerable: true,
  16182. configurable: true
  16183. });
  16184. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16185. /**
  16186. * 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
  16187. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16188. * See http://doc.babylonjs.com/resources/baking_transformations
  16189. */
  16190. get: function () {
  16191. return this._cameraGazer._gazeTracker;
  16192. },
  16193. set: function (value) {
  16194. if (value) {
  16195. // Dispose of existing meshes
  16196. if (this._cameraGazer._gazeTracker) {
  16197. this._cameraGazer._gazeTracker.dispose();
  16198. }
  16199. if (this._leftController && this._leftController._gazeTracker) {
  16200. this._leftController._gazeTracker.dispose();
  16201. }
  16202. if (this._rightController && this._rightController._gazeTracker) {
  16203. this._rightController._gazeTracker.dispose();
  16204. }
  16205. // Set and create gaze trackers on head and controllers
  16206. this._cameraGazer._gazeTracker = value;
  16207. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16208. this._cameraGazer._gazeTracker.isPickable = false;
  16209. this._cameraGazer._gazeTracker.isVisible = false;
  16210. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16211. if (this._leftController) {
  16212. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16213. }
  16214. if (this._rightController) {
  16215. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16216. }
  16217. }
  16218. },
  16219. enumerable: true,
  16220. configurable: true
  16221. });
  16222. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16223. /**
  16224. * The gaze tracking mesh corresponding to the left controller
  16225. */
  16226. get: function () {
  16227. if (this._leftController) {
  16228. return this._leftController._gazeTracker;
  16229. }
  16230. return null;
  16231. },
  16232. enumerable: true,
  16233. configurable: true
  16234. });
  16235. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16236. /**
  16237. * The gaze tracking mesh corresponding to the right controller
  16238. */
  16239. get: function () {
  16240. if (this._rightController) {
  16241. return this._rightController._gazeTracker;
  16242. }
  16243. return null;
  16244. },
  16245. enumerable: true,
  16246. configurable: true
  16247. });
  16248. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16249. /**
  16250. * If the ray of the gaze should be displayed.
  16251. */
  16252. get: function () {
  16253. return this._displayGaze;
  16254. },
  16255. /**
  16256. * Sets if the ray of the gaze should be displayed.
  16257. */
  16258. set: function (value) {
  16259. this._displayGaze = value;
  16260. if (!value) {
  16261. this._cameraGazer._gazeTracker.isVisible = false;
  16262. if (this._leftController) {
  16263. this._leftController._gazeTracker.isVisible = false;
  16264. }
  16265. if (this._rightController) {
  16266. this._rightController._gazeTracker.isVisible = false;
  16267. }
  16268. }
  16269. },
  16270. enumerable: true,
  16271. configurable: true
  16272. });
  16273. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16274. /**
  16275. * If the ray of the LaserPointer should be displayed.
  16276. */
  16277. get: function () {
  16278. return this._displayLaserPointer;
  16279. },
  16280. /**
  16281. * Sets if the ray of the LaserPointer should be displayed.
  16282. */
  16283. set: function (value) {
  16284. this._displayLaserPointer = value;
  16285. if (!value) {
  16286. if (this._rightController) {
  16287. this._rightController._deactivatePointer();
  16288. this._rightController._gazeTracker.isVisible = false;
  16289. }
  16290. if (this._leftController) {
  16291. this._leftController._deactivatePointer();
  16292. this._leftController._gazeTracker.isVisible = false;
  16293. }
  16294. }
  16295. else {
  16296. if (this._rightController) {
  16297. this._rightController._activatePointer();
  16298. }
  16299. if (this._leftController) {
  16300. this._leftController._activatePointer();
  16301. }
  16302. }
  16303. },
  16304. enumerable: true,
  16305. configurable: true
  16306. });
  16307. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16308. /**
  16309. * The deviceOrientationCamera used as the camera when not in VR.
  16310. */
  16311. get: function () {
  16312. return this._deviceOrientationCamera;
  16313. },
  16314. enumerable: true,
  16315. configurable: true
  16316. });
  16317. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16318. /**
  16319. * Based on the current WebVR support, returns the current VR camera used.
  16320. */
  16321. get: function () {
  16322. if (this._webVRready) {
  16323. return this._webVRCamera;
  16324. }
  16325. else {
  16326. return this._scene.activeCamera;
  16327. }
  16328. },
  16329. enumerable: true,
  16330. configurable: true
  16331. });
  16332. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16333. /**
  16334. * The webVRCamera which is used when in VR.
  16335. */
  16336. get: function () {
  16337. return this._webVRCamera;
  16338. },
  16339. enumerable: true,
  16340. configurable: true
  16341. });
  16342. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16343. /**
  16344. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16345. */
  16346. get: function () {
  16347. return this._vrDeviceOrientationCamera;
  16348. },
  16349. enumerable: true,
  16350. configurable: true
  16351. });
  16352. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16353. get: function () {
  16354. var result = this._cameraGazer._teleportationRequestInitiated
  16355. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16356. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16357. return result;
  16358. },
  16359. enumerable: true,
  16360. configurable: true
  16361. });
  16362. // Raised when one of the controller has loaded successfully its associated default mesh
  16363. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16364. if (this._leftController && this._leftController.webVRController == webVRController) {
  16365. if (webVRController.mesh) {
  16366. this._leftController._setLaserPointerParent(webVRController.mesh);
  16367. }
  16368. }
  16369. if (this._rightController && this._rightController.webVRController == webVRController) {
  16370. if (webVRController.mesh) {
  16371. this._rightController._setLaserPointerParent(webVRController.mesh);
  16372. }
  16373. }
  16374. try {
  16375. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16376. }
  16377. catch (err) {
  16378. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16379. }
  16380. };
  16381. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16382. /**
  16383. * Gets a value indicating if we are currently in VR mode.
  16384. */
  16385. get: function () {
  16386. return this._webVRpresenting || this._fullscreenVRpresenting;
  16387. },
  16388. enumerable: true,
  16389. configurable: true
  16390. });
  16391. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16392. var vrDisplay = this._scene.getEngine().getVRDevice();
  16393. if (vrDisplay) {
  16394. var wasPresenting = this._webVRpresenting;
  16395. this._webVRpresenting = vrDisplay.isPresenting;
  16396. if (wasPresenting && !this._webVRpresenting) {
  16397. this.exitVR();
  16398. }
  16399. }
  16400. else {
  16401. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16402. }
  16403. this.updateButtonVisibility();
  16404. };
  16405. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16406. this._webVRsupported = eventArgs.vrSupported;
  16407. this._webVRready = !!eventArgs.vrDisplay;
  16408. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16409. this.updateButtonVisibility();
  16410. };
  16411. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16412. if (this._canvas && !this._useCustomVRButton) {
  16413. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16414. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16415. }
  16416. };
  16417. VRExperienceHelper.prototype.displayVRButton = function () {
  16418. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16419. document.body.appendChild(this._btnVR);
  16420. this._btnVRDisplayed = true;
  16421. }
  16422. };
  16423. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16424. if (!this._btnVR || this._useCustomVRButton) {
  16425. return;
  16426. }
  16427. this._btnVR.className = "babylonVRicon";
  16428. if (this.isInVRMode) {
  16429. this._btnVR.className += " vrdisplaypresenting";
  16430. }
  16431. else {
  16432. if (this._webVRready) {
  16433. this._btnVR.className += " vrdisplayready";
  16434. }
  16435. if (this._webVRsupported) {
  16436. this._btnVR.className += " vrdisplaysupported";
  16437. }
  16438. if (this._webVRrequesting) {
  16439. this._btnVR.className += " vrdisplayrequesting";
  16440. }
  16441. }
  16442. };
  16443. /**
  16444. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16445. * Otherwise, will use the fullscreen API.
  16446. */
  16447. VRExperienceHelper.prototype.enterVR = function () {
  16448. if (this.onEnteringVRObservable) {
  16449. try {
  16450. this.onEnteringVRObservable.notifyObservers(this);
  16451. }
  16452. catch (err) {
  16453. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16454. }
  16455. }
  16456. if (this._scene.activeCamera) {
  16457. this._position = this._scene.activeCamera.position.clone();
  16458. if (this.vrDeviceOrientationCamera) {
  16459. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16460. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16461. }
  16462. if (this.webVRCamera) {
  16463. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16464. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16465. var delta = desiredYRotation - currentYRotation;
  16466. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16467. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16468. }
  16469. // make sure that we return to the last active camera
  16470. this._existingCamera = this._scene.activeCamera;
  16471. // Remove and cache angular sensability to avoid camera rotation when in VR
  16472. if (this._existingCamera.angularSensibilityX) {
  16473. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16474. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16475. }
  16476. if (this._existingCamera.angularSensibilityY) {
  16477. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16478. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16479. }
  16480. if (this._existingCamera.angularSensibility) {
  16481. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16482. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16483. }
  16484. }
  16485. if (this._webVRrequesting) {
  16486. return;
  16487. }
  16488. // If WebVR is supported and a headset is connected
  16489. if (this._webVRready) {
  16490. if (!this._webVRpresenting) {
  16491. this._webVRCamera.position = this._position;
  16492. this._scene.activeCamera = this._webVRCamera;
  16493. }
  16494. }
  16495. else if (this._vrDeviceOrientationCamera) {
  16496. this._vrDeviceOrientationCamera.position = this._position;
  16497. if (this._scene.activeCamera) {
  16498. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16499. }
  16500. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16501. this._scene.getEngine().switchFullscreen(true);
  16502. this.updateButtonVisibility();
  16503. }
  16504. if (this._scene.activeCamera && this._canvas) {
  16505. this._scene.activeCamera.attachControl(this._canvas);
  16506. }
  16507. if (this._interactionsEnabled) {
  16508. this._scene.registerBeforeRender(this.beforeRender);
  16509. }
  16510. if (this._displayLaserPointer) {
  16511. [this._leftController, this._rightController].forEach(function (controller) {
  16512. if (controller) {
  16513. controller._activatePointer();
  16514. }
  16515. });
  16516. }
  16517. this._hasEnteredVR = true;
  16518. };
  16519. /**
  16520. * Attempt to exit VR, or fullscreen.
  16521. */
  16522. VRExperienceHelper.prototype.exitVR = function () {
  16523. if (this._hasEnteredVR) {
  16524. if (this.onExitingVRObservable) {
  16525. try {
  16526. this.onExitingVRObservable.notifyObservers(this);
  16527. }
  16528. catch (err) {
  16529. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16530. }
  16531. }
  16532. if (this._webVRpresenting) {
  16533. this._scene.getEngine().disableVR();
  16534. }
  16535. if (this._scene.activeCamera) {
  16536. this._position = this._scene.activeCamera.position.clone();
  16537. }
  16538. if (this.vrDeviceOrientationCamera) {
  16539. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16540. }
  16541. if (this._deviceOrientationCamera) {
  16542. this._deviceOrientationCamera.position = this._position;
  16543. this._scene.activeCamera = this._deviceOrientationCamera;
  16544. if (this._canvas) {
  16545. this._scene.activeCamera.attachControl(this._canvas);
  16546. }
  16547. // Restore angular sensibility
  16548. if (this._cachedAngularSensibility.angularSensibilityX) {
  16549. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16550. this._cachedAngularSensibility.angularSensibilityX = null;
  16551. }
  16552. if (this._cachedAngularSensibility.angularSensibilityY) {
  16553. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16554. this._cachedAngularSensibility.angularSensibilityY = null;
  16555. }
  16556. if (this._cachedAngularSensibility.angularSensibility) {
  16557. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16558. this._cachedAngularSensibility.angularSensibility = null;
  16559. }
  16560. }
  16561. else if (this._existingCamera) {
  16562. this._existingCamera.position = this._position;
  16563. this._scene.activeCamera = this._existingCamera;
  16564. // Restore angular sensibility
  16565. if (this._cachedAngularSensibility.angularSensibilityX) {
  16566. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16567. this._cachedAngularSensibility.angularSensibilityX = null;
  16568. }
  16569. if (this._cachedAngularSensibility.angularSensibilityY) {
  16570. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16571. this._cachedAngularSensibility.angularSensibilityY = null;
  16572. }
  16573. if (this._cachedAngularSensibility.angularSensibility) {
  16574. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16575. this._cachedAngularSensibility.angularSensibility = null;
  16576. }
  16577. }
  16578. this.updateButtonVisibility();
  16579. if (this._interactionsEnabled) {
  16580. this._scene.unregisterBeforeRender(this.beforeRender);
  16581. this._cameraGazer._gazeTracker.isVisible = false;
  16582. if (this._leftController) {
  16583. this._leftController._gazeTracker.isVisible = false;
  16584. }
  16585. if (this._rightController) {
  16586. this._rightController._gazeTracker.isVisible = false;
  16587. }
  16588. }
  16589. // resize to update width and height when exiting vr exits fullscreen
  16590. this._scene.getEngine().resize();
  16591. [this._leftController, this._rightController].forEach(function (controller) {
  16592. if (controller) {
  16593. controller._deactivatePointer();
  16594. }
  16595. });
  16596. this._hasEnteredVR = false;
  16597. }
  16598. };
  16599. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16600. /**
  16601. * The position of the vr experience helper.
  16602. */
  16603. get: function () {
  16604. return this._position;
  16605. },
  16606. /**
  16607. * Sets the position of the vr experience helper.
  16608. */
  16609. set: function (value) {
  16610. this._position = value;
  16611. if (this._scene.activeCamera) {
  16612. this._scene.activeCamera.position = value;
  16613. }
  16614. },
  16615. enumerable: true,
  16616. configurable: true
  16617. });
  16618. /**
  16619. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16620. */
  16621. VRExperienceHelper.prototype.enableInteractions = function () {
  16622. var _this = this;
  16623. if (!this._interactionsEnabled) {
  16624. this._interactionsRequested = true;
  16625. if (this._leftController) {
  16626. this._enableInteractionOnController(this._leftController);
  16627. }
  16628. if (this._rightController) {
  16629. this._enableInteractionOnController(this._rightController);
  16630. }
  16631. this.raySelectionPredicate = function (mesh) {
  16632. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16633. };
  16634. this.meshSelectionPredicate = function () {
  16635. return true;
  16636. };
  16637. this._raySelectionPredicate = function (mesh) {
  16638. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16639. && mesh.name.indexOf("teleportationTarget") === -1
  16640. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16641. return _this.raySelectionPredicate(mesh);
  16642. }
  16643. return false;
  16644. };
  16645. this._interactionsEnabled = true;
  16646. }
  16647. };
  16648. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16649. get: function () {
  16650. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16651. },
  16652. enumerable: true,
  16653. configurable: true
  16654. });
  16655. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16656. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16657. if (this._floorMeshesCollection[i].id === mesh.id) {
  16658. return true;
  16659. }
  16660. }
  16661. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16662. return true;
  16663. }
  16664. return false;
  16665. };
  16666. /**
  16667. * Adds a floor mesh to be used for teleportation.
  16668. * @param floorMesh the mesh to be used for teleportation.
  16669. */
  16670. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16671. if (!this._floorMeshesCollection) {
  16672. return;
  16673. }
  16674. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16675. return;
  16676. }
  16677. this._floorMeshesCollection.push(floorMesh);
  16678. };
  16679. /**
  16680. * Removes a floor mesh from being used for teleportation.
  16681. * @param floorMesh the mesh to be removed.
  16682. */
  16683. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16684. if (!this._floorMeshesCollection) {
  16685. return;
  16686. }
  16687. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16688. if (meshIndex !== -1) {
  16689. this._floorMeshesCollection.splice(meshIndex, 1);
  16690. }
  16691. };
  16692. /**
  16693. * Enables interactions and teleportation using the VR controllers and gaze.
  16694. * @param vrTeleportationOptions options to modify teleportation behavior.
  16695. */
  16696. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16697. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16698. if (!this._teleportationInitialized) {
  16699. this._teleportationRequested = true;
  16700. this.enableInteractions();
  16701. if (vrTeleportationOptions.floorMeshName) {
  16702. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16703. }
  16704. if (vrTeleportationOptions.floorMeshes) {
  16705. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16706. }
  16707. if (this._leftController != null) {
  16708. this._enableTeleportationOnController(this._leftController);
  16709. }
  16710. if (this._rightController != null) {
  16711. this._enableTeleportationOnController(this._rightController);
  16712. }
  16713. // Creates an image processing post process for the vignette not relying
  16714. // on the main scene configuration for image processing to reduce setup and spaces
  16715. // (gamma/linear) conflicts.
  16716. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16717. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16718. imageProcessingConfiguration.vignetteEnabled = true;
  16719. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16720. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16721. this._teleportationInitialized = true;
  16722. if (this._isDefaultTeleportationTarget) {
  16723. this._createTeleportationCircles();
  16724. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16725. }
  16726. }
  16727. };
  16728. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16729. var _this = this;
  16730. var controllerMesh = controller.webVRController.mesh;
  16731. if (controllerMesh) {
  16732. controller._interactionsEnabled = true;
  16733. if (this.isInVRMode && this._displayLaserPointer) {
  16734. controller._activatePointer();
  16735. }
  16736. if (this.webVROptions.laserToggle) {
  16737. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16738. // Enabling / disabling laserPointer
  16739. if (_this._displayLaserPointer && stateObject.value === 1) {
  16740. if (controller._activePointer) {
  16741. controller._deactivatePointer();
  16742. }
  16743. else {
  16744. controller._activatePointer();
  16745. }
  16746. if (_this.displayGaze) {
  16747. controller._gazeTracker.isVisible = controller._activePointer;
  16748. }
  16749. }
  16750. });
  16751. }
  16752. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16753. var gazer = controller;
  16754. if (_this._noControllerIsActive) {
  16755. gazer = _this._cameraGazer;
  16756. }
  16757. if (!gazer._pointerDownOnMeshAsked) {
  16758. if (stateObject.value > _this._padSensibilityUp) {
  16759. gazer._selectionPointerDown();
  16760. }
  16761. }
  16762. else if (stateObject.value < _this._padSensibilityDown) {
  16763. gazer._selectionPointerUp();
  16764. }
  16765. });
  16766. }
  16767. };
  16768. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16769. // Dont teleport if another gaze already requested teleportation
  16770. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16771. return;
  16772. }
  16773. if (!gazer._teleportationRequestInitiated) {
  16774. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16775. gazer._activatePointer();
  16776. gazer._teleportationRequestInitiated = true;
  16777. }
  16778. }
  16779. else {
  16780. // Listening to the proper controller values changes to confirm teleportation
  16781. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16782. if (this._teleportActive) {
  16783. this.teleportCamera(this._haloCenter);
  16784. }
  16785. gazer._teleportationRequestInitiated = false;
  16786. }
  16787. }
  16788. };
  16789. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16790. // Only rotate when user is not currently selecting a teleportation location
  16791. if (gazer._teleportationRequestInitiated) {
  16792. return;
  16793. }
  16794. if (!gazer._rotationLeftAsked) {
  16795. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16796. gazer._rotationLeftAsked = true;
  16797. if (this._rotationAllowed) {
  16798. this._rotateCamera(false);
  16799. }
  16800. }
  16801. }
  16802. else {
  16803. if (stateObject.x > -this._padSensibilityDown) {
  16804. gazer._rotationLeftAsked = false;
  16805. }
  16806. }
  16807. if (!gazer._rotationRightAsked) {
  16808. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16809. gazer._rotationRightAsked = true;
  16810. if (this._rotationAllowed) {
  16811. this._rotateCamera(true);
  16812. }
  16813. }
  16814. }
  16815. else {
  16816. if (stateObject.x < this._padSensibilityDown) {
  16817. gazer._rotationRightAsked = false;
  16818. }
  16819. }
  16820. };
  16821. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16822. // Only teleport backwards when user is not currently selecting a teleportation location
  16823. if (gazer._teleportationRequestInitiated) {
  16824. return;
  16825. }
  16826. // Teleport backwards
  16827. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16828. if (!gazer._teleportationBackRequestInitiated) {
  16829. if (!this.currentVRCamera) {
  16830. return;
  16831. }
  16832. // Get rotation and position of the current camera
  16833. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16834. var position = this.currentVRCamera.position;
  16835. // If the camera has device position, use that instead
  16836. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16837. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16838. position = this.currentVRCamera.devicePosition;
  16839. }
  16840. // Get matrix with only the y rotation of the device rotation
  16841. rotation.toEulerAnglesToRef(this._workingVector);
  16842. this._workingVector.z = 0;
  16843. this._workingVector.x = 0;
  16844. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16845. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16846. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16847. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16848. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16849. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16850. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16851. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16852. this.teleportCamera(hit.pickedPoint);
  16853. }
  16854. gazer._teleportationBackRequestInitiated = true;
  16855. }
  16856. }
  16857. else {
  16858. gazer._teleportationBackRequestInitiated = false;
  16859. }
  16860. };
  16861. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16862. var _this = this;
  16863. var controllerMesh = controller.webVRController.mesh;
  16864. if (controllerMesh) {
  16865. if (!controller._interactionsEnabled) {
  16866. this._enableInteractionOnController(controller);
  16867. }
  16868. controller._interactionsEnabled = true;
  16869. controller._teleportationEnabled = true;
  16870. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16871. controller._dpadPressed = false;
  16872. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16873. controller._dpadPressed = stateObject.pressed;
  16874. if (!controller._dpadPressed) {
  16875. controller._rotationLeftAsked = false;
  16876. controller._rotationRightAsked = false;
  16877. controller._teleportationBackRequestInitiated = false;
  16878. }
  16879. });
  16880. }
  16881. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16882. if (_this.teleportationEnabled) {
  16883. _this._checkTeleportBackwards(stateObject, controller);
  16884. _this._checkTeleportWithRay(stateObject, controller);
  16885. }
  16886. _this._checkRotate(stateObject, controller);
  16887. });
  16888. }
  16889. };
  16890. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16891. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16892. this._teleportationTarget.isPickable = false;
  16893. var length = 512;
  16894. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16895. dynamicTexture.hasAlpha = true;
  16896. var context = dynamicTexture.getContext();
  16897. var centerX = length / 2;
  16898. var centerY = length / 2;
  16899. var radius = 200;
  16900. context.beginPath();
  16901. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16902. context.fillStyle = this._teleportationFillColor;
  16903. context.fill();
  16904. context.lineWidth = 10;
  16905. context.strokeStyle = this._teleportationBorderColor;
  16906. context.stroke();
  16907. context.closePath();
  16908. dynamicTexture.update();
  16909. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16910. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16911. this._teleportationTarget.material = teleportationCircleMaterial;
  16912. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16913. torus.isPickable = false;
  16914. torus.parent = this._teleportationTarget;
  16915. 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);
  16916. var keys = [];
  16917. keys.push({
  16918. frame: 0,
  16919. value: 0
  16920. });
  16921. keys.push({
  16922. frame: 30,
  16923. value: 0.4
  16924. });
  16925. keys.push({
  16926. frame: 60,
  16927. value: 0
  16928. });
  16929. animationInnerCircle.setKeys(keys);
  16930. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16931. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16932. animationInnerCircle.setEasingFunction(easingFunction);
  16933. torus.animations = [];
  16934. torus.animations.push(animationInnerCircle);
  16935. this._scene.beginAnimation(torus, 0, 60, true);
  16936. this._hideTeleportationTarget();
  16937. };
  16938. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16939. this._teleportActive = true;
  16940. if (this._teleportationInitialized) {
  16941. this._teleportationTarget.isVisible = true;
  16942. if (this._isDefaultTeleportationTarget) {
  16943. this._teleportationTarget.getChildren()[0].isVisible = true;
  16944. }
  16945. }
  16946. };
  16947. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16948. this._teleportActive = false;
  16949. if (this._teleportationInitialized) {
  16950. this._teleportationTarget.isVisible = false;
  16951. if (this._isDefaultTeleportationTarget) {
  16952. this._teleportationTarget.getChildren()[0].isVisible = false;
  16953. }
  16954. }
  16955. };
  16956. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16957. var _this = this;
  16958. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16959. return;
  16960. }
  16961. if (right) {
  16962. this._rotationAngle++;
  16963. }
  16964. else {
  16965. this._rotationAngle--;
  16966. }
  16967. this.currentVRCamera.animations = [];
  16968. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16969. 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);
  16970. var animationRotationKeys = [];
  16971. animationRotationKeys.push({
  16972. frame: 0,
  16973. value: this.currentVRCamera.rotationQuaternion
  16974. });
  16975. animationRotationKeys.push({
  16976. frame: 6,
  16977. value: target
  16978. });
  16979. animationRotation.setKeys(animationRotationKeys);
  16980. animationRotation.setEasingFunction(this._circleEase);
  16981. this.currentVRCamera.animations.push(animationRotation);
  16982. this._postProcessMove.animations = [];
  16983. 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);
  16984. var vignetteWeightKeys = [];
  16985. vignetteWeightKeys.push({
  16986. frame: 0,
  16987. value: 0
  16988. });
  16989. vignetteWeightKeys.push({
  16990. frame: 3,
  16991. value: 4
  16992. });
  16993. vignetteWeightKeys.push({
  16994. frame: 6,
  16995. value: 0
  16996. });
  16997. animationPP.setKeys(vignetteWeightKeys);
  16998. animationPP.setEasingFunction(this._circleEase);
  16999. this._postProcessMove.animations.push(animationPP);
  17000. 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);
  17001. var vignetteStretchKeys = [];
  17002. vignetteStretchKeys.push({
  17003. frame: 0,
  17004. value: 0
  17005. });
  17006. vignetteStretchKeys.push({
  17007. frame: 3,
  17008. value: 10
  17009. });
  17010. vignetteStretchKeys.push({
  17011. frame: 6,
  17012. value: 0
  17013. });
  17014. animationPP2.setKeys(vignetteStretchKeys);
  17015. animationPP2.setEasingFunction(this._circleEase);
  17016. this._postProcessMove.animations.push(animationPP2);
  17017. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17018. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17019. this._postProcessMove.samples = 4;
  17020. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17021. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17022. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17023. });
  17024. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17025. };
  17026. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17027. if (hit.pickedPoint) {
  17028. if (gazer._teleportationRequestInitiated) {
  17029. this._displayTeleportationTarget();
  17030. this._haloCenter.copyFrom(hit.pickedPoint);
  17031. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17032. }
  17033. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17034. if (pickNormal) {
  17035. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17036. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17037. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17038. }
  17039. this._teleportationTarget.position.y += 0.1;
  17040. }
  17041. };
  17042. /**
  17043. * Teleports the users feet to the desired location
  17044. * @param location The location where the user's feet should be placed
  17045. */
  17046. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17047. var _this = this;
  17048. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17049. return;
  17050. }
  17051. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17052. // offset of the headset from the anchor.
  17053. if (this.webVRCamera.leftCamera) {
  17054. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17055. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17056. location.subtractToRef(this._workingVector, this._workingVector);
  17057. }
  17058. else {
  17059. this._workingVector.copyFrom(location);
  17060. }
  17061. // Add height to account for user's height offset
  17062. if (this.isInVRMode) {
  17063. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17064. }
  17065. else {
  17066. this._workingVector.y += this._defaultHeight;
  17067. }
  17068. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17069. // Create animation from the camera's position to the new location
  17070. this.currentVRCamera.animations = [];
  17071. 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);
  17072. var animationCameraTeleportationKeys = [{
  17073. frame: 0,
  17074. value: this.currentVRCamera.position
  17075. },
  17076. {
  17077. frame: 11,
  17078. value: this._workingVector
  17079. }
  17080. ];
  17081. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17082. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17083. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17084. this._postProcessMove.animations = [];
  17085. 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);
  17086. var vignetteWeightKeys = [];
  17087. vignetteWeightKeys.push({
  17088. frame: 0,
  17089. value: 0
  17090. });
  17091. vignetteWeightKeys.push({
  17092. frame: 5,
  17093. value: 8
  17094. });
  17095. vignetteWeightKeys.push({
  17096. frame: 11,
  17097. value: 0
  17098. });
  17099. animationPP.setKeys(vignetteWeightKeys);
  17100. this._postProcessMove.animations.push(animationPP);
  17101. 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);
  17102. var vignetteStretchKeys = [];
  17103. vignetteStretchKeys.push({
  17104. frame: 0,
  17105. value: 0
  17106. });
  17107. vignetteStretchKeys.push({
  17108. frame: 5,
  17109. value: 10
  17110. });
  17111. vignetteStretchKeys.push({
  17112. frame: 11,
  17113. value: 0
  17114. });
  17115. animationPP2.setKeys(vignetteStretchKeys);
  17116. this._postProcessMove.animations.push(animationPP2);
  17117. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17118. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17119. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17120. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17121. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17122. });
  17123. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17124. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17125. });
  17126. this._hideTeleportationTarget();
  17127. };
  17128. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17129. if (normal) {
  17130. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17131. if (angle < Math.PI / 2) {
  17132. normal.scaleInPlace(-1);
  17133. }
  17134. }
  17135. return normal;
  17136. };
  17137. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17138. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17139. return;
  17140. }
  17141. var ray = gazer._getForwardRay(this._rayLength);
  17142. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17143. if (hit) {
  17144. // Populate the contrllers mesh that can be used for drag/drop
  17145. if (gazer._laserPointer) {
  17146. hit.originMesh = gazer._laserPointer.parent;
  17147. }
  17148. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17149. }
  17150. gazer._currentHit = hit;
  17151. // Moving the gazeTracker on the mesh face targetted
  17152. if (hit && hit.pickedPoint) {
  17153. if (this._displayGaze) {
  17154. var multiplier = 1;
  17155. gazer._gazeTracker.isVisible = true;
  17156. if (gazer._isActionableMesh) {
  17157. multiplier = 3;
  17158. }
  17159. if (this.updateGazeTrackerScale) {
  17160. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17161. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17162. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17163. }
  17164. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17165. // To avoid z-fighting
  17166. var deltaFighting = 0.002;
  17167. if (pickNormal) {
  17168. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17169. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17170. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17171. }
  17172. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17173. if (gazer._gazeTracker.position.x < 0) {
  17174. gazer._gazeTracker.position.x += deltaFighting;
  17175. }
  17176. else {
  17177. gazer._gazeTracker.position.x -= deltaFighting;
  17178. }
  17179. if (gazer._gazeTracker.position.y < 0) {
  17180. gazer._gazeTracker.position.y += deltaFighting;
  17181. }
  17182. else {
  17183. gazer._gazeTracker.position.y -= deltaFighting;
  17184. }
  17185. if (gazer._gazeTracker.position.z < 0) {
  17186. gazer._gazeTracker.position.z += deltaFighting;
  17187. }
  17188. else {
  17189. gazer._gazeTracker.position.z -= deltaFighting;
  17190. }
  17191. }
  17192. // Changing the size of the laser pointer based on the distance from the targetted point
  17193. gazer._updatePointerDistance(hit.distance);
  17194. }
  17195. else {
  17196. gazer._updatePointerDistance();
  17197. gazer._gazeTracker.isVisible = false;
  17198. }
  17199. if (hit && hit.pickedMesh) {
  17200. // The object selected is the floor, we're in a teleportation scenario
  17201. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17202. // Moving the teleportation area to this targetted point
  17203. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17204. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17205. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17206. }
  17207. gazer._currentMeshSelected = null;
  17208. if (gazer._teleportationRequestInitiated) {
  17209. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17210. }
  17211. return;
  17212. }
  17213. // If not, we're in a selection scenario
  17214. //this._teleportationAllowed = false;
  17215. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17216. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17217. this.onNewMeshPicked.notifyObservers(hit);
  17218. gazer._currentMeshSelected = hit.pickedMesh;
  17219. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17220. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17221. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17222. gazer._isActionableMesh = true;
  17223. }
  17224. else {
  17225. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17226. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17227. gazer._isActionableMesh = false;
  17228. }
  17229. try {
  17230. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17231. }
  17232. catch (err) {
  17233. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17234. }
  17235. }
  17236. else {
  17237. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17238. gazer._currentMeshSelected = null;
  17239. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17240. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17241. }
  17242. }
  17243. }
  17244. else {
  17245. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17246. gazer._currentMeshSelected = null;
  17247. //this._teleportationAllowed = false;
  17248. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17249. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17250. }
  17251. };
  17252. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17253. if (mesh) {
  17254. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17255. }
  17256. };
  17257. /**
  17258. * Sets the color of the laser ray from the vr controllers.
  17259. * @param color new color for the ray.
  17260. */
  17261. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17262. if (this._leftController) {
  17263. this._leftController._setLaserPointerColor(color);
  17264. }
  17265. if (this._rightController) {
  17266. this._rightController._setLaserPointerColor(color);
  17267. }
  17268. };
  17269. /**
  17270. * Sets the color of the ray from the vr headsets gaze.
  17271. * @param color new color for the ray.
  17272. */
  17273. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17274. if (!this.updateGazeTrackerColor) {
  17275. return;
  17276. }
  17277. if (!this._cameraGazer._gazeTracker.material) {
  17278. return;
  17279. }
  17280. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17281. if (this._leftController) {
  17282. this._leftController._gazeTracker.material.emissiveColor = color;
  17283. }
  17284. if (this._rightController) {
  17285. this._rightController._gazeTracker.material.emissiveColor = color;
  17286. }
  17287. };
  17288. /**
  17289. * Exits VR and disposes of the vr experience helper
  17290. */
  17291. VRExperienceHelper.prototype.dispose = function () {
  17292. if (this.isInVRMode) {
  17293. this.exitVR();
  17294. }
  17295. if (this._postProcessMove) {
  17296. this._postProcessMove.dispose();
  17297. }
  17298. if (this._webVRCamera) {
  17299. this._webVRCamera.dispose();
  17300. }
  17301. if (this._vrDeviceOrientationCamera) {
  17302. this._vrDeviceOrientationCamera.dispose();
  17303. }
  17304. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17305. document.body.removeChild(this._btnVR);
  17306. }
  17307. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17308. this._deviceOrientationCamera.dispose();
  17309. }
  17310. if (this._cameraGazer) {
  17311. this._cameraGazer.dispose();
  17312. }
  17313. if (this._leftController) {
  17314. this._leftController.dispose();
  17315. }
  17316. if (this._rightController) {
  17317. this._rightController.dispose();
  17318. }
  17319. if (this._teleportationTarget) {
  17320. this._teleportationTarget.dispose();
  17321. }
  17322. this._floorMeshesCollection = [];
  17323. document.removeEventListener("keydown", this._onKeyDown);
  17324. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17325. window.removeEventListener("resize", this._onResize);
  17326. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17327. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17328. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17329. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17330. document.onmsfullscreenchange = null;
  17331. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17332. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17333. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17334. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17335. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17336. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17337. this._scene.unregisterBeforeRender(this.beforeRender);
  17338. };
  17339. /**
  17340. * Gets the name of the VRExperienceHelper class
  17341. * @returns "VRExperienceHelper"
  17342. */
  17343. VRExperienceHelper.prototype.getClassName = function () {
  17344. return "VRExperienceHelper";
  17345. };
  17346. return VRExperienceHelper;
  17347. }());
  17348. /***/ }),
  17349. /***/ "./Cameras/VR/webVRCamera.ts":
  17350. /*!***********************************!*\
  17351. !*** ./Cameras/VR/webVRCamera.ts ***!
  17352. \***********************************/
  17353. /*! exports provided: WebVRFreeCamera */
  17354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17355. "use strict";
  17356. __webpack_require__.r(__webpack_exports__);
  17357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17359. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17360. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17361. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17362. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17363. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17364. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17365. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17366. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17367. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17368. // Side effect import to define the stereoscopic mode.
  17369. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17370. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17371. });
  17372. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17373. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17374. });
  17375. /**
  17376. * This represents a WebVR camera.
  17377. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17378. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17379. */
  17380. var WebVRFreeCamera = /** @class */ (function (_super) {
  17381. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17382. /**
  17383. * Instantiates a WebVRFreeCamera.
  17384. * @param name The name of the WebVRFreeCamera
  17385. * @param position The starting anchor position for the camera
  17386. * @param scene The scene the camera belongs to
  17387. * @param webVROptions a set of customizable options for the webVRCamera
  17388. */
  17389. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17390. if (webVROptions === void 0) { webVROptions = {}; }
  17391. var _this = _super.call(this, name, position, scene) || this;
  17392. _this.webVROptions = webVROptions;
  17393. /**
  17394. * @hidden
  17395. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17396. */
  17397. _this._vrDevice = null;
  17398. /**
  17399. * The rawPose of the vrDevice.
  17400. */
  17401. _this.rawPose = null;
  17402. _this._specsVersion = "1.1";
  17403. _this._attached = false;
  17404. _this._descendants = [];
  17405. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17406. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17407. /** @hidden */
  17408. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17409. _this._standingMatrix = null;
  17410. /**
  17411. * Represents device position in babylon space.
  17412. */
  17413. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17414. /**
  17415. * Represents device rotation in babylon space.
  17416. */
  17417. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17418. /**
  17419. * The scale of the device to be used when translating from device space to babylon space.
  17420. */
  17421. _this.deviceScaleFactor = 1;
  17422. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17423. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17424. /**
  17425. * References to the webVR controllers for the vrDevice.
  17426. */
  17427. _this.controllers = [];
  17428. /**
  17429. * Emits an event when a controller is attached.
  17430. */
  17431. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17432. /**
  17433. * Emits an event when a controller's mesh has been loaded;
  17434. */
  17435. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17436. /**
  17437. * Emits an event when the HMD's pose has been updated.
  17438. */
  17439. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17440. _this._poseSet = false;
  17441. /**
  17442. * If the rig cameras be used as parent instead of this camera.
  17443. */
  17444. _this.rigParenting = true;
  17445. _this._defaultHeight = undefined;
  17446. _this._htmlElementAttached = null;
  17447. _this._detachIfAttached = function () {
  17448. var vrDisplay = _this.getEngine().getVRDevice();
  17449. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17450. _this.detachControl(_this._htmlElementAttached);
  17451. }
  17452. };
  17453. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17454. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17455. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17456. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17457. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17458. if (webVROptions.defaultHeight) {
  17459. _this._defaultHeight = webVROptions.defaultHeight;
  17460. _this.position.y = _this._defaultHeight;
  17461. }
  17462. _this.minZ = 0.1;
  17463. //legacy support - the compensation boolean was removed.
  17464. if (arguments.length === 5) {
  17465. _this.webVROptions = arguments[4];
  17466. }
  17467. // default webVR options
  17468. if (_this.webVROptions.trackPosition == undefined) {
  17469. _this.webVROptions.trackPosition = true;
  17470. }
  17471. if (_this.webVROptions.controllerMeshes == undefined) {
  17472. _this.webVROptions.controllerMeshes = true;
  17473. }
  17474. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17475. _this.webVROptions.defaultLightingOnControllers = true;
  17476. }
  17477. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17478. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17479. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17480. }
  17481. //enable VR
  17482. var engine = _this.getEngine();
  17483. _this._onVREnabled = function (success) { if (success) {
  17484. _this.initControllers();
  17485. } };
  17486. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17487. engine.initWebVR().add(function (event) {
  17488. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17489. return;
  17490. }
  17491. _this._vrDevice = event.vrDisplay;
  17492. //reset the rig parameters.
  17493. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17494. if (_this._attached) {
  17495. _this.getEngine().enableVR();
  17496. }
  17497. });
  17498. if (typeof (VRFrameData) !== "undefined") {
  17499. _this._frameData = new VRFrameData();
  17500. }
  17501. /**
  17502. * The idea behind the following lines:
  17503. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17504. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17505. * the second will not show it correctly.
  17506. *
  17507. * To solve this - each object that has the camera as parent will be added to a protected array.
  17508. * When the rig camera renders, it will take this array and set all of those to be its children.
  17509. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17510. * Amazing!
  17511. */
  17512. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17513. if (camera.parent === _this && _this.rigParenting) {
  17514. _this._descendants = _this.getDescendants(true, function (n) {
  17515. // don't take the cameras or the controllers!
  17516. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17517. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17518. return !isController && !isRigCamera;
  17519. });
  17520. _this._descendants.forEach(function (node) {
  17521. node.parent = camera;
  17522. });
  17523. }
  17524. });
  17525. scene.onAfterCameraRenderObservable.add(function (camera) {
  17526. if (camera.parent === _this && _this.rigParenting) {
  17527. _this._descendants.forEach(function (node) {
  17528. node.parent = _this;
  17529. });
  17530. }
  17531. });
  17532. return _this;
  17533. }
  17534. /**
  17535. * Gets the device distance from the ground in meters.
  17536. * @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.
  17537. */
  17538. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17539. if (this._standingMatrix) {
  17540. // Add standing matrix offset to get real offset from ground in room
  17541. this._standingMatrix.getTranslationToRef(this._workingVector);
  17542. return this._deviceRoomPosition.y + this._workingVector.y;
  17543. }
  17544. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17545. return this._defaultHeight || 0;
  17546. };
  17547. /**
  17548. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17549. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17550. */
  17551. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17552. var _this = this;
  17553. if (callback === void 0) { callback = function (bool) { }; }
  17554. // Use standing matrix if available
  17555. this.getEngine().initWebVRAsync().then(function (result) {
  17556. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17557. callback(false);
  17558. }
  17559. else {
  17560. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17561. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17562. if (!_this.getScene().useRightHandedSystem) {
  17563. if (_this._standingMatrix) {
  17564. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17565. }
  17566. }
  17567. callback(true);
  17568. }
  17569. });
  17570. };
  17571. /**
  17572. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17573. * @returns A promise with a boolean set to if the standing matrix is supported.
  17574. */
  17575. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17576. var _this = this;
  17577. return new Promise(function (res) {
  17578. _this.useStandingMatrix(function (supported) {
  17579. res(supported);
  17580. });
  17581. });
  17582. };
  17583. /**
  17584. * Disposes the camera
  17585. */
  17586. WebVRFreeCamera.prototype.dispose = function () {
  17587. this._detachIfAttached();
  17588. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17589. if (this._updateCacheWhenTrackingDisabledObserver) {
  17590. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17591. }
  17592. _super.prototype.dispose.call(this);
  17593. };
  17594. /**
  17595. * Gets a vrController by name.
  17596. * @param name The name of the controller to retreive
  17597. * @returns the controller matching the name specified or null if not found
  17598. */
  17599. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17600. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17601. var gp = _a[_i];
  17602. if (gp.hand === name) {
  17603. return gp;
  17604. }
  17605. }
  17606. return null;
  17607. };
  17608. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17609. /**
  17610. * The controller corrisponding to the users left hand.
  17611. */
  17612. get: function () {
  17613. if (!this._leftController) {
  17614. this._leftController = this.getControllerByName("left");
  17615. }
  17616. return this._leftController;
  17617. },
  17618. enumerable: true,
  17619. configurable: true
  17620. });
  17621. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17622. /**
  17623. * The controller corrisponding to the users right hand.
  17624. */
  17625. get: function () {
  17626. if (!this._rightController) {
  17627. this._rightController = this.getControllerByName("right");
  17628. }
  17629. return this._rightController;
  17630. },
  17631. enumerable: true,
  17632. configurable: true
  17633. });
  17634. /**
  17635. * Casts a ray forward from the vrCamera's gaze.
  17636. * @param length Length of the ray (default: 100)
  17637. * @returns the ray corrisponding to the gaze
  17638. */
  17639. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17640. if (length === void 0) { length = 100; }
  17641. if (this.leftCamera) {
  17642. // Use left eye to avoid computation to compute center on every call
  17643. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17644. }
  17645. else {
  17646. return _super.prototype.getForwardRay.call(this, length);
  17647. }
  17648. };
  17649. /**
  17650. * @hidden
  17651. * Updates the camera based on device's frame data
  17652. */
  17653. WebVRFreeCamera.prototype._checkInputs = function () {
  17654. if (this._vrDevice && this._vrDevice.isPresenting) {
  17655. this._vrDevice.getFrameData(this._frameData);
  17656. this.updateFromDevice(this._frameData.pose);
  17657. }
  17658. _super.prototype._checkInputs.call(this);
  17659. };
  17660. /**
  17661. * Updates the poseControlled values based on the input device pose.
  17662. * @param poseData Pose coming from the device
  17663. */
  17664. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17665. if (poseData && poseData.orientation) {
  17666. this.rawPose = poseData;
  17667. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17668. if (this.getScene().useRightHandedSystem) {
  17669. this._deviceRoomRotationQuaternion.z *= -1;
  17670. this._deviceRoomRotationQuaternion.w *= -1;
  17671. }
  17672. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17673. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17674. if (this.getScene().useRightHandedSystem) {
  17675. this._deviceRoomPosition.z *= -1;
  17676. }
  17677. }
  17678. this._poseSet = true;
  17679. }
  17680. };
  17681. /**
  17682. * WebVR's attach control will start broadcasting frames to the device.
  17683. * Note that in certain browsers (chrome for example) this function must be called
  17684. * within a user-interaction callback. Example:
  17685. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17686. *
  17687. * @param element html element to attach the vrDevice to
  17688. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17689. */
  17690. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17691. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17692. this._attached = true;
  17693. this._htmlElementAttached = element;
  17694. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17695. if (this._vrDevice) {
  17696. this.getEngine().enableVR();
  17697. }
  17698. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17699. };
  17700. /**
  17701. * Detaches the camera from the html element and disables VR
  17702. *
  17703. * @param element html element to detach from
  17704. */
  17705. WebVRFreeCamera.prototype.detachControl = function (element) {
  17706. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17707. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17708. _super.prototype.detachControl.call(this, element);
  17709. this._attached = false;
  17710. this.getEngine().disableVR();
  17711. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17712. };
  17713. /**
  17714. * @returns the name of this class
  17715. */
  17716. WebVRFreeCamera.prototype.getClassName = function () {
  17717. return "WebVRFreeCamera";
  17718. };
  17719. /**
  17720. * Calls resetPose on the vrDisplay
  17721. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17722. */
  17723. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17724. //uses the vrDisplay's "resetPose()".
  17725. //pitch and roll won't be affected.
  17726. this._vrDevice.resetPose();
  17727. };
  17728. /**
  17729. * @hidden
  17730. * Updates the rig cameras (left and right eye)
  17731. */
  17732. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17733. var camLeft = this._rigCameras[0];
  17734. var camRight = this._rigCameras[1];
  17735. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17736. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17737. camLeft.position.copyFrom(this._deviceRoomPosition);
  17738. camRight.position.copyFrom(this._deviceRoomPosition);
  17739. };
  17740. // Remove translation from 6dof headset if trackposition is set to false
  17741. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17742. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17743. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17744. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17745. if (!isViewMatrix) {
  17746. this._tmpMatrix.invert();
  17747. }
  17748. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17749. }
  17750. };
  17751. /**
  17752. * @hidden
  17753. * Updates the cached values of the camera
  17754. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17755. */
  17756. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17757. var _this = this;
  17758. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17759. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17760. if (!this.updateCacheCalled) {
  17761. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17762. this.updateCacheCalled = true;
  17763. this.update();
  17764. }
  17765. // Set working vector to the device position in room space rotated by the new rotation
  17766. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17767. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17768. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17769. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17770. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17771. // Add translation from anchor position
  17772. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17773. this._workingVector.addInPlace(this.position);
  17774. this._workingVector.subtractInPlace(this._cache.position);
  17775. this._deviceToWorld.setTranslation(this._workingVector);
  17776. // Set an inverted matrix to be used when updating the camera
  17777. this._deviceToWorld.invertToRef(this._worldToDevice);
  17778. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17779. this.controllers.forEach(function (controller) {
  17780. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17781. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17782. controller.update();
  17783. });
  17784. }
  17785. if (!ignoreParentClass) {
  17786. _super.prototype._updateCache.call(this);
  17787. }
  17788. this.updateCacheCalled = false;
  17789. };
  17790. /**
  17791. * @hidden
  17792. * Get current device position in babylon world
  17793. */
  17794. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17795. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17796. };
  17797. /**
  17798. * Updates the current device position and rotation in the babylon world
  17799. */
  17800. WebVRFreeCamera.prototype.update = function () {
  17801. this._computeDevicePosition();
  17802. // Get current device rotation in babylon world
  17803. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17804. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17805. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17806. if (this._poseSet) {
  17807. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17808. }
  17809. _super.prototype.update.call(this);
  17810. };
  17811. /**
  17812. * @hidden
  17813. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17814. * @returns an identity matrix
  17815. */
  17816. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17817. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17818. };
  17819. /**
  17820. * This function is called by the two RIG cameras.
  17821. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17822. * @hidden
  17823. */
  17824. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17825. // Update the parent camera prior to using a child camera to avoid desynchronization
  17826. var parentCamera = this._cameraRigParams["parentCamera"];
  17827. parentCamera._updateCache();
  17828. //WebVR 1.1
  17829. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17830. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17831. if (!this.getScene().useRightHandedSystem) {
  17832. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17833. }
  17834. // update the camera rotation matrix
  17835. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17836. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17837. // Computing target and final matrix
  17838. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17839. // should the view matrix be updated with scale and position offset?
  17840. if (parentCamera.deviceScaleFactor !== 1) {
  17841. this._webvrViewMatrix.invert();
  17842. // scale the position, if set
  17843. if (parentCamera.deviceScaleFactor) {
  17844. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17845. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17846. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17847. }
  17848. this._webvrViewMatrix.invert();
  17849. }
  17850. // Remove translation from 6dof headset if trackposition is set to false
  17851. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17852. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17853. // Compute global position
  17854. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17855. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17856. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17857. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17858. this._markSyncedWithParent();
  17859. return this._webvrViewMatrix;
  17860. };
  17861. /** @hidden */
  17862. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17863. var parentCamera = this.parent;
  17864. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17865. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17866. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17867. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17868. //babylon compatible matrix
  17869. if (!this.getScene().useRightHandedSystem) {
  17870. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17871. }
  17872. return this._projectionMatrix;
  17873. };
  17874. /**
  17875. * Initializes the controllers and their meshes
  17876. */
  17877. WebVRFreeCamera.prototype.initControllers = function () {
  17878. var _this = this;
  17879. this.controllers = [];
  17880. var manager = this.getScene().gamepadManager;
  17881. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17882. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17883. var webVrController = gamepad;
  17884. if (webVrController.defaultModel) {
  17885. webVrController.defaultModel.setEnabled(false);
  17886. }
  17887. if (webVrController.hand === "right") {
  17888. _this._rightController = null;
  17889. }
  17890. if (webVrController.hand === "left") {
  17891. _this._leftController = null;
  17892. }
  17893. var controllerIndex = _this.controllers.indexOf(webVrController);
  17894. if (controllerIndex !== -1) {
  17895. _this.controllers.splice(controllerIndex, 1);
  17896. }
  17897. }
  17898. });
  17899. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17900. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17901. var webVrController_1 = gamepad;
  17902. if (!_this.webVROptions.trackPosition) {
  17903. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17904. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17905. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17906. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17907. _this._updateCache();
  17908. });
  17909. }
  17910. }
  17911. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17912. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17913. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17914. if (_this.webVROptions.controllerMeshes) {
  17915. if (webVrController_1.defaultModel) {
  17916. webVrController_1.defaultModel.setEnabled(true);
  17917. }
  17918. else {
  17919. // Load the meshes
  17920. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17921. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17922. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17923. if (_this.webVROptions.defaultLightingOnControllers) {
  17924. if (!_this._lightOnControllers) {
  17925. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17926. }
  17927. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17928. var children = mesh.getChildren();
  17929. if (children && children.length !== 0) {
  17930. children.forEach(function (mesh) {
  17931. light.includedOnlyMeshes.push(mesh);
  17932. activateLightOnSubMeshes_1(mesh, light);
  17933. });
  17934. }
  17935. };
  17936. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17937. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17938. }
  17939. });
  17940. }
  17941. }
  17942. webVrController_1.attachToPoseControlledCamera(_this);
  17943. // since this is async - sanity check. Is the controller already stored?
  17944. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17945. //add to the controllers array
  17946. _this.controllers.push(webVrController_1);
  17947. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17948. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17949. // So we're overriding setting left & right manually to be sure
  17950. var firstViveWandDetected = false;
  17951. for (var i = 0; i < _this.controllers.length; i++) {
  17952. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17953. if (!firstViveWandDetected) {
  17954. firstViveWandDetected = true;
  17955. _this.controllers[i].hand = "left";
  17956. }
  17957. else {
  17958. _this.controllers[i].hand = "right";
  17959. }
  17960. }
  17961. }
  17962. //did we find enough controllers? Great! let the developer know.
  17963. if (_this.controllers.length >= 2) {
  17964. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17965. }
  17966. }
  17967. }
  17968. });
  17969. };
  17970. return WebVRFreeCamera;
  17971. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17972. /***/ }),
  17973. /***/ "./Cameras/XR/index.ts":
  17974. /*!*****************************!*\
  17975. !*** ./Cameras/XR/index.ts ***!
  17976. \*****************************/
  17977. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17979. "use strict";
  17980. __webpack_require__.r(__webpack_exports__);
  17981. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17983. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  17985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  17986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  17987. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  17989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  17990. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  17991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  17992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  17993. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  17994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  17995. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  17997. /***/ }),
  17998. /***/ "./Cameras/XR/webXRCamera.ts":
  17999. /*!***********************************!*\
  18000. !*** ./Cameras/XR/webXRCamera.ts ***!
  18001. \***********************************/
  18002. /*! exports provided: WebXRCamera */
  18003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18004. "use strict";
  18005. __webpack_require__.r(__webpack_exports__);
  18006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18007. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18008. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18009. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18010. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18011. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18012. /**
  18013. * WebXR Camera which holds the views for the xrSession
  18014. * @see https://doc.babylonjs.com/how_to/webxr
  18015. */
  18016. var WebXRCamera = /** @class */ (function (_super) {
  18017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18018. /**
  18019. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18020. * @param name the name of the camera
  18021. * @param scene the scene to add the camera to
  18022. */
  18023. function WebXRCamera(name, scene) {
  18024. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18025. // Initial camera configuration
  18026. _this.minZ = 0;
  18027. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18028. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18029. _this.updateUpVectorFromRotation = true;
  18030. _this._updateNumberOfRigCameras(1);
  18031. return _this;
  18032. }
  18033. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18034. if (viewCount === void 0) { viewCount = 1; }
  18035. while (this.rigCameras.length < viewCount) {
  18036. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18037. newCamera.minZ = 0;
  18038. newCamera.parent = this;
  18039. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18040. newCamera.updateUpVectorFromRotation = true;
  18041. this.rigCameras.push(newCamera);
  18042. }
  18043. while (this.rigCameras.length > viewCount) {
  18044. var removedCamera = this.rigCameras.pop();
  18045. if (removedCamera) {
  18046. removedCamera.dispose();
  18047. }
  18048. }
  18049. };
  18050. /** @hidden */
  18051. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18052. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18053. // Create initial camera rigs
  18054. this._updateNumberOfRigCameras(2);
  18055. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18056. this.rigCameras[0].position.x = -pupilDistance / 2;
  18057. this.rigCameras[0].outputRenderTarget = null;
  18058. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18059. this.rigCameras[1].position.x = pupilDistance / 2;
  18060. this.rigCameras[1].outputRenderTarget = null;
  18061. };
  18062. /**
  18063. * Updates the cameras position from the current pose information of the XR session
  18064. * @param xrSessionManager the session containing pose information
  18065. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18066. */
  18067. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18068. var _this = this;
  18069. // Ensure all frame data is available
  18070. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18071. return false;
  18072. }
  18073. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18074. if (!pose || !pose.poseModelMatrix) {
  18075. return false;
  18076. }
  18077. // Update the parent cameras matrix
  18078. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18079. if (!this._scene.useRightHandedSystem) {
  18080. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18081. }
  18082. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18083. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18084. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18085. this.computeWorldMatrix();
  18086. // Update camera rigs
  18087. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18088. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18089. // Update view/projection matrix
  18090. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18091. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18092. if (!_this._scene.useRightHandedSystem) {
  18093. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18094. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18095. }
  18096. // Update viewport
  18097. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18098. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18099. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18100. _this.rigCameras[i].viewport.width = viewport.width / width;
  18101. _this.rigCameras[i].viewport.height = viewport.height / height;
  18102. _this.rigCameras[i].viewport.x = viewport.x / width;
  18103. _this.rigCameras[i].viewport.y = viewport.y / height;
  18104. // Set cameras to render to the session's render target
  18105. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18106. });
  18107. return true;
  18108. };
  18109. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18110. return WebXRCamera;
  18111. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18112. /***/ }),
  18113. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18114. /*!****************************************!*\
  18115. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18116. \****************************************/
  18117. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18119. "use strict";
  18120. __webpack_require__.r(__webpack_exports__);
  18121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18124. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18125. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18126. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18127. /**
  18128. * Button which can be used to enter a different mode of XR
  18129. */
  18130. var WebXREnterExitUIButton = /** @class */ (function () {
  18131. /**
  18132. * Creates a WebXREnterExitUIButton
  18133. * @param element button element
  18134. * @param initializationOptions XR initialization options for the button
  18135. */
  18136. function WebXREnterExitUIButton(
  18137. /** button element */
  18138. element,
  18139. /** XR initialization options for the button */
  18140. initializationOptions) {
  18141. this.element = element;
  18142. this.initializationOptions = initializationOptions;
  18143. }
  18144. /**
  18145. * Overwritable function which can be used to update the button's visuals when the state changes
  18146. * @param activeButton the current active button in the UI
  18147. */
  18148. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18149. };
  18150. return WebXREnterExitUIButton;
  18151. }());
  18152. /**
  18153. * Options to create the webXR UI
  18154. */
  18155. var WebXREnterExitUIOptions = /** @class */ (function () {
  18156. function WebXREnterExitUIOptions() {
  18157. }
  18158. return WebXREnterExitUIOptions;
  18159. }());
  18160. /**
  18161. * UI to allow the user to enter/exit XR mode
  18162. */
  18163. var WebXREnterExitUI = /** @class */ (function () {
  18164. function WebXREnterExitUI(scene, options) {
  18165. var _this = this;
  18166. this.scene = scene;
  18167. this._buttons = [];
  18168. this._activeButton = null;
  18169. /**
  18170. * Fired every time the active button is changed.
  18171. *
  18172. * When xr is entered via a button that launches xr that button will be the callback parameter
  18173. *
  18174. * When exiting xr the callback parameter will be null)
  18175. */
  18176. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18177. this._overlay = document.createElement("div");
  18178. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18179. if (options.customButtons) {
  18180. this._buttons = options.customButtons;
  18181. }
  18182. else {
  18183. var hmdBtn = document.createElement("button");
  18184. 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;";
  18185. hmdBtn.innerText = "HMD";
  18186. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18187. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18188. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18189. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18190. };
  18191. var windowBtn = document.createElement("button");
  18192. windowBtn.style.cssText = hmdBtn.style.cssText;
  18193. windowBtn.innerText = "Window";
  18194. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18195. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18196. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18197. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18198. };
  18199. this._updateButtons(null);
  18200. }
  18201. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18202. if (renderCanvas && renderCanvas.parentNode) {
  18203. renderCanvas.parentNode.appendChild(this._overlay);
  18204. scene.onDisposeObservable.addOnce(function () {
  18205. _this.dispose();
  18206. });
  18207. }
  18208. }
  18209. /**
  18210. * Creates UI to allow the user to enter/exit XR mode
  18211. * @param scene the scene to add the ui to
  18212. * @param helper the xr experience helper to enter/exit xr with
  18213. * @param options options to configure the UI
  18214. * @returns the created ui
  18215. */
  18216. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18217. var _this = this;
  18218. var ui = new WebXREnterExitUI(scene, options);
  18219. var supportedPromises = ui._buttons.map(function (btn) {
  18220. return helper.supportsSessionAsync(btn.initializationOptions);
  18221. });
  18222. helper.onStateChangedObservable.add(function (state) {
  18223. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18224. ui._updateButtons(null);
  18225. }
  18226. });
  18227. return Promise.all(supportedPromises).then(function (results) {
  18228. results.forEach(function (supported, i) {
  18229. if (supported) {
  18230. ui._overlay.appendChild(ui._buttons[i].element);
  18231. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18232. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18233. switch (_a.label) {
  18234. case 0:
  18235. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18236. ui._updateButtons(null);
  18237. return [4 /*yield*/, helper.exitXRAsync()];
  18238. case 1:
  18239. _a.sent();
  18240. return [2 /*return*/];
  18241. case 2:
  18242. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18243. ui._updateButtons(ui._buttons[i]);
  18244. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18245. case 3:
  18246. _a.sent();
  18247. _a.label = 4;
  18248. case 4: return [2 /*return*/];
  18249. }
  18250. });
  18251. }); };
  18252. }
  18253. });
  18254. return ui;
  18255. });
  18256. };
  18257. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18258. var _this = this;
  18259. this._activeButton = activeButton;
  18260. this._buttons.forEach(function (b) {
  18261. b.update(_this._activeButton);
  18262. });
  18263. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18264. };
  18265. /**
  18266. * Disposes of the object
  18267. */
  18268. WebXREnterExitUI.prototype.dispose = function () {
  18269. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18270. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18271. renderCanvas.parentNode.removeChild(this._overlay);
  18272. }
  18273. this.activeButtonChangedObservable.clear();
  18274. };
  18275. return WebXREnterExitUI;
  18276. }());
  18277. /***/ }),
  18278. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18279. /*!*********************************************!*\
  18280. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18281. \*********************************************/
  18282. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18284. "use strict";
  18285. __webpack_require__.r(__webpack_exports__);
  18286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18288. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18289. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18290. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18291. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18292. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18293. /**
  18294. * States of the webXR experience
  18295. */
  18296. var WebXRState;
  18297. (function (WebXRState) {
  18298. /**
  18299. * Transitioning to being in XR mode
  18300. */
  18301. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18302. /**
  18303. * Transitioning to non XR mode
  18304. */
  18305. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18306. /**
  18307. * In XR mode and presenting
  18308. */
  18309. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18310. /**
  18311. * Not entered XR mode
  18312. */
  18313. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18314. })(WebXRState || (WebXRState = {}));
  18315. /**
  18316. * Helper class used to enable XR
  18317. * @see https://doc.babylonjs.com/how_to/webxr
  18318. */
  18319. var WebXRExperienceHelper = /** @class */ (function () {
  18320. /**
  18321. * Creates a WebXRExperienceHelper
  18322. * @param scene The scene the helper should be created in
  18323. */
  18324. function WebXRExperienceHelper(scene) {
  18325. this.scene = scene;
  18326. /**
  18327. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18328. */
  18329. this.state = WebXRState.NOT_IN_XR;
  18330. /**
  18331. * Fires when the state of the experience helper has changed
  18332. */
  18333. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18334. this._nonVRCamera = null;
  18335. this._originalSceneAutoClear = true;
  18336. this._supported = false;
  18337. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18338. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18339. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18340. this.camera.parent = this.container;
  18341. }
  18342. WebXRExperienceHelper.prototype._setState = function (val) {
  18343. this.state = val;
  18344. this.onStateChangedObservable.notifyObservers(this.state);
  18345. };
  18346. /**
  18347. * Creates the experience helper
  18348. * @param scene the scene to attach the experience helper to
  18349. * @returns a promise for the experience helper
  18350. */
  18351. WebXRExperienceHelper.CreateAsync = function (scene) {
  18352. var helper = new WebXRExperienceHelper(scene);
  18353. return helper._sessionManager.initializeAsync().then(function () {
  18354. helper._supported = true;
  18355. return helper;
  18356. }).catch(function () {
  18357. return helper;
  18358. });
  18359. };
  18360. /**
  18361. * Exits XR mode and returns the scene to its original state
  18362. * @returns promise that resolves after xr mode has exited
  18363. */
  18364. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18365. this._setState(WebXRState.EXITING_XR);
  18366. return this._sessionManager.exitXRAsync();
  18367. };
  18368. /**
  18369. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18370. * @param sessionCreationOptions options for the XR session
  18371. * @param frameOfReference frame of reference of the XR session
  18372. * @returns promise that resolves after xr mode has entered
  18373. */
  18374. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18375. var _this = this;
  18376. if (!this._supported) {
  18377. throw "XR session not supported by this browser";
  18378. }
  18379. this._setState(WebXRState.ENTERING_XR);
  18380. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18381. // Cache pre xr scene settings
  18382. _this._originalSceneAutoClear = _this.scene.autoClear;
  18383. _this._nonVRCamera = _this.scene.activeCamera;
  18384. // Overwrite current scene settings
  18385. _this.scene.autoClear = false;
  18386. _this.scene.activeCamera = _this.camera;
  18387. _this._sessionManager.onXRFrameObservable.add(function () {
  18388. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18389. });
  18390. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18391. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18392. _this.camera.rigCameras.forEach(function (c) {
  18393. c.outputRenderTarget = null;
  18394. });
  18395. // Restore scene settings
  18396. _this.scene.autoClear = _this._originalSceneAutoClear;
  18397. _this.scene.activeCamera = _this._nonVRCamera;
  18398. _this._sessionManager.onXRFrameObservable.clear();
  18399. _this._setState(WebXRState.NOT_IN_XR);
  18400. });
  18401. _this._setState(WebXRState.IN_XR);
  18402. });
  18403. };
  18404. /**
  18405. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18406. * @param ray ray to cast into the environment
  18407. * @returns Promise which resolves with a collision point in the environment if it exists
  18408. */
  18409. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18410. return this._sessionManager.environmentPointHitTestAsync(ray);
  18411. };
  18412. /**
  18413. * Updates the global position of the camera by moving the camera's container
  18414. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18415. * @param position The desired global position of the camera
  18416. */
  18417. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18418. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18419. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18420. };
  18421. /**
  18422. * Rotates the xr camera by rotating the camera's container around the camera's position
  18423. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18424. * @param rotation the desired quaternion rotation to apply to the camera
  18425. */
  18426. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18427. if (!this.container.rotationQuaternion) {
  18428. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18429. }
  18430. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18431. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18432. };
  18433. /**
  18434. * Checks if the creation options are supported by the xr session
  18435. * @param options creation options
  18436. * @returns true if supported
  18437. */
  18438. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18439. if (!this._supported) {
  18440. return Promise.resolve(false);
  18441. }
  18442. return this._sessionManager.supportsSessionAsync(options);
  18443. };
  18444. /**
  18445. * Disposes of the experience helper
  18446. */
  18447. WebXRExperienceHelper.prototype.dispose = function () {
  18448. this.camera.dispose();
  18449. this.container.dispose();
  18450. this.onStateChangedObservable.clear();
  18451. this._sessionManager.dispose();
  18452. };
  18453. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18454. return WebXRExperienceHelper;
  18455. }());
  18456. /***/ }),
  18457. /***/ "./Cameras/XR/webXRInput.ts":
  18458. /*!**********************************!*\
  18459. !*** ./Cameras/XR/webXRInput.ts ***!
  18460. \**********************************/
  18461. /*! exports provided: WebXRController, WebXRInput */
  18462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18463. "use strict";
  18464. __webpack_require__.r(__webpack_exports__);
  18465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18468. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18469. /**
  18470. * Represents an XR input
  18471. */
  18472. var WebXRController = /** @class */ (function () {
  18473. /**
  18474. * Creates the controller
  18475. * @see https://doc.babylonjs.com/how_to/webxr
  18476. * @param scene the scene which the controller should be associated to
  18477. */
  18478. function WebXRController(scene) {
  18479. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18480. }
  18481. /**
  18482. * Disposes of the object
  18483. */
  18484. WebXRController.prototype.dispose = function () {
  18485. if (this.grip) {
  18486. this.grip.dispose();
  18487. }
  18488. this.pointer.dispose();
  18489. };
  18490. return WebXRController;
  18491. }());
  18492. /**
  18493. * XR input used to track XR inputs such as controllers/rays
  18494. */
  18495. var WebXRInput = /** @class */ (function () {
  18496. /**
  18497. * Initializes the WebXRInput
  18498. * @param helper experience helper which the input should be created for
  18499. */
  18500. function WebXRInput(helper) {
  18501. var _this = this;
  18502. this.helper = helper;
  18503. /**
  18504. * XR controllers being tracked
  18505. */
  18506. this.controllers = [];
  18507. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18508. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18509. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18510. return;
  18511. }
  18512. var xrFrame = helper._sessionManager._currentXRFrame;
  18513. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18514. inputSources.forEach(function (input, i) {
  18515. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18516. if (inputPose) {
  18517. if (_this.controllers.length <= i) {
  18518. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18519. }
  18520. var controller = _this.controllers[i];
  18521. // Manage the grip if it exists
  18522. if (inputPose.gripMatrix) {
  18523. if (!controller.grip) {
  18524. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18525. }
  18526. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18527. if (!controller.grip.getScene().useRightHandedSystem) {
  18528. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18529. }
  18530. if (!controller.grip.rotationQuaternion) {
  18531. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18532. }
  18533. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18534. }
  18535. // Manager pointer of controller
  18536. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18537. if (!controller.pointer.getScene().useRightHandedSystem) {
  18538. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18539. }
  18540. if (!controller.pointer.rotationQuaternion) {
  18541. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18542. }
  18543. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18544. }
  18545. });
  18546. });
  18547. }
  18548. /**
  18549. * Disposes of the object
  18550. */
  18551. WebXRInput.prototype.dispose = function () {
  18552. this.controllers.forEach(function (c) {
  18553. c.dispose();
  18554. });
  18555. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18556. };
  18557. return WebXRInput;
  18558. }());
  18559. /***/ }),
  18560. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18561. /*!************************************************!*\
  18562. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18563. \************************************************/
  18564. /*! exports provided: WebXRManagedOutputCanvas */
  18565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18566. "use strict";
  18567. __webpack_require__.r(__webpack_exports__);
  18568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18569. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18570. /**
  18571. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18572. */
  18573. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18574. /**
  18575. * Initializes the canvas to be added/removed upon entering/exiting xr
  18576. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18577. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18578. */
  18579. function WebXRManagedOutputCanvas(helper, canvas) {
  18580. var _this = this;
  18581. this._canvas = null;
  18582. /**
  18583. * xrpresent context of the canvas which can be used to display/mirror xr content
  18584. */
  18585. this.canvasContext = null;
  18586. if (!canvas) {
  18587. canvas = document.createElement('canvas');
  18588. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18589. }
  18590. this._setManagedOutputCanvas(canvas);
  18591. helper.onStateChangedObservable.add(function (stateInfo) {
  18592. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18593. // 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
  18594. _this._addCanvas();
  18595. }
  18596. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18597. _this._removeCanvas();
  18598. }
  18599. });
  18600. }
  18601. /**
  18602. * Disposes of the object
  18603. */
  18604. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18605. this._removeCanvas();
  18606. this._setManagedOutputCanvas(null);
  18607. };
  18608. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18609. this._removeCanvas();
  18610. if (!canvas) {
  18611. this._canvas = null;
  18612. this.canvasContext = null;
  18613. }
  18614. else {
  18615. this._canvas = canvas;
  18616. this.canvasContext = this._canvas.getContext('xrpresent');
  18617. }
  18618. };
  18619. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18620. if (this._canvas) {
  18621. document.body.appendChild(this._canvas);
  18622. }
  18623. };
  18624. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18625. if (this._canvas && document.body.contains(this._canvas)) {
  18626. document.body.removeChild(this._canvas);
  18627. }
  18628. };
  18629. return WebXRManagedOutputCanvas;
  18630. }());
  18631. /***/ }),
  18632. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18633. /*!*******************************************!*\
  18634. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18635. \*******************************************/
  18636. /*! exports provided: WebXRSessionManager */
  18637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18638. "use strict";
  18639. __webpack_require__.r(__webpack_exports__);
  18640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18641. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18642. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18643. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18644. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18645. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18646. /**
  18647. * Manages an XRSession
  18648. * @see https://doc.babylonjs.com/how_to/webxr
  18649. */
  18650. var WebXRSessionManager = /** @class */ (function () {
  18651. /**
  18652. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18653. * @param scene The scene which the session should be created for
  18654. */
  18655. function WebXRSessionManager(scene) {
  18656. this.scene = scene;
  18657. /**
  18658. * Fires every time a new xrFrame arrives which can be used to update the camera
  18659. */
  18660. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18661. /**
  18662. * Fires when the xr session is ended either by the device or manually done
  18663. */
  18664. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18665. /** @hidden */
  18666. this._sessionRenderTargetTexture = null;
  18667. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18668. }
  18669. /**
  18670. * Initializes the manager
  18671. * After initialization enterXR can be called to start an XR session
  18672. * @returns Promise which resolves after it is initialized
  18673. */
  18674. WebXRSessionManager.prototype.initializeAsync = function () {
  18675. var _this = this;
  18676. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18677. // Check if the browser supports webXR
  18678. this._xrNavigator = navigator;
  18679. if (!this._xrNavigator.xr) {
  18680. return Promise.reject("webXR not supported by this browser");
  18681. }
  18682. // Request the webXR device
  18683. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18684. _this._xrDevice = device;
  18685. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18686. });
  18687. };
  18688. /**
  18689. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18690. * @param sessionCreationOptions xr options to create the session with
  18691. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18692. * @returns Promise which resolves after it enters XR
  18693. */
  18694. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18695. var _this = this;
  18696. // initialize session
  18697. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18698. _this._xrSession = session;
  18699. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18700. _this._xrSession.addEventListener("end", function () {
  18701. // Remove render target texture and notify frame obervers
  18702. _this._sessionRenderTargetTexture = null;
  18703. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18704. _this.scene.getEngine().restoreDefaultFramebuffer();
  18705. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18706. _this.scene.getEngine().customAnimationFrameRequester = null;
  18707. _this.onXRSessionEnded.notifyObservers(null);
  18708. _this.scene.getEngine()._renderLoop();
  18709. }, { once: true });
  18710. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18711. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18712. }).then(function (frameOfRef) {
  18713. _this._frameOfReference = frameOfRef;
  18714. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18715. _this.scene.getEngine().customAnimationFrameRequester = {
  18716. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18717. renderFunction: function (timestamp, xrFrame) {
  18718. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18719. _this._currentXRFrame = xrFrame;
  18720. _this.onXRFrameObservable.notifyObservers(null);
  18721. _this.scene.getEngine()._renderLoop();
  18722. }
  18723. };
  18724. // Create render target texture from xr's webgl render target
  18725. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18726. // Stop window's animation frame and trigger sessions animation frame
  18727. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18728. _this.scene.getEngine()._renderLoop();
  18729. });
  18730. };
  18731. /**
  18732. * Stops the xrSession and restores the renderloop
  18733. * @returns Promise which resolves after it exits XR
  18734. */
  18735. WebXRSessionManager.prototype.exitXRAsync = function () {
  18736. return this._xrSession.end();
  18737. };
  18738. /**
  18739. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18740. * @param ray ray to cast into the environment
  18741. * @returns Promise which resolves with a collision point in the environment if it exists
  18742. */
  18743. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18744. var _this = this;
  18745. return new Promise(function (res) {
  18746. // Compute left handed inputs to request hit test
  18747. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18748. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18749. if (!_this.scene.useRightHandedSystem) {
  18750. origin[2] *= -1;
  18751. direction[2] *= -1;
  18752. }
  18753. // Fire hittest
  18754. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18755. .then(function (hits) {
  18756. if (hits.length > 0) {
  18757. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18758. var hitPoint = _this._tmpMatrix.getTranslation();
  18759. if (!_this.scene.useRightHandedSystem) {
  18760. hitPoint.z *= -1;
  18761. }
  18762. res(hitPoint);
  18763. }
  18764. else {
  18765. res(null);
  18766. }
  18767. }).catch(function () {
  18768. res(null);
  18769. });
  18770. });
  18771. };
  18772. /**
  18773. * Checks if a session would be supported for the creation options specified
  18774. * @param options creation options to check if they are supported
  18775. * @returns true if supported
  18776. */
  18777. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18778. return this._xrDevice.supportsSession(options).then(function () {
  18779. return true;
  18780. }).catch(function () {
  18781. return false;
  18782. });
  18783. };
  18784. /**
  18785. * @hidden
  18786. * Converts the render layer of xrSession to a render target
  18787. * @param session session to create render target for
  18788. * @param scene scene the new render target should be created for
  18789. */
  18790. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18791. // Create internal texture
  18792. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18793. internalTexture.width = session.baseLayer.framebufferWidth;
  18794. internalTexture.height = session.baseLayer.framebufferHeight;
  18795. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18796. // Create render target texture from the internal texture
  18797. 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);
  18798. renderTargetTexture._texture = internalTexture;
  18799. return renderTargetTexture;
  18800. };
  18801. /**
  18802. * Disposes of the session manager
  18803. */
  18804. WebXRSessionManager.prototype.dispose = function () {
  18805. this.onXRFrameObservable.clear();
  18806. this.onXRSessionEnded.clear();
  18807. };
  18808. return WebXRSessionManager;
  18809. }());
  18810. /***/ }),
  18811. /***/ "./Cameras/arcRotateCamera.ts":
  18812. /*!************************************!*\
  18813. !*** ./Cameras/arcRotateCamera.ts ***!
  18814. \************************************/
  18815. /*! exports provided: ArcRotateCamera */
  18816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18817. "use strict";
  18818. __webpack_require__.r(__webpack_exports__);
  18819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18821. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18822. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18823. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18824. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18825. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18826. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18827. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18828. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18829. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18830. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18831. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18832. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18833. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18834. });
  18835. /**
  18836. * This represents an orbital type of camera.
  18837. *
  18838. * 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.
  18839. * 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.
  18840. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18841. */
  18842. var ArcRotateCamera = /** @class */ (function (_super) {
  18843. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18844. /**
  18845. * Instantiates a new ArcRotateCamera in a given scene
  18846. * @param name Defines the name of the camera
  18847. * @param alpha Defines the camera rotation along the logitudinal axis
  18848. * @param beta Defines the camera rotation along the latitudinal axis
  18849. * @param radius Defines the camera distance from its target
  18850. * @param target Defines the camera target
  18851. * @param scene Defines the scene the camera belongs to
  18852. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18853. */
  18854. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18855. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18856. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18857. /**
  18858. * Current inertia value on the longitudinal axis.
  18859. * The bigger this number the longer it will take for the camera to stop.
  18860. */
  18861. _this.inertialAlphaOffset = 0;
  18862. /**
  18863. * Current inertia value on the latitudinal axis.
  18864. * The bigger this number the longer it will take for the camera to stop.
  18865. */
  18866. _this.inertialBetaOffset = 0;
  18867. /**
  18868. * Current inertia value on the radius axis.
  18869. * The bigger this number the longer it will take for the camera to stop.
  18870. */
  18871. _this.inertialRadiusOffset = 0;
  18872. /**
  18873. * Minimum allowed angle on the longitudinal axis.
  18874. * This can help limiting how the Camera is able to move in the scene.
  18875. */
  18876. _this.lowerAlphaLimit = null;
  18877. /**
  18878. * Maximum allowed angle on the longitudinal axis.
  18879. * This can help limiting how the Camera is able to move in the scene.
  18880. */
  18881. _this.upperAlphaLimit = null;
  18882. /**
  18883. * Minimum allowed angle on the latitudinal axis.
  18884. * This can help limiting how the Camera is able to move in the scene.
  18885. */
  18886. _this.lowerBetaLimit = 0.01;
  18887. /**
  18888. * Maximum allowed angle on the latitudinal axis.
  18889. * This can help limiting how the Camera is able to move in the scene.
  18890. */
  18891. _this.upperBetaLimit = Math.PI - 0.01;
  18892. /**
  18893. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18894. * This can help limiting how the Camera is able to move in the scene.
  18895. */
  18896. _this.lowerRadiusLimit = null;
  18897. /**
  18898. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18899. * This can help limiting how the Camera is able to move in the scene.
  18900. */
  18901. _this.upperRadiusLimit = null;
  18902. /**
  18903. * Defines the current inertia value used during panning of the camera along the X axis.
  18904. */
  18905. _this.inertialPanningX = 0;
  18906. /**
  18907. * Defines the current inertia value used during panning of the camera along the Y axis.
  18908. */
  18909. _this.inertialPanningY = 0;
  18910. /**
  18911. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18912. * Basically if your fingers moves away from more than this distance you will be considered
  18913. * in pinch mode.
  18914. */
  18915. _this.pinchToPanMaxDistance = 20;
  18916. /**
  18917. * Defines the maximum distance the camera can pan.
  18918. * This could help keeping the cammera always in your scene.
  18919. */
  18920. _this.panningDistanceLimit = null;
  18921. /**
  18922. * Defines the target of the camera before paning.
  18923. */
  18924. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18925. /**
  18926. * Defines the value of the inertia used during panning.
  18927. * 0 would mean stop inertia and one would mean no decelleration at all.
  18928. */
  18929. _this.panningInertia = 0.9;
  18930. //-- end properties for backward compatibility for inputs
  18931. /**
  18932. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18933. */
  18934. _this.zoomOnFactor = 1;
  18935. /**
  18936. * Defines a screen offset for the camera position.
  18937. */
  18938. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18939. /**
  18940. * Allows the camera to be completely reversed.
  18941. * If false the camera can not arrive upside down.
  18942. */
  18943. _this.allowUpsideDown = true;
  18944. /**
  18945. * Define if double tap/click is used to restore the previously saved state of the camera.
  18946. */
  18947. _this.useInputToRestoreState = true;
  18948. /** @hidden */
  18949. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18950. /**
  18951. * Defines the allowed panning axis.
  18952. */
  18953. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18954. /**
  18955. * Observable triggered when the mesh target has been changed on the camera.
  18956. */
  18957. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18958. /**
  18959. * Defines whether the camera should check collision with the objects oh the scene.
  18960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18961. */
  18962. _this.checkCollisions = false;
  18963. /**
  18964. * Defines the collision radius of the camera.
  18965. * This simulates a sphere around the camera.
  18966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18967. */
  18968. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18969. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18970. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18971. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18972. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18973. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18974. if (collidedMesh === void 0) { collidedMesh = null; }
  18975. if (!collidedMesh) {
  18976. _this._previousPosition.copyFrom(_this.position);
  18977. }
  18978. else {
  18979. _this.setPosition(newPosition);
  18980. if (_this.onCollide) {
  18981. _this.onCollide(collidedMesh);
  18982. }
  18983. }
  18984. // Recompute because of constraints
  18985. var cosa = Math.cos(_this.alpha);
  18986. var sina = Math.sin(_this.alpha);
  18987. var cosb = Math.cos(_this.beta);
  18988. var sinb = Math.sin(_this.beta);
  18989. if (sinb === 0) {
  18990. sinb = 0.0001;
  18991. }
  18992. var target = _this._getTargetPosition();
  18993. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  18994. target.addToRef(_this._computationVector, _this._newPosition);
  18995. _this.position.copyFrom(_this._newPosition);
  18996. var up = _this.upVector;
  18997. if (_this.allowUpsideDown && _this.beta < 0) {
  18998. up = up.clone();
  18999. up = up.negate();
  19000. }
  19001. _this._computeViewMatrix(_this.position, target, up);
  19002. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19003. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19004. _this._collisionTriggered = false;
  19005. };
  19006. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19007. if (target) {
  19008. _this.setTarget(target);
  19009. }
  19010. _this.alpha = alpha;
  19011. _this.beta = beta;
  19012. _this.radius = radius;
  19013. _this.getViewMatrix();
  19014. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19015. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19016. return _this;
  19017. }
  19018. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19019. /**
  19020. * Defines the target point of the camera.
  19021. * The camera looks towards it form the radius distance.
  19022. */
  19023. get: function () {
  19024. return this._target;
  19025. },
  19026. set: function (value) {
  19027. this.setTarget(value);
  19028. },
  19029. enumerable: true,
  19030. configurable: true
  19031. });
  19032. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19033. //-- begin properties for backward compatibility for inputs
  19034. /**
  19035. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19036. */
  19037. get: function () {
  19038. var pointers = this.inputs.attached["pointers"];
  19039. if (pointers) {
  19040. return pointers.angularSensibilityX;
  19041. }
  19042. return 0;
  19043. },
  19044. set: function (value) {
  19045. var pointers = this.inputs.attached["pointers"];
  19046. if (pointers) {
  19047. pointers.angularSensibilityX = value;
  19048. }
  19049. },
  19050. enumerable: true,
  19051. configurable: true
  19052. });
  19053. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19054. /**
  19055. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19056. */
  19057. get: function () {
  19058. var pointers = this.inputs.attached["pointers"];
  19059. if (pointers) {
  19060. return pointers.angularSensibilityY;
  19061. }
  19062. return 0;
  19063. },
  19064. set: function (value) {
  19065. var pointers = this.inputs.attached["pointers"];
  19066. if (pointers) {
  19067. pointers.angularSensibilityY = value;
  19068. }
  19069. },
  19070. enumerable: true,
  19071. configurable: true
  19072. });
  19073. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19074. /**
  19075. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19076. */
  19077. get: function () {
  19078. var pointers = this.inputs.attached["pointers"];
  19079. if (pointers) {
  19080. return pointers.pinchPrecision;
  19081. }
  19082. return 0;
  19083. },
  19084. set: function (value) {
  19085. var pointers = this.inputs.attached["pointers"];
  19086. if (pointers) {
  19087. pointers.pinchPrecision = value;
  19088. }
  19089. },
  19090. enumerable: true,
  19091. configurable: true
  19092. });
  19093. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19094. /**
  19095. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19096. * It will be used instead of pinchDeltaPrecision if different from 0.
  19097. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19098. */
  19099. get: function () {
  19100. var pointers = this.inputs.attached["pointers"];
  19101. if (pointers) {
  19102. return pointers.pinchDeltaPercentage;
  19103. }
  19104. return 0;
  19105. },
  19106. set: function (value) {
  19107. var pointers = this.inputs.attached["pointers"];
  19108. if (pointers) {
  19109. pointers.pinchDeltaPercentage = value;
  19110. }
  19111. },
  19112. enumerable: true,
  19113. configurable: true
  19114. });
  19115. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19116. /**
  19117. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19118. */
  19119. get: function () {
  19120. var pointers = this.inputs.attached["pointers"];
  19121. if (pointers) {
  19122. return pointers.panningSensibility;
  19123. }
  19124. return 0;
  19125. },
  19126. set: function (value) {
  19127. var pointers = this.inputs.attached["pointers"];
  19128. if (pointers) {
  19129. pointers.panningSensibility = value;
  19130. }
  19131. },
  19132. enumerable: true,
  19133. configurable: true
  19134. });
  19135. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19136. /**
  19137. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19138. */
  19139. get: function () {
  19140. var keyboard = this.inputs.attached["keyboard"];
  19141. if (keyboard) {
  19142. return keyboard.keysUp;
  19143. }
  19144. return [];
  19145. },
  19146. set: function (value) {
  19147. var keyboard = this.inputs.attached["keyboard"];
  19148. if (keyboard) {
  19149. keyboard.keysUp = value;
  19150. }
  19151. },
  19152. enumerable: true,
  19153. configurable: true
  19154. });
  19155. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19156. /**
  19157. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19158. */
  19159. get: function () {
  19160. var keyboard = this.inputs.attached["keyboard"];
  19161. if (keyboard) {
  19162. return keyboard.keysDown;
  19163. }
  19164. return [];
  19165. },
  19166. set: function (value) {
  19167. var keyboard = this.inputs.attached["keyboard"];
  19168. if (keyboard) {
  19169. keyboard.keysDown = value;
  19170. }
  19171. },
  19172. enumerable: true,
  19173. configurable: true
  19174. });
  19175. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19176. /**
  19177. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19178. */
  19179. get: function () {
  19180. var keyboard = this.inputs.attached["keyboard"];
  19181. if (keyboard) {
  19182. return keyboard.keysLeft;
  19183. }
  19184. return [];
  19185. },
  19186. set: function (value) {
  19187. var keyboard = this.inputs.attached["keyboard"];
  19188. if (keyboard) {
  19189. keyboard.keysLeft = value;
  19190. }
  19191. },
  19192. enumerable: true,
  19193. configurable: true
  19194. });
  19195. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19196. /**
  19197. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19198. */
  19199. get: function () {
  19200. var keyboard = this.inputs.attached["keyboard"];
  19201. if (keyboard) {
  19202. return keyboard.keysRight;
  19203. }
  19204. return [];
  19205. },
  19206. set: function (value) {
  19207. var keyboard = this.inputs.attached["keyboard"];
  19208. if (keyboard) {
  19209. keyboard.keysRight = value;
  19210. }
  19211. },
  19212. enumerable: true,
  19213. configurable: true
  19214. });
  19215. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19216. /**
  19217. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19218. */
  19219. get: function () {
  19220. var mousewheel = this.inputs.attached["mousewheel"];
  19221. if (mousewheel) {
  19222. return mousewheel.wheelPrecision;
  19223. }
  19224. return 0;
  19225. },
  19226. set: function (value) {
  19227. var mousewheel = this.inputs.attached["mousewheel"];
  19228. if (mousewheel) {
  19229. mousewheel.wheelPrecision = value;
  19230. }
  19231. },
  19232. enumerable: true,
  19233. configurable: true
  19234. });
  19235. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19236. /**
  19237. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19238. * It will be used instead of pinchDeltaPrecision if different from 0.
  19239. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19240. */
  19241. get: function () {
  19242. var mousewheel = this.inputs.attached["mousewheel"];
  19243. if (mousewheel) {
  19244. return mousewheel.wheelDeltaPercentage;
  19245. }
  19246. return 0;
  19247. },
  19248. set: function (value) {
  19249. var mousewheel = this.inputs.attached["mousewheel"];
  19250. if (mousewheel) {
  19251. mousewheel.wheelDeltaPercentage = value;
  19252. }
  19253. },
  19254. enumerable: true,
  19255. configurable: true
  19256. });
  19257. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19258. /**
  19259. * Gets the bouncing behavior of the camera if it has been enabled.
  19260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19261. */
  19262. get: function () {
  19263. return this._bouncingBehavior;
  19264. },
  19265. enumerable: true,
  19266. configurable: true
  19267. });
  19268. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19269. /**
  19270. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19272. */
  19273. get: function () {
  19274. return this._bouncingBehavior != null;
  19275. },
  19276. set: function (value) {
  19277. if (value === this.useBouncingBehavior) {
  19278. return;
  19279. }
  19280. if (value) {
  19281. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19282. this.addBehavior(this._bouncingBehavior);
  19283. }
  19284. else if (this._bouncingBehavior) {
  19285. this.removeBehavior(this._bouncingBehavior);
  19286. this._bouncingBehavior = null;
  19287. }
  19288. },
  19289. enumerable: true,
  19290. configurable: true
  19291. });
  19292. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19293. /**
  19294. * Gets the framing behavior of the camera if it has been enabled.
  19295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19296. */
  19297. get: function () {
  19298. return this._framingBehavior;
  19299. },
  19300. enumerable: true,
  19301. configurable: true
  19302. });
  19303. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19304. /**
  19305. * Defines if the framing behavior of the camera is enabled on the camera.
  19306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19307. */
  19308. get: function () {
  19309. return this._framingBehavior != null;
  19310. },
  19311. set: function (value) {
  19312. if (value === this.useFramingBehavior) {
  19313. return;
  19314. }
  19315. if (value) {
  19316. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19317. this.addBehavior(this._framingBehavior);
  19318. }
  19319. else if (this._framingBehavior) {
  19320. this.removeBehavior(this._framingBehavior);
  19321. this._framingBehavior = null;
  19322. }
  19323. },
  19324. enumerable: true,
  19325. configurable: true
  19326. });
  19327. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19328. /**
  19329. * Gets the auto rotation behavior of the camera if it has been enabled.
  19330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19331. */
  19332. get: function () {
  19333. return this._autoRotationBehavior;
  19334. },
  19335. enumerable: true,
  19336. configurable: true
  19337. });
  19338. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19339. /**
  19340. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19341. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19342. */
  19343. get: function () {
  19344. return this._autoRotationBehavior != null;
  19345. },
  19346. set: function (value) {
  19347. if (value === this.useAutoRotationBehavior) {
  19348. return;
  19349. }
  19350. if (value) {
  19351. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19352. this.addBehavior(this._autoRotationBehavior);
  19353. }
  19354. else if (this._autoRotationBehavior) {
  19355. this.removeBehavior(this._autoRotationBehavior);
  19356. this._autoRotationBehavior = null;
  19357. }
  19358. },
  19359. enumerable: true,
  19360. configurable: true
  19361. });
  19362. // Cache
  19363. /** @hidden */
  19364. ArcRotateCamera.prototype._initCache = function () {
  19365. _super.prototype._initCache.call(this);
  19366. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19367. this._cache.alpha = undefined;
  19368. this._cache.beta = undefined;
  19369. this._cache.radius = undefined;
  19370. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19371. };
  19372. /** @hidden */
  19373. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19374. if (!ignoreParentClass) {
  19375. _super.prototype._updateCache.call(this);
  19376. }
  19377. this._cache._target.copyFrom(this._getTargetPosition());
  19378. this._cache.alpha = this.alpha;
  19379. this._cache.beta = this.beta;
  19380. this._cache.radius = this.radius;
  19381. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19382. };
  19383. ArcRotateCamera.prototype._getTargetPosition = function () {
  19384. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19385. var pos = this._targetHost.absolutePosition;
  19386. if (this._targetBoundingCenter) {
  19387. pos.addToRef(this._targetBoundingCenter, this._target);
  19388. }
  19389. else {
  19390. this._target.copyFrom(pos);
  19391. }
  19392. }
  19393. var lockedTargetPosition = this._getLockedTargetPosition();
  19394. if (lockedTargetPosition) {
  19395. return lockedTargetPosition;
  19396. }
  19397. return this._target;
  19398. };
  19399. /**
  19400. * Stores the current state of the camera (alpha, beta, radius and target)
  19401. * @returns the camera itself
  19402. */
  19403. ArcRotateCamera.prototype.storeState = function () {
  19404. this._storedAlpha = this.alpha;
  19405. this._storedBeta = this.beta;
  19406. this._storedRadius = this.radius;
  19407. this._storedTarget = this._getTargetPosition().clone();
  19408. return _super.prototype.storeState.call(this);
  19409. };
  19410. /**
  19411. * @hidden
  19412. * Restored camera state. You must call storeState() first
  19413. */
  19414. ArcRotateCamera.prototype._restoreStateValues = function () {
  19415. if (!_super.prototype._restoreStateValues.call(this)) {
  19416. return false;
  19417. }
  19418. this.alpha = this._storedAlpha;
  19419. this.beta = this._storedBeta;
  19420. this.radius = this._storedRadius;
  19421. this.setTarget(this._storedTarget.clone());
  19422. this.inertialAlphaOffset = 0;
  19423. this.inertialBetaOffset = 0;
  19424. this.inertialRadiusOffset = 0;
  19425. this.inertialPanningX = 0;
  19426. this.inertialPanningY = 0;
  19427. return true;
  19428. };
  19429. // Synchronized
  19430. /** @hidden */
  19431. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19432. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19433. return false;
  19434. }
  19435. return this._cache._target.equals(this._getTargetPosition())
  19436. && this._cache.alpha === this.alpha
  19437. && this._cache.beta === this.beta
  19438. && this._cache.radius === this.radius
  19439. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19440. };
  19441. /**
  19442. * Attached controls to the current camera.
  19443. * @param element Defines the element the controls should be listened from
  19444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19445. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19446. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19447. */
  19448. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19449. var _this = this;
  19450. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19451. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19452. this._useCtrlForPanning = useCtrlForPanning;
  19453. this._panningMouseButton = panningMouseButton;
  19454. this.inputs.attachElement(element, noPreventDefault);
  19455. this._reset = function () {
  19456. _this.inertialAlphaOffset = 0;
  19457. _this.inertialBetaOffset = 0;
  19458. _this.inertialRadiusOffset = 0;
  19459. _this.inertialPanningX = 0;
  19460. _this.inertialPanningY = 0;
  19461. };
  19462. };
  19463. /**
  19464. * Detach the current controls from the camera.
  19465. * The camera will stop reacting to inputs.
  19466. * @param element Defines the element to stop listening the inputs from
  19467. */
  19468. ArcRotateCamera.prototype.detachControl = function (element) {
  19469. this.inputs.detachElement(element);
  19470. if (this._reset) {
  19471. this._reset();
  19472. }
  19473. };
  19474. /** @hidden */
  19475. ArcRotateCamera.prototype._checkInputs = function () {
  19476. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19477. if (this._collisionTriggered) {
  19478. return;
  19479. }
  19480. this.inputs.checkInputs();
  19481. // Inertia
  19482. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19483. var inertialAlphaOffset = this.inertialAlphaOffset;
  19484. if (this.beta <= 0) {
  19485. inertialAlphaOffset *= -1;
  19486. }
  19487. if (this.getScene().useRightHandedSystem) {
  19488. inertialAlphaOffset *= -1;
  19489. }
  19490. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19491. inertialAlphaOffset *= -1;
  19492. }
  19493. this.alpha += inertialAlphaOffset;
  19494. this.beta += this.inertialBetaOffset;
  19495. this.radius -= this.inertialRadiusOffset;
  19496. this.inertialAlphaOffset *= this.inertia;
  19497. this.inertialBetaOffset *= this.inertia;
  19498. this.inertialRadiusOffset *= this.inertia;
  19499. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19500. this.inertialAlphaOffset = 0;
  19501. }
  19502. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19503. this.inertialBetaOffset = 0;
  19504. }
  19505. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19506. this.inertialRadiusOffset = 0;
  19507. }
  19508. }
  19509. // Panning inertia
  19510. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19511. if (!this._localDirection) {
  19512. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19513. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19514. }
  19515. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19516. this._localDirection.multiplyInPlace(this.panningAxis);
  19517. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19518. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19519. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19520. if (!this.panningAxis.y) {
  19521. this._transformedDirection.y = 0;
  19522. }
  19523. if (!this._targetHost) {
  19524. if (this.panningDistanceLimit) {
  19525. this._transformedDirection.addInPlace(this._target);
  19526. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19527. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19528. this._target.copyFrom(this._transformedDirection);
  19529. }
  19530. }
  19531. else {
  19532. this._target.addInPlace(this._transformedDirection);
  19533. }
  19534. }
  19535. this.inertialPanningX *= this.panningInertia;
  19536. this.inertialPanningY *= this.panningInertia;
  19537. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19538. this.inertialPanningX = 0;
  19539. }
  19540. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19541. this.inertialPanningY = 0;
  19542. }
  19543. }
  19544. // Limits
  19545. this._checkLimits();
  19546. _super.prototype._checkInputs.call(this);
  19547. };
  19548. ArcRotateCamera.prototype._checkLimits = function () {
  19549. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19550. if (this.allowUpsideDown && this.beta > Math.PI) {
  19551. this.beta = this.beta - (2 * Math.PI);
  19552. }
  19553. }
  19554. else {
  19555. if (this.beta < this.lowerBetaLimit) {
  19556. this.beta = this.lowerBetaLimit;
  19557. }
  19558. }
  19559. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19560. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19561. this.beta = this.beta + (2 * Math.PI);
  19562. }
  19563. }
  19564. else {
  19565. if (this.beta > this.upperBetaLimit) {
  19566. this.beta = this.upperBetaLimit;
  19567. }
  19568. }
  19569. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19570. this.alpha = this.lowerAlphaLimit;
  19571. }
  19572. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19573. this.alpha = this.upperAlphaLimit;
  19574. }
  19575. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19576. this.radius = this.lowerRadiusLimit;
  19577. this.inertialRadiusOffset = 0;
  19578. }
  19579. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19580. this.radius = this.upperRadiusLimit;
  19581. this.inertialRadiusOffset = 0;
  19582. }
  19583. };
  19584. /**
  19585. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19586. */
  19587. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19588. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19589. this.radius = this._computationVector.length();
  19590. if (this.radius === 0) {
  19591. this.radius = 0.0001; // Just to avoid division by zero
  19592. }
  19593. // Alpha
  19594. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19595. if (this._computationVector.z < 0) {
  19596. this.alpha = 2 * Math.PI - this.alpha;
  19597. }
  19598. // Beta
  19599. this.beta = Math.acos(this._computationVector.y / this.radius);
  19600. this._checkLimits();
  19601. };
  19602. /**
  19603. * Use a position to define the current camera related information like aplha, beta and radius
  19604. * @param position Defines the position to set the camera at
  19605. */
  19606. ArcRotateCamera.prototype.setPosition = function (position) {
  19607. if (this.position.equals(position)) {
  19608. return;
  19609. }
  19610. this.position.copyFrom(position);
  19611. this.rebuildAnglesAndRadius();
  19612. };
  19613. /**
  19614. * Defines the target the camera should look at.
  19615. * This will automatically adapt alpha beta and radius to fit within the new target.
  19616. * @param target Defines the new target as a Vector or a mesh
  19617. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19618. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19619. */
  19620. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19621. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19622. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19623. if (target.getBoundingInfo) {
  19624. if (toBoundingCenter) {
  19625. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19626. }
  19627. else {
  19628. this._targetBoundingCenter = null;
  19629. }
  19630. this._targetHost = target;
  19631. this._target = this._getTargetPosition();
  19632. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19633. }
  19634. else {
  19635. var newTarget = target;
  19636. var currentTarget = this._getTargetPosition();
  19637. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19638. return;
  19639. }
  19640. this._targetHost = null;
  19641. this._target = newTarget;
  19642. this._targetBoundingCenter = null;
  19643. this.onMeshTargetChangedObservable.notifyObservers(null);
  19644. }
  19645. this.rebuildAnglesAndRadius();
  19646. };
  19647. /** @hidden */
  19648. ArcRotateCamera.prototype._getViewMatrix = function () {
  19649. // Compute
  19650. var cosa = Math.cos(this.alpha);
  19651. var sina = Math.sin(this.alpha);
  19652. var cosb = Math.cos(this.beta);
  19653. var sinb = Math.sin(this.beta);
  19654. if (sinb === 0) {
  19655. sinb = 0.0001;
  19656. }
  19657. var target = this._getTargetPosition();
  19658. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19659. // Rotate according to up vector
  19660. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19661. if (!this._tempAxisVector) {
  19662. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19663. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19664. }
  19665. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19666. this._tempAxisVector.normalize();
  19667. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19668. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19669. this._tempAxisVector.copyFrom(this._computationVector);
  19670. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19671. }
  19672. target.addToRef(this._computationVector, this._newPosition);
  19673. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19674. var coordinator = this.getScene().collisionCoordinator;
  19675. if (!this._collider) {
  19676. this._collider = coordinator.createCollider();
  19677. }
  19678. this._collider._radius = this.collisionRadius;
  19679. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19680. this._collisionTriggered = true;
  19681. coordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19682. }
  19683. else {
  19684. this.position.copyFrom(this._newPosition);
  19685. var up = this.upVector;
  19686. if (this.allowUpsideDown && sinb < 0) {
  19687. up = up.clone();
  19688. up = up.negate();
  19689. }
  19690. this._computeViewMatrix(this.position, target, up);
  19691. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19692. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19693. }
  19694. this._currentTarget = target;
  19695. return this._viewMatrix;
  19696. };
  19697. /**
  19698. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19699. * @param meshes Defines the mesh to zoom on
  19700. * @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)
  19701. */
  19702. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19703. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19704. meshes = meshes || this.getScene().meshes;
  19705. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19706. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19707. this.radius = distance * this.zoomOnFactor;
  19708. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19709. };
  19710. /**
  19711. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19712. * The target will be changed but the radius
  19713. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19714. * @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)
  19715. */
  19716. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19717. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19718. var meshesOrMinMaxVector;
  19719. var distance;
  19720. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19721. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19722. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19723. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19724. }
  19725. else { //minMaxVector and distance
  19726. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19727. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19728. distance = minMaxVectorAndDistance.distance;
  19729. }
  19730. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19731. if (!doNotUpdateMaxZ) {
  19732. this.maxZ = distance * 2;
  19733. }
  19734. };
  19735. /**
  19736. * @override
  19737. * Override Camera.createRigCamera
  19738. */
  19739. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19740. var alphaShift = 0;
  19741. switch (this.cameraRigMode) {
  19742. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19743. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19744. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19745. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19746. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19747. break;
  19748. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19749. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19750. break;
  19751. }
  19752. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19753. rigCam._cameraRigParams = {};
  19754. return rigCam;
  19755. };
  19756. /**
  19757. * @hidden
  19758. * @override
  19759. * Override Camera._updateRigCameras
  19760. */
  19761. ArcRotateCamera.prototype._updateRigCameras = function () {
  19762. var camLeft = this._rigCameras[0];
  19763. var camRight = this._rigCameras[1];
  19764. camLeft.beta = camRight.beta = this.beta;
  19765. switch (this.cameraRigMode) {
  19766. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19767. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19768. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19769. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19770. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19771. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19772. break;
  19773. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19774. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19775. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19776. break;
  19777. }
  19778. _super.prototype._updateRigCameras.call(this);
  19779. };
  19780. /**
  19781. * Destroy the camera and release the current resources hold by it.
  19782. */
  19783. ArcRotateCamera.prototype.dispose = function () {
  19784. this.inputs.clear();
  19785. _super.prototype.dispose.call(this);
  19786. };
  19787. /**
  19788. * Gets the current object class name.
  19789. * @return the class name
  19790. */
  19791. ArcRotateCamera.prototype.getClassName = function () {
  19792. return "ArcRotateCamera";
  19793. };
  19794. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19795. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19796. ], ArcRotateCamera.prototype, "alpha", void 0);
  19797. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19799. ], ArcRotateCamera.prototype, "beta", void 0);
  19800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19802. ], ArcRotateCamera.prototype, "radius", void 0);
  19803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19805. ], ArcRotateCamera.prototype, "_target", void 0);
  19806. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19807. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19808. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19811. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19814. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19817. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19820. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19823. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19826. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19829. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19832. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19835. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19838. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19841. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19844. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19847. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19850. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19853. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19856. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19859. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19862. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19863. return ArcRotateCamera;
  19864. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  19865. /***/ }),
  19866. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19867. /*!*************************************************!*\
  19868. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19869. \*************************************************/
  19870. /*! exports provided: ArcRotateCameraInputsManager */
  19871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19872. "use strict";
  19873. __webpack_require__.r(__webpack_exports__);
  19874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19876. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19877. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19878. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19879. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19880. /**
  19881. * Default Inputs manager for the ArcRotateCamera.
  19882. * It groups all the default supported inputs for ease of use.
  19883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19884. */
  19885. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19886. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19887. /**
  19888. * Instantiates a new ArcRotateCameraInputsManager.
  19889. * @param camera Defines the camera the inputs belong to
  19890. */
  19891. function ArcRotateCameraInputsManager(camera) {
  19892. return _super.call(this, camera) || this;
  19893. }
  19894. /**
  19895. * Add mouse wheel input support to the input manager.
  19896. * @returns the current input manager
  19897. */
  19898. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19899. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19900. return this;
  19901. };
  19902. /**
  19903. * Add pointers input support to the input manager.
  19904. * @returns the current input manager
  19905. */
  19906. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19907. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19908. return this;
  19909. };
  19910. /**
  19911. * Add keyboard input support to the input manager.
  19912. * @returns the current input manager
  19913. */
  19914. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19915. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19916. return this;
  19917. };
  19918. return ArcRotateCameraInputsManager;
  19919. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19920. /***/ }),
  19921. /***/ "./Cameras/camera.ts":
  19922. /*!***************************!*\
  19923. !*** ./Cameras/camera.ts ***!
  19924. \***************************/
  19925. /*! exports provided: Camera */
  19926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19927. "use strict";
  19928. __webpack_require__.r(__webpack_exports__);
  19929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19931. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19932. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19933. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19934. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19935. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19936. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19937. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  19938. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19939. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  19940. /**
  19941. * This is the base class of all the camera used in the application.
  19942. * @see http://doc.babylonjs.com/features/cameras
  19943. */
  19944. var Camera = /** @class */ (function (_super) {
  19945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19946. /**
  19947. * Instantiates a new camera object.
  19948. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19949. * @see http://doc.babylonjs.com/features/cameras
  19950. * @param name Defines the name of the camera in the scene
  19951. * @param position Defines the position of the camera
  19952. * @param scene Defines the scene the camera belongs too
  19953. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19954. */
  19955. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19956. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19957. var _this = _super.call(this, name, scene) || this;
  19958. /**
  19959. * The vector the camera should consider as up.
  19960. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19961. */
  19962. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19963. /**
  19964. * Define the current limit on the left side for an orthographic camera
  19965. * In scene unit
  19966. */
  19967. _this.orthoLeft = null;
  19968. /**
  19969. * Define the current limit on the right side for an orthographic camera
  19970. * In scene unit
  19971. */
  19972. _this.orthoRight = null;
  19973. /**
  19974. * Define the current limit on the bottom side for an orthographic camera
  19975. * In scene unit
  19976. */
  19977. _this.orthoBottom = null;
  19978. /**
  19979. * Define the current limit on the top side for an orthographic camera
  19980. * In scene unit
  19981. */
  19982. _this.orthoTop = null;
  19983. /**
  19984. * Field Of View is set in Radians. (default is 0.8)
  19985. */
  19986. _this.fov = 0.8;
  19987. /**
  19988. * Define the minimum distance the camera can see from.
  19989. * This is important to note that the depth buffer are not infinite and the closer it starts
  19990. * the more your scene might encounter depth fighting issue.
  19991. */
  19992. _this.minZ = 1;
  19993. /**
  19994. * Define the maximum distance the camera can see to.
  19995. * This is important to note that the depth buffer are not infinite and the further it end
  19996. * the more your scene might encounter depth fighting issue.
  19997. */
  19998. _this.maxZ = 10000.0;
  19999. /**
  20000. * Define the default inertia of the camera.
  20001. * This helps giving a smooth feeling to the camera movement.
  20002. */
  20003. _this.inertia = 0.9;
  20004. /**
  20005. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20006. */
  20007. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20008. /**
  20009. * Define wether the camera is intermediate.
  20010. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20011. */
  20012. _this.isIntermediate = false;
  20013. /**
  20014. * Define the viewport of the camera.
  20015. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20016. */
  20017. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20018. /**
  20019. * Restricts the camera to viewing objects with the same layerMask.
  20020. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20021. */
  20022. _this.layerMask = 0x0FFFFFFF;
  20023. /**
  20024. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20025. */
  20026. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20027. /**
  20028. * Rig mode of the camera.
  20029. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20030. * This is normally controlled byt the camera themselves as internal use.
  20031. */
  20032. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20033. /**
  20034. * 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
  20035. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20036. * else in the scene.
  20037. */
  20038. _this.customRenderTargets = new Array();
  20039. /**
  20040. * When set, the camera will render to this render target instead of the default canvas
  20041. */
  20042. _this.outputRenderTarget = null;
  20043. /**
  20044. * Observable triggered when the camera view matrix has changed.
  20045. */
  20046. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20047. /**
  20048. * Observable triggered when the camera Projection matrix has changed.
  20049. */
  20050. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20051. /**
  20052. * Observable triggered when the inputs have been processed.
  20053. */
  20054. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20055. /**
  20056. * Observable triggered when reset has been called and applied to the camera.
  20057. */
  20058. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20059. /** @hidden */
  20060. _this._rigCameras = new Array();
  20061. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20062. /** @hidden */
  20063. _this._skipRendering = false;
  20064. /** @hidden */
  20065. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20066. /** @hidden */
  20067. _this._postProcesses = new Array();
  20068. /** @hidden */
  20069. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20070. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20071. /** hidden */
  20072. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20073. _this._doNotComputeProjectionMatrix = false;
  20074. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20075. _this._refreshFrustumPlanes = true;
  20076. /** @hidden */
  20077. _this._isCamera = true;
  20078. _this.getScene().addCamera(_this);
  20079. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20080. _this.getScene().activeCamera = _this;
  20081. }
  20082. _this.position = position;
  20083. return _this;
  20084. }
  20085. /**
  20086. * Store current camera state (fov, position, etc..)
  20087. * @returns the camera
  20088. */
  20089. Camera.prototype.storeState = function () {
  20090. this._stateStored = true;
  20091. this._storedFov = this.fov;
  20092. return this;
  20093. };
  20094. /**
  20095. * Restores the camera state values if it has been stored. You must call storeState() first
  20096. */
  20097. Camera.prototype._restoreStateValues = function () {
  20098. if (!this._stateStored) {
  20099. return false;
  20100. }
  20101. this.fov = this._storedFov;
  20102. return true;
  20103. };
  20104. /**
  20105. * Restored camera state. You must call storeState() first.
  20106. * @returns true if restored and false otherwise
  20107. */
  20108. Camera.prototype.restoreState = function () {
  20109. if (this._restoreStateValues()) {
  20110. this.onRestoreStateObservable.notifyObservers(this);
  20111. return true;
  20112. }
  20113. return false;
  20114. };
  20115. /**
  20116. * Gets the class name of the camera.
  20117. * @returns the class name
  20118. */
  20119. Camera.prototype.getClassName = function () {
  20120. return "Camera";
  20121. };
  20122. /**
  20123. * Gets a string representation of the camera useful for debug purpose.
  20124. * @param fullDetails Defines that a more verboe level of logging is required
  20125. * @returns the string representation
  20126. */
  20127. Camera.prototype.toString = function (fullDetails) {
  20128. var ret = "Name: " + this.name;
  20129. ret += ", type: " + this.getClassName();
  20130. if (this.animations) {
  20131. for (var i = 0; i < this.animations.length; i++) {
  20132. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20133. }
  20134. }
  20135. if (fullDetails) {
  20136. }
  20137. return ret;
  20138. };
  20139. Object.defineProperty(Camera.prototype, "globalPosition", {
  20140. /**
  20141. * Gets the current world space position of the camera.
  20142. */
  20143. get: function () {
  20144. return this._globalPosition;
  20145. },
  20146. enumerable: true,
  20147. configurable: true
  20148. });
  20149. /**
  20150. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20151. * @returns the active meshe list
  20152. */
  20153. Camera.prototype.getActiveMeshes = function () {
  20154. return this._activeMeshes;
  20155. };
  20156. /**
  20157. * Check wether a mesh is part of the current active mesh list of the camera
  20158. * @param mesh Defines the mesh to check
  20159. * @returns true if active, false otherwise
  20160. */
  20161. Camera.prototype.isActiveMesh = function (mesh) {
  20162. return (this._activeMeshes.indexOf(mesh) !== -1);
  20163. };
  20164. /**
  20165. * Is this camera ready to be used/rendered
  20166. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20167. * @return true if the camera is ready
  20168. */
  20169. Camera.prototype.isReady = function (completeCheck) {
  20170. if (completeCheck === void 0) { completeCheck = false; }
  20171. if (completeCheck) {
  20172. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20173. var pp = _a[_i];
  20174. if (pp && !pp.isReady()) {
  20175. return false;
  20176. }
  20177. }
  20178. }
  20179. return _super.prototype.isReady.call(this, completeCheck);
  20180. };
  20181. /** @hidden */
  20182. Camera.prototype._initCache = function () {
  20183. _super.prototype._initCache.call(this);
  20184. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20185. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20186. this._cache.mode = undefined;
  20187. this._cache.minZ = undefined;
  20188. this._cache.maxZ = undefined;
  20189. this._cache.fov = undefined;
  20190. this._cache.fovMode = undefined;
  20191. this._cache.aspectRatio = undefined;
  20192. this._cache.orthoLeft = undefined;
  20193. this._cache.orthoRight = undefined;
  20194. this._cache.orthoBottom = undefined;
  20195. this._cache.orthoTop = undefined;
  20196. this._cache.renderWidth = undefined;
  20197. this._cache.renderHeight = undefined;
  20198. };
  20199. /** @hidden */
  20200. Camera.prototype._updateCache = function (ignoreParentClass) {
  20201. if (!ignoreParentClass) {
  20202. _super.prototype._updateCache.call(this);
  20203. }
  20204. this._cache.position.copyFrom(this.position);
  20205. this._cache.upVector.copyFrom(this.upVector);
  20206. };
  20207. /** @hidden */
  20208. Camera.prototype._isSynchronized = function () {
  20209. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20210. };
  20211. /** @hidden */
  20212. Camera.prototype._isSynchronizedViewMatrix = function () {
  20213. if (!_super.prototype._isSynchronized.call(this)) {
  20214. return false;
  20215. }
  20216. return this._cache.position.equals(this.position)
  20217. && this._cache.upVector.equals(this.upVector)
  20218. && this.isSynchronizedWithParent();
  20219. };
  20220. /** @hidden */
  20221. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20222. var check = this._cache.mode === this.mode
  20223. && this._cache.minZ === this.minZ
  20224. && this._cache.maxZ === this.maxZ;
  20225. if (!check) {
  20226. return false;
  20227. }
  20228. var engine = this.getEngine();
  20229. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20230. check = this._cache.fov === this.fov
  20231. && this._cache.fovMode === this.fovMode
  20232. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20233. }
  20234. else {
  20235. check = this._cache.orthoLeft === this.orthoLeft
  20236. && this._cache.orthoRight === this.orthoRight
  20237. && this._cache.orthoBottom === this.orthoBottom
  20238. && this._cache.orthoTop === this.orthoTop
  20239. && this._cache.renderWidth === engine.getRenderWidth()
  20240. && this._cache.renderHeight === engine.getRenderHeight();
  20241. }
  20242. return check;
  20243. };
  20244. /**
  20245. * Attach the input controls to a specific dom element to get the input from.
  20246. * @param element Defines the element the controls should be listened from
  20247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20248. */
  20249. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20250. };
  20251. /**
  20252. * Detach the current controls from the specified dom element.
  20253. * @param element Defines the element to stop listening the inputs from
  20254. */
  20255. Camera.prototype.detachControl = function (element) {
  20256. };
  20257. /**
  20258. * Update the camera state according to the different inputs gathered during the frame.
  20259. */
  20260. Camera.prototype.update = function () {
  20261. this._checkInputs();
  20262. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20263. this._updateRigCameras();
  20264. }
  20265. };
  20266. /** @hidden */
  20267. Camera.prototype._checkInputs = function () {
  20268. this.onAfterCheckInputsObservable.notifyObservers(this);
  20269. };
  20270. Object.defineProperty(Camera.prototype, "rigCameras", {
  20271. /** @hidden */
  20272. get: function () {
  20273. return this._rigCameras;
  20274. },
  20275. enumerable: true,
  20276. configurable: true
  20277. });
  20278. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20279. /**
  20280. * Gets the post process used by the rig cameras
  20281. */
  20282. get: function () {
  20283. return this._rigPostProcess;
  20284. },
  20285. enumerable: true,
  20286. configurable: true
  20287. });
  20288. /**
  20289. * Internal, gets the first post proces.
  20290. * @returns the first post process to be run on this camera.
  20291. */
  20292. Camera.prototype._getFirstPostProcess = function () {
  20293. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20294. if (this._postProcesses[ppIndex] !== null) {
  20295. return this._postProcesses[ppIndex];
  20296. }
  20297. }
  20298. return null;
  20299. };
  20300. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20301. // invalidate framebuffer
  20302. var firstPostProcess = this._getFirstPostProcess();
  20303. if (firstPostProcess) {
  20304. firstPostProcess.markTextureDirty();
  20305. }
  20306. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20307. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20308. var cam = this._rigCameras[i];
  20309. var rigPostProcess = cam._rigPostProcess;
  20310. // for VR rig, there does not have to be a post process
  20311. if (rigPostProcess) {
  20312. var isPass = rigPostProcess.getEffectName() === "pass";
  20313. if (isPass) {
  20314. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20315. cam.isIntermediate = this._postProcesses.length === 0;
  20316. }
  20317. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20318. rigPostProcess.markTextureDirty();
  20319. }
  20320. else {
  20321. cam._postProcesses = this._postProcesses.slice(0);
  20322. }
  20323. }
  20324. };
  20325. /**
  20326. * Attach a post process to the camera.
  20327. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20328. * @param postProcess The post process to attach to the camera
  20329. * @param insertAt The position of the post process in case several of them are in use in the scene
  20330. * @returns the position the post process has been inserted at
  20331. */
  20332. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20333. if (insertAt === void 0) { insertAt = null; }
  20334. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20335. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20336. return 0;
  20337. }
  20338. if (insertAt == null || insertAt < 0) {
  20339. this._postProcesses.push(postProcess);
  20340. }
  20341. else if (this._postProcesses[insertAt] === null) {
  20342. this._postProcesses[insertAt] = postProcess;
  20343. }
  20344. else {
  20345. this._postProcesses.splice(insertAt, 0, postProcess);
  20346. }
  20347. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20348. return this._postProcesses.indexOf(postProcess);
  20349. };
  20350. /**
  20351. * Detach a post process to the camera.
  20352. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20353. * @param postProcess The post process to detach from the camera
  20354. */
  20355. Camera.prototype.detachPostProcess = function (postProcess) {
  20356. var idx = this._postProcesses.indexOf(postProcess);
  20357. if (idx !== -1) {
  20358. this._postProcesses[idx] = null;
  20359. }
  20360. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20361. };
  20362. /**
  20363. * Gets the current world matrix of the camera
  20364. */
  20365. Camera.prototype.getWorldMatrix = function () {
  20366. if (this._isSynchronizedViewMatrix()) {
  20367. return this._worldMatrix;
  20368. }
  20369. // Getting the the view matrix will also compute the world matrix.
  20370. this.getViewMatrix();
  20371. return this._worldMatrix;
  20372. };
  20373. /** @hidden */
  20374. Camera.prototype._getViewMatrix = function () {
  20375. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20376. };
  20377. /**
  20378. * Gets the current view matrix of the camera.
  20379. * @param force forces the camera to recompute the matrix without looking at the cached state
  20380. * @returns the view matrix
  20381. */
  20382. Camera.prototype.getViewMatrix = function (force) {
  20383. if (!force && this._isSynchronizedViewMatrix()) {
  20384. return this._computedViewMatrix;
  20385. }
  20386. this.updateCache();
  20387. this._computedViewMatrix = this._getViewMatrix();
  20388. this._currentRenderId = this.getScene().getRenderId();
  20389. this._childRenderId = this._currentRenderId;
  20390. this._refreshFrustumPlanes = true;
  20391. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20392. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20393. }
  20394. this.onViewMatrixChangedObservable.notifyObservers(this);
  20395. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20396. return this._computedViewMatrix;
  20397. };
  20398. /**
  20399. * Freeze the projection matrix.
  20400. * It will prevent the cache check of the camera projection compute and can speed up perf
  20401. * if no parameter of the camera are meant to change
  20402. * @param projection Defines manually a projection if necessary
  20403. */
  20404. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20405. this._doNotComputeProjectionMatrix = true;
  20406. if (projection !== undefined) {
  20407. this._projectionMatrix = projection;
  20408. }
  20409. };
  20410. /**
  20411. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20412. */
  20413. Camera.prototype.unfreezeProjectionMatrix = function () {
  20414. this._doNotComputeProjectionMatrix = false;
  20415. };
  20416. /**
  20417. * Gets the current projection matrix of the camera.
  20418. * @param force forces the camera to recompute the matrix without looking at the cached state
  20419. * @returns the projection matrix
  20420. */
  20421. Camera.prototype.getProjectionMatrix = function (force) {
  20422. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20423. return this._projectionMatrix;
  20424. }
  20425. // Cache
  20426. this._cache.mode = this.mode;
  20427. this._cache.minZ = this.minZ;
  20428. this._cache.maxZ = this.maxZ;
  20429. // Matrix
  20430. this._refreshFrustumPlanes = true;
  20431. var engine = this.getEngine();
  20432. var scene = this.getScene();
  20433. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20434. this._cache.fov = this.fov;
  20435. this._cache.fovMode = this.fovMode;
  20436. this._cache.aspectRatio = engine.getAspectRatio(this);
  20437. if (this.minZ <= 0) {
  20438. this.minZ = 0.1;
  20439. }
  20440. if (scene.useRightHandedSystem) {
  20441. _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);
  20442. }
  20443. else {
  20444. _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);
  20445. }
  20446. }
  20447. else {
  20448. var halfWidth = engine.getRenderWidth() / 2.0;
  20449. var halfHeight = engine.getRenderHeight() / 2.0;
  20450. if (scene.useRightHandedSystem) {
  20451. _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);
  20452. }
  20453. else {
  20454. _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);
  20455. }
  20456. this._cache.orthoLeft = this.orthoLeft;
  20457. this._cache.orthoRight = this.orthoRight;
  20458. this._cache.orthoBottom = this.orthoBottom;
  20459. this._cache.orthoTop = this.orthoTop;
  20460. this._cache.renderWidth = engine.getRenderWidth();
  20461. this._cache.renderHeight = engine.getRenderHeight();
  20462. }
  20463. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20464. return this._projectionMatrix;
  20465. };
  20466. /**
  20467. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20468. * @returns a Matrix
  20469. */
  20470. Camera.prototype.getTransformationMatrix = function () {
  20471. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20472. return this._transformMatrix;
  20473. };
  20474. Camera.prototype._updateFrustumPlanes = function () {
  20475. if (!this._refreshFrustumPlanes) {
  20476. return;
  20477. }
  20478. this.getTransformationMatrix();
  20479. if (!this._frustumPlanes) {
  20480. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20481. }
  20482. else {
  20483. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20484. }
  20485. this._refreshFrustumPlanes = false;
  20486. };
  20487. /**
  20488. * Checks if a cullable object (mesh...) is in the camera frustum
  20489. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20490. * @param target The object to check
  20491. * @returns true if the object is in frustum otherwise false
  20492. */
  20493. Camera.prototype.isInFrustum = function (target) {
  20494. this._updateFrustumPlanes();
  20495. return target.isInFrustum(this._frustumPlanes);
  20496. };
  20497. /**
  20498. * Checks if a cullable object (mesh...) is in the camera frustum
  20499. * Unlike isInFrustum this cheks the full bounding box
  20500. * @param target The object to check
  20501. * @returns true if the object is in frustum otherwise false
  20502. */
  20503. Camera.prototype.isCompletelyInFrustum = function (target) {
  20504. this._updateFrustumPlanes();
  20505. return target.isCompletelyInFrustum(this._frustumPlanes);
  20506. };
  20507. /**
  20508. * Gets a ray in the forward direction from the camera.
  20509. * @param length Defines the length of the ray to create
  20510. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20511. * @param origin Defines the start point of the ray which defaults to the camera position
  20512. * @returns the forward ray
  20513. */
  20514. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20515. if (length === void 0) { length = 100; }
  20516. if (!transform) {
  20517. transform = this.getWorldMatrix();
  20518. }
  20519. if (!origin) {
  20520. origin = this.position;
  20521. }
  20522. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 1);
  20523. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(forward, transform);
  20524. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(forwardWorld);
  20525. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_7__["Ray"](origin, direction, length);
  20526. };
  20527. /**
  20528. * Releases resources associated with this node.
  20529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20531. */
  20532. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20533. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20534. // Observables
  20535. this.onViewMatrixChangedObservable.clear();
  20536. this.onProjectionMatrixChangedObservable.clear();
  20537. this.onAfterCheckInputsObservable.clear();
  20538. this.onRestoreStateObservable.clear();
  20539. // Inputs
  20540. if (this.inputs) {
  20541. this.inputs.clear();
  20542. }
  20543. // Animations
  20544. this.getScene().stopAnimation(this);
  20545. // Remove from scene
  20546. this.getScene().removeCamera(this);
  20547. while (this._rigCameras.length > 0) {
  20548. var camera = this._rigCameras.pop();
  20549. if (camera) {
  20550. camera.dispose();
  20551. }
  20552. }
  20553. // Postprocesses
  20554. if (this._rigPostProcess) {
  20555. this._rigPostProcess.dispose(this);
  20556. this._rigPostProcess = null;
  20557. this._postProcesses = [];
  20558. }
  20559. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20560. this._rigPostProcess = null;
  20561. this._postProcesses = [];
  20562. }
  20563. else {
  20564. var i = this._postProcesses.length;
  20565. while (--i >= 0) {
  20566. var postProcess = this._postProcesses[i];
  20567. if (postProcess) {
  20568. postProcess.dispose(this);
  20569. }
  20570. }
  20571. }
  20572. // Render targets
  20573. var i = this.customRenderTargets.length;
  20574. while (--i >= 0) {
  20575. this.customRenderTargets[i].dispose();
  20576. }
  20577. this.customRenderTargets = [];
  20578. // Active Meshes
  20579. this._activeMeshes.dispose();
  20580. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20581. };
  20582. Object.defineProperty(Camera.prototype, "leftCamera", {
  20583. /**
  20584. * Gets the left camera of a rig setup in case of Rigged Camera
  20585. */
  20586. get: function () {
  20587. if (this._rigCameras.length < 1) {
  20588. return null;
  20589. }
  20590. return this._rigCameras[0];
  20591. },
  20592. enumerable: true,
  20593. configurable: true
  20594. });
  20595. Object.defineProperty(Camera.prototype, "rightCamera", {
  20596. /**
  20597. * Gets the right camera of a rig setup in case of Rigged Camera
  20598. */
  20599. get: function () {
  20600. if (this._rigCameras.length < 2) {
  20601. return null;
  20602. }
  20603. return this._rigCameras[1];
  20604. },
  20605. enumerable: true,
  20606. configurable: true
  20607. });
  20608. /**
  20609. * Gets the left camera target of a rig setup in case of Rigged Camera
  20610. * @returns the target position
  20611. */
  20612. Camera.prototype.getLeftTarget = function () {
  20613. if (this._rigCameras.length < 1) {
  20614. return null;
  20615. }
  20616. return this._rigCameras[0].getTarget();
  20617. };
  20618. /**
  20619. * Gets the right camera target of a rig setup in case of Rigged Camera
  20620. * @returns the target position
  20621. */
  20622. Camera.prototype.getRightTarget = function () {
  20623. if (this._rigCameras.length < 2) {
  20624. return null;
  20625. }
  20626. return this._rigCameras[1].getTarget();
  20627. };
  20628. /**
  20629. * @hidden
  20630. */
  20631. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20632. if (this.cameraRigMode === mode) {
  20633. return;
  20634. }
  20635. while (this._rigCameras.length > 0) {
  20636. var camera = this._rigCameras.pop();
  20637. if (camera) {
  20638. camera.dispose();
  20639. }
  20640. }
  20641. this.cameraRigMode = mode;
  20642. this._cameraRigParams = {};
  20643. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20644. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20645. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20646. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20647. // create the rig cameras, unless none
  20648. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20649. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20650. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20651. if (leftCamera && rightCamera) {
  20652. this._rigCameras.push(leftCamera);
  20653. this._rigCameras.push(rightCamera);
  20654. }
  20655. }
  20656. switch (this.cameraRigMode) {
  20657. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20658. Camera._setStereoscopicAnaglyphRigMode(this);
  20659. break;
  20660. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20661. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20662. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20663. Camera._setStereoscopicRigMode(this);
  20664. break;
  20665. case Camera.RIG_MODE_VR:
  20666. Camera._setVRRigMode(this, rigParams);
  20667. break;
  20668. case Camera.RIG_MODE_WEBVR:
  20669. Camera._setWebVRRigMode(this, rigParams);
  20670. break;
  20671. }
  20672. this._cascadePostProcessesToRigCams();
  20673. this.update();
  20674. };
  20675. /** @hidden */
  20676. Camera._setStereoscopicRigMode = function (camera) {
  20677. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20678. };
  20679. /** @hidden */
  20680. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20681. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20682. };
  20683. /** @hidden */
  20684. Camera._setVRRigMode = function (camera, rigParams) {
  20685. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20686. };
  20687. /** @hidden */
  20688. Camera._setWebVRRigMode = function (camera, rigParams) {
  20689. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20690. };
  20691. /** @hidden */
  20692. Camera.prototype._getVRProjectionMatrix = function () {
  20693. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20694. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20695. return this._projectionMatrix;
  20696. };
  20697. Camera.prototype._updateCameraRotationMatrix = function () {
  20698. //Here for WebVR
  20699. };
  20700. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20701. //Here for WebVR
  20702. };
  20703. /**
  20704. * This function MUST be overwritten by the different WebVR cameras available.
  20705. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20706. * @hidden
  20707. */
  20708. Camera.prototype._getWebVRProjectionMatrix = function () {
  20709. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20710. };
  20711. /**
  20712. * This function MUST be overwritten by the different WebVR cameras available.
  20713. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20714. * @hidden
  20715. */
  20716. Camera.prototype._getWebVRViewMatrix = function () {
  20717. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20718. };
  20719. /** @hidden */
  20720. Camera.prototype.setCameraRigParameter = function (name, value) {
  20721. if (!this._cameraRigParams) {
  20722. this._cameraRigParams = {};
  20723. }
  20724. this._cameraRigParams[name] = value;
  20725. //provisionnally:
  20726. if (name === "interaxialDistance") {
  20727. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20728. }
  20729. };
  20730. /**
  20731. * needs to be overridden by children so sub has required properties to be copied
  20732. * @hidden
  20733. */
  20734. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20735. return null;
  20736. };
  20737. /**
  20738. * May need to be overridden by children
  20739. * @hidden
  20740. */
  20741. Camera.prototype._updateRigCameras = function () {
  20742. for (var i = 0; i < this._rigCameras.length; i++) {
  20743. this._rigCameras[i].minZ = this.minZ;
  20744. this._rigCameras[i].maxZ = this.maxZ;
  20745. this._rigCameras[i].fov = this.fov;
  20746. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20747. }
  20748. // only update viewport when ANAGLYPH
  20749. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20750. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20751. }
  20752. };
  20753. /** @hidden */
  20754. Camera.prototype._setupInputs = function () {
  20755. };
  20756. /**
  20757. * Serialiaze the camera setup to a json represention
  20758. * @returns the JSON representation
  20759. */
  20760. Camera.prototype.serialize = function () {
  20761. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20762. // Type
  20763. serializationObject.type = this.getClassName();
  20764. // Parent
  20765. if (this.parent) {
  20766. serializationObject.parentId = this.parent.id;
  20767. }
  20768. if (this.inputs) {
  20769. this.inputs.serialize(serializationObject);
  20770. }
  20771. // Animations
  20772. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20773. serializationObject.ranges = this.serializeAnimationRanges();
  20774. return serializationObject;
  20775. };
  20776. /**
  20777. * Clones the current camera.
  20778. * @param name The cloned camera name
  20779. * @returns the cloned camera
  20780. */
  20781. Camera.prototype.clone = function (name) {
  20782. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20783. };
  20784. /**
  20785. * Gets the direction of the camera relative to a given local axis.
  20786. * @param localAxis Defines the reference axis to provide a relative direction.
  20787. * @return the direction
  20788. */
  20789. Camera.prototype.getDirection = function (localAxis) {
  20790. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20791. this.getDirectionToRef(localAxis, result);
  20792. return result;
  20793. };
  20794. /**
  20795. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20796. * @param localAxis Defines the reference axis to provide a relative direction.
  20797. * @param result Defines the vector to store the result in
  20798. */
  20799. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20800. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20801. };
  20802. /**
  20803. * Gets a camera constructor for a given camera type
  20804. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20805. * @param name The name of the camera the result will be able to instantiate
  20806. * @param scene The scene the result will construct the camera in
  20807. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20808. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20809. * @returns a factory method to construc the camera
  20810. */
  20811. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20812. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20813. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20814. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20815. interaxial_distance: interaxial_distance,
  20816. isStereoscopicSideBySide: isStereoscopicSideBySide
  20817. });
  20818. if (constructorFunc) {
  20819. return constructorFunc;
  20820. }
  20821. // Default to universal camera
  20822. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20823. };
  20824. /**
  20825. * Compute the world matrix of the camera.
  20826. * @returns the camera workd matrix
  20827. */
  20828. Camera.prototype.computeWorldMatrix = function () {
  20829. return this.getWorldMatrix();
  20830. };
  20831. /**
  20832. * Parse a JSON and creates the camera from the parsed information
  20833. * @param parsedCamera The JSON to parse
  20834. * @param scene The scene to instantiate the camera in
  20835. * @returns the newly constructed camera
  20836. */
  20837. Camera.Parse = function (parsedCamera, scene) {
  20838. var type = parsedCamera.type;
  20839. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20840. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20841. // Parent
  20842. if (parsedCamera.parentId) {
  20843. camera._waitingParentId = parsedCamera.parentId;
  20844. }
  20845. //If camera has an input manager, let it parse inputs settings
  20846. if (camera.inputs) {
  20847. camera.inputs.parse(parsedCamera);
  20848. camera._setupInputs();
  20849. }
  20850. if (camera.setPosition) { // need to force position
  20851. camera.position.copyFromFloats(0, 0, 0);
  20852. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20853. }
  20854. // Target
  20855. if (parsedCamera.target) {
  20856. if (camera.setTarget) {
  20857. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20858. }
  20859. }
  20860. // Apply 3d rig, when found
  20861. if (parsedCamera.cameraRigMode) {
  20862. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20863. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20864. }
  20865. // Animations
  20866. if (parsedCamera.animations) {
  20867. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20868. var parsedAnimation = parsedCamera.animations[animationIndex];
  20869. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_9__["_TypeStore"].GetClass("BABYLON.Animation");
  20870. if (internalClass) {
  20871. camera.animations.push(internalClass.Parse(parsedAnimation));
  20872. }
  20873. }
  20874. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20875. }
  20876. if (parsedCamera.autoAnimate) {
  20877. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20878. }
  20879. return camera;
  20880. };
  20881. /** @hidden */
  20882. Camera._createDefaultParsedCamera = function (name, scene) {
  20883. throw "UniversalCamera needs to be imported before deserialization can create a default camera.";
  20884. };
  20885. /**
  20886. * This is the default projection mode used by the cameras.
  20887. * It helps recreating a feeling of perspective and better appreciate depth.
  20888. * This is the best way to simulate real life cameras.
  20889. */
  20890. Camera.PERSPECTIVE_CAMERA = 0;
  20891. /**
  20892. * This helps creating camera with an orthographic mode.
  20893. * 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.
  20894. */
  20895. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20896. /**
  20897. * This is the default FOV mode for perspective cameras.
  20898. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20899. */
  20900. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20901. /**
  20902. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20903. */
  20904. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20905. /**
  20906. * This specifies ther is no need for a camera rig.
  20907. * Basically only one eye is rendered corresponding to the camera.
  20908. */
  20909. Camera.RIG_MODE_NONE = 0;
  20910. /**
  20911. * Simulates a camera Rig with one blue eye and one red eye.
  20912. * This can be use with 3d blue and red glasses.
  20913. */
  20914. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20915. /**
  20916. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20917. */
  20918. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20919. /**
  20920. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20921. */
  20922. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20923. /**
  20924. * Defines that both eyes of the camera will be rendered over under each other.
  20925. */
  20926. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20927. /**
  20928. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20929. */
  20930. Camera.RIG_MODE_VR = 20;
  20931. /**
  20932. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20933. */
  20934. Camera.RIG_MODE_WEBVR = 21;
  20935. /**
  20936. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20937. */
  20938. Camera.RIG_MODE_CUSTOM = 22;
  20939. /**
  20940. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20941. */
  20942. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20943. /**
  20944. * @hidden
  20945. * Might be removed once multiview will be a thing
  20946. */
  20947. Camera.UseAlternateWebVRRendering = false;
  20948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20950. ], Camera.prototype, "position", void 0);
  20951. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20953. ], Camera.prototype, "upVector", void 0);
  20954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20956. ], Camera.prototype, "orthoLeft", void 0);
  20957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20959. ], Camera.prototype, "orthoRight", void 0);
  20960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20962. ], Camera.prototype, "orthoBottom", void 0);
  20963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20965. ], Camera.prototype, "orthoTop", void 0);
  20966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20968. ], Camera.prototype, "fov", void 0);
  20969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20971. ], Camera.prototype, "minZ", void 0);
  20972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20974. ], Camera.prototype, "maxZ", void 0);
  20975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20977. ], Camera.prototype, "inertia", void 0);
  20978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20980. ], Camera.prototype, "mode", void 0);
  20981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20983. ], Camera.prototype, "layerMask", void 0);
  20984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20986. ], Camera.prototype, "fovMode", void 0);
  20987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20989. ], Camera.prototype, "cameraRigMode", void 0);
  20990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20992. ], Camera.prototype, "interaxialDistance", void 0);
  20993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20995. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  20996. return Camera;
  20997. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  20998. /***/ }),
  20999. /***/ "./Cameras/cameraInputsManager.ts":
  21000. /*!****************************************!*\
  21001. !*** ./Cameras/cameraInputsManager.ts ***!
  21002. \****************************************/
  21003. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21005. "use strict";
  21006. __webpack_require__.r(__webpack_exports__);
  21007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21009. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21010. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21011. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21012. /**
  21013. * @ignore
  21014. * This is a list of all the different input types that are available in the application.
  21015. * Fo instance: ArcRotateCameraGamepadInput...
  21016. */
  21017. var CameraInputTypes = {};
  21018. /**
  21019. * This represents the input manager used within a camera.
  21020. * It helps dealing with all the different kind of input attached to a camera.
  21021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21022. */
  21023. var CameraInputsManager = /** @class */ (function () {
  21024. /**
  21025. * Instantiate a new Camera Input Manager.
  21026. * @param camera Defines the camera the input manager blongs to
  21027. */
  21028. function CameraInputsManager(camera) {
  21029. this.attached = {};
  21030. this.camera = camera;
  21031. this.checkInputs = function () { };
  21032. }
  21033. /**
  21034. * Add an input method to a camera
  21035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21036. * @param input camera input method
  21037. */
  21038. CameraInputsManager.prototype.add = function (input) {
  21039. var type = input.getSimpleName();
  21040. if (this.attached[type]) {
  21041. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21042. return;
  21043. }
  21044. this.attached[type] = input;
  21045. input.camera = this.camera;
  21046. //for checkInputs, we are dynamically creating a function
  21047. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21048. if (input.checkInputs) {
  21049. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21050. }
  21051. if (this.attachedElement) {
  21052. input.attachControl(this.attachedElement);
  21053. }
  21054. };
  21055. /**
  21056. * Remove a specific input method from a camera
  21057. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21058. * @param inputToRemove camera input method
  21059. */
  21060. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21061. for (var cam in this.attached) {
  21062. var input = this.attached[cam];
  21063. if (input === inputToRemove) {
  21064. input.detachControl(this.attachedElement);
  21065. input.camera = null;
  21066. delete this.attached[cam];
  21067. this.rebuildInputCheck();
  21068. }
  21069. }
  21070. };
  21071. /**
  21072. * Remove a specific input type from a camera
  21073. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21074. * @param inputType the type of the input to remove
  21075. */
  21076. CameraInputsManager.prototype.removeByType = function (inputType) {
  21077. for (var cam in this.attached) {
  21078. var input = this.attached[cam];
  21079. if (input.getClassName() === inputType) {
  21080. input.detachControl(this.attachedElement);
  21081. input.camera = null;
  21082. delete this.attached[cam];
  21083. this.rebuildInputCheck();
  21084. }
  21085. }
  21086. };
  21087. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21088. var current = this.checkInputs;
  21089. return function () {
  21090. current();
  21091. fn();
  21092. };
  21093. };
  21094. /**
  21095. * Attach the input controls to the currently attached dom element to listen the events from.
  21096. * @param input Defines the input to attach
  21097. */
  21098. CameraInputsManager.prototype.attachInput = function (input) {
  21099. if (this.attachedElement) {
  21100. input.attachControl(this.attachedElement, this.noPreventDefault);
  21101. }
  21102. };
  21103. /**
  21104. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21105. * @param element Defines the dom element to collect the events from
  21106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21107. */
  21108. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21109. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21110. if (this.attachedElement) {
  21111. return;
  21112. }
  21113. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21114. this.attachedElement = element;
  21115. this.noPreventDefault = noPreventDefault;
  21116. for (var cam in this.attached) {
  21117. this.attached[cam].attachControl(element, noPreventDefault);
  21118. }
  21119. };
  21120. /**
  21121. * Detach the current manager inputs controls from a specific dom element.
  21122. * @param element Defines the dom element to collect the events from
  21123. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21124. */
  21125. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21126. if (disconnect === void 0) { disconnect = false; }
  21127. if (this.attachedElement !== element) {
  21128. return;
  21129. }
  21130. for (var cam in this.attached) {
  21131. this.attached[cam].detachControl(element);
  21132. if (disconnect) {
  21133. this.attached[cam].camera = null;
  21134. }
  21135. }
  21136. this.attachedElement = null;
  21137. };
  21138. /**
  21139. * Rebuild the dynamic inputCheck function from the current list of
  21140. * defined inputs in the manager.
  21141. */
  21142. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21143. this.checkInputs = function () { };
  21144. for (var cam in this.attached) {
  21145. var input = this.attached[cam];
  21146. if (input.checkInputs) {
  21147. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21148. }
  21149. }
  21150. };
  21151. /**
  21152. * Remove all attached input methods from a camera
  21153. */
  21154. CameraInputsManager.prototype.clear = function () {
  21155. if (this.attachedElement) {
  21156. this.detachElement(this.attachedElement, true);
  21157. }
  21158. this.attached = {};
  21159. this.attachedElement = null;
  21160. this.checkInputs = function () { };
  21161. };
  21162. /**
  21163. * Serialize the current input manager attached to a camera.
  21164. * This ensures than once parsed,
  21165. * the input associated to the camera will be identical to the current ones
  21166. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21167. */
  21168. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21169. var inputs = {};
  21170. for (var cam in this.attached) {
  21171. var input = this.attached[cam];
  21172. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21173. inputs[input.getClassName()] = res;
  21174. }
  21175. serializedCamera.inputsmgr = inputs;
  21176. };
  21177. /**
  21178. * Parses an input manager serialized JSON to restore the previous list of inputs
  21179. * and states associated to a camera.
  21180. * @param parsedCamera Defines the JSON to parse
  21181. */
  21182. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21183. var parsedInputs = parsedCamera.inputsmgr;
  21184. if (parsedInputs) {
  21185. this.clear();
  21186. for (var n in parsedInputs) {
  21187. var construct = CameraInputTypes[n];
  21188. if (construct) {
  21189. var parsedinput = parsedInputs[n];
  21190. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21191. this.add(input);
  21192. }
  21193. }
  21194. }
  21195. else {
  21196. //2016-03-08 this part is for managing backward compatibility
  21197. for (var n in this.attached) {
  21198. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21199. if (construct) {
  21200. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21201. this.remove(this.attached[n]);
  21202. this.add(input);
  21203. }
  21204. }
  21205. }
  21206. };
  21207. return CameraInputsManager;
  21208. }());
  21209. /***/ }),
  21210. /***/ "./Cameras/deviceOrientationCamera.ts":
  21211. /*!********************************************!*\
  21212. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21213. \********************************************/
  21214. /*! exports provided: DeviceOrientationCamera */
  21215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21216. "use strict";
  21217. __webpack_require__.r(__webpack_exports__);
  21218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21219. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21220. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21221. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21222. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21223. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21224. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21225. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21226. });
  21227. // We're mainly based on the logic defined into the FreeCamera code
  21228. /**
  21229. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21230. * being tilted forward or back and left or right.
  21231. */
  21232. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21234. /**
  21235. * Creates a new device orientation camera
  21236. * @param name The name of the camera
  21237. * @param position The start position camera
  21238. * @param scene The scene the camera belongs to
  21239. */
  21240. function DeviceOrientationCamera(name, position, scene) {
  21241. var _this = _super.call(this, name, position, scene) || this;
  21242. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21243. _this.inputs.addDeviceOrientation();
  21244. return _this;
  21245. }
  21246. /**
  21247. * Gets the current instance class name ("DeviceOrientationCamera").
  21248. * This helps avoiding instanceof at run time.
  21249. * @returns the class name
  21250. */
  21251. DeviceOrientationCamera.prototype.getClassName = function () {
  21252. return "DeviceOrientationCamera";
  21253. };
  21254. /**
  21255. * @hidden
  21256. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21257. */
  21258. DeviceOrientationCamera.prototype._checkInputs = function () {
  21259. _super.prototype._checkInputs.call(this);
  21260. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21261. if (this._initialQuaternion) {
  21262. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21263. }
  21264. };
  21265. /**
  21266. * Reset the camera to its default orientation on the specified axis only.
  21267. * @param axis The axis to reset
  21268. */
  21269. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21270. var _this = this;
  21271. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21272. //can only work if this camera has a rotation quaternion already.
  21273. if (!this.rotationQuaternion) {
  21274. return;
  21275. }
  21276. if (!this._initialQuaternion) {
  21277. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21278. }
  21279. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21280. ['x', 'y', 'z'].forEach(function (axisName) {
  21281. if (!axis[axisName]) {
  21282. _this._initialQuaternion[axisName] = 0;
  21283. }
  21284. else {
  21285. _this._initialQuaternion[axisName] *= -1;
  21286. }
  21287. });
  21288. this._initialQuaternion.normalize();
  21289. //force rotation update
  21290. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21291. };
  21292. return DeviceOrientationCamera;
  21293. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21294. /***/ }),
  21295. /***/ "./Cameras/flyCamera.ts":
  21296. /*!******************************!*\
  21297. !*** ./Cameras/flyCamera.ts ***!
  21298. \******************************/
  21299. /*! exports provided: FlyCamera */
  21300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21301. "use strict";
  21302. __webpack_require__.r(__webpack_exports__);
  21303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21304. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21305. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21306. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21307. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21308. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21309. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21310. /**
  21311. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21312. * such as in a 3D Space Shooter or a Flight Simulator.
  21313. */
  21314. var FlyCamera = /** @class */ (function (_super) {
  21315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21316. /**
  21317. * Instantiates a FlyCamera.
  21318. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21319. * such as in a 3D Space Shooter or a Flight Simulator.
  21320. * @param name Define the name of the camera in the scene.
  21321. * @param position Define the starting position of the camera in the scene.
  21322. * @param scene Define the scene the camera belongs to.
  21323. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21324. */
  21325. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21326. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21327. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21328. /**
  21329. * Define the collision ellipsoid of the camera.
  21330. * This is helpful for simulating a camera body, like a player's body.
  21331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21332. */
  21333. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21334. /**
  21335. * Define an offset for the position of the ellipsoid around the camera.
  21336. * This can be helpful if the camera is attached away from the player's body center,
  21337. * such as at its head.
  21338. */
  21339. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21340. /**
  21341. * Enable or disable collisions of the camera with the rest of the scene objects.
  21342. */
  21343. _this.checkCollisions = false;
  21344. /**
  21345. * Enable or disable gravity on the camera.
  21346. */
  21347. _this.applyGravity = false;
  21348. /**
  21349. * Define the current direction the camera is moving to.
  21350. */
  21351. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21352. /**
  21353. * Track Roll to maintain the wanted Rolling when looking around.
  21354. */
  21355. _this._trackRoll = 0;
  21356. /**
  21357. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21358. */
  21359. _this.rollCorrect = 100;
  21360. /**
  21361. * Mimic a banked turn, Rolling the camera when Yawing.
  21362. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21363. */
  21364. _this.bankedTurn = false;
  21365. /**
  21366. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21367. */
  21368. _this.bankedTurnLimit = Math.PI / 2;
  21369. /**
  21370. * Value of 0 disables the banked Roll.
  21371. * Value of 1 is equal to the Yaw angle in radians.
  21372. */
  21373. _this.bankedTurnMultiplier = 1;
  21374. _this._needMoveForGravity = false;
  21375. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21376. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21377. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21378. // Collisions.
  21379. _this._collisionMask = -1;
  21380. /** @hidden */
  21381. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21382. if (collidedMesh === void 0) { collidedMesh = null; }
  21383. var updatePosition = function (newPos) {
  21384. _this._newPosition.copyFrom(newPos);
  21385. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21386. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21387. _this.position.addInPlace(_this._diffPosition);
  21388. if (_this.onCollide && collidedMesh) {
  21389. _this.onCollide(collidedMesh);
  21390. }
  21391. }
  21392. };
  21393. updatePosition(newPosition);
  21394. };
  21395. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21396. _this.inputs.addKeyboard().addMouse();
  21397. return _this;
  21398. }
  21399. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21400. /**
  21401. * Gets the input sensibility for mouse input.
  21402. * Higher values reduce sensitivity.
  21403. */
  21404. get: function () {
  21405. var mouse = this.inputs.attached["mouse"];
  21406. if (mouse) {
  21407. return mouse.angularSensibility;
  21408. }
  21409. return 0;
  21410. },
  21411. /**
  21412. * Sets the input sensibility for a mouse input.
  21413. * Higher values reduce sensitivity.
  21414. */
  21415. set: function (value) {
  21416. var mouse = this.inputs.attached["mouse"];
  21417. if (mouse) {
  21418. mouse.angularSensibility = value;
  21419. }
  21420. },
  21421. enumerable: true,
  21422. configurable: true
  21423. });
  21424. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21425. /**
  21426. * Get the keys for camera movement forward.
  21427. */
  21428. get: function () {
  21429. var keyboard = this.inputs.attached["keyboard"];
  21430. if (keyboard) {
  21431. return keyboard.keysForward;
  21432. }
  21433. return [];
  21434. },
  21435. /**
  21436. * Set the keys for camera movement forward.
  21437. */
  21438. set: function (value) {
  21439. var keyboard = this.inputs.attached["keyboard"];
  21440. if (keyboard) {
  21441. keyboard.keysForward = value;
  21442. }
  21443. },
  21444. enumerable: true,
  21445. configurable: true
  21446. });
  21447. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21448. /**
  21449. * Get the keys for camera movement backward.
  21450. */
  21451. get: function () {
  21452. var keyboard = this.inputs.attached["keyboard"];
  21453. if (keyboard) {
  21454. return keyboard.keysBackward;
  21455. }
  21456. return [];
  21457. },
  21458. set: function (value) {
  21459. var keyboard = this.inputs.attached["keyboard"];
  21460. if (keyboard) {
  21461. keyboard.keysBackward = value;
  21462. }
  21463. },
  21464. enumerable: true,
  21465. configurable: true
  21466. });
  21467. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21468. /**
  21469. * Get the keys for camera movement up.
  21470. */
  21471. get: function () {
  21472. var keyboard = this.inputs.attached["keyboard"];
  21473. if (keyboard) {
  21474. return keyboard.keysUp;
  21475. }
  21476. return [];
  21477. },
  21478. /**
  21479. * Set the keys for camera movement up.
  21480. */
  21481. set: function (value) {
  21482. var keyboard = this.inputs.attached["keyboard"];
  21483. if (keyboard) {
  21484. keyboard.keysUp = value;
  21485. }
  21486. },
  21487. enumerable: true,
  21488. configurable: true
  21489. });
  21490. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21491. /**
  21492. * Get the keys for camera movement down.
  21493. */
  21494. get: function () {
  21495. var keyboard = this.inputs.attached["keyboard"];
  21496. if (keyboard) {
  21497. return keyboard.keysDown;
  21498. }
  21499. return [];
  21500. },
  21501. /**
  21502. * Set the keys for camera movement down.
  21503. */
  21504. set: function (value) {
  21505. var keyboard = this.inputs.attached["keyboard"];
  21506. if (keyboard) {
  21507. keyboard.keysDown = value;
  21508. }
  21509. },
  21510. enumerable: true,
  21511. configurable: true
  21512. });
  21513. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21514. /**
  21515. * Get the keys for camera movement left.
  21516. */
  21517. get: function () {
  21518. var keyboard = this.inputs.attached["keyboard"];
  21519. if (keyboard) {
  21520. return keyboard.keysLeft;
  21521. }
  21522. return [];
  21523. },
  21524. /**
  21525. * Set the keys for camera movement left.
  21526. */
  21527. set: function (value) {
  21528. var keyboard = this.inputs.attached["keyboard"];
  21529. if (keyboard) {
  21530. keyboard.keysLeft = value;
  21531. }
  21532. },
  21533. enumerable: true,
  21534. configurable: true
  21535. });
  21536. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21537. /**
  21538. * Set the keys for camera movement right.
  21539. */
  21540. get: function () {
  21541. var keyboard = this.inputs.attached["keyboard"];
  21542. if (keyboard) {
  21543. return keyboard.keysRight;
  21544. }
  21545. return [];
  21546. },
  21547. /**
  21548. * Set the keys for camera movement right.
  21549. */
  21550. set: function (value) {
  21551. var keyboard = this.inputs.attached["keyboard"];
  21552. if (keyboard) {
  21553. keyboard.keysRight = value;
  21554. }
  21555. },
  21556. enumerable: true,
  21557. configurable: true
  21558. });
  21559. /**
  21560. * Attach a control to the HTML DOM element.
  21561. * @param element Defines the element that listens to the input events.
  21562. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21563. */
  21564. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21565. this.inputs.attachElement(element, noPreventDefault);
  21566. };
  21567. /**
  21568. * Detach a control from the HTML DOM element.
  21569. * The camera will stop reacting to that input.
  21570. * @param element Defines the element that listens to the input events.
  21571. */
  21572. FlyCamera.prototype.detachControl = function (element) {
  21573. this.inputs.detachElement(element);
  21574. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21575. };
  21576. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21577. /**
  21578. * Get the mask that the camera ignores in collision events.
  21579. */
  21580. get: function () {
  21581. return this._collisionMask;
  21582. },
  21583. /**
  21584. * Set the mask that the camera ignores in collision events.
  21585. */
  21586. set: function (mask) {
  21587. this._collisionMask = !isNaN(mask) ? mask : -1;
  21588. },
  21589. enumerable: true,
  21590. configurable: true
  21591. });
  21592. /** @hidden */
  21593. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21594. var globalPosition;
  21595. if (this.parent) {
  21596. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21597. }
  21598. else {
  21599. globalPosition = this.position;
  21600. }
  21601. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21602. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21603. var coordinator = this.getScene().collisionCoordinator;
  21604. if (!this._collider) {
  21605. this._collider = coordinator.createCollider();
  21606. }
  21607. this._collider._radius = this.ellipsoid;
  21608. this._collider.collisionMask = this._collisionMask;
  21609. // No need for clone, as long as gravity is not on.
  21610. var actualDisplacement = displacement;
  21611. // Add gravity to direction to prevent dual-collision checking.
  21612. if (this.applyGravity) {
  21613. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21614. actualDisplacement = displacement.add(this.getScene().gravity);
  21615. }
  21616. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21617. };
  21618. /** @hidden */
  21619. FlyCamera.prototype._checkInputs = function () {
  21620. if (!this._localDirection) {
  21621. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21622. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21623. }
  21624. this.inputs.checkInputs();
  21625. _super.prototype._checkInputs.call(this);
  21626. };
  21627. /** @hidden */
  21628. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21629. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21630. };
  21631. /** @hidden */
  21632. FlyCamera.prototype._updatePosition = function () {
  21633. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21634. this._collideWithWorld(this.cameraDirection);
  21635. }
  21636. else {
  21637. _super.prototype._updatePosition.call(this);
  21638. }
  21639. };
  21640. /**
  21641. * Restore the Roll to its target value at the rate specified.
  21642. * @param rate - Higher means slower restoring.
  21643. * @hidden
  21644. */
  21645. FlyCamera.prototype.restoreRoll = function (rate) {
  21646. var limit = this._trackRoll; // Target Roll.
  21647. var z = this.rotation.z; // Current Roll.
  21648. var delta = limit - z; // Difference in Roll.
  21649. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21650. // If the difference is noticable, restore the Roll.
  21651. if (Math.abs(delta) >= minRad) {
  21652. // Change Z rotation towards the target Roll.
  21653. this.rotation.z += delta / rate;
  21654. // Match when near enough.
  21655. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21656. this.rotation.z = limit;
  21657. }
  21658. }
  21659. };
  21660. /**
  21661. * Destroy the camera and release the current resources held by it.
  21662. */
  21663. FlyCamera.prototype.dispose = function () {
  21664. this.inputs.clear();
  21665. _super.prototype.dispose.call(this);
  21666. };
  21667. /**
  21668. * Get the current object class name.
  21669. * @returns the class name.
  21670. */
  21671. FlyCamera.prototype.getClassName = function () {
  21672. return "FlyCamera";
  21673. };
  21674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21676. ], FlyCamera.prototype, "ellipsoid", void 0);
  21677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21679. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21682. ], FlyCamera.prototype, "checkCollisions", void 0);
  21683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21685. ], FlyCamera.prototype, "applyGravity", void 0);
  21686. return FlyCamera;
  21687. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  21688. /***/ }),
  21689. /***/ "./Cameras/flyCameraInputsManager.ts":
  21690. /*!*******************************************!*\
  21691. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21692. \*******************************************/
  21693. /*! exports provided: FlyCameraInputsManager */
  21694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21695. "use strict";
  21696. __webpack_require__.r(__webpack_exports__);
  21697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21698. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21699. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21700. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21701. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21702. /**
  21703. * Default Inputs manager for the FlyCamera.
  21704. * It groups all the default supported inputs for ease of use.
  21705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21706. */
  21707. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21708. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21709. /**
  21710. * Instantiates a new FlyCameraInputsManager.
  21711. * @param camera Defines the camera the inputs belong to.
  21712. */
  21713. function FlyCameraInputsManager(camera) {
  21714. return _super.call(this, camera) || this;
  21715. }
  21716. /**
  21717. * Add keyboard input support to the input manager.
  21718. * @returns the new FlyCameraKeyboardMoveInput().
  21719. */
  21720. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21721. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21722. return this;
  21723. };
  21724. /**
  21725. * Add mouse input support to the input manager.
  21726. * @param touchEnabled Enable touch screen support.
  21727. * @returns the new FlyCameraMouseInput().
  21728. */
  21729. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21730. if (touchEnabled === void 0) { touchEnabled = true; }
  21731. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21732. return this;
  21733. };
  21734. return FlyCameraInputsManager;
  21735. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21736. /***/ }),
  21737. /***/ "./Cameras/followCamera.ts":
  21738. /*!*********************************!*\
  21739. !*** ./Cameras/followCamera.ts ***!
  21740. \*********************************/
  21741. /*! exports provided: FollowCamera, ArcFollowCamera */
  21742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21743. "use strict";
  21744. __webpack_require__.r(__webpack_exports__);
  21745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21748. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21749. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21750. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21751. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21752. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21753. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21754. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21755. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21756. });
  21757. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21758. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21759. });
  21760. /**
  21761. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21762. * an arc rotate version arcFollowCamera are available.
  21763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21764. */
  21765. var FollowCamera = /** @class */ (function (_super) {
  21766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21767. /**
  21768. * Instantiates the follow camera.
  21769. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21770. * @param name Define the name of the camera in the scene
  21771. * @param position Define the position of the camera
  21772. * @param scene Define the scene the camera belong to
  21773. * @param lockedTarget Define the target of the camera
  21774. */
  21775. function FollowCamera(name, position, scene, lockedTarget) {
  21776. if (lockedTarget === void 0) { lockedTarget = null; }
  21777. var _this = _super.call(this, name, position, scene) || this;
  21778. /**
  21779. * Distance the follow camera should follow an object at
  21780. */
  21781. _this.radius = 12;
  21782. /**
  21783. * Minimum allowed distance of the camera to the axis of rotation
  21784. * (The camera can not get closer).
  21785. * This can help limiting how the Camera is able to move in the scene.
  21786. */
  21787. _this.lowerRadiusLimit = null;
  21788. /**
  21789. * Maximum allowed distance of the camera to the axis of rotation
  21790. * (The camera can not get further).
  21791. * This can help limiting how the Camera is able to move in the scene.
  21792. */
  21793. _this.upperRadiusLimit = null;
  21794. /**
  21795. * Define a rotation offset between the camera and the object it follows
  21796. */
  21797. _this.rotationOffset = 0;
  21798. /**
  21799. * Minimum allowed angle to camera position relative to target object.
  21800. * This can help limiting how the Camera is able to move in the scene.
  21801. */
  21802. _this.lowerRotationOffsetLimit = null;
  21803. /**
  21804. * Maximum allowed angle to camera position relative to target object.
  21805. * This can help limiting how the Camera is able to move in the scene.
  21806. */
  21807. _this.upperRotationOffsetLimit = null;
  21808. /**
  21809. * Define a height offset between the camera and the object it follows.
  21810. * It can help following an object from the top (like a car chaing a plane)
  21811. */
  21812. _this.heightOffset = 4;
  21813. /**
  21814. * Minimum allowed height of camera position relative to target object.
  21815. * This can help limiting how the Camera is able to move in the scene.
  21816. */
  21817. _this.lowerHeightOffsetLimit = null;
  21818. /**
  21819. * Maximum allowed height of camera position relative to target object.
  21820. * This can help limiting how the Camera is able to move in the scene.
  21821. */
  21822. _this.upperHeightOffsetLimit = null;
  21823. /**
  21824. * Define how fast the camera can accelerate to follow it s target.
  21825. */
  21826. _this.cameraAcceleration = 0.05;
  21827. /**
  21828. * Define the speed limit of the camera following an object.
  21829. */
  21830. _this.maxCameraSpeed = 20;
  21831. _this.lockedTarget = lockedTarget;
  21832. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21833. _this.inputs.addKeyboard().addMouseWheel();
  21834. return _this;
  21835. // Uncomment the following line when the relevant handlers have been implemented.
  21836. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21837. }
  21838. FollowCamera.prototype._follow = function (cameraTarget) {
  21839. if (!cameraTarget) {
  21840. return;
  21841. }
  21842. var yRotation;
  21843. if (cameraTarget.rotationQuaternion) {
  21844. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21845. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21846. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21847. }
  21848. else {
  21849. yRotation = cameraTarget.rotation.y;
  21850. }
  21851. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21852. var targetPosition = cameraTarget.getAbsolutePosition();
  21853. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21854. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21855. var dx = targetX - this.position.x;
  21856. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21857. var dz = (targetZ) - this.position.z;
  21858. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21859. var vy = dy * this.cameraAcceleration;
  21860. var vz = dz * this.cameraAcceleration * 2;
  21861. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21862. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21863. }
  21864. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21865. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21866. }
  21867. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21868. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21869. }
  21870. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21871. this.setTarget(targetPosition);
  21872. };
  21873. /**
  21874. * Attached controls to the current camera.
  21875. * @param element Defines the element the controls should be listened from
  21876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21877. */
  21878. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21879. this.inputs.attachElement(element, noPreventDefault);
  21880. this._reset = function () {
  21881. };
  21882. };
  21883. /**
  21884. * Detach the current controls from the camera.
  21885. * The camera will stop reacting to inputs.
  21886. * @param element Defines the element to stop listening the inputs from
  21887. */
  21888. FollowCamera.prototype.detachControl = function (element) {
  21889. this.inputs.detachElement(element);
  21890. if (this._reset) {
  21891. this._reset();
  21892. }
  21893. };
  21894. /** @hidden */
  21895. FollowCamera.prototype._checkInputs = function () {
  21896. this.inputs.checkInputs();
  21897. this._checkLimits();
  21898. _super.prototype._checkInputs.call(this);
  21899. if (this.lockedTarget) {
  21900. this._follow(this.lockedTarget);
  21901. }
  21902. };
  21903. FollowCamera.prototype._checkLimits = function () {
  21904. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21905. this.radius = this.lowerRadiusLimit;
  21906. }
  21907. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21908. this.radius = this.upperRadiusLimit;
  21909. }
  21910. if (this.lowerHeightOffsetLimit !== null &&
  21911. this.heightOffset < this.lowerHeightOffsetLimit) {
  21912. this.heightOffset = this.lowerHeightOffsetLimit;
  21913. }
  21914. if (this.upperHeightOffsetLimit !== null &&
  21915. this.heightOffset > this.upperHeightOffsetLimit) {
  21916. this.heightOffset = this.upperHeightOffsetLimit;
  21917. }
  21918. if (this.lowerRotationOffsetLimit !== null &&
  21919. this.rotationOffset < this.lowerRotationOffsetLimit) {
  21920. this.rotationOffset = this.lowerRotationOffsetLimit;
  21921. }
  21922. if (this.upperRotationOffsetLimit !== null &&
  21923. this.rotationOffset > this.upperRotationOffsetLimit) {
  21924. this.rotationOffset = this.upperRotationOffsetLimit;
  21925. }
  21926. };
  21927. /**
  21928. * Gets the camera class name.
  21929. * @returns the class name
  21930. */
  21931. FollowCamera.prototype.getClassName = function () {
  21932. return "FollowCamera";
  21933. };
  21934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21936. ], FollowCamera.prototype, "radius", void 0);
  21937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21939. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  21940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21942. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  21943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21945. ], FollowCamera.prototype, "rotationOffset", void 0);
  21946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21948. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  21949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21951. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21954. ], FollowCamera.prototype, "heightOffset", void 0);
  21955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21957. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  21958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21960. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  21961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21963. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21966. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21969. ], FollowCamera.prototype, "lockedTarget", void 0);
  21970. return FollowCamera;
  21971. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21972. /**
  21973. * Arc Rotate version of the follow camera.
  21974. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21976. */
  21977. var ArcFollowCamera = /** @class */ (function (_super) {
  21978. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21979. /**
  21980. * Instantiates a new ArcFollowCamera
  21981. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21982. * @param name Define the name of the camera
  21983. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21984. * @param beta Define the rotation angle of the camera around the elevation axis
  21985. * @param radius Define the radius of the camera from its target point
  21986. * @param target Define the target of the camera
  21987. * @param scene Define the scene the camera belongs to
  21988. */
  21989. function ArcFollowCamera(name,
  21990. /** The longitudinal angle of the camera */
  21991. alpha,
  21992. /** The latitudinal angle of the camera */
  21993. beta,
  21994. /** The radius of the camera from its target */
  21995. radius,
  21996. /** Define the camera target (the messh it should follow) */
  21997. target, scene) {
  21998. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  21999. _this.alpha = alpha;
  22000. _this.beta = beta;
  22001. _this.radius = radius;
  22002. _this.target = target;
  22003. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22004. _this._follow();
  22005. return _this;
  22006. }
  22007. ArcFollowCamera.prototype._follow = function () {
  22008. if (!this.target) {
  22009. return;
  22010. }
  22011. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22012. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22013. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22014. var targetPosition = this.target.getAbsolutePosition();
  22015. this.position = targetPosition.add(this._cartesianCoordinates);
  22016. this.setTarget(targetPosition);
  22017. };
  22018. /** @hidden */
  22019. ArcFollowCamera.prototype._checkInputs = function () {
  22020. _super.prototype._checkInputs.call(this);
  22021. this._follow();
  22022. };
  22023. /**
  22024. * Returns the class name of the object.
  22025. * It is mostly used internally for serialization purposes.
  22026. */
  22027. ArcFollowCamera.prototype.getClassName = function () {
  22028. return "ArcFollowCamera";
  22029. };
  22030. return ArcFollowCamera;
  22031. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22032. /***/ }),
  22033. /***/ "./Cameras/followCameraInputsManager.ts":
  22034. /*!**********************************************!*\
  22035. !*** ./Cameras/followCameraInputsManager.ts ***!
  22036. \**********************************************/
  22037. /*! exports provided: FollowCameraInputsManager */
  22038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22039. "use strict";
  22040. __webpack_require__.r(__webpack_exports__);
  22041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22042. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22043. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22044. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22045. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22046. /**
  22047. * Default Inputs manager for the FollowCamera.
  22048. * It groups all the default supported inputs for ease of use.
  22049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22050. */
  22051. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22052. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22053. /**
  22054. * Instantiates a new FollowCameraInputsManager.
  22055. * @param camera Defines the camera the inputs belong to
  22056. */
  22057. function FollowCameraInputsManager(camera) {
  22058. return _super.call(this, camera) || this;
  22059. }
  22060. /**
  22061. * Add keyboard input support to the input manager.
  22062. * @returns the current input manager
  22063. */
  22064. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22065. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22066. return this;
  22067. };
  22068. /**
  22069. * Add mouse wheel input support to the input manager.
  22070. * @returns the current input manager
  22071. */
  22072. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22073. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22074. return this;
  22075. };
  22076. /**
  22077. * Add pointers input support to the input manager.
  22078. * @returns the current input manager
  22079. */
  22080. FollowCameraInputsManager.prototype.addPointers = function () {
  22081. console.warn("Pointer support not yet implemented for FollowCamera.");
  22082. return this;
  22083. };
  22084. /**
  22085. * Add orientation input support to the input manager.
  22086. * @returns the current input manager
  22087. */
  22088. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22089. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22090. return this;
  22091. };
  22092. return FollowCameraInputsManager;
  22093. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22094. /***/ }),
  22095. /***/ "./Cameras/freeCamera.ts":
  22096. /*!*******************************!*\
  22097. !*** ./Cameras/freeCamera.ts ***!
  22098. \*******************************/
  22099. /*! exports provided: FreeCamera */
  22100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22101. "use strict";
  22102. __webpack_require__.r(__webpack_exports__);
  22103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22104. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22105. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22106. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22107. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22108. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22109. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22110. /**
  22111. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22112. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22113. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22114. */
  22115. var FreeCamera = /** @class */ (function (_super) {
  22116. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22117. /**
  22118. * Instantiates a Free Camera.
  22119. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22120. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22121. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22122. * @param name Define the name of the camera in the scene
  22123. * @param position Define the start position of the camera in the scene
  22124. * @param scene Define the scene the camera belongs to
  22125. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22126. */
  22127. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22128. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22129. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22130. /**
  22131. * Define the collision ellipsoid of the camera.
  22132. * This is helpful to simulate a camera body like the player body around the camera
  22133. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22134. */
  22135. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22136. /**
  22137. * Define an offset for the position of the ellipsoid around the camera.
  22138. * This can be helpful to determine the center of the body near the gravity center of the body
  22139. * instead of its head.
  22140. */
  22141. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22142. /**
  22143. * Enable or disable collisions of the camera with the rest of the scene objects.
  22144. */
  22145. _this.checkCollisions = false;
  22146. /**
  22147. * Enable or disable gravity on the camera.
  22148. */
  22149. _this.applyGravity = false;
  22150. _this._needMoveForGravity = false;
  22151. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22152. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22153. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22154. // Collisions
  22155. _this._collisionMask = -1;
  22156. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22157. if (collidedMesh === void 0) { collidedMesh = null; }
  22158. var updatePosition = function (newPos) {
  22159. _this._newPosition.copyFrom(newPos);
  22160. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22161. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22162. _this.position.addInPlace(_this._diffPosition);
  22163. if (_this.onCollide && collidedMesh) {
  22164. _this.onCollide(collidedMesh);
  22165. }
  22166. }
  22167. };
  22168. updatePosition(newPosition);
  22169. };
  22170. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22171. _this.inputs.addKeyboard().addMouse();
  22172. return _this;
  22173. }
  22174. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22175. /**
  22176. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22177. * Higher values reduce sensitivity.
  22178. */
  22179. get: function () {
  22180. var mouse = this.inputs.attached["mouse"];
  22181. if (mouse) {
  22182. return mouse.angularSensibility;
  22183. }
  22184. return 0;
  22185. },
  22186. /**
  22187. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22188. * Higher values reduce sensitivity.
  22189. */
  22190. set: function (value) {
  22191. var mouse = this.inputs.attached["mouse"];
  22192. if (mouse) {
  22193. mouse.angularSensibility = value;
  22194. }
  22195. },
  22196. enumerable: true,
  22197. configurable: true
  22198. });
  22199. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22200. /**
  22201. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22202. */
  22203. get: function () {
  22204. var keyboard = this.inputs.attached["keyboard"];
  22205. if (keyboard) {
  22206. return keyboard.keysUp;
  22207. }
  22208. return [];
  22209. },
  22210. set: function (value) {
  22211. var keyboard = this.inputs.attached["keyboard"];
  22212. if (keyboard) {
  22213. keyboard.keysUp = value;
  22214. }
  22215. },
  22216. enumerable: true,
  22217. configurable: true
  22218. });
  22219. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22220. /**
  22221. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22222. */
  22223. get: function () {
  22224. var keyboard = this.inputs.attached["keyboard"];
  22225. if (keyboard) {
  22226. return keyboard.keysDown;
  22227. }
  22228. return [];
  22229. },
  22230. set: function (value) {
  22231. var keyboard = this.inputs.attached["keyboard"];
  22232. if (keyboard) {
  22233. keyboard.keysDown = value;
  22234. }
  22235. },
  22236. enumerable: true,
  22237. configurable: true
  22238. });
  22239. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22240. /**
  22241. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22242. */
  22243. get: function () {
  22244. var keyboard = this.inputs.attached["keyboard"];
  22245. if (keyboard) {
  22246. return keyboard.keysLeft;
  22247. }
  22248. return [];
  22249. },
  22250. set: function (value) {
  22251. var keyboard = this.inputs.attached["keyboard"];
  22252. if (keyboard) {
  22253. keyboard.keysLeft = value;
  22254. }
  22255. },
  22256. enumerable: true,
  22257. configurable: true
  22258. });
  22259. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22260. /**
  22261. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22262. */
  22263. get: function () {
  22264. var keyboard = this.inputs.attached["keyboard"];
  22265. if (keyboard) {
  22266. return keyboard.keysRight;
  22267. }
  22268. return [];
  22269. },
  22270. set: function (value) {
  22271. var keyboard = this.inputs.attached["keyboard"];
  22272. if (keyboard) {
  22273. keyboard.keysRight = value;
  22274. }
  22275. },
  22276. enumerable: true,
  22277. configurable: true
  22278. });
  22279. /**
  22280. * Attached controls to the current camera.
  22281. * @param element Defines the element the controls should be listened from
  22282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22283. */
  22284. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22285. this.inputs.attachElement(element, noPreventDefault);
  22286. };
  22287. /**
  22288. * Detach the current controls from the camera.
  22289. * The camera will stop reacting to inputs.
  22290. * @param element Defines the element to stop listening the inputs from
  22291. */
  22292. FreeCamera.prototype.detachControl = function (element) {
  22293. this.inputs.detachElement(element);
  22294. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22295. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22296. };
  22297. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22298. /**
  22299. * Define a collision mask to limit the list of object the camera can collide with
  22300. */
  22301. get: function () {
  22302. return this._collisionMask;
  22303. },
  22304. set: function (mask) {
  22305. this._collisionMask = !isNaN(mask) ? mask : -1;
  22306. },
  22307. enumerable: true,
  22308. configurable: true
  22309. });
  22310. /** @hidden */
  22311. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22312. var globalPosition;
  22313. if (this.parent) {
  22314. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22315. }
  22316. else {
  22317. globalPosition = this.position;
  22318. }
  22319. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22320. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22321. var coordinator = this.getScene().collisionCoordinator;
  22322. if (!this._collider) {
  22323. this._collider = coordinator.createCollider();
  22324. }
  22325. this._collider._radius = this.ellipsoid;
  22326. this._collider.collisionMask = this._collisionMask;
  22327. //no need for clone, as long as gravity is not on.
  22328. var actualDisplacement = displacement;
  22329. //add gravity to the direction to prevent the dual-collision checking
  22330. if (this.applyGravity) {
  22331. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22332. actualDisplacement = displacement.add(this.getScene().gravity);
  22333. }
  22334. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22335. };
  22336. /** @hidden */
  22337. FreeCamera.prototype._checkInputs = function () {
  22338. if (!this._localDirection) {
  22339. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22340. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22341. }
  22342. this.inputs.checkInputs();
  22343. _super.prototype._checkInputs.call(this);
  22344. };
  22345. /** @hidden */
  22346. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22347. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22348. };
  22349. /** @hidden */
  22350. FreeCamera.prototype._updatePosition = function () {
  22351. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22352. this._collideWithWorld(this.cameraDirection);
  22353. }
  22354. else {
  22355. _super.prototype._updatePosition.call(this);
  22356. }
  22357. };
  22358. /**
  22359. * Destroy the camera and release the current resources hold by it.
  22360. */
  22361. FreeCamera.prototype.dispose = function () {
  22362. this.inputs.clear();
  22363. _super.prototype.dispose.call(this);
  22364. };
  22365. /**
  22366. * Gets the current object class name.
  22367. * @return the class name
  22368. */
  22369. FreeCamera.prototype.getClassName = function () {
  22370. return "FreeCamera";
  22371. };
  22372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22374. ], FreeCamera.prototype, "ellipsoid", void 0);
  22375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22377. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22380. ], FreeCamera.prototype, "checkCollisions", void 0);
  22381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22383. ], FreeCamera.prototype, "applyGravity", void 0);
  22384. return FreeCamera;
  22385. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22386. /***/ }),
  22387. /***/ "./Cameras/freeCameraInputsManager.ts":
  22388. /*!********************************************!*\
  22389. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22390. \********************************************/
  22391. /*! exports provided: FreeCameraInputsManager */
  22392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22393. "use strict";
  22394. __webpack_require__.r(__webpack_exports__);
  22395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22397. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22398. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22399. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22400. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22401. /**
  22402. * Default Inputs manager for the FreeCamera.
  22403. * It groups all the default supported inputs for ease of use.
  22404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22405. */
  22406. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22407. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22408. /**
  22409. * Instantiates a new FreeCameraInputsManager.
  22410. * @param camera Defines the camera the inputs belong to
  22411. */
  22412. function FreeCameraInputsManager(camera) {
  22413. return _super.call(this, camera) || this;
  22414. }
  22415. /**
  22416. * Add keyboard input support to the input manager.
  22417. * @returns the current input manager
  22418. */
  22419. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22420. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22421. return this;
  22422. };
  22423. /**
  22424. * Add mouse input support to the input manager.
  22425. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22426. * @returns the current input manager
  22427. */
  22428. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22429. if (touchEnabled === void 0) { touchEnabled = true; }
  22430. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22431. return this;
  22432. };
  22433. /**
  22434. * Add touch input support to the input manager.
  22435. * @returns the current input manager
  22436. */
  22437. FreeCameraInputsManager.prototype.addTouch = function () {
  22438. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22439. return this;
  22440. };
  22441. return FreeCameraInputsManager;
  22442. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22443. /***/ }),
  22444. /***/ "./Cameras/gamepadCamera.ts":
  22445. /*!**********************************!*\
  22446. !*** ./Cameras/gamepadCamera.ts ***!
  22447. \**********************************/
  22448. /*! exports provided: GamepadCamera */
  22449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22450. "use strict";
  22451. __webpack_require__.r(__webpack_exports__);
  22452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22453. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22454. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22455. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22456. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22457. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22458. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22459. });
  22460. /**
  22461. * This represents a FPS type of camera. This is only here for back compat purpose.
  22462. * Please use the UniversalCamera instead as both are identical.
  22463. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22464. */
  22465. var GamepadCamera = /** @class */ (function (_super) {
  22466. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22467. /**
  22468. * Instantiates a new Gamepad Camera
  22469. * This represents a FPS type of camera. This is only here for back compat purpose.
  22470. * Please use the UniversalCamera instead as both are identical.
  22471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22472. * @param name Define the name of the camera in the scene
  22473. * @param position Define the start position of the camera in the scene
  22474. * @param scene Define the scene the camera belongs to
  22475. */
  22476. function GamepadCamera(name, position, scene) {
  22477. return _super.call(this, name, position, scene) || this;
  22478. }
  22479. /**
  22480. * Gets the current object class name.
  22481. * @return the class name
  22482. */
  22483. GamepadCamera.prototype.getClassName = function () {
  22484. return "GamepadCamera";
  22485. };
  22486. return GamepadCamera;
  22487. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22488. /***/ }),
  22489. /***/ "./Cameras/index.ts":
  22490. /*!**************************!*\
  22491. !*** ./Cameras/index.ts ***!
  22492. \**************************/
  22493. /*! 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, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22495. "use strict";
  22496. __webpack_require__.r(__webpack_exports__);
  22497. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22511. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22514. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22516. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22518. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22520. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22522. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22524. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22526. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22528. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22530. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22532. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22534. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22537. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22539. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22548. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22550. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22552. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22559. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22570. /***/ }),
  22571. /***/ "./Cameras/targetCamera.ts":
  22572. /*!*********************************!*\
  22573. !*** ./Cameras/targetCamera.ts ***!
  22574. \*********************************/
  22575. /*! exports provided: TargetCamera */
  22576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22577. "use strict";
  22578. __webpack_require__.r(__webpack_exports__);
  22579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22580. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22581. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22582. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22583. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22584. /**
  22585. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22586. * This is the base of the follow, arc rotate cameras and Free camera
  22587. * @see http://doc.babylonjs.com/features/cameras
  22588. */
  22589. var TargetCamera = /** @class */ (function (_super) {
  22590. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22591. /**
  22592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22593. * This is the base of the follow, arc rotate cameras and Free camera
  22594. * @see http://doc.babylonjs.com/features/cameras
  22595. * @param name Defines the name of the camera in the scene
  22596. * @param position Defines the start position of the camera in the scene
  22597. * @param scene Defines the scene the camera belongs to
  22598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22599. */
  22600. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22601. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22602. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22603. /**
  22604. * Define the current direction the camera is moving to
  22605. */
  22606. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22607. /**
  22608. * Define the current rotation the camera is rotating to
  22609. */
  22610. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22611. /**
  22612. * When set, the up vector of the camera will be updated by the rotation of the camera
  22613. */
  22614. _this.updateUpVectorFromRotation = false;
  22615. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22616. /**
  22617. * Define the current rotation of the camera
  22618. */
  22619. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22620. /**
  22621. * Define the current speed of the camera
  22622. */
  22623. _this.speed = 2.0;
  22624. /**
  22625. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22626. * around all axis.
  22627. */
  22628. _this.noRotationConstraint = false;
  22629. /**
  22630. * Define the current target of the camera as an object or a position.
  22631. */
  22632. _this.lockedTarget = null;
  22633. /** @hidden */
  22634. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22635. /** @hidden */
  22636. _this._initialFocalDistance = 1;
  22637. /** @hidden */
  22638. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22639. /** @hidden */
  22640. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22641. /** @hidden */
  22642. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22643. /** @hidden */
  22644. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22645. /** @hidden */
  22646. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22647. /** @hidden */
  22648. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22649. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22650. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22651. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22652. _this._cachedRotationZ = 0;
  22653. _this._cachedQuaternionRotationZ = 0;
  22654. return _this;
  22655. }
  22656. /**
  22657. * Gets the position in front of the camera at a given distance.
  22658. * @param distance The distance from the camera we want the position to be
  22659. * @returns the position
  22660. */
  22661. TargetCamera.prototype.getFrontPosition = function (distance) {
  22662. this.getWorldMatrix();
  22663. var direction = this.getTarget().subtract(this.position);
  22664. direction.normalize();
  22665. direction.scaleInPlace(distance);
  22666. return this.globalPosition.add(direction);
  22667. };
  22668. /** @hidden */
  22669. TargetCamera.prototype._getLockedTargetPosition = function () {
  22670. if (!this.lockedTarget) {
  22671. return null;
  22672. }
  22673. if (this.lockedTarget.absolutePosition) {
  22674. this.lockedTarget.computeWorldMatrix();
  22675. }
  22676. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22677. };
  22678. /**
  22679. * Store current camera state of the camera (fov, position, rotation, etc..)
  22680. * @returns the camera
  22681. */
  22682. TargetCamera.prototype.storeState = function () {
  22683. this._storedPosition = this.position.clone();
  22684. this._storedRotation = this.rotation.clone();
  22685. if (this.rotationQuaternion) {
  22686. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22687. }
  22688. return _super.prototype.storeState.call(this);
  22689. };
  22690. /**
  22691. * Restored camera state. You must call storeState() first
  22692. * @returns whether it was successful or not
  22693. * @hidden
  22694. */
  22695. TargetCamera.prototype._restoreStateValues = function () {
  22696. if (!_super.prototype._restoreStateValues.call(this)) {
  22697. return false;
  22698. }
  22699. this.position = this._storedPosition.clone();
  22700. this.rotation = this._storedRotation.clone();
  22701. if (this.rotationQuaternion) {
  22702. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22703. }
  22704. this.cameraDirection.copyFromFloats(0, 0, 0);
  22705. this.cameraRotation.copyFromFloats(0, 0);
  22706. return true;
  22707. };
  22708. /** @hidden */
  22709. TargetCamera.prototype._initCache = function () {
  22710. _super.prototype._initCache.call(this);
  22711. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22712. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22713. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22714. };
  22715. /** @hidden */
  22716. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22717. if (!ignoreParentClass) {
  22718. _super.prototype._updateCache.call(this);
  22719. }
  22720. var lockedTargetPosition = this._getLockedTargetPosition();
  22721. if (!lockedTargetPosition) {
  22722. this._cache.lockedTarget = null;
  22723. }
  22724. else {
  22725. if (!this._cache.lockedTarget) {
  22726. this._cache.lockedTarget = lockedTargetPosition.clone();
  22727. }
  22728. else {
  22729. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22730. }
  22731. }
  22732. this._cache.rotation.copyFrom(this.rotation);
  22733. if (this.rotationQuaternion) {
  22734. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22735. }
  22736. };
  22737. // Synchronized
  22738. /** @hidden */
  22739. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22740. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22741. return false;
  22742. }
  22743. var lockedTargetPosition = this._getLockedTargetPosition();
  22744. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22745. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22746. };
  22747. // Methods
  22748. /** @hidden */
  22749. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22750. var engine = this.getEngine();
  22751. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22752. };
  22753. // Target
  22754. /** @hidden */
  22755. TargetCamera.prototype.setTarget = function (target) {
  22756. this.upVector.normalize();
  22757. this._initialFocalDistance = target.subtract(this.position).length();
  22758. if (this.position.z === target.z) {
  22759. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22760. }
  22761. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22762. this._camMatrix.invert();
  22763. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22764. var vDir = target.subtract(this.position);
  22765. if (vDir.x >= 0.0) {
  22766. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22767. }
  22768. else {
  22769. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22770. }
  22771. this.rotation.z = 0;
  22772. if (isNaN(this.rotation.x)) {
  22773. this.rotation.x = 0;
  22774. }
  22775. if (isNaN(this.rotation.y)) {
  22776. this.rotation.y = 0;
  22777. }
  22778. if (isNaN(this.rotation.z)) {
  22779. this.rotation.z = 0;
  22780. }
  22781. if (this.rotationQuaternion) {
  22782. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22783. }
  22784. };
  22785. /**
  22786. * Return the current target position of the camera. This value is expressed in local space.
  22787. * @returns the target position
  22788. */
  22789. TargetCamera.prototype.getTarget = function () {
  22790. return this._currentTarget;
  22791. };
  22792. /** @hidden */
  22793. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22794. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22795. };
  22796. /** @hidden */
  22797. TargetCamera.prototype._updatePosition = function () {
  22798. if (this.parent) {
  22799. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22800. _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]);
  22801. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22802. return;
  22803. }
  22804. this.position.addInPlace(this.cameraDirection);
  22805. };
  22806. /** @hidden */
  22807. TargetCamera.prototype._checkInputs = function () {
  22808. var needToMove = this._decideIfNeedsToMove();
  22809. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22810. // Move
  22811. if (needToMove) {
  22812. this._updatePosition();
  22813. }
  22814. // Rotate
  22815. if (needToRotate) {
  22816. this.rotation.x += this.cameraRotation.x;
  22817. this.rotation.y += this.cameraRotation.y;
  22818. //rotate, if quaternion is set and rotation was used
  22819. if (this.rotationQuaternion) {
  22820. var len = this.rotation.lengthSquared();
  22821. if (len) {
  22822. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22823. }
  22824. }
  22825. if (!this.noRotationConstraint) {
  22826. var limit = (Math.PI / 2) * 0.95;
  22827. if (this.rotation.x > limit) {
  22828. this.rotation.x = limit;
  22829. }
  22830. if (this.rotation.x < -limit) {
  22831. this.rotation.x = -limit;
  22832. }
  22833. }
  22834. }
  22835. // Inertia
  22836. if (needToMove) {
  22837. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22838. this.cameraDirection.x = 0;
  22839. }
  22840. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22841. this.cameraDirection.y = 0;
  22842. }
  22843. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22844. this.cameraDirection.z = 0;
  22845. }
  22846. this.cameraDirection.scaleInPlace(this.inertia);
  22847. }
  22848. if (needToRotate) {
  22849. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22850. this.cameraRotation.x = 0;
  22851. }
  22852. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22853. this.cameraRotation.y = 0;
  22854. }
  22855. this.cameraRotation.scaleInPlace(this.inertia);
  22856. }
  22857. _super.prototype._checkInputs.call(this);
  22858. };
  22859. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22860. if (this.rotationQuaternion) {
  22861. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22862. }
  22863. else {
  22864. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22865. }
  22866. };
  22867. /**
  22868. * 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)
  22869. * @returns the current camera
  22870. */
  22871. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22872. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22873. return this;
  22874. };
  22875. /** @hidden */
  22876. TargetCamera.prototype._getViewMatrix = function () {
  22877. if (this.lockedTarget) {
  22878. this.setTarget(this._getLockedTargetPosition());
  22879. }
  22880. // Compute
  22881. this._updateCameraRotationMatrix();
  22882. // Apply the changed rotation to the upVector
  22883. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22884. this._rotateUpVectorWithCameraRotationMatrix();
  22885. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22886. }
  22887. else if (this._cachedRotationZ != this.rotation.z) {
  22888. this._rotateUpVectorWithCameraRotationMatrix();
  22889. this._cachedRotationZ = this.rotation.z;
  22890. }
  22891. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22892. // Computing target and final matrix
  22893. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22894. if (this.updateUpVectorFromRotation) {
  22895. if (this.rotationQuaternion) {
  22896. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22897. }
  22898. else {
  22899. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22900. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22901. }
  22902. }
  22903. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22904. return this._viewMatrix;
  22905. };
  22906. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22907. if (this.parent) {
  22908. var parentWorldMatrix = this.parent.getWorldMatrix();
  22909. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22910. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22911. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22912. this._markSyncedWithParent();
  22913. }
  22914. else {
  22915. this._globalPosition.copyFrom(position);
  22916. this._globalCurrentTarget.copyFrom(target);
  22917. this._globalCurrentUpVector.copyFrom(up);
  22918. }
  22919. if (this.getScene().useRightHandedSystem) {
  22920. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22921. }
  22922. else {
  22923. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22924. }
  22925. };
  22926. /**
  22927. * @hidden
  22928. */
  22929. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22930. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22931. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22932. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22933. if (!this.rotationQuaternion) {
  22934. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22935. }
  22936. rigCamera._cameraRigParams = {};
  22937. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22938. }
  22939. return rigCamera;
  22940. }
  22941. return null;
  22942. };
  22943. /**
  22944. * @hidden
  22945. */
  22946. TargetCamera.prototype._updateRigCameras = function () {
  22947. var camLeft = this._rigCameras[0];
  22948. var camRight = this._rigCameras[1];
  22949. this.computeWorldMatrix();
  22950. switch (this.cameraRigMode) {
  22951. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22952. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22953. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22954. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22955. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22956. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22957. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22958. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22959. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22960. break;
  22961. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22962. if (camLeft.rotationQuaternion) {
  22963. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22964. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22965. }
  22966. else {
  22967. camLeft.rotation.copyFrom(this.rotation);
  22968. camRight.rotation.copyFrom(this.rotation);
  22969. }
  22970. camLeft.position.copyFrom(this.position);
  22971. camRight.position.copyFrom(this.position);
  22972. break;
  22973. }
  22974. _super.prototype._updateRigCameras.call(this);
  22975. };
  22976. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22977. var target = this.getTarget();
  22978. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22979. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22980. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22981. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22982. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22983. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22984. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22985. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22986. rigCamera.setTarget(newFocalTarget);
  22987. };
  22988. /**
  22989. * Gets the current object class name.
  22990. * @return the class name
  22991. */
  22992. TargetCamera.prototype.getClassName = function () {
  22993. return "TargetCamera";
  22994. };
  22995. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22996. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22997. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  22998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23000. ], TargetCamera.prototype, "rotation", void 0);
  23001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23003. ], TargetCamera.prototype, "speed", void 0);
  23004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23006. ], TargetCamera.prototype, "lockedTarget", void 0);
  23007. return TargetCamera;
  23008. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23009. /***/ }),
  23010. /***/ "./Cameras/touchCamera.ts":
  23011. /*!********************************!*\
  23012. !*** ./Cameras/touchCamera.ts ***!
  23013. \********************************/
  23014. /*! exports provided: TouchCamera */
  23015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23016. "use strict";
  23017. __webpack_require__.r(__webpack_exports__);
  23018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23019. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23020. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23021. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23022. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23023. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23024. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23025. });
  23026. /**
  23027. * This represents a FPS type of camera controlled by touch.
  23028. * This is like a universal camera minus the Gamepad controls.
  23029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23030. */
  23031. var TouchCamera = /** @class */ (function (_super) {
  23032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23033. /**
  23034. * Instantiates a new touch camera.
  23035. * This represents a FPS type of camera controlled by touch.
  23036. * This is like a universal camera minus the Gamepad controls.
  23037. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23038. * @param name Define the name of the camera in the scene
  23039. * @param position Define the start position of the camera in the scene
  23040. * @param scene Define the scene the camera belongs to
  23041. */
  23042. function TouchCamera(name, position, scene) {
  23043. var _this = _super.call(this, name, position, scene) || this;
  23044. _this.inputs.addTouch();
  23045. _this._setupInputs();
  23046. return _this;
  23047. }
  23048. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23049. /**
  23050. * Defines the touch sensibility for rotation.
  23051. * The higher the faster.
  23052. */
  23053. get: function () {
  23054. var touch = this.inputs.attached["touch"];
  23055. if (touch) {
  23056. return touch.touchAngularSensibility;
  23057. }
  23058. return 0;
  23059. },
  23060. set: function (value) {
  23061. var touch = this.inputs.attached["touch"];
  23062. if (touch) {
  23063. touch.touchAngularSensibility = value;
  23064. }
  23065. },
  23066. enumerable: true,
  23067. configurable: true
  23068. });
  23069. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23070. /**
  23071. * Defines the touch sensibility for move.
  23072. * The higher the faster.
  23073. */
  23074. get: function () {
  23075. var touch = this.inputs.attached["touch"];
  23076. if (touch) {
  23077. return touch.touchMoveSensibility;
  23078. }
  23079. return 0;
  23080. },
  23081. set: function (value) {
  23082. var touch = this.inputs.attached["touch"];
  23083. if (touch) {
  23084. touch.touchMoveSensibility = value;
  23085. }
  23086. },
  23087. enumerable: true,
  23088. configurable: true
  23089. });
  23090. /**
  23091. * Gets the current object class name.
  23092. * @return the class name
  23093. */
  23094. TouchCamera.prototype.getClassName = function () {
  23095. return "TouchCamera";
  23096. };
  23097. /** @hidden */
  23098. TouchCamera.prototype._setupInputs = function () {
  23099. var mouse = this.inputs.attached["mouse"];
  23100. if (mouse) {
  23101. mouse.touchEnabled = false;
  23102. }
  23103. };
  23104. return TouchCamera;
  23105. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23106. /***/ }),
  23107. /***/ "./Cameras/universalCamera.ts":
  23108. /*!************************************!*\
  23109. !*** ./Cameras/universalCamera.ts ***!
  23110. \************************************/
  23111. /*! exports provided: UniversalCamera */
  23112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23113. "use strict";
  23114. __webpack_require__.r(__webpack_exports__);
  23115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23116. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23117. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23118. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23119. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23120. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23121. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23122. // Forcing to use the Universal camera
  23123. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23124. });
  23125. /**
  23126. * 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,
  23127. * which still works and will still be found in many Playgrounds.
  23128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23129. */
  23130. var UniversalCamera = /** @class */ (function (_super) {
  23131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23132. /**
  23133. * 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,
  23134. * which still works and will still be found in many Playgrounds.
  23135. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23136. * @param name Define the name of the camera in the scene
  23137. * @param position Define the start position of the camera in the scene
  23138. * @param scene Define the scene the camera belongs to
  23139. */
  23140. function UniversalCamera(name, position, scene) {
  23141. var _this = _super.call(this, name, position, scene) || this;
  23142. _this.inputs.addGamepad();
  23143. return _this;
  23144. }
  23145. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23146. /**
  23147. * Defines the gamepad rotation sensiblity.
  23148. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23149. */
  23150. get: function () {
  23151. var gamepad = this.inputs.attached["gamepad"];
  23152. if (gamepad) {
  23153. return gamepad.gamepadAngularSensibility;
  23154. }
  23155. return 0;
  23156. },
  23157. set: function (value) {
  23158. var gamepad = this.inputs.attached["gamepad"];
  23159. if (gamepad) {
  23160. gamepad.gamepadAngularSensibility = value;
  23161. }
  23162. },
  23163. enumerable: true,
  23164. configurable: true
  23165. });
  23166. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23167. /**
  23168. * Defines the gamepad move sensiblity.
  23169. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23170. */
  23171. get: function () {
  23172. var gamepad = this.inputs.attached["gamepad"];
  23173. if (gamepad) {
  23174. return gamepad.gamepadMoveSensibility;
  23175. }
  23176. return 0;
  23177. },
  23178. set: function (value) {
  23179. var gamepad = this.inputs.attached["gamepad"];
  23180. if (gamepad) {
  23181. gamepad.gamepadMoveSensibility = value;
  23182. }
  23183. },
  23184. enumerable: true,
  23185. configurable: true
  23186. });
  23187. /**
  23188. * Gets the current object class name.
  23189. * @return the class name
  23190. */
  23191. UniversalCamera.prototype.getClassName = function () {
  23192. return "UniversalCamera";
  23193. };
  23194. return UniversalCamera;
  23195. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23196. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23197. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23198. };
  23199. /***/ }),
  23200. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23201. /*!*******************************************!*\
  23202. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23203. \*******************************************/
  23204. /*! exports provided: VirtualJoysticksCamera */
  23205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23206. "use strict";
  23207. __webpack_require__.r(__webpack_exports__);
  23208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23209. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23210. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23211. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23212. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23213. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23214. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23215. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23216. });
  23217. /**
  23218. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23219. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23220. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23221. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23222. */
  23223. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23224. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23225. /**
  23226. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23227. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23228. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23229. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23230. * @param name Define the name of the camera in the scene
  23231. * @param position Define the start position of the camera in the scene
  23232. * @param scene Define the scene the camera belongs to
  23233. */
  23234. function VirtualJoysticksCamera(name, position, scene) {
  23235. var _this = _super.call(this, name, position, scene) || this;
  23236. _this.inputs.addVirtualJoystick();
  23237. return _this;
  23238. }
  23239. /**
  23240. * Gets the current object class name.
  23241. * @return the class name
  23242. */
  23243. VirtualJoysticksCamera.prototype.getClassName = function () {
  23244. return "VirtualJoysticksCamera";
  23245. };
  23246. return VirtualJoysticksCamera;
  23247. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23248. /***/ }),
  23249. /***/ "./Collisions/collider.ts":
  23250. /*!********************************!*\
  23251. !*** ./Collisions/collider.ts ***!
  23252. \********************************/
  23253. /*! exports provided: Collider */
  23254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23255. "use strict";
  23256. __webpack_require__.r(__webpack_exports__);
  23257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23258. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23259. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23260. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23261. return false;
  23262. }
  23263. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23264. return false;
  23265. }
  23266. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23267. return false;
  23268. }
  23269. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23270. return false;
  23271. }
  23272. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23273. return false;
  23274. }
  23275. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23276. return false;
  23277. }
  23278. return true;
  23279. };
  23280. var getLowestRoot = (function () {
  23281. var result = { root: 0, found: false };
  23282. return function (a, b, c, maxR) {
  23283. result.root = 0;
  23284. result.found = false;
  23285. var determinant = b * b - 4.0 * a * c;
  23286. if (determinant < 0) {
  23287. return result;
  23288. }
  23289. var sqrtD = Math.sqrt(determinant);
  23290. var r1 = (-b - sqrtD) / (2.0 * a);
  23291. var r2 = (-b + sqrtD) / (2.0 * a);
  23292. if (r1 > r2) {
  23293. var temp = r2;
  23294. r2 = r1;
  23295. r1 = temp;
  23296. }
  23297. if (r1 > 0 && r1 < maxR) {
  23298. result.root = r1;
  23299. result.found = true;
  23300. return result;
  23301. }
  23302. if (r2 > 0 && r2 < maxR) {
  23303. result.root = r2;
  23304. result.found = true;
  23305. return result;
  23306. }
  23307. return result;
  23308. };
  23309. })();
  23310. /** @hidden */
  23311. var Collider = /** @class */ (function () {
  23312. function Collider() {
  23313. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23314. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23315. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23316. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23317. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23318. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23319. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23320. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23321. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23322. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23323. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23324. /** @hidden */
  23325. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23326. /** @hidden */
  23327. this._retry = 0;
  23328. /** @hidden */
  23329. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23330. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23331. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23332. this._collisionMask = -1;
  23333. }
  23334. Object.defineProperty(Collider.prototype, "collisionMask", {
  23335. get: function () {
  23336. return this._collisionMask;
  23337. },
  23338. set: function (mask) {
  23339. this._collisionMask = !isNaN(mask) ? mask : -1;
  23340. },
  23341. enumerable: true,
  23342. configurable: true
  23343. });
  23344. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23345. /**
  23346. * Gets the plane normal used to compute the sliding response (in local space)
  23347. */
  23348. get: function () {
  23349. return this._slidePlaneNormal;
  23350. },
  23351. enumerable: true,
  23352. configurable: true
  23353. });
  23354. // Methods
  23355. /** @hidden */
  23356. Collider.prototype._initialize = function (source, dir, e) {
  23357. this._velocity = dir;
  23358. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23359. this._basePoint = source;
  23360. source.multiplyToRef(this._radius, this._basePointWorld);
  23361. dir.multiplyToRef(this._radius, this._velocityWorld);
  23362. this._velocityWorldLength = this._velocityWorld.length();
  23363. this._epsilon = e;
  23364. this.collisionFound = false;
  23365. };
  23366. /** @hidden */
  23367. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23368. pa.subtractToRef(point, this._tempVector);
  23369. pb.subtractToRef(point, this._tempVector2);
  23370. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23371. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23372. if (d < 0) {
  23373. return false;
  23374. }
  23375. pc.subtractToRef(point, this._tempVector3);
  23376. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23377. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23378. if (d < 0) {
  23379. return false;
  23380. }
  23381. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23382. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23383. return d >= 0;
  23384. };
  23385. /** @hidden */
  23386. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23387. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23388. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23389. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23390. return false;
  23391. }
  23392. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23393. return false;
  23394. }
  23395. return true;
  23396. };
  23397. /** @hidden */
  23398. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23399. var t0;
  23400. var embeddedInPlane = false;
  23401. //defensive programming, actually not needed.
  23402. if (!trianglePlaneArray) {
  23403. trianglePlaneArray = [];
  23404. }
  23405. if (!trianglePlaneArray[faceIndex]) {
  23406. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23407. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23408. }
  23409. var trianglePlane = trianglePlaneArray[faceIndex];
  23410. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23411. return;
  23412. }
  23413. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23414. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23415. if (normalDotVelocity == 0) {
  23416. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23417. return;
  23418. }
  23419. embeddedInPlane = true;
  23420. t0 = 0;
  23421. }
  23422. else {
  23423. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23424. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23425. if (t0 > t1) {
  23426. var temp = t1;
  23427. t1 = t0;
  23428. t0 = temp;
  23429. }
  23430. if (t0 > 1.0 || t1 < 0.0) {
  23431. return;
  23432. }
  23433. if (t0 < 0) {
  23434. t0 = 0;
  23435. }
  23436. if (t0 > 1.0) {
  23437. t0 = 1.0;
  23438. }
  23439. }
  23440. this._collisionPoint.copyFromFloats(0, 0, 0);
  23441. var found = false;
  23442. var t = 1.0;
  23443. if (!embeddedInPlane) {
  23444. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23445. this._velocity.scaleToRef(t0, this._tempVector);
  23446. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23447. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23448. found = true;
  23449. t = t0;
  23450. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23451. }
  23452. }
  23453. if (!found) {
  23454. var velocitySquaredLength = this._velocity.lengthSquared();
  23455. var a = velocitySquaredLength;
  23456. this._basePoint.subtractToRef(p1, this._tempVector);
  23457. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23458. var c = this._tempVector.lengthSquared() - 1.0;
  23459. var lowestRoot = getLowestRoot(a, b, c, t);
  23460. if (lowestRoot.found) {
  23461. t = lowestRoot.root;
  23462. found = true;
  23463. this._collisionPoint.copyFrom(p1);
  23464. }
  23465. this._basePoint.subtractToRef(p2, this._tempVector);
  23466. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23467. c = this._tempVector.lengthSquared() - 1.0;
  23468. lowestRoot = getLowestRoot(a, b, c, t);
  23469. if (lowestRoot.found) {
  23470. t = lowestRoot.root;
  23471. found = true;
  23472. this._collisionPoint.copyFrom(p2);
  23473. }
  23474. this._basePoint.subtractToRef(p3, this._tempVector);
  23475. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23476. c = this._tempVector.lengthSquared() - 1.0;
  23477. lowestRoot = getLowestRoot(a, b, c, t);
  23478. if (lowestRoot.found) {
  23479. t = lowestRoot.root;
  23480. found = true;
  23481. this._collisionPoint.copyFrom(p3);
  23482. }
  23483. p2.subtractToRef(p1, this._edge);
  23484. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23485. var edgeSquaredLength = this._edge.lengthSquared();
  23486. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23487. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23488. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23489. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23490. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23491. lowestRoot = getLowestRoot(a, b, c, t);
  23492. if (lowestRoot.found) {
  23493. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23494. if (f >= 0.0 && f <= 1.0) {
  23495. t = lowestRoot.root;
  23496. found = true;
  23497. this._edge.scaleInPlace(f);
  23498. p1.addToRef(this._edge, this._collisionPoint);
  23499. }
  23500. }
  23501. p3.subtractToRef(p2, this._edge);
  23502. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23503. edgeSquaredLength = this._edge.lengthSquared();
  23504. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23505. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23506. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23507. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23508. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23509. lowestRoot = getLowestRoot(a, b, c, t);
  23510. if (lowestRoot.found) {
  23511. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23512. if (f >= 0.0 && f <= 1.0) {
  23513. t = lowestRoot.root;
  23514. found = true;
  23515. this._edge.scaleInPlace(f);
  23516. p2.addToRef(this._edge, this._collisionPoint);
  23517. }
  23518. }
  23519. p1.subtractToRef(p3, this._edge);
  23520. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23521. edgeSquaredLength = this._edge.lengthSquared();
  23522. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23523. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23524. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23525. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23526. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23527. lowestRoot = getLowestRoot(a, b, c, t);
  23528. if (lowestRoot.found) {
  23529. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23530. if (f >= 0.0 && f <= 1.0) {
  23531. t = lowestRoot.root;
  23532. found = true;
  23533. this._edge.scaleInPlace(f);
  23534. p3.addToRef(this._edge, this._collisionPoint);
  23535. }
  23536. }
  23537. }
  23538. if (found) {
  23539. var distToCollision = t * this._velocity.length();
  23540. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23541. if (!this.intersectionPoint) {
  23542. this.intersectionPoint = this._collisionPoint.clone();
  23543. }
  23544. else {
  23545. this.intersectionPoint.copyFrom(this._collisionPoint);
  23546. }
  23547. this._nearestDistance = distToCollision;
  23548. this.collisionFound = true;
  23549. }
  23550. }
  23551. };
  23552. /** @hidden */
  23553. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23554. for (var i = indexStart; i < indexEnd; i += 3) {
  23555. var p1 = pts[indices[i] - decal];
  23556. var p2 = pts[indices[i + 1] - decal];
  23557. var p3 = pts[indices[i + 2] - decal];
  23558. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23559. }
  23560. };
  23561. /** @hidden */
  23562. Collider.prototype._getResponse = function (pos, vel) {
  23563. pos.addToRef(vel, this._destinationPoint);
  23564. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23565. this._basePoint.addToRef(vel, pos);
  23566. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23567. this._slidePlaneNormal.normalize();
  23568. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23569. pos.addInPlace(this._displacementVector);
  23570. this.intersectionPoint.addInPlace(this._displacementVector);
  23571. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23572. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23573. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23574. };
  23575. return Collider;
  23576. }());
  23577. /***/ }),
  23578. /***/ "./Collisions/collisionCoordinator.ts":
  23579. /*!********************************************!*\
  23580. !*** ./Collisions/collisionCoordinator.ts ***!
  23581. \********************************************/
  23582. /*! exports provided: DefaultCollisionCoordinator */
  23583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23584. "use strict";
  23585. __webpack_require__.r(__webpack_exports__);
  23586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  23587. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  23588. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23589. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23590. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23591. /** @hidden */
  23592. var DefaultCollisionCoordinator = /** @class */ (function () {
  23593. function DefaultCollisionCoordinator() {
  23594. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23595. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23596. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23597. }
  23598. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23599. position.divideToRef(collider._radius, this._scaledPosition);
  23600. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23601. collider.collidedMesh = null;
  23602. collider._retry = 0;
  23603. collider._initialVelocity = this._scaledVelocity;
  23604. collider._initialPosition = this._scaledPosition;
  23605. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23606. this._finalPosition.multiplyInPlace(collider._radius);
  23607. //run the callback
  23608. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23609. };
  23610. DefaultCollisionCoordinator.prototype.createCollider = function () {
  23611. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  23612. };
  23613. DefaultCollisionCoordinator.prototype.init = function (scene) {
  23614. this._scene = scene;
  23615. };
  23616. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23617. if (excludedMesh === void 0) { excludedMesh = null; }
  23618. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  23619. if (collider._retry >= maximumRetry) {
  23620. finalPosition.copyFrom(position);
  23621. return;
  23622. }
  23623. // Check if this is a mesh else camera or -1
  23624. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23625. collider._initialize(position, velocity, closeDistance);
  23626. // Check all meshes
  23627. for (var index = 0; index < this._scene.meshes.length; index++) {
  23628. var mesh = this._scene.meshes[index];
  23629. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23630. mesh._checkCollision(collider);
  23631. }
  23632. }
  23633. if (!collider.collisionFound) {
  23634. position.addToRef(velocity, finalPosition);
  23635. return;
  23636. }
  23637. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23638. collider._getResponse(position, velocity);
  23639. }
  23640. if (velocity.length() <= closeDistance) {
  23641. finalPosition.copyFrom(position);
  23642. return;
  23643. }
  23644. collider._retry++;
  23645. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23646. };
  23647. return DefaultCollisionCoordinator;
  23648. }());
  23649. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  23650. return new DefaultCollisionCoordinator();
  23651. };
  23652. /***/ }),
  23653. /***/ "./Collisions/index.ts":
  23654. /*!*****************************!*\
  23655. !*** ./Collisions/index.ts ***!
  23656. \*****************************/
  23657. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  23658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23659. "use strict";
  23660. __webpack_require__.r(__webpack_exports__);
  23661. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23663. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  23665. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23667. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23669. /***/ }),
  23670. /***/ "./Collisions/intersectionInfo.ts":
  23671. /*!****************************************!*\
  23672. !*** ./Collisions/intersectionInfo.ts ***!
  23673. \****************************************/
  23674. /*! exports provided: IntersectionInfo */
  23675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23676. "use strict";
  23677. __webpack_require__.r(__webpack_exports__);
  23678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23679. /**
  23680. * @hidden
  23681. */
  23682. var IntersectionInfo = /** @class */ (function () {
  23683. function IntersectionInfo(bu, bv, distance) {
  23684. this.bu = bu;
  23685. this.bv = bv;
  23686. this.distance = distance;
  23687. this.faceId = 0;
  23688. this.subMeshId = 0;
  23689. }
  23690. return IntersectionInfo;
  23691. }());
  23692. /***/ }),
  23693. /***/ "./Collisions/pickingInfo.ts":
  23694. /*!***********************************!*\
  23695. !*** ./Collisions/pickingInfo.ts ***!
  23696. \***********************************/
  23697. /*! exports provided: PickingInfo */
  23698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23699. "use strict";
  23700. __webpack_require__.r(__webpack_exports__);
  23701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23703. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23704. /**
  23705. * Information about the result of picking within a scene
  23706. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23707. */
  23708. var PickingInfo = /** @class */ (function () {
  23709. function PickingInfo() {
  23710. /**
  23711. * If the pick collided with an object
  23712. */
  23713. this.hit = false;
  23714. /**
  23715. * Distance away where the pick collided
  23716. */
  23717. this.distance = 0;
  23718. /**
  23719. * The location of pick collision
  23720. */
  23721. this.pickedPoint = null;
  23722. /**
  23723. * The mesh corresponding the the pick collision
  23724. */
  23725. this.pickedMesh = null;
  23726. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23727. this.bu = 0;
  23728. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23729. this.bv = 0;
  23730. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23731. this.faceId = -1;
  23732. /** Id of the the submesh that was picked */
  23733. this.subMeshId = 0;
  23734. /** If a sprite was picked, this will be the sprite the pick collided with */
  23735. this.pickedSprite = null;
  23736. /**
  23737. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23738. */
  23739. this.originMesh = null;
  23740. /**
  23741. * The ray that was used to perform the picking.
  23742. */
  23743. this.ray = null;
  23744. }
  23745. /**
  23746. * Gets the normal correspodning to the face the pick collided with
  23747. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23748. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23749. * @returns The normal correspodning to the face the pick collided with
  23750. */
  23751. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23752. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23753. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23754. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23755. return null;
  23756. }
  23757. var indices = this.pickedMesh.getIndices();
  23758. if (!indices) {
  23759. return null;
  23760. }
  23761. var result;
  23762. if (useVerticesNormals) {
  23763. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23764. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23765. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23766. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23767. normal0 = normal0.scale(this.bu);
  23768. normal1 = normal1.scale(this.bv);
  23769. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23770. 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);
  23771. }
  23772. else {
  23773. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23774. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23775. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23776. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23777. var p1p2 = vertex1.subtract(vertex2);
  23778. var p3p2 = vertex3.subtract(vertex2);
  23779. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23780. }
  23781. if (useWorldCoordinates) {
  23782. var wm = this.pickedMesh.getWorldMatrix();
  23783. if (this.pickedMesh.nonUniformScaling) {
  23784. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23785. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23786. wm.setTranslationFromFloats(0, 0, 0);
  23787. wm.invert();
  23788. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23789. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23790. }
  23791. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23792. }
  23793. result.normalize();
  23794. return result;
  23795. };
  23796. /**
  23797. * Gets the texture coordinates of where the pick occured
  23798. * @returns the vector containing the coordnates of the texture
  23799. */
  23800. PickingInfo.prototype.getTextureCoordinates = function () {
  23801. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23802. return null;
  23803. }
  23804. var indices = this.pickedMesh.getIndices();
  23805. if (!indices) {
  23806. return null;
  23807. }
  23808. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23809. if (!uvs) {
  23810. return null;
  23811. }
  23812. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23813. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23814. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23815. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23816. uv1 = uv1.scale(this.bu);
  23817. uv2 = uv2.scale(this.bv);
  23818. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23819. };
  23820. return PickingInfo;
  23821. }());
  23822. /***/ }),
  23823. /***/ "./Culling/Octrees/index.ts":
  23824. /*!**********************************!*\
  23825. !*** ./Culling/Octrees/index.ts ***!
  23826. \**********************************/
  23827. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23829. "use strict";
  23830. __webpack_require__.r(__webpack_exports__);
  23831. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23833. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23835. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23837. /***/ }),
  23838. /***/ "./Culling/Octrees/octree.ts":
  23839. /*!***********************************!*\
  23840. !*** ./Culling/Octrees/octree.ts ***!
  23841. \***********************************/
  23842. /*! exports provided: Octree */
  23843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23844. "use strict";
  23845. __webpack_require__.r(__webpack_exports__);
  23846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23847. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23848. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23849. /**
  23850. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23852. */
  23853. var Octree = /** @class */ (function () {
  23854. /**
  23855. * Creates a octree
  23856. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23857. * @param creationFunc function to be used to instatiate the octree
  23858. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23859. * @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.)
  23860. */
  23861. function Octree(creationFunc, maxBlockCapacity,
  23862. /** 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.) */
  23863. maxDepth) {
  23864. if (maxDepth === void 0) { maxDepth = 2; }
  23865. this.maxDepth = maxDepth;
  23866. /**
  23867. * Content stored in the octree
  23868. */
  23869. this.dynamicContent = new Array();
  23870. this._maxBlockCapacity = maxBlockCapacity || 64;
  23871. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23872. this._creationFunc = creationFunc;
  23873. }
  23874. // Methods
  23875. /**
  23876. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23877. * @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);
  23878. * @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);
  23879. * @param entries meshes to be added to the octree blocks
  23880. */
  23881. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23882. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23883. };
  23884. /**
  23885. * Adds a mesh to the octree
  23886. * @param entry Mesh to add to the octree
  23887. */
  23888. Octree.prototype.addMesh = function (entry) {
  23889. for (var index = 0; index < this.blocks.length; index++) {
  23890. var block = this.blocks[index];
  23891. block.addEntry(entry);
  23892. }
  23893. };
  23894. /**
  23895. * Remove an element from the octree
  23896. * @param entry defines the element to remove
  23897. */
  23898. Octree.prototype.removeMesh = function (entry) {
  23899. for (var index = 0; index < this.blocks.length; index++) {
  23900. var block = this.blocks[index];
  23901. block.removeEntry(entry);
  23902. }
  23903. };
  23904. /**
  23905. * Selects an array of meshes within the frustum
  23906. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23907. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23908. * @returns array of meshes within the frustum
  23909. */
  23910. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23911. this._selectionContent.reset();
  23912. for (var index = 0; index < this.blocks.length; index++) {
  23913. var block = this.blocks[index];
  23914. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23915. }
  23916. if (allowDuplicate) {
  23917. this._selectionContent.concat(this.dynamicContent);
  23918. }
  23919. else {
  23920. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23921. }
  23922. return this._selectionContent;
  23923. };
  23924. /**
  23925. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23926. * @param sphereCenter defines the bounding sphere center
  23927. * @param sphereRadius defines the bounding sphere radius
  23928. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23929. * @returns an array of objects that intersect the sphere
  23930. */
  23931. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23932. this._selectionContent.reset();
  23933. for (var index = 0; index < this.blocks.length; index++) {
  23934. var block = this.blocks[index];
  23935. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23936. }
  23937. if (allowDuplicate) {
  23938. this._selectionContent.concat(this.dynamicContent);
  23939. }
  23940. else {
  23941. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23942. }
  23943. return this._selectionContent;
  23944. };
  23945. /**
  23946. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23947. * @param ray defines the ray to test with
  23948. * @returns array of intersected objects
  23949. */
  23950. Octree.prototype.intersectsRay = function (ray) {
  23951. this._selectionContent.reset();
  23952. for (var index = 0; index < this.blocks.length; index++) {
  23953. var block = this.blocks[index];
  23954. block.intersectsRay(ray, this._selectionContent);
  23955. }
  23956. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23957. return this._selectionContent;
  23958. };
  23959. /**
  23960. * Adds a mesh into the octree block if it intersects the block
  23961. */
  23962. Octree.CreationFuncForMeshes = function (entry, block) {
  23963. var boundingInfo = entry.getBoundingInfo();
  23964. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23965. block.entries.push(entry);
  23966. }
  23967. };
  23968. /**
  23969. * Adds a submesh into the octree block if it intersects the block
  23970. */
  23971. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23972. var boundingInfo = entry.getBoundingInfo();
  23973. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23974. block.entries.push(entry);
  23975. }
  23976. };
  23977. return Octree;
  23978. }());
  23979. /***/ }),
  23980. /***/ "./Culling/Octrees/octreeBlock.ts":
  23981. /*!****************************************!*\
  23982. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23983. \****************************************/
  23984. /*! exports provided: OctreeBlock */
  23985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23986. "use strict";
  23987. __webpack_require__.r(__webpack_exports__);
  23988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23989. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23990. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23991. /**
  23992. * Class used to store a cell in an octree
  23993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23994. */
  23995. var OctreeBlock = /** @class */ (function () {
  23996. /**
  23997. * Creates a new block
  23998. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  23999. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24000. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24001. * @param depth defines the current depth of this block in the octree
  24002. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24003. * @param creationFunc defines a callback to call when an element is added to the block
  24004. */
  24005. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24006. /**
  24007. * Gets the content of the current block
  24008. */
  24009. this.entries = new Array();
  24010. this._boundingVectors = new Array();
  24011. this._capacity = capacity;
  24012. this._depth = depth;
  24013. this._maxDepth = maxDepth;
  24014. this._creationFunc = creationFunc;
  24015. this._minPoint = minPoint;
  24016. this._maxPoint = maxPoint;
  24017. this._boundingVectors.push(minPoint.clone());
  24018. this._boundingVectors.push(maxPoint.clone());
  24019. this._boundingVectors.push(minPoint.clone());
  24020. this._boundingVectors[2].x = maxPoint.x;
  24021. this._boundingVectors.push(minPoint.clone());
  24022. this._boundingVectors[3].y = maxPoint.y;
  24023. this._boundingVectors.push(minPoint.clone());
  24024. this._boundingVectors[4].z = maxPoint.z;
  24025. this._boundingVectors.push(maxPoint.clone());
  24026. this._boundingVectors[5].z = minPoint.z;
  24027. this._boundingVectors.push(maxPoint.clone());
  24028. this._boundingVectors[6].x = minPoint.x;
  24029. this._boundingVectors.push(maxPoint.clone());
  24030. this._boundingVectors[7].y = minPoint.y;
  24031. }
  24032. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24033. // Property
  24034. /**
  24035. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24036. */
  24037. get: function () {
  24038. return this._capacity;
  24039. },
  24040. enumerable: true,
  24041. configurable: true
  24042. });
  24043. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24044. /**
  24045. * Gets the minimum vector (in world space) of the block's bounding box
  24046. */
  24047. get: function () {
  24048. return this._minPoint;
  24049. },
  24050. enumerable: true,
  24051. configurable: true
  24052. });
  24053. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24054. /**
  24055. * Gets the maximum vector (in world space) of the block's bounding box
  24056. */
  24057. get: function () {
  24058. return this._maxPoint;
  24059. },
  24060. enumerable: true,
  24061. configurable: true
  24062. });
  24063. // Methods
  24064. /**
  24065. * Add a new element to this block
  24066. * @param entry defines the element to add
  24067. */
  24068. OctreeBlock.prototype.addEntry = function (entry) {
  24069. if (this.blocks) {
  24070. for (var index = 0; index < this.blocks.length; index++) {
  24071. var block = this.blocks[index];
  24072. block.addEntry(entry);
  24073. }
  24074. return;
  24075. }
  24076. this._creationFunc(entry, this);
  24077. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24078. this.createInnerBlocks();
  24079. }
  24080. };
  24081. /**
  24082. * Remove an element from this block
  24083. * @param entry defines the element to remove
  24084. */
  24085. OctreeBlock.prototype.removeEntry = function (entry) {
  24086. if (this.blocks) {
  24087. for (var index = 0; index < this.blocks.length; index++) {
  24088. var block = this.blocks[index];
  24089. block.removeEntry(entry);
  24090. }
  24091. return;
  24092. }
  24093. var entryIndex = this.entries.indexOf(entry);
  24094. if (entryIndex > -1) {
  24095. this.entries.splice(entryIndex, 1);
  24096. }
  24097. };
  24098. /**
  24099. * Add an array of elements to this block
  24100. * @param entries defines the array of elements to add
  24101. */
  24102. OctreeBlock.prototype.addEntries = function (entries) {
  24103. for (var index = 0; index < entries.length; index++) {
  24104. var mesh = entries[index];
  24105. this.addEntry(mesh);
  24106. }
  24107. };
  24108. /**
  24109. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24110. * @param frustumPlanes defines the frustum planes to test
  24111. * @param selection defines the array to store current content if selection is positive
  24112. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24113. */
  24114. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24115. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24116. if (this.blocks) {
  24117. for (var index = 0; index < this.blocks.length; index++) {
  24118. var block = this.blocks[index];
  24119. block.select(frustumPlanes, selection, allowDuplicate);
  24120. }
  24121. return;
  24122. }
  24123. if (allowDuplicate) {
  24124. selection.concat(this.entries);
  24125. }
  24126. else {
  24127. selection.concatWithNoDuplicate(this.entries);
  24128. }
  24129. }
  24130. };
  24131. /**
  24132. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24133. * @param sphereCenter defines the bounding sphere center
  24134. * @param sphereRadius defines the bounding sphere radius
  24135. * @param selection defines the array to store current content if selection is positive
  24136. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24137. */
  24138. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24139. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24140. if (this.blocks) {
  24141. for (var index = 0; index < this.blocks.length; index++) {
  24142. var block = this.blocks[index];
  24143. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24144. }
  24145. return;
  24146. }
  24147. if (allowDuplicate) {
  24148. selection.concat(this.entries);
  24149. }
  24150. else {
  24151. selection.concatWithNoDuplicate(this.entries);
  24152. }
  24153. }
  24154. };
  24155. /**
  24156. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24157. * @param ray defines the ray to test with
  24158. * @param selection defines the array to store current content if selection is positive
  24159. */
  24160. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24161. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24162. if (this.blocks) {
  24163. for (var index = 0; index < this.blocks.length; index++) {
  24164. var block = this.blocks[index];
  24165. block.intersectsRay(ray, selection);
  24166. }
  24167. return;
  24168. }
  24169. selection.concatWithNoDuplicate(this.entries);
  24170. }
  24171. };
  24172. /**
  24173. * Subdivide the content into child blocks (this block will then be empty)
  24174. */
  24175. OctreeBlock.prototype.createInnerBlocks = function () {
  24176. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24177. };
  24178. /**
  24179. * @hidden
  24180. */
  24181. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24182. target.blocks = new Array();
  24183. 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);
  24184. // Segmenting space
  24185. for (var x = 0; x < 2; x++) {
  24186. for (var y = 0; y < 2; y++) {
  24187. for (var z = 0; z < 2; z++) {
  24188. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24189. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24190. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24191. block.addEntries(entries);
  24192. target.blocks.push(block);
  24193. }
  24194. }
  24195. }
  24196. };
  24197. return OctreeBlock;
  24198. }());
  24199. /***/ }),
  24200. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24201. /*!*************************************************!*\
  24202. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24203. \*************************************************/
  24204. /*! exports provided: OctreeSceneComponent */
  24205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24206. "use strict";
  24207. __webpack_require__.r(__webpack_exports__);
  24208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24209. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24210. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24211. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24212. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24213. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24214. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24215. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24216. if (maxCapacity === void 0) { maxCapacity = 64; }
  24217. if (maxDepth === void 0) { maxDepth = 2; }
  24218. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24219. if (!component) {
  24220. component = new OctreeSceneComponent(this);
  24221. this._addComponent(component);
  24222. }
  24223. if (!this._selectionOctree) {
  24224. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24225. }
  24226. var worldExtends = this.getWorldExtends();
  24227. // Update octree
  24228. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24229. return this._selectionOctree;
  24230. };
  24231. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24232. get: function () {
  24233. return this._selectionOctree;
  24234. },
  24235. enumerable: true,
  24236. configurable: true
  24237. });
  24238. /**
  24239. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24240. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24241. * @param maxCapacity defines the maximum size of each block (64 by default)
  24242. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24243. * @returns the new octree
  24244. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24246. */
  24247. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24248. if (maxCapacity === void 0) { maxCapacity = 64; }
  24249. if (maxDepth === void 0) { maxDepth = 2; }
  24250. var scene = this.getScene();
  24251. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24252. if (!component) {
  24253. component = new OctreeSceneComponent(scene);
  24254. scene._addComponent(component);
  24255. }
  24256. if (!this._submeshesOctree) {
  24257. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24258. }
  24259. this.computeWorldMatrix(true);
  24260. var boundingInfo = this.getBoundingInfo();
  24261. // Update octree
  24262. var bbox = boundingInfo.boundingBox;
  24263. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24264. return this._submeshesOctree;
  24265. };
  24266. /**
  24267. * Defines the octree scene component responsible to manage any octrees
  24268. * in a given scene.
  24269. */
  24270. var OctreeSceneComponent = /** @class */ (function () {
  24271. /**
  24272. * Creates a new instance of the component for the given scene
  24273. * @param scene Defines the scene to register the component in
  24274. */
  24275. function OctreeSceneComponent(scene) {
  24276. /**
  24277. * The component name helpfull to identify the component in the list of scene components.
  24278. */
  24279. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24280. /**
  24281. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24282. */
  24283. this.checksIsEnabled = true;
  24284. 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));
  24285. this.scene = scene;
  24286. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24287. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24288. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24289. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24290. }
  24291. /**
  24292. * Registers the component in a given scene
  24293. */
  24294. OctreeSceneComponent.prototype.register = function () {
  24295. var _this = this;
  24296. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24297. var sceneOctree = _this.scene.selectionOctree;
  24298. if (sceneOctree !== undefined && sceneOctree !== null) {
  24299. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24300. if (index !== -1) {
  24301. sceneOctree.dynamicContent.splice(index, 1);
  24302. }
  24303. }
  24304. });
  24305. this.scene.onMeshImportedObservable.add(function (mesh) {
  24306. var sceneOctree = _this.scene.selectionOctree;
  24307. if (sceneOctree !== undefined && sceneOctree !== null) {
  24308. sceneOctree.addMesh(mesh);
  24309. }
  24310. });
  24311. };
  24312. /**
  24313. * Return the list of active meshes
  24314. * @returns the list of active meshes
  24315. */
  24316. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24317. if (this.scene._selectionOctree) {
  24318. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24319. return selection;
  24320. }
  24321. return this.scene._getDefaultMeshCandidates();
  24322. };
  24323. /**
  24324. * Return the list of active sub meshes
  24325. * @param mesh The mesh to get the candidates sub meshes from
  24326. * @returns the list of active sub meshes
  24327. */
  24328. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24329. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24330. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24331. return intersections;
  24332. }
  24333. return this.scene._getDefaultSubMeshCandidates(mesh);
  24334. };
  24335. /**
  24336. * Return the list of sub meshes intersecting with a given local ray
  24337. * @param mesh defines the mesh to find the submesh for
  24338. * @param localRay defines the ray in local space
  24339. * @returns the list of intersecting sub meshes
  24340. */
  24341. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24342. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24343. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24344. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24345. return intersections;
  24346. }
  24347. return this.scene._getDefaultSubMeshCandidates(mesh);
  24348. };
  24349. /**
  24350. * Return the list of sub meshes colliding with a collider
  24351. * @param mesh defines the mesh to find the submesh for
  24352. * @param collider defines the collider to evaluate the collision against
  24353. * @returns the list of colliding sub meshes
  24354. */
  24355. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24356. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24357. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24358. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24359. return intersections;
  24360. }
  24361. return this.scene._getDefaultSubMeshCandidates(mesh);
  24362. };
  24363. /**
  24364. * Rebuilds the elements related to this component in case of
  24365. * context lost for instance.
  24366. */
  24367. OctreeSceneComponent.prototype.rebuild = function () {
  24368. // Nothing to do here.
  24369. };
  24370. /**
  24371. * Disposes the component and the associated ressources.
  24372. */
  24373. OctreeSceneComponent.prototype.dispose = function () {
  24374. // Nothing to do here.
  24375. };
  24376. return OctreeSceneComponent;
  24377. }());
  24378. /***/ }),
  24379. /***/ "./Culling/boundingBox.ts":
  24380. /*!********************************!*\
  24381. !*** ./Culling/boundingBox.ts ***!
  24382. \********************************/
  24383. /*! exports provided: BoundingBox */
  24384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24385. "use strict";
  24386. __webpack_require__.r(__webpack_exports__);
  24387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24388. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24389. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24390. /**
  24391. * Class used to store bounding box information
  24392. */
  24393. var BoundingBox = /** @class */ (function () {
  24394. /**
  24395. * Creates a new bounding box
  24396. * @param min defines the minimum vector (in local space)
  24397. * @param max defines the maximum vector (in local space)
  24398. * @param worldMatrix defines the new world matrix
  24399. */
  24400. function BoundingBox(min, max, worldMatrix) {
  24401. /**
  24402. * Gets the 8 vectors representing the bounding box in local space
  24403. */
  24404. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24405. /**
  24406. * Gets the center of the bounding box in local space
  24407. */
  24408. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24409. /**
  24410. * Gets the center of the bounding box in world space
  24411. */
  24412. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24413. /**
  24414. * Gets the extend size in local space
  24415. */
  24416. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24417. /**
  24418. * Gets the extend size in world space
  24419. */
  24420. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24421. /**
  24422. * Gets the OBB (object bounding box) directions
  24423. */
  24424. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24425. /**
  24426. * Gets the 8 vectors representing the bounding box in world space
  24427. */
  24428. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24429. /**
  24430. * Gets the minimum vector in world space
  24431. */
  24432. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24433. /**
  24434. * Gets the maximum vector in world space
  24435. */
  24436. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24437. /**
  24438. * Gets the minimum vector in local space
  24439. */
  24440. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24441. /**
  24442. * Gets the maximum vector in local space
  24443. */
  24444. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24445. this.reConstruct(min, max, worldMatrix);
  24446. }
  24447. // Methods
  24448. /**
  24449. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24450. * @param min defines the new minimum vector (in local space)
  24451. * @param max defines the new maximum vector (in local space)
  24452. * @param worldMatrix defines the new world matrix
  24453. */
  24454. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24455. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24456. var vectors = this.vectors;
  24457. this.minimum.copyFromFloats(minX, minY, minZ);
  24458. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24459. vectors[0].copyFromFloats(minX, minY, minZ);
  24460. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24461. vectors[2].copyFromFloats(maxX, minY, minZ);
  24462. vectors[3].copyFromFloats(minX, maxY, minZ);
  24463. vectors[4].copyFromFloats(minX, minY, maxZ);
  24464. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24465. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24466. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24467. // OBB
  24468. max.addToRef(min, this.center).scaleInPlace(0.5);
  24469. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24470. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24471. };
  24472. /**
  24473. * Scale the current bounding box by applying a scale factor
  24474. * @param factor defines the scale factor to apply
  24475. * @returns the current bounding box
  24476. */
  24477. BoundingBox.prototype.scale = function (factor) {
  24478. var tmpVectors = BoundingBox.TmpVector3;
  24479. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24480. var len = diff.length();
  24481. diff.normalizeFromLength(len);
  24482. var distance = len * factor;
  24483. var newRadius = diff.scaleInPlace(distance * 0.5);
  24484. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24485. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24486. this.reConstruct(min, max, this._worldMatrix);
  24487. return this;
  24488. };
  24489. /**
  24490. * Gets the world matrix of the bounding box
  24491. * @returns a matrix
  24492. */
  24493. BoundingBox.prototype.getWorldMatrix = function () {
  24494. return this._worldMatrix;
  24495. };
  24496. /** @hidden */
  24497. BoundingBox.prototype._update = function (world) {
  24498. var minWorld = this.minimumWorld;
  24499. var maxWorld = this.maximumWorld;
  24500. var directions = this.directions;
  24501. var vectorsWorld = this.vectorsWorld;
  24502. var vectors = this.vectors;
  24503. if (!world.isIdentity()) {
  24504. minWorld.setAll(Number.MAX_VALUE);
  24505. maxWorld.setAll(-Number.MAX_VALUE);
  24506. for (var index = 0; index < 8; ++index) {
  24507. var v = vectorsWorld[index];
  24508. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24509. minWorld.minimizeInPlace(v);
  24510. maxWorld.maximizeInPlace(v);
  24511. }
  24512. // Extend
  24513. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24514. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24515. }
  24516. else {
  24517. minWorld.copyFrom(this.minimum);
  24518. maxWorld.copyFrom(this.maximum);
  24519. for (var index = 0; index < 8; ++index) {
  24520. vectorsWorld[index].copyFrom(vectors[index]);
  24521. }
  24522. // Extend
  24523. this.extendSizeWorld.copyFrom(this.extendSize);
  24524. this.centerWorld.copyFrom(this.center);
  24525. }
  24526. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24527. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24528. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24529. this._worldMatrix = world;
  24530. };
  24531. /**
  24532. * Tests if the bounding box is intersecting the frustum planes
  24533. * @param frustumPlanes defines the frustum planes to test
  24534. * @returns true if there is an intersection
  24535. */
  24536. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24537. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24538. };
  24539. /**
  24540. * Tests if the bounding box is entirely inside the frustum planes
  24541. * @param frustumPlanes defines the frustum planes to test
  24542. * @returns true if there is an inclusion
  24543. */
  24544. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24545. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24546. };
  24547. /**
  24548. * Tests if a point is inside the bounding box
  24549. * @param point defines the point to test
  24550. * @returns true if the point is inside the bounding box
  24551. */
  24552. BoundingBox.prototype.intersectsPoint = function (point) {
  24553. var min = this.minimumWorld;
  24554. var max = this.maximumWorld;
  24555. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24556. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24557. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24558. if (maxX - pointX < delta || delta > pointX - minX) {
  24559. return false;
  24560. }
  24561. if (maxY - pointY < delta || delta > pointY - minY) {
  24562. return false;
  24563. }
  24564. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24565. return false;
  24566. }
  24567. return true;
  24568. };
  24569. /**
  24570. * Tests if the bounding box intersects with a bounding sphere
  24571. * @param sphere defines the sphere to test
  24572. * @returns true if there is an intersection
  24573. */
  24574. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24575. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24576. };
  24577. /**
  24578. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24579. * @param min defines the min vector to use
  24580. * @param max defines the max vector to use
  24581. * @returns true if there is an intersection
  24582. */
  24583. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24584. var myMin = this.minimumWorld;
  24585. var myMax = this.maximumWorld;
  24586. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24587. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24588. if (myMaxX < minX || myMinX > maxX) {
  24589. return false;
  24590. }
  24591. if (myMaxY < minY || myMinY > maxY) {
  24592. return false;
  24593. }
  24594. if (myMaxZ < minZ || myMinZ > maxZ) {
  24595. return false;
  24596. }
  24597. return true;
  24598. };
  24599. // Statics
  24600. /**
  24601. * Tests if two bounding boxes are intersections
  24602. * @param box0 defines the first box to test
  24603. * @param box1 defines the second box to test
  24604. * @returns true if there is an intersection
  24605. */
  24606. BoundingBox.Intersects = function (box0, box1) {
  24607. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24608. };
  24609. /**
  24610. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24611. * @param minPoint defines the minimum vector of the bounding box
  24612. * @param maxPoint defines the maximum vector of the bounding box
  24613. * @param sphereCenter defines the sphere center
  24614. * @param sphereRadius defines the sphere radius
  24615. * @returns true if there is an intersection
  24616. */
  24617. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24618. var vector = BoundingBox.TmpVector3[0];
  24619. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24620. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24621. return (num <= (sphereRadius * sphereRadius));
  24622. };
  24623. /**
  24624. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24625. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24626. * @param frustumPlanes defines the frustum planes to test
  24627. * @return true if there is an inclusion
  24628. */
  24629. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24630. for (var p = 0; p < 6; ++p) {
  24631. var frustumPlane = frustumPlanes[p];
  24632. for (var i = 0; i < 8; ++i) {
  24633. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24634. return false;
  24635. }
  24636. }
  24637. }
  24638. return true;
  24639. };
  24640. /**
  24641. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24642. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24643. * @param frustumPlanes defines the frustum planes to test
  24644. * @return true if there is an intersection
  24645. */
  24646. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24647. for (var p = 0; p < 6; ++p) {
  24648. var canReturnFalse = true;
  24649. var frustumPlane = frustumPlanes[p];
  24650. for (var i = 0; i < 8; ++i) {
  24651. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24652. canReturnFalse = false;
  24653. break;
  24654. }
  24655. }
  24656. if (canReturnFalse) {
  24657. return false;
  24658. }
  24659. }
  24660. return true;
  24661. };
  24662. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24663. return BoundingBox;
  24664. }());
  24665. /***/ }),
  24666. /***/ "./Culling/boundingInfo.ts":
  24667. /*!*********************************!*\
  24668. !*** ./Culling/boundingInfo.ts ***!
  24669. \*********************************/
  24670. /*! exports provided: BoundingInfo */
  24671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24672. "use strict";
  24673. __webpack_require__.r(__webpack_exports__);
  24674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24675. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24676. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24677. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24678. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24679. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24680. var _result0 = { min: 0, max: 0 };
  24681. var _result1 = { min: 0, max: 0 };
  24682. var computeBoxExtents = function (axis, box, result) {
  24683. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24684. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24685. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24686. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24687. var r = r0 + r1 + r2;
  24688. result.min = p - r;
  24689. result.max = p + r;
  24690. };
  24691. var axisOverlap = function (axis, box0, box1) {
  24692. computeBoxExtents(axis, box0, _result0);
  24693. computeBoxExtents(axis, box1, _result1);
  24694. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24695. };
  24696. /**
  24697. * Info for a bounding data of a mesh
  24698. */
  24699. var BoundingInfo = /** @class */ (function () {
  24700. /**
  24701. * Constructs bounding info
  24702. * @param minimum min vector of the bounding box/sphere
  24703. * @param maximum max vector of the bounding box/sphere
  24704. * @param worldMatrix defines the new world matrix
  24705. */
  24706. function BoundingInfo(minimum, maximum, worldMatrix) {
  24707. this._isLocked = false;
  24708. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24709. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24710. }
  24711. /**
  24712. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24713. * @param min defines the new minimum vector (in local space)
  24714. * @param max defines the new maximum vector (in local space)
  24715. * @param worldMatrix defines the new world matrix
  24716. */
  24717. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24718. this.boundingBox.reConstruct(min, max, worldMatrix);
  24719. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24720. };
  24721. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24722. /**
  24723. * min vector of the bounding box/sphere
  24724. */
  24725. get: function () {
  24726. return this.boundingBox.minimum;
  24727. },
  24728. enumerable: true,
  24729. configurable: true
  24730. });
  24731. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24732. /**
  24733. * max vector of the bounding box/sphere
  24734. */
  24735. get: function () {
  24736. return this.boundingBox.maximum;
  24737. },
  24738. enumerable: true,
  24739. configurable: true
  24740. });
  24741. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24742. /**
  24743. * If the info is locked and won't be updated to avoid perf overhead
  24744. */
  24745. get: function () {
  24746. return this._isLocked;
  24747. },
  24748. set: function (value) {
  24749. this._isLocked = value;
  24750. },
  24751. enumerable: true,
  24752. configurable: true
  24753. });
  24754. // Methods
  24755. /**
  24756. * Updates the bounding sphere and box
  24757. * @param world world matrix to be used to update
  24758. */
  24759. BoundingInfo.prototype.update = function (world) {
  24760. if (this._isLocked) {
  24761. return;
  24762. }
  24763. this.boundingBox._update(world);
  24764. this.boundingSphere._update(world);
  24765. };
  24766. /**
  24767. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24768. * @param center New center of the bounding info
  24769. * @param extend New extend of the bounding info
  24770. * @returns the current bounding info
  24771. */
  24772. BoundingInfo.prototype.centerOn = function (center, extend) {
  24773. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24774. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24775. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24776. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24777. return this;
  24778. };
  24779. /**
  24780. * Scale the current bounding info by applying a scale factor
  24781. * @param factor defines the scale factor to apply
  24782. * @returns the current bounding info
  24783. */
  24784. BoundingInfo.prototype.scale = function (factor) {
  24785. this.boundingBox.scale(factor);
  24786. this.boundingSphere.scale(factor);
  24787. return this;
  24788. };
  24789. /**
  24790. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24791. * @param frustumPlanes defines the frustum to test
  24792. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24793. * @returns true if the bounding info is in the frustum planes
  24794. */
  24795. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24796. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24797. 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);
  24798. if (inclusionTest) {
  24799. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24800. return true;
  24801. }
  24802. }
  24803. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24804. return false;
  24805. }
  24806. 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);
  24807. if (bSphereOnlyTest) {
  24808. return true;
  24809. }
  24810. return this.boundingBox.isInFrustum(frustumPlanes);
  24811. };
  24812. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24813. /**
  24814. * Gets the world distance between the min and max points of the bounding box
  24815. */
  24816. get: function () {
  24817. var boundingBox = this.boundingBox;
  24818. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24819. return diag.length();
  24820. },
  24821. enumerable: true,
  24822. configurable: true
  24823. });
  24824. /**
  24825. * Checks if a cullable object (mesh...) is in the camera frustum
  24826. * Unlike isInFrustum this cheks the full bounding box
  24827. * @param frustumPlanes Camera near/planes
  24828. * @returns true if the object is in frustum otherwise false
  24829. */
  24830. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24831. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24832. };
  24833. /** @hidden */
  24834. BoundingInfo.prototype._checkCollision = function (collider) {
  24835. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24836. };
  24837. /**
  24838. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24839. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24840. * @param point the point to check intersection with
  24841. * @returns if the point intersects
  24842. */
  24843. BoundingInfo.prototype.intersectsPoint = function (point) {
  24844. if (!this.boundingSphere.centerWorld) {
  24845. return false;
  24846. }
  24847. if (!this.boundingSphere.intersectsPoint(point)) {
  24848. return false;
  24849. }
  24850. if (!this.boundingBox.intersectsPoint(point)) {
  24851. return false;
  24852. }
  24853. return true;
  24854. };
  24855. /**
  24856. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24857. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24858. * @param boundingInfo the bounding info to check intersection with
  24859. * @param precise if the intersection should be done using OBB
  24860. * @returns if the bounding info intersects
  24861. */
  24862. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24863. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24864. return false;
  24865. }
  24866. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24867. return false;
  24868. }
  24869. if (!precise) {
  24870. return true;
  24871. }
  24872. var box0 = this.boundingBox;
  24873. var box1 = boundingInfo.boundingBox;
  24874. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24875. return false;
  24876. }
  24877. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24878. return false;
  24879. }
  24880. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24881. return false;
  24882. }
  24883. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24884. return false;
  24885. }
  24886. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24887. return false;
  24888. }
  24889. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24890. return false;
  24891. }
  24892. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24893. return false;
  24894. }
  24895. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24896. return false;
  24897. }
  24898. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24899. return false;
  24900. }
  24901. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24902. return false;
  24903. }
  24904. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24905. return false;
  24906. }
  24907. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24908. return false;
  24909. }
  24910. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24911. return false;
  24912. }
  24913. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24914. return false;
  24915. }
  24916. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24917. return false;
  24918. }
  24919. return true;
  24920. };
  24921. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24922. return BoundingInfo;
  24923. }());
  24924. /***/ }),
  24925. /***/ "./Culling/boundingSphere.ts":
  24926. /*!***********************************!*\
  24927. !*** ./Culling/boundingSphere.ts ***!
  24928. \***********************************/
  24929. /*! exports provided: BoundingSphere */
  24930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24931. "use strict";
  24932. __webpack_require__.r(__webpack_exports__);
  24933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24934. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24935. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24936. /**
  24937. * Class used to store bounding sphere information
  24938. */
  24939. var BoundingSphere = /** @class */ (function () {
  24940. /**
  24941. * Creates a new bounding sphere
  24942. * @param min defines the minimum vector (in local space)
  24943. * @param max defines the maximum vector (in local space)
  24944. * @param worldMatrix defines the new world matrix
  24945. */
  24946. function BoundingSphere(min, max, worldMatrix) {
  24947. /**
  24948. * Gets the center of the bounding sphere in local space
  24949. */
  24950. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24951. /**
  24952. * Gets the center of the bounding sphere in world space
  24953. */
  24954. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24955. /**
  24956. * Gets the minimum vector in local space
  24957. */
  24958. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24959. /**
  24960. * Gets the maximum vector in local space
  24961. */
  24962. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24963. this.reConstruct(min, max, worldMatrix);
  24964. }
  24965. /**
  24966. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24967. * @param min defines the new minimum vector (in local space)
  24968. * @param max defines the new maximum vector (in local space)
  24969. * @param worldMatrix defines the new world matrix
  24970. */
  24971. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24972. this.minimum.copyFrom(min);
  24973. this.maximum.copyFrom(max);
  24974. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24975. max.addToRef(min, this.center).scaleInPlace(0.5);
  24976. this.radius = distance * 0.5;
  24977. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24978. };
  24979. /**
  24980. * Scale the current bounding sphere by applying a scale factor
  24981. * @param factor defines the scale factor to apply
  24982. * @returns the current bounding box
  24983. */
  24984. BoundingSphere.prototype.scale = function (factor) {
  24985. var newRadius = this.radius * factor;
  24986. var tmpVectors = BoundingSphere.TmpVector3;
  24987. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24988. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24989. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24990. this.reConstruct(min, max, this._worldMatrix);
  24991. return this;
  24992. };
  24993. /**
  24994. * Gets the world matrix of the bounding box
  24995. * @returns a matrix
  24996. */
  24997. BoundingSphere.prototype.getWorldMatrix = function () {
  24998. return this._worldMatrix;
  24999. };
  25000. // Methods
  25001. /** @hidden */
  25002. BoundingSphere.prototype._update = function (worldMatrix) {
  25003. if (!worldMatrix.isIdentity()) {
  25004. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25005. var tempVector = BoundingSphere.TmpVector3[0];
  25006. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25007. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25008. }
  25009. else {
  25010. this.centerWorld.copyFrom(this.center);
  25011. this.radiusWorld = this.radius;
  25012. }
  25013. };
  25014. /**
  25015. * Tests if the bounding sphere is intersecting the frustum planes
  25016. * @param frustumPlanes defines the frustum planes to test
  25017. * @returns true if there is an intersection
  25018. */
  25019. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25020. var center = this.centerWorld;
  25021. var radius = this.radiusWorld;
  25022. for (var i = 0; i < 6; i++) {
  25023. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25024. return false;
  25025. }
  25026. }
  25027. return true;
  25028. };
  25029. /**
  25030. * Tests if the bounding sphere center is in between the frustum planes.
  25031. * Used for optimistic fast inclusion.
  25032. * @param frustumPlanes defines the frustum planes to test
  25033. * @returns true if the sphere center is in between the frustum planes
  25034. */
  25035. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25036. var center = this.centerWorld;
  25037. for (var i = 0; i < 6; i++) {
  25038. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25039. return false;
  25040. }
  25041. }
  25042. return true;
  25043. };
  25044. /**
  25045. * Tests if a point is inside the bounding sphere
  25046. * @param point defines the point to test
  25047. * @returns true if the point is inside the bounding sphere
  25048. */
  25049. BoundingSphere.prototype.intersectsPoint = function (point) {
  25050. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25051. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25052. return false;
  25053. }
  25054. return true;
  25055. };
  25056. // Statics
  25057. /**
  25058. * Checks if two sphere intersct
  25059. * @param sphere0 sphere 0
  25060. * @param sphere1 sphere 1
  25061. * @returns true if the speres intersect
  25062. */
  25063. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25064. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25065. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25066. if (radiusSum * radiusSum < squareDistance) {
  25067. return false;
  25068. }
  25069. return true;
  25070. };
  25071. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25072. return BoundingSphere;
  25073. }());
  25074. /***/ }),
  25075. /***/ "./Culling/index.ts":
  25076. /*!**************************!*\
  25077. !*** ./Culling/index.ts ***!
  25078. \**************************/
  25079. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25081. "use strict";
  25082. __webpack_require__.r(__webpack_exports__);
  25083. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25085. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25087. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25089. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25093. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25095. /***/ }),
  25096. /***/ "./Culling/ray.ts":
  25097. /*!************************!*\
  25098. !*** ./Culling/ray.ts ***!
  25099. \************************/
  25100. /*! exports provided: Ray */
  25101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25102. "use strict";
  25103. __webpack_require__.r(__webpack_exports__);
  25104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25105. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25106. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25107. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25108. /**
  25109. * Class representing a ray with position and direction
  25110. */
  25111. var Ray = /** @class */ (function () {
  25112. /**
  25113. * Creates a new ray
  25114. * @param origin origin point
  25115. * @param direction direction
  25116. * @param length length of the ray
  25117. */
  25118. function Ray(
  25119. /** origin point */
  25120. origin,
  25121. /** direction */
  25122. direction,
  25123. /** length of the ray */
  25124. length) {
  25125. if (length === void 0) { length = Number.MAX_VALUE; }
  25126. this.origin = origin;
  25127. this.direction = direction;
  25128. this.length = length;
  25129. }
  25130. // Methods
  25131. /**
  25132. * Checks if the ray intersects a box
  25133. * @param minimum bound of the box
  25134. * @param maximum bound of the box
  25135. * @param intersectionTreshold extra extend to be added to the box in all direction
  25136. * @returns if the box was hit
  25137. */
  25138. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25139. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25140. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25141. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25142. var d = 0.0;
  25143. var maxValue = Number.MAX_VALUE;
  25144. var inv;
  25145. var min;
  25146. var max;
  25147. var temp;
  25148. if (Math.abs(this.direction.x) < 0.0000001) {
  25149. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25150. return false;
  25151. }
  25152. }
  25153. else {
  25154. inv = 1.0 / this.direction.x;
  25155. min = (newMinimum.x - this.origin.x) * inv;
  25156. max = (newMaximum.x - this.origin.x) * inv;
  25157. if (max === -Infinity) {
  25158. max = Infinity;
  25159. }
  25160. if (min > max) {
  25161. temp = min;
  25162. min = max;
  25163. max = temp;
  25164. }
  25165. d = Math.max(min, d);
  25166. maxValue = Math.min(max, maxValue);
  25167. if (d > maxValue) {
  25168. return false;
  25169. }
  25170. }
  25171. if (Math.abs(this.direction.y) < 0.0000001) {
  25172. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25173. return false;
  25174. }
  25175. }
  25176. else {
  25177. inv = 1.0 / this.direction.y;
  25178. min = (newMinimum.y - this.origin.y) * inv;
  25179. max = (newMaximum.y - this.origin.y) * inv;
  25180. if (max === -Infinity) {
  25181. max = Infinity;
  25182. }
  25183. if (min > max) {
  25184. temp = min;
  25185. min = max;
  25186. max = temp;
  25187. }
  25188. d = Math.max(min, d);
  25189. maxValue = Math.min(max, maxValue);
  25190. if (d > maxValue) {
  25191. return false;
  25192. }
  25193. }
  25194. if (Math.abs(this.direction.z) < 0.0000001) {
  25195. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25196. return false;
  25197. }
  25198. }
  25199. else {
  25200. inv = 1.0 / this.direction.z;
  25201. min = (newMinimum.z - this.origin.z) * inv;
  25202. max = (newMaximum.z - this.origin.z) * inv;
  25203. if (max === -Infinity) {
  25204. max = Infinity;
  25205. }
  25206. if (min > max) {
  25207. temp = min;
  25208. min = max;
  25209. max = temp;
  25210. }
  25211. d = Math.max(min, d);
  25212. maxValue = Math.min(max, maxValue);
  25213. if (d > maxValue) {
  25214. return false;
  25215. }
  25216. }
  25217. return true;
  25218. };
  25219. /**
  25220. * Checks if the ray intersects a box
  25221. * @param box the bounding box to check
  25222. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25223. * @returns if the box was hit
  25224. */
  25225. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25226. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25227. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25228. };
  25229. /**
  25230. * If the ray hits a sphere
  25231. * @param sphere the bounding sphere to check
  25232. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25233. * @returns true if it hits the sphere
  25234. */
  25235. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25236. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25237. var x = sphere.center.x - this.origin.x;
  25238. var y = sphere.center.y - this.origin.y;
  25239. var z = sphere.center.z - this.origin.z;
  25240. var pyth = (x * x) + (y * y) + (z * z);
  25241. var radius = sphere.radius + intersectionTreshold;
  25242. var rr = radius * radius;
  25243. if (pyth <= rr) {
  25244. return true;
  25245. }
  25246. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25247. if (dot < 0.0) {
  25248. return false;
  25249. }
  25250. var temp = pyth - (dot * dot);
  25251. return temp <= rr;
  25252. };
  25253. /**
  25254. * If the ray hits a triange
  25255. * @param vertex0 triangle vertex
  25256. * @param vertex1 triangle vertex
  25257. * @param vertex2 triangle vertex
  25258. * @returns intersection information if hit
  25259. */
  25260. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25261. var edge1 = Ray.TmpVector3[0];
  25262. var edge2 = Ray.TmpVector3[1];
  25263. var pvec = Ray.TmpVector3[2];
  25264. var tvec = Ray.TmpVector3[3];
  25265. var qvec = Ray.TmpVector3[4];
  25266. vertex1.subtractToRef(vertex0, edge1);
  25267. vertex2.subtractToRef(vertex0, edge2);
  25268. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25269. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25270. if (det === 0) {
  25271. return null;
  25272. }
  25273. var invdet = 1 / det;
  25274. this.origin.subtractToRef(vertex0, tvec);
  25275. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25276. if (bu < 0 || bu > 1.0) {
  25277. return null;
  25278. }
  25279. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25280. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25281. if (bv < 0 || bu + bv > 1.0) {
  25282. return null;
  25283. }
  25284. //check if the distance is longer than the predefined length.
  25285. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25286. if (distance > this.length) {
  25287. return null;
  25288. }
  25289. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__["IntersectionInfo"](bu, bv, distance);
  25290. };
  25291. /**
  25292. * Checks if ray intersects a plane
  25293. * @param plane the plane to check
  25294. * @returns the distance away it was hit
  25295. */
  25296. Ray.prototype.intersectsPlane = function (plane) {
  25297. var distance;
  25298. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25299. if (Math.abs(result1) < 9.99999997475243E-07) {
  25300. return null;
  25301. }
  25302. else {
  25303. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25304. distance = (-plane.d - result2) / result1;
  25305. if (distance < 0.0) {
  25306. if (distance < -9.99999997475243E-07) {
  25307. return null;
  25308. }
  25309. else {
  25310. return 0;
  25311. }
  25312. }
  25313. return distance;
  25314. }
  25315. };
  25316. /**
  25317. * Checks if ray intersects a mesh
  25318. * @param mesh the mesh to check
  25319. * @param fastCheck if only the bounding box should checked
  25320. * @returns picking info of the intersecton
  25321. */
  25322. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25323. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25324. mesh.getWorldMatrix().invertToRef(tm);
  25325. if (this._tmpRay) {
  25326. Ray.TransformToRef(this, tm, this._tmpRay);
  25327. }
  25328. else {
  25329. this._tmpRay = Ray.Transform(this, tm);
  25330. }
  25331. return mesh.intersects(this._tmpRay, fastCheck);
  25332. };
  25333. /**
  25334. * Checks if ray intersects a mesh
  25335. * @param meshes the meshes to check
  25336. * @param fastCheck if only the bounding box should checked
  25337. * @param results array to store result in
  25338. * @returns Array of picking infos
  25339. */
  25340. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25341. if (results) {
  25342. results.length = 0;
  25343. }
  25344. else {
  25345. results = [];
  25346. }
  25347. for (var i = 0; i < meshes.length; i++) {
  25348. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25349. if (pickInfo.hit) {
  25350. results.push(pickInfo);
  25351. }
  25352. }
  25353. results.sort(this._comparePickingInfo);
  25354. return results;
  25355. };
  25356. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25357. if (pickingInfoA.distance < pickingInfoB.distance) {
  25358. return -1;
  25359. }
  25360. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25361. return 1;
  25362. }
  25363. else {
  25364. return 0;
  25365. }
  25366. };
  25367. /**
  25368. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25369. * @param sega the first point of the segment to test the intersection against
  25370. * @param segb the second point of the segment to test the intersection against
  25371. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25372. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25373. */
  25374. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25375. var o = this.origin;
  25376. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25377. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25378. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25379. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25380. segb.subtractToRef(sega, u);
  25381. this.direction.scaleToRef(Ray.rayl, v);
  25382. o.addToRef(v, rsegb);
  25383. sega.subtractToRef(o, w);
  25384. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25385. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25386. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25387. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25388. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25389. var D = a * c - b * b; // always >= 0
  25390. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25391. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25392. // compute the line parameters of the two closest points
  25393. if (D < Ray.smallnum) { // the lines are almost parallel
  25394. sN = 0.0; // force using point P0 on segment S1
  25395. sD = 1.0; // to prevent possible division by 0.0 later
  25396. tN = e;
  25397. tD = c;
  25398. }
  25399. else { // get the closest points on the infinite lines
  25400. sN = (b * e - c * d);
  25401. tN = (a * e - b * d);
  25402. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25403. sN = 0.0;
  25404. tN = e;
  25405. tD = c;
  25406. }
  25407. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25408. sN = sD;
  25409. tN = e + b;
  25410. tD = c;
  25411. }
  25412. }
  25413. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25414. tN = 0.0;
  25415. // recompute sc for this edge
  25416. if (-d < 0.0) {
  25417. sN = 0.0;
  25418. }
  25419. else if (-d > a) {
  25420. sN = sD;
  25421. }
  25422. else {
  25423. sN = -d;
  25424. sD = a;
  25425. }
  25426. }
  25427. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25428. tN = tD;
  25429. // recompute sc for this edge
  25430. if ((-d + b) < 0.0) {
  25431. sN = 0;
  25432. }
  25433. else if ((-d + b) > a) {
  25434. sN = sD;
  25435. }
  25436. else {
  25437. sN = (-d + b);
  25438. sD = a;
  25439. }
  25440. }
  25441. // finally do the division to get sc and tc
  25442. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25443. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25444. // get the difference of the two closest points
  25445. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25446. v.scaleToRef(tc, qtc);
  25447. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25448. u.scaleToRef(sc, qsc);
  25449. qsc.addInPlace(w);
  25450. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25451. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25452. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25453. if (isIntersected) {
  25454. return qsc.length();
  25455. }
  25456. return -1;
  25457. };
  25458. /**
  25459. * Update the ray from viewport position
  25460. * @param x position
  25461. * @param y y position
  25462. * @param viewportWidth viewport width
  25463. * @param viewportHeight viewport height
  25464. * @param world world matrix
  25465. * @param view view matrix
  25466. * @param projection projection matrix
  25467. * @returns this ray updated
  25468. */
  25469. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25470. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25471. return this;
  25472. };
  25473. // Statics
  25474. /**
  25475. * Creates a ray with origin and direction of 0,0,0
  25476. * @returns the new ray
  25477. */
  25478. Ray.Zero = function () {
  25479. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25480. };
  25481. /**
  25482. * Creates a new ray from screen space and viewport
  25483. * @param x position
  25484. * @param y y position
  25485. * @param viewportWidth viewport width
  25486. * @param viewportHeight viewport height
  25487. * @param world world matrix
  25488. * @param view view matrix
  25489. * @param projection projection matrix
  25490. * @returns new ray
  25491. */
  25492. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25493. var result = Ray.Zero();
  25494. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25495. };
  25496. /**
  25497. * 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
  25498. * transformed to the given world matrix.
  25499. * @param origin The origin point
  25500. * @param end The end point
  25501. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25502. * @returns the new ray
  25503. */
  25504. Ray.CreateNewFromTo = function (origin, end, world) {
  25505. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25506. var direction = end.subtract(origin);
  25507. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25508. direction.normalize();
  25509. return Ray.Transform(new Ray(origin, direction, length), world);
  25510. };
  25511. /**
  25512. * Transforms a ray by a matrix
  25513. * @param ray ray to transform
  25514. * @param matrix matrix to apply
  25515. * @returns the resulting new ray
  25516. */
  25517. Ray.Transform = function (ray, matrix) {
  25518. 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));
  25519. Ray.TransformToRef(ray, matrix, result);
  25520. return result;
  25521. };
  25522. /**
  25523. * Transforms a ray by a matrix
  25524. * @param ray ray to transform
  25525. * @param matrix matrix to apply
  25526. * @param result ray to store result in
  25527. */
  25528. Ray.TransformToRef = function (ray, matrix, result) {
  25529. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25530. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25531. result.length = ray.length;
  25532. var dir = result.direction;
  25533. var len = dir.length();
  25534. if (!(len === 0 || len === 1)) {
  25535. var num = 1.0 / len;
  25536. dir.x *= num;
  25537. dir.y *= num;
  25538. dir.z *= num;
  25539. result.length *= len;
  25540. }
  25541. };
  25542. /**
  25543. * Unproject a ray from screen space to object space
  25544. * @param sourceX defines the screen space x coordinate to use
  25545. * @param sourceY defines the screen space y coordinate to use
  25546. * @param viewportWidth defines the current width of the viewport
  25547. * @param viewportHeight defines the current height of the viewport
  25548. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25549. * @param view defines the view matrix to use
  25550. * @param projection defines the projection matrix to use
  25551. */
  25552. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25553. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25554. world.multiplyToRef(view, matrix);
  25555. matrix.multiplyToRef(projection, matrix);
  25556. matrix.invert();
  25557. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25558. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25559. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25560. nearScreenSource.z = -1.0;
  25561. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25562. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25563. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25564. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25565. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25566. this.origin.copyFrom(nearVec3);
  25567. farVec3.subtractToRef(nearVec3, this.direction);
  25568. this.direction.normalize();
  25569. };
  25570. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25571. Ray.smallnum = 0.00000001;
  25572. Ray.rayl = 10e8;
  25573. return Ray;
  25574. }());
  25575. /***/ }),
  25576. /***/ "./Debug/axesViewer.ts":
  25577. /*!*****************************!*\
  25578. !*** ./Debug/axesViewer.ts ***!
  25579. \*****************************/
  25580. /*! exports provided: AxesViewer */
  25581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25582. "use strict";
  25583. __webpack_require__.r(__webpack_exports__);
  25584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25585. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25586. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25587. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25588. /**
  25589. * The Axes viewer will show 3 axes in a specific point in space
  25590. */
  25591. var AxesViewer = /** @class */ (function () {
  25592. /**
  25593. * Creates a new AxesViewer
  25594. * @param scene defines the hosting scene
  25595. * @param scaleLines defines a number used to scale line length (1 by default)
  25596. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25597. * @param xAxis defines the node hierarchy used to render the x-axis
  25598. * @param yAxis defines the node hierarchy used to render the y-axis
  25599. * @param zAxis defines the node hierarchy used to render the z-axis
  25600. */
  25601. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25602. if (scaleLines === void 0) { scaleLines = 1; }
  25603. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25604. this._scaleLinesFactor = 4;
  25605. this._instanced = false;
  25606. /**
  25607. * Gets or sets a number used to scale line length
  25608. */
  25609. this.scaleLines = 1;
  25610. this.scaleLines = scaleLines;
  25611. if (!xAxis) {
  25612. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25613. redColoredMaterial.disableLighting = true;
  25614. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25615. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25616. }
  25617. if (!yAxis) {
  25618. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25619. greenColoredMaterial.disableLighting = true;
  25620. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25621. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25622. }
  25623. if (!zAxis) {
  25624. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25625. blueColoredMaterial.disableLighting = true;
  25626. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25627. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25628. }
  25629. this._xAxis = xAxis;
  25630. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25631. this._yAxis = yAxis;
  25632. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25633. this._zAxis = zAxis;
  25634. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25635. if (renderingGroupId != null) {
  25636. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25637. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25638. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25639. }
  25640. this.scene = scene;
  25641. 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());
  25642. }
  25643. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25644. /** Gets the node hierarchy used to render x-axis */
  25645. get: function () {
  25646. return this._xAxis;
  25647. },
  25648. enumerable: true,
  25649. configurable: true
  25650. });
  25651. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25652. /** Gets the node hierarchy used to render y-axis */
  25653. get: function () {
  25654. return this._yAxis;
  25655. },
  25656. enumerable: true,
  25657. configurable: true
  25658. });
  25659. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25660. /** Gets the node hierarchy used to render z-axis */
  25661. get: function () {
  25662. return this._zAxis;
  25663. },
  25664. enumerable: true,
  25665. configurable: true
  25666. });
  25667. /**
  25668. * Force the viewer to update
  25669. * @param position defines the position of the viewer
  25670. * @param xaxis defines the x axis of the viewer
  25671. * @param yaxis defines the y axis of the viewer
  25672. * @param zaxis defines the z axis of the viewer
  25673. */
  25674. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25675. this._xAxis.position.copyFrom(position);
  25676. this._xAxis.setDirection(xaxis);
  25677. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25678. this._yAxis.position.copyFrom(position);
  25679. this._yAxis.setDirection(yaxis);
  25680. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25681. this._zAxis.position.copyFrom(position);
  25682. this._zAxis.setDirection(zaxis);
  25683. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25684. };
  25685. /**
  25686. * Creates an instance of this axes viewer.
  25687. * @returns a new axes viewer with instanced meshes
  25688. */
  25689. AxesViewer.prototype.createInstance = function () {
  25690. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25691. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25692. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25693. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25694. axesViewer._instanced = true;
  25695. return axesViewer;
  25696. };
  25697. /** Releases resources */
  25698. AxesViewer.prototype.dispose = function () {
  25699. if (this._xAxis) {
  25700. this._xAxis.dispose(false, !this._instanced);
  25701. delete this._xAxis;
  25702. }
  25703. if (this._yAxis) {
  25704. this._yAxis.dispose(false, !this._instanced);
  25705. delete this._yAxis;
  25706. }
  25707. if (this._zAxis) {
  25708. this._zAxis.dispose(false, !this._instanced);
  25709. delete this._zAxis;
  25710. }
  25711. delete this.scene;
  25712. };
  25713. AxesViewer._SetRenderingGroupId = function (node, id) {
  25714. node.getChildMeshes().forEach(function (mesh) {
  25715. mesh.renderingGroupId = id;
  25716. });
  25717. };
  25718. return AxesViewer;
  25719. }());
  25720. /***/ }),
  25721. /***/ "./Debug/boneAxesViewer.ts":
  25722. /*!*********************************!*\
  25723. !*** ./Debug/boneAxesViewer.ts ***!
  25724. \*********************************/
  25725. /*! exports provided: BoneAxesViewer */
  25726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25727. "use strict";
  25728. __webpack_require__.r(__webpack_exports__);
  25729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25731. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25732. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25733. /**
  25734. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25735. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25736. */
  25737. var BoneAxesViewer = /** @class */ (function (_super) {
  25738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25739. /**
  25740. * Creates a new BoneAxesViewer
  25741. * @param scene defines the hosting scene
  25742. * @param bone defines the target bone
  25743. * @param mesh defines the target mesh
  25744. * @param scaleLines defines a scaling factor for line length (1 by default)
  25745. */
  25746. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25747. if (scaleLines === void 0) { scaleLines = 1; }
  25748. var _this = _super.call(this, scene, scaleLines) || this;
  25749. /** Gets current position */
  25750. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25751. /** Gets direction of X axis */
  25752. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25753. /** Gets direction of Y axis */
  25754. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25755. /** Gets direction of Z axis */
  25756. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25757. _this.mesh = mesh;
  25758. _this.bone = bone;
  25759. return _this;
  25760. }
  25761. /**
  25762. * Force the viewer to update
  25763. */
  25764. BoneAxesViewer.prototype.update = function () {
  25765. if (!this.mesh || !this.bone) {
  25766. return;
  25767. }
  25768. var bone = this.bone;
  25769. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25770. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25771. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25772. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25773. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25774. };
  25775. /** Releases resources */
  25776. BoneAxesViewer.prototype.dispose = function () {
  25777. if (this.mesh) {
  25778. this.mesh = null;
  25779. this.bone = null;
  25780. _super.prototype.dispose.call(this);
  25781. }
  25782. };
  25783. return BoneAxesViewer;
  25784. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25785. /***/ }),
  25786. /***/ "./Debug/debugLayer.ts":
  25787. /*!*****************************!*\
  25788. !*** ./Debug/debugLayer.ts ***!
  25789. \*****************************/
  25790. /*! exports provided: DebugLayer */
  25791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25792. "use strict";
  25793. __webpack_require__.r(__webpack_exports__);
  25794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25796. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25797. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25798. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25799. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25800. get: function () {
  25801. if (!this._debugLayer) {
  25802. this._debugLayer = new DebugLayer(this);
  25803. }
  25804. return this._debugLayer;
  25805. },
  25806. enumerable: true,
  25807. configurable: true
  25808. });
  25809. /**
  25810. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25811. * what is happening in your scene
  25812. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25813. */
  25814. var DebugLayer = /** @class */ (function () {
  25815. /**
  25816. * Instantiates a new debug layer.
  25817. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25818. * what is happening in your scene
  25819. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25820. * @param scene Defines the scene to inspect
  25821. */
  25822. function DebugLayer(scene) {
  25823. var _this = this;
  25824. this.BJSINSPECTOR = this._getGlobalInspector();
  25825. /**
  25826. * Observable triggered when a property is changed through the inspector.
  25827. */
  25828. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  25829. this._scene = scene;
  25830. this._scene.onDisposeObservable.add(function () {
  25831. // Debug layer
  25832. if (_this._scene._debugLayer) {
  25833. _this._scene._debugLayer.hide();
  25834. }
  25835. });
  25836. }
  25837. /** Creates the inspector window. */
  25838. DebugLayer.prototype._createInspector = function (config) {
  25839. if (this.isVisible()) {
  25840. return;
  25841. }
  25842. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  25843. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  25844. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  25845. };
  25846. /** Get the inspector from bundle or global */
  25847. DebugLayer.prototype._getGlobalInspector = function () {
  25848. // UMD Global name detection from Webpack Bundle UMD Name.
  25849. if (typeof INSPECTOR !== 'undefined') {
  25850. return INSPECTOR;
  25851. }
  25852. // In case of module let s check the global emitted from the Inspector entry point.
  25853. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  25854. return BABYLON;
  25855. }
  25856. return undefined;
  25857. };
  25858. /**
  25859. * Get if the inspector is visible or not.
  25860. * @returns true if visible otherwise, false
  25861. */
  25862. DebugLayer.prototype.isVisible = function () {
  25863. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  25864. };
  25865. /**
  25866. * Hide the inspector and close its window.
  25867. */
  25868. DebugLayer.prototype.hide = function () {
  25869. if (this.BJSINSPECTOR) {
  25870. this.BJSINSPECTOR.Inspector.Hide();
  25871. }
  25872. };
  25873. /**
  25874. * Launch the debugLayer.
  25875. * @param config Define the configuration of the inspector
  25876. */
  25877. DebugLayer.prototype.show = function (config) {
  25878. if (typeof this.BJSINSPECTOR == 'undefined') {
  25879. // Load inspector and add it to the DOM
  25880. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  25881. }
  25882. else {
  25883. // Otherwise creates the inspector
  25884. this._createInspector(config);
  25885. }
  25886. };
  25887. /**
  25888. * Define the url to get the inspector script from.
  25889. * By default it uses the babylonjs CDN.
  25890. * @ignoreNaming
  25891. */
  25892. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  25893. return DebugLayer;
  25894. }());
  25895. /***/ }),
  25896. /***/ "./Debug/index.ts":
  25897. /*!************************!*\
  25898. !*** ./Debug/index.ts ***!
  25899. \************************/
  25900. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  25901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25902. "use strict";
  25903. __webpack_require__.r(__webpack_exports__);
  25904. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  25905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  25906. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  25907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  25908. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  25909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  25910. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  25911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  25912. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  25913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  25914. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  25915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  25916. /***/ }),
  25917. /***/ "./Debug/physicsViewer.ts":
  25918. /*!********************************!*\
  25919. !*** ./Debug/physicsViewer.ts ***!
  25920. \********************************/
  25921. /*! exports provided: PhysicsViewer */
  25922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25923. "use strict";
  25924. __webpack_require__.r(__webpack_exports__);
  25925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  25926. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  25927. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  25928. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25929. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  25930. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25931. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  25932. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25933. /**
  25934. * Used to show the physics impostor around the specific mesh
  25935. */
  25936. var PhysicsViewer = /** @class */ (function () {
  25937. /**
  25938. * Creates a new PhysicsViewer
  25939. * @param scene defines the hosting scene
  25940. */
  25941. function PhysicsViewer(scene) {
  25942. /** @hidden */
  25943. this._impostors = [];
  25944. /** @hidden */
  25945. this._meshes = [];
  25946. /** @hidden */
  25947. this._numMeshes = 0;
  25948. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  25949. var physicEngine = this._scene.getPhysicsEngine();
  25950. if (physicEngine) {
  25951. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  25952. }
  25953. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  25954. this._utilityLayer.pickUtilitySceneFirst = false;
  25955. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25956. }
  25957. /** @hidden */
  25958. PhysicsViewer.prototype._updateDebugMeshes = function () {
  25959. var plugin = this._physicsEnginePlugin;
  25960. for (var i = 0; i < this._numMeshes; i++) {
  25961. var impostor = this._impostors[i];
  25962. if (!impostor) {
  25963. continue;
  25964. }
  25965. if (impostor.isDisposed) {
  25966. this.hideImpostor(this._impostors[i--]);
  25967. }
  25968. else {
  25969. var mesh = this._meshes[i];
  25970. if (mesh && plugin) {
  25971. plugin.syncMeshWithImpostor(mesh, impostor);
  25972. }
  25973. }
  25974. }
  25975. };
  25976. /**
  25977. * Renders a specified physic impostor
  25978. * @param impostor defines the impostor to render
  25979. * @returns the new debug mesh used to render the impostor
  25980. */
  25981. PhysicsViewer.prototype.showImpostor = function (impostor) {
  25982. if (!this._scene) {
  25983. return null;
  25984. }
  25985. for (var i = 0; i < this._numMeshes; i++) {
  25986. if (this._impostors[i] == impostor) {
  25987. return null;
  25988. }
  25989. }
  25990. var debugMesh = this._getDebugMesh(impostor);
  25991. if (debugMesh) {
  25992. this._impostors[this._numMeshes] = impostor;
  25993. this._meshes[this._numMeshes] = debugMesh;
  25994. if (this._numMeshes === 0) {
  25995. this._renderFunction = this._updateDebugMeshes.bind(this);
  25996. this._scene.registerBeforeRender(this._renderFunction);
  25997. }
  25998. this._numMeshes++;
  25999. }
  26000. return debugMesh;
  26001. };
  26002. /**
  26003. * Hides a specified physic impostor
  26004. * @param impostor defines the impostor to hide
  26005. */
  26006. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26007. if (!impostor || !this._scene || !this._utilityLayer) {
  26008. return;
  26009. }
  26010. var removed = false;
  26011. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26012. for (var i = 0; i < this._numMeshes; i++) {
  26013. if (this._impostors[i] == impostor) {
  26014. var mesh = this._meshes[i];
  26015. if (!mesh) {
  26016. continue;
  26017. }
  26018. utilityLayerScene.removeMesh(mesh);
  26019. mesh.dispose();
  26020. this._numMeshes--;
  26021. if (this._numMeshes > 0) {
  26022. this._meshes[i] = this._meshes[this._numMeshes];
  26023. this._impostors[i] = this._impostors[this._numMeshes];
  26024. this._meshes[this._numMeshes] = null;
  26025. this._impostors[this._numMeshes] = null;
  26026. }
  26027. else {
  26028. this._meshes[0] = null;
  26029. this._impostors[0] = null;
  26030. }
  26031. removed = true;
  26032. break;
  26033. }
  26034. }
  26035. if (removed && this._numMeshes === 0) {
  26036. this._scene.unregisterBeforeRender(this._renderFunction);
  26037. }
  26038. };
  26039. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26040. if (!this._debugMaterial) {
  26041. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26042. this._debugMaterial.wireframe = true;
  26043. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26044. this._debugMaterial.disableLighting = true;
  26045. }
  26046. return this._debugMaterial;
  26047. };
  26048. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26049. if (!this._debugBoxMesh) {
  26050. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26051. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26052. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26053. }
  26054. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26055. };
  26056. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26057. if (!this._debugSphereMesh) {
  26058. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26059. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26060. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26061. }
  26062. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26063. };
  26064. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26065. if (!this._utilityLayer) {
  26066. return null;
  26067. }
  26068. var mesh = null;
  26069. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26070. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26071. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26072. impostor.getBoxSizeToRef(mesh.scaling);
  26073. }
  26074. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26075. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26076. var radius = impostor.getRadius();
  26077. mesh.scaling.x = radius * 2;
  26078. mesh.scaling.y = radius * 2;
  26079. mesh.scaling.z = radius * 2;
  26080. }
  26081. return mesh;
  26082. };
  26083. /** Releases all resources */
  26084. PhysicsViewer.prototype.dispose = function () {
  26085. for (var i = 0; i < this._numMeshes; i++) {
  26086. this.hideImpostor(this._impostors[i]);
  26087. }
  26088. if (this._debugBoxMesh) {
  26089. this._debugBoxMesh.dispose();
  26090. }
  26091. if (this._debugSphereMesh) {
  26092. this._debugSphereMesh.dispose();
  26093. }
  26094. if (this._debugMaterial) {
  26095. this._debugMaterial.dispose();
  26096. }
  26097. this._impostors.length = 0;
  26098. this._scene = null;
  26099. this._physicsEnginePlugin = null;
  26100. if (this._utilityLayer) {
  26101. this._utilityLayer.dispose();
  26102. this._utilityLayer = null;
  26103. }
  26104. };
  26105. return PhysicsViewer;
  26106. }());
  26107. /***/ }),
  26108. /***/ "./Debug/rayHelper.ts":
  26109. /*!****************************!*\
  26110. !*** ./Debug/rayHelper.ts ***!
  26111. \****************************/
  26112. /*! exports provided: RayHelper */
  26113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26114. "use strict";
  26115. __webpack_require__.r(__webpack_exports__);
  26116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26117. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26118. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26119. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26120. /**
  26121. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26122. * in order to better appreciate the issue one might have.
  26123. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26124. */
  26125. var RayHelper = /** @class */ (function () {
  26126. /**
  26127. * Instantiate a new ray helper.
  26128. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26129. * in order to better appreciate the issue one might have.
  26130. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26131. * @param ray Defines the ray we are currently tryin to visualize
  26132. */
  26133. function RayHelper(ray) {
  26134. this.ray = ray;
  26135. }
  26136. /**
  26137. * Helper function to create a colored helper in a scene in one line.
  26138. * @param ray Defines the ray we are currently tryin to visualize
  26139. * @param scene Defines the scene the ray is used in
  26140. * @param color Defines the color we want to see the ray in
  26141. * @returns The newly created ray helper.
  26142. */
  26143. RayHelper.CreateAndShow = function (ray, scene, color) {
  26144. var helper = new RayHelper(ray);
  26145. helper.show(scene, color);
  26146. return helper;
  26147. };
  26148. /**
  26149. * Shows the ray we are willing to debug.
  26150. * @param scene Defines the scene the ray needs to be rendered in
  26151. * @param color Defines the color the ray needs to be rendered in
  26152. */
  26153. RayHelper.prototype.show = function (scene, color) {
  26154. if (!this._renderFunction && this.ray) {
  26155. var ray = this.ray;
  26156. this._renderFunction = this._render.bind(this);
  26157. this._scene = scene;
  26158. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26159. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26160. if (this._renderFunction) {
  26161. this._scene.registerBeforeRender(this._renderFunction);
  26162. }
  26163. }
  26164. if (color && this._renderLine) {
  26165. this._renderLine.color.copyFrom(color);
  26166. }
  26167. };
  26168. /**
  26169. * Hides the ray we are debugging.
  26170. */
  26171. RayHelper.prototype.hide = function () {
  26172. if (this._renderFunction && this._scene) {
  26173. this._scene.unregisterBeforeRender(this._renderFunction);
  26174. this._scene = null;
  26175. this._renderFunction = null;
  26176. if (this._renderLine) {
  26177. this._renderLine.dispose();
  26178. this._renderLine = null;
  26179. }
  26180. this._renderPoints = [];
  26181. }
  26182. };
  26183. RayHelper.prototype._render = function () {
  26184. var ray = this.ray;
  26185. if (!ray) {
  26186. return;
  26187. }
  26188. var point = this._renderPoints[1];
  26189. var len = Math.min(ray.length, 1000000);
  26190. point.copyFrom(ray.direction);
  26191. point.scaleInPlace(len);
  26192. point.addInPlace(ray.origin);
  26193. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26194. };
  26195. /**
  26196. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26197. * @param mesh Defines the mesh we want the helper attached to
  26198. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26199. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26200. * @param length Defines the length of the ray
  26201. */
  26202. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26203. this._attachedToMesh = mesh;
  26204. var ray = this.ray;
  26205. if (!ray) {
  26206. return;
  26207. }
  26208. if (!ray.direction) {
  26209. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26210. }
  26211. if (!ray.origin) {
  26212. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26213. }
  26214. if (length) {
  26215. ray.length = length;
  26216. }
  26217. if (!meshSpaceOrigin) {
  26218. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26219. }
  26220. if (!meshSpaceDirection) {
  26221. // -1 so that this will work with Mesh.lookAt
  26222. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26223. }
  26224. if (!this._meshSpaceDirection) {
  26225. this._meshSpaceDirection = meshSpaceDirection.clone();
  26226. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26227. }
  26228. else {
  26229. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26230. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26231. }
  26232. if (!this._updateToMeshFunction) {
  26233. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26234. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26235. }
  26236. this._updateToMesh();
  26237. };
  26238. /**
  26239. * Detach the ray helper from the mesh it has previously been attached to.
  26240. */
  26241. RayHelper.prototype.detachFromMesh = function () {
  26242. if (this._attachedToMesh) {
  26243. if (this._updateToMeshFunction) {
  26244. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26245. }
  26246. this._attachedToMesh = null;
  26247. this._updateToMeshFunction = null;
  26248. }
  26249. };
  26250. RayHelper.prototype._updateToMesh = function () {
  26251. var ray = this.ray;
  26252. if (!this._attachedToMesh || !ray) {
  26253. return;
  26254. }
  26255. if (this._attachedToMesh._isDisposed) {
  26256. this.detachFromMesh();
  26257. return;
  26258. }
  26259. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26260. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26261. };
  26262. /**
  26263. * Dispose the helper and release its associated resources.
  26264. */
  26265. RayHelper.prototype.dispose = function () {
  26266. this.hide();
  26267. this.detachFromMesh();
  26268. this.ray = null;
  26269. };
  26270. return RayHelper;
  26271. }());
  26272. /***/ }),
  26273. /***/ "./Debug/skeletonViewer.ts":
  26274. /*!*********************************!*\
  26275. !*** ./Debug/skeletonViewer.ts ***!
  26276. \*********************************/
  26277. /*! exports provided: SkeletonViewer */
  26278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26279. "use strict";
  26280. __webpack_require__.r(__webpack_exports__);
  26281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26282. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26283. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26284. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26285. /**
  26286. * Class used to render a debug view of a given skeleton
  26287. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26288. */
  26289. var SkeletonViewer = /** @class */ (function () {
  26290. /**
  26291. * Creates a new SkeletonViewer
  26292. * @param skeleton defines the skeleton to render
  26293. * @param mesh defines the mesh attached to the skeleton
  26294. * @param scene defines the hosting scene
  26295. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26296. * @param renderingGroupId defines the rendering group id to use with the viewer
  26297. */
  26298. function SkeletonViewer(
  26299. /** defines the skeleton to render */
  26300. skeleton,
  26301. /** defines the mesh attached to the skeleton */
  26302. mesh, scene,
  26303. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26304. autoUpdateBonesMatrices,
  26305. /** defines the rendering group id to use with the viewer */
  26306. renderingGroupId) {
  26307. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26308. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26309. this.skeleton = skeleton;
  26310. this.mesh = mesh;
  26311. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26312. this.renderingGroupId = renderingGroupId;
  26313. /** Gets or sets the color used to render the skeleton */
  26314. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26315. this._debugLines = new Array();
  26316. this._isEnabled = false;
  26317. this._scene = scene;
  26318. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26319. this._utilityLayer.pickUtilitySceneFirst = false;
  26320. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26321. this.update();
  26322. this._renderFunction = this.update.bind(this);
  26323. }
  26324. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26325. /**
  26326. * Returns the mesh used to render the bones
  26327. */
  26328. get: function () {
  26329. return this._debugMesh;
  26330. },
  26331. enumerable: true,
  26332. configurable: true
  26333. });
  26334. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  26335. get: function () {
  26336. return this._isEnabled;
  26337. },
  26338. /** Gets or sets a boolean indicating if the viewer is enabled */
  26339. set: function (value) {
  26340. if (this._isEnabled === value) {
  26341. return;
  26342. }
  26343. this._isEnabled = value;
  26344. if (value) {
  26345. this._scene.registerBeforeRender(this._renderFunction);
  26346. }
  26347. else {
  26348. this._scene.unregisterBeforeRender(this._renderFunction);
  26349. }
  26350. },
  26351. enumerable: true,
  26352. configurable: true
  26353. });
  26354. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  26355. if (x === void 0) { x = 0; }
  26356. if (y === void 0) { y = 0; }
  26357. if (z === void 0) { z = 0; }
  26358. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  26359. var parentBone = bone.getParent();
  26360. tmat.copyFrom(bone.getLocalMatrix());
  26361. if (x !== 0 || y !== 0 || z !== 0) {
  26362. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  26363. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  26364. tmat2.setTranslationFromFloats(x, y, z);
  26365. tmat2.multiplyToRef(tmat, tmat);
  26366. }
  26367. if (parentBone) {
  26368. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  26369. }
  26370. tmat.multiplyToRef(meshMat, tmat);
  26371. position.x = tmat.m[12];
  26372. position.y = tmat.m[13];
  26373. position.z = tmat.m[14];
  26374. };
  26375. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  26376. var len = bones.length;
  26377. var meshPos = this.mesh.position;
  26378. for (var i = 0; i < len; i++) {
  26379. var bone = bones[i];
  26380. var points = this._debugLines[i];
  26381. if (!points) {
  26382. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26383. this._debugLines[i] = points;
  26384. }
  26385. this._getBonePosition(points[0], bone, meshMat);
  26386. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  26387. points[0].subtractInPlace(meshPos);
  26388. points[1].subtractInPlace(meshPos);
  26389. }
  26390. };
  26391. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  26392. var len = bones.length;
  26393. var boneNum = 0;
  26394. var meshPos = this.mesh.position;
  26395. for (var i = len - 1; i >= 0; i--) {
  26396. var childBone = bones[i];
  26397. var parentBone = childBone.getParent();
  26398. if (!parentBone) {
  26399. continue;
  26400. }
  26401. var points = this._debugLines[boneNum];
  26402. if (!points) {
  26403. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26404. this._debugLines[boneNum] = points;
  26405. }
  26406. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  26407. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  26408. points[0].subtractInPlace(meshPos);
  26409. points[1].subtractInPlace(meshPos);
  26410. boneNum++;
  26411. }
  26412. };
  26413. /** Update the viewer to sync with current skeleton state */
  26414. SkeletonViewer.prototype.update = function () {
  26415. if (!this._utilityLayer) {
  26416. return;
  26417. }
  26418. if (this.autoUpdateBonesMatrices) {
  26419. this.skeleton.computeAbsoluteTransforms();
  26420. }
  26421. if (this.skeleton.bones[0].length === undefined) {
  26422. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26423. }
  26424. else {
  26425. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26426. }
  26427. var targetScene = this._utilityLayer.utilityLayerScene;
  26428. if (!this._debugMesh) {
  26429. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  26430. this._debugMesh.renderingGroupId = this.renderingGroupId;
  26431. }
  26432. else {
  26433. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  26434. }
  26435. this._debugMesh.position.copyFrom(this.mesh.position);
  26436. this._debugMesh.color = this.color;
  26437. };
  26438. /** Release associated resources */
  26439. SkeletonViewer.prototype.dispose = function () {
  26440. this.isEnabled = false;
  26441. if (this._debugMesh) {
  26442. this.isEnabled = false;
  26443. this._debugMesh.dispose();
  26444. this._debugMesh = null;
  26445. }
  26446. if (this._utilityLayer) {
  26447. this._utilityLayer.dispose();
  26448. this._utilityLayer = null;
  26449. }
  26450. };
  26451. return SkeletonViewer;
  26452. }());
  26453. /***/ }),
  26454. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26455. /*!*****************************************************!*\
  26456. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26457. \*****************************************************/
  26458. /*! exports provided: _OcclusionDataStorage */
  26459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26460. "use strict";
  26461. __webpack_require__.r(__webpack_exports__);
  26462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26463. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26464. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26465. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26466. /** @hidden */
  26467. var _OcclusionDataStorage = /** @class */ (function () {
  26468. function _OcclusionDataStorage() {
  26469. /** @hidden */
  26470. this.occlusionInternalRetryCounter = 0;
  26471. /** @hidden */
  26472. this.isOcclusionQueryInProgress = false;
  26473. /** @hidden */
  26474. this.isOccluded = false;
  26475. /** @hidden */
  26476. this.occlusionRetryCount = -1;
  26477. /** @hidden */
  26478. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26479. /** @hidden */
  26480. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26481. }
  26482. return _OcclusionDataStorage;
  26483. }());
  26484. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26485. return this._gl.createQuery();
  26486. };
  26487. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26488. this._gl.deleteQuery(query);
  26489. return this;
  26490. };
  26491. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26492. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26493. };
  26494. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26495. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26496. };
  26497. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26498. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26499. this._gl.beginQuery(glAlgorithm, query);
  26500. return this;
  26501. };
  26502. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26503. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26504. this._gl.endQuery(glAlgorithm);
  26505. return this;
  26506. };
  26507. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26508. var timerQuery = this.getCaps().timerQuery;
  26509. if (timerQuery.createQueryEXT) {
  26510. return timerQuery.createQueryEXT();
  26511. }
  26512. return this.createQuery();
  26513. };
  26514. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26515. var timerQuery = this.getCaps().timerQuery;
  26516. if (timerQuery.deleteQueryEXT) {
  26517. timerQuery.deleteQueryEXT(query);
  26518. return;
  26519. }
  26520. this.deleteQuery(query);
  26521. };
  26522. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26523. var timerQuery = this.getCaps().timerQuery;
  26524. if (timerQuery.getQueryObjectEXT) {
  26525. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26526. }
  26527. return this.getQueryResult(query);
  26528. };
  26529. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26530. var timerQuery = this.getCaps().timerQuery;
  26531. if (timerQuery.getQueryObjectEXT) {
  26532. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26533. }
  26534. return this.isQueryResultAvailable(query);
  26535. };
  26536. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26537. var caps = this.getCaps();
  26538. var timerQuery = caps.timerQuery;
  26539. if (!timerQuery) {
  26540. return null;
  26541. }
  26542. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26543. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26544. if (caps.canUseTimestampForTimerQuery) {
  26545. token._startTimeQuery = this._createTimeQuery();
  26546. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26547. }
  26548. else {
  26549. if (this._currentNonTimestampToken) {
  26550. return this._currentNonTimestampToken;
  26551. }
  26552. token._timeElapsedQuery = this._createTimeQuery();
  26553. if (timerQuery.beginQueryEXT) {
  26554. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26555. }
  26556. else {
  26557. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26558. }
  26559. this._currentNonTimestampToken = token;
  26560. }
  26561. return token;
  26562. };
  26563. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26564. var caps = this.getCaps();
  26565. var timerQuery = caps.timerQuery;
  26566. if (!timerQuery || !token) {
  26567. return -1;
  26568. }
  26569. if (caps.canUseTimestampForTimerQuery) {
  26570. if (!token._startTimeQuery) {
  26571. return -1;
  26572. }
  26573. if (!token._endTimeQuery) {
  26574. token._endTimeQuery = this._createTimeQuery();
  26575. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26576. }
  26577. }
  26578. else if (!token._timeElapsedQueryEnded) {
  26579. if (!token._timeElapsedQuery) {
  26580. return -1;
  26581. }
  26582. if (timerQuery.endQueryEXT) {
  26583. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26584. }
  26585. else {
  26586. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26587. }
  26588. token._timeElapsedQueryEnded = true;
  26589. }
  26590. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26591. var available = false;
  26592. if (token._endTimeQuery) {
  26593. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26594. }
  26595. else if (token._timeElapsedQuery) {
  26596. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26597. }
  26598. if (available && !disjoint) {
  26599. var result = 0;
  26600. if (caps.canUseTimestampForTimerQuery) {
  26601. if (!token._startTimeQuery || !token._endTimeQuery) {
  26602. return -1;
  26603. }
  26604. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26605. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26606. result = timeEnd - timeStart;
  26607. this._deleteTimeQuery(token._startTimeQuery);
  26608. this._deleteTimeQuery(token._endTimeQuery);
  26609. token._startTimeQuery = null;
  26610. token._endTimeQuery = null;
  26611. }
  26612. else {
  26613. if (!token._timeElapsedQuery) {
  26614. return -1;
  26615. }
  26616. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26617. this._deleteTimeQuery(token._timeElapsedQuery);
  26618. token._timeElapsedQuery = null;
  26619. token._timeElapsedQueryEnded = false;
  26620. this._currentNonTimestampToken = null;
  26621. }
  26622. return result;
  26623. }
  26624. return -1;
  26625. };
  26626. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26627. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26628. };
  26629. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26630. get: function () {
  26631. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26632. },
  26633. enumerable: false,
  26634. configurable: true
  26635. });
  26636. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26637. get: function () {
  26638. if (!this.__occlusionDataStorage) {
  26639. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26640. }
  26641. return this.__occlusionDataStorage;
  26642. },
  26643. enumerable: false,
  26644. configurable: true
  26645. });
  26646. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26647. get: function () {
  26648. return this._occlusionDataStorage.isOccluded;
  26649. },
  26650. set: function (value) {
  26651. this._occlusionDataStorage.isOccluded = value;
  26652. },
  26653. enumerable: true,
  26654. configurable: true
  26655. });
  26656. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26657. get: function () {
  26658. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26659. },
  26660. set: function (value) {
  26661. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26662. },
  26663. enumerable: true,
  26664. configurable: true
  26665. });
  26666. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26667. get: function () {
  26668. return this._occlusionDataStorage.occlusionType;
  26669. },
  26670. set: function (value) {
  26671. this._occlusionDataStorage.occlusionType = value;
  26672. },
  26673. enumerable: true,
  26674. configurable: true
  26675. });
  26676. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26677. get: function () {
  26678. return this._occlusionDataStorage.occlusionRetryCount;
  26679. },
  26680. set: function (value) {
  26681. this._occlusionDataStorage.occlusionRetryCount = value;
  26682. },
  26683. enumerable: true,
  26684. configurable: true
  26685. });
  26686. // We also need to update AbstractMesh as there is a portion of the code there
  26687. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26688. var dataStorage = this._occlusionDataStorage;
  26689. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26690. dataStorage.isOccluded = false;
  26691. return false;
  26692. }
  26693. var engine = this.getEngine();
  26694. if (engine.webGLVersion < 2) {
  26695. dataStorage.isOccluded = false;
  26696. return false;
  26697. }
  26698. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26699. dataStorage.isOccluded = false;
  26700. return false;
  26701. }
  26702. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26703. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26704. if (isOcclusionQueryAvailable) {
  26705. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26706. dataStorage.isOcclusionQueryInProgress = false;
  26707. dataStorage.occlusionInternalRetryCounter = 0;
  26708. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26709. }
  26710. else {
  26711. dataStorage.occlusionInternalRetryCounter++;
  26712. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26713. dataStorage.isOcclusionQueryInProgress = false;
  26714. dataStorage.occlusionInternalRetryCounter = 0;
  26715. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26716. // if strict continue the last state of the object.
  26717. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26718. }
  26719. else {
  26720. return false;
  26721. }
  26722. }
  26723. }
  26724. var scene = this.getScene();
  26725. if (scene.getBoundingBoxRenderer) {
  26726. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26727. if (!this._occlusionQuery) {
  26728. this._occlusionQuery = engine.createQuery();
  26729. }
  26730. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26731. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26732. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26733. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26734. }
  26735. return dataStorage.isOccluded;
  26736. };
  26737. /***/ }),
  26738. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26739. /*!********************************************************!*\
  26740. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26741. \********************************************************/
  26742. /*! exports provided: _forceTransformFeedbackToBundle */
  26743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26744. "use strict";
  26745. __webpack_require__.r(__webpack_exports__);
  26746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26747. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26748. /** @hidden */
  26749. var _forceTransformFeedbackToBundle = true;
  26750. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26751. return this._gl.createTransformFeedback();
  26752. };
  26753. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26754. this._gl.deleteTransformFeedback(value);
  26755. };
  26756. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26757. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26758. };
  26759. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26760. if (usePoints === void 0) { usePoints = true; }
  26761. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26762. };
  26763. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26764. this._gl.endTransformFeedback();
  26765. };
  26766. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26767. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26768. };
  26769. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26770. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26771. };
  26772. /***/ }),
  26773. /***/ "./Engines/Extensions/index.ts":
  26774. /*!*************************************!*\
  26775. !*** ./Engines/Extensions/index.ts ***!
  26776. \*************************************/
  26777. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26779. "use strict";
  26780. __webpack_require__.r(__webpack_exports__);
  26781. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26783. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26785. /***/ }),
  26786. /***/ "./Engines/constants.ts":
  26787. /*!******************************!*\
  26788. !*** ./Engines/constants.ts ***!
  26789. \******************************/
  26790. /*! exports provided: Constants */
  26791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26792. "use strict";
  26793. __webpack_require__.r(__webpack_exports__);
  26794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26795. /** Defines the cross module used constants to avoid circular dependncies */
  26796. var Constants = /** @class */ (function () {
  26797. function Constants() {
  26798. }
  26799. /** Defines that alpha blending is disabled */
  26800. Constants.ALPHA_DISABLE = 0;
  26801. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26802. Constants.ALPHA_ADD = 1;
  26803. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26804. Constants.ALPHA_COMBINE = 2;
  26805. /** Defines that alpha blending to DEST - SRC * DEST */
  26806. Constants.ALPHA_SUBTRACT = 3;
  26807. /** Defines that alpha blending to SRC * DEST */
  26808. Constants.ALPHA_MULTIPLY = 4;
  26809. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26810. Constants.ALPHA_MAXIMIZED = 5;
  26811. /** Defines that alpha blending to SRC + DEST */
  26812. Constants.ALPHA_ONEONE = 6;
  26813. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26814. Constants.ALPHA_PREMULTIPLIED = 7;
  26815. /**
  26816. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26817. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26818. */
  26819. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  26820. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26821. Constants.ALPHA_INTERPOLATE = 9;
  26822. /**
  26823. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26824. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26825. */
  26826. Constants.ALPHA_SCREENMODE = 10;
  26827. /** Defines that the ressource is not delayed*/
  26828. Constants.DELAYLOADSTATE_NONE = 0;
  26829. /** Defines that the ressource was successfully delay loaded */
  26830. Constants.DELAYLOADSTATE_LOADED = 1;
  26831. /** Defines that the ressource is currently delay loading */
  26832. Constants.DELAYLOADSTATE_LOADING = 2;
  26833. /** Defines that the ressource is delayed and has not started loading */
  26834. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  26835. // Depht or Stencil test Constants.
  26836. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26837. Constants.NEVER = 0x0200;
  26838. /** 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 */
  26839. Constants.ALWAYS = 0x0207;
  26840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26841. Constants.LESS = 0x0201;
  26842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26843. Constants.EQUAL = 0x0202;
  26844. /** 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 */
  26845. Constants.LEQUAL = 0x0203;
  26846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26847. Constants.GREATER = 0x0204;
  26848. /** 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 */
  26849. Constants.GEQUAL = 0x0206;
  26850. /** 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 */
  26851. Constants.NOTEQUAL = 0x0205;
  26852. // Stencil Actions Constants.
  26853. /** Passed to stencilOperation to specify that stencil value must be kept */
  26854. Constants.KEEP = 0x1E00;
  26855. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26856. Constants.REPLACE = 0x1E01;
  26857. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26858. Constants.INCR = 0x1E02;
  26859. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26860. Constants.DECR = 0x1E03;
  26861. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26862. Constants.INVERT = 0x150A;
  26863. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26864. Constants.INCR_WRAP = 0x8507;
  26865. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26866. Constants.DECR_WRAP = 0x8508;
  26867. /** Texture is not repeating outside of 0..1 UVs */
  26868. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  26869. /** Texture is repeating outside of 0..1 UVs */
  26870. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  26871. /** Texture is repeating and mirrored */
  26872. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  26873. /** ALPHA */
  26874. Constants.TEXTUREFORMAT_ALPHA = 0;
  26875. /** LUMINANCE */
  26876. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  26877. /** LUMINANCE_ALPHA */
  26878. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  26879. /** RGB */
  26880. Constants.TEXTUREFORMAT_RGB = 4;
  26881. /** RGBA */
  26882. Constants.TEXTUREFORMAT_RGBA = 5;
  26883. /** RED */
  26884. Constants.TEXTUREFORMAT_RED = 6;
  26885. /** RED (2nd reference) */
  26886. Constants.TEXTUREFORMAT_R = 6;
  26887. /** RG */
  26888. Constants.TEXTUREFORMAT_RG = 7;
  26889. /** RED_INTEGER */
  26890. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  26891. /** RED_INTEGER (2nd reference) */
  26892. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  26893. /** RG_INTEGER */
  26894. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  26895. /** RGB_INTEGER */
  26896. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  26897. /** RGBA_INTEGER */
  26898. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  26899. /** UNSIGNED_BYTE */
  26900. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  26901. /** UNSIGNED_BYTE (2nd reference) */
  26902. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  26903. /** FLOAT */
  26904. Constants.TEXTURETYPE_FLOAT = 1;
  26905. /** HALF_FLOAT */
  26906. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  26907. /** BYTE */
  26908. Constants.TEXTURETYPE_BYTE = 3;
  26909. /** SHORT */
  26910. Constants.TEXTURETYPE_SHORT = 4;
  26911. /** UNSIGNED_SHORT */
  26912. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  26913. /** INT */
  26914. Constants.TEXTURETYPE_INT = 6;
  26915. /** UNSIGNED_INT */
  26916. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  26917. /** UNSIGNED_SHORT_4_4_4_4 */
  26918. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  26919. /** UNSIGNED_SHORT_5_5_5_1 */
  26920. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  26921. /** UNSIGNED_SHORT_5_6_5 */
  26922. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  26923. /** UNSIGNED_INT_2_10_10_10_REV */
  26924. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  26925. /** UNSIGNED_INT_24_8 */
  26926. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  26927. /** UNSIGNED_INT_10F_11F_11F_REV */
  26928. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  26929. /** UNSIGNED_INT_5_9_9_9_REV */
  26930. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  26931. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26932. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  26933. /** nearest is mag = nearest and min = nearest and mip = linear */
  26934. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  26935. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26936. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  26937. /** Trilinear is mag = linear and min = linear and mip = linear */
  26938. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  26939. /** nearest is mag = nearest and min = nearest and mip = linear */
  26940. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  26941. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26942. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  26943. /** Trilinear is mag = linear and min = linear and mip = linear */
  26944. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  26945. /** mag = nearest and min = nearest and mip = nearest */
  26946. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  26947. /** mag = nearest and min = linear and mip = nearest */
  26948. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  26949. /** mag = nearest and min = linear and mip = linear */
  26950. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  26951. /** mag = nearest and min = linear and mip = none */
  26952. Constants.TEXTURE_NEAREST_LINEAR = 7;
  26953. /** mag = nearest and min = nearest and mip = none */
  26954. Constants.TEXTURE_NEAREST_NEAREST = 8;
  26955. /** mag = linear and min = nearest and mip = nearest */
  26956. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  26957. /** mag = linear and min = nearest and mip = linear */
  26958. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  26959. /** mag = linear and min = linear and mip = none */
  26960. Constants.TEXTURE_LINEAR_LINEAR = 11;
  26961. /** mag = linear and min = nearest and mip = none */
  26962. Constants.TEXTURE_LINEAR_NEAREST = 12;
  26963. /** Explicit coordinates mode */
  26964. Constants.TEXTURE_EXPLICIT_MODE = 0;
  26965. /** Spherical coordinates mode */
  26966. Constants.TEXTURE_SPHERICAL_MODE = 1;
  26967. /** Planar coordinates mode */
  26968. Constants.TEXTURE_PLANAR_MODE = 2;
  26969. /** Cubic coordinates mode */
  26970. Constants.TEXTURE_CUBIC_MODE = 3;
  26971. /** Projection coordinates mode */
  26972. Constants.TEXTURE_PROJECTION_MODE = 4;
  26973. /** Skybox coordinates mode */
  26974. Constants.TEXTURE_SKYBOX_MODE = 5;
  26975. /** Inverse Cubic coordinates mode */
  26976. Constants.TEXTURE_INVCUBIC_MODE = 6;
  26977. /** Equirectangular coordinates mode */
  26978. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  26979. /** Equirectangular Fixed coordinates mode */
  26980. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  26981. /** Equirectangular Fixed Mirrored coordinates mode */
  26982. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  26983. // Texture rescaling mode
  26984. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26985. Constants.SCALEMODE_FLOOR = 1;
  26986. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26987. Constants.SCALEMODE_NEAREST = 2;
  26988. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26989. Constants.SCALEMODE_CEILING = 3;
  26990. /**
  26991. * The dirty texture flag value
  26992. */
  26993. Constants.MATERIAL_TextureDirtyFlag = 1;
  26994. /**
  26995. * The dirty light flag value
  26996. */
  26997. Constants.MATERIAL_LightDirtyFlag = 2;
  26998. /**
  26999. * The dirty fresnel flag value
  27000. */
  27001. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27002. /**
  27003. * The dirty attribute flag value
  27004. */
  27005. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27006. /**
  27007. * The dirty misc flag value
  27008. */
  27009. Constants.MATERIAL_MiscDirtyFlag = 16;
  27010. /**
  27011. * The all dirty flag value
  27012. */
  27013. Constants.MATERIAL_AllDirtyFlag = 31;
  27014. /**
  27015. * Returns the triangle fill mode
  27016. */
  27017. Constants.MATERIAL_TriangleFillMode = 0;
  27018. /**
  27019. * Returns the wireframe mode
  27020. */
  27021. Constants.MATERIAL_WireFrameFillMode = 1;
  27022. /**
  27023. * Returns the point fill mode
  27024. */
  27025. Constants.MATERIAL_PointFillMode = 2;
  27026. /**
  27027. * Returns the point list draw mode
  27028. */
  27029. Constants.MATERIAL_PointListDrawMode = 3;
  27030. /**
  27031. * Returns the line list draw mode
  27032. */
  27033. Constants.MATERIAL_LineListDrawMode = 4;
  27034. /**
  27035. * Returns the line loop draw mode
  27036. */
  27037. Constants.MATERIAL_LineLoopDrawMode = 5;
  27038. /**
  27039. * Returns the line strip draw mode
  27040. */
  27041. Constants.MATERIAL_LineStripDrawMode = 6;
  27042. /**
  27043. * Returns the triangle strip draw mode
  27044. */
  27045. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27046. /**
  27047. * Returns the triangle fan draw mode
  27048. */
  27049. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27050. /**
  27051. * Stores the clock-wise side orientation
  27052. */
  27053. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27054. /**
  27055. * Stores the counter clock-wise side orientation
  27056. */
  27057. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27058. /**
  27059. * Nothing
  27060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27061. */
  27062. Constants.ACTION_NothingTrigger = 0;
  27063. /**
  27064. * On pick
  27065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27066. */
  27067. Constants.ACTION_OnPickTrigger = 1;
  27068. /**
  27069. * On left pick
  27070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27071. */
  27072. Constants.ACTION_OnLeftPickTrigger = 2;
  27073. /**
  27074. * On right pick
  27075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27076. */
  27077. Constants.ACTION_OnRightPickTrigger = 3;
  27078. /**
  27079. * On center pick
  27080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27081. */
  27082. Constants.ACTION_OnCenterPickTrigger = 4;
  27083. /**
  27084. * On pick down
  27085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27086. */
  27087. Constants.ACTION_OnPickDownTrigger = 5;
  27088. /**
  27089. * On double pick
  27090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27091. */
  27092. Constants.ACTION_OnDoublePickTrigger = 6;
  27093. /**
  27094. * On pick up
  27095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27096. */
  27097. Constants.ACTION_OnPickUpTrigger = 7;
  27098. /**
  27099. * On pick out.
  27100. * This trigger will only be raised if you also declared a OnPickDown
  27101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27102. */
  27103. Constants.ACTION_OnPickOutTrigger = 16;
  27104. /**
  27105. * On long press
  27106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27107. */
  27108. Constants.ACTION_OnLongPressTrigger = 8;
  27109. /**
  27110. * On pointer over
  27111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27112. */
  27113. Constants.ACTION_OnPointerOverTrigger = 9;
  27114. /**
  27115. * On pointer out
  27116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27117. */
  27118. Constants.ACTION_OnPointerOutTrigger = 10;
  27119. /**
  27120. * On every frame
  27121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27122. */
  27123. Constants.ACTION_OnEveryFrameTrigger = 11;
  27124. /**
  27125. * On intersection enter
  27126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27127. */
  27128. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27129. /**
  27130. * On intersection exit
  27131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27132. */
  27133. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27134. /**
  27135. * On key down
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27137. */
  27138. Constants.ACTION_OnKeyDownTrigger = 14;
  27139. /**
  27140. * On key up
  27141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27142. */
  27143. Constants.ACTION_OnKeyUpTrigger = 15;
  27144. /**
  27145. * Billboard mode will only apply to Y axis
  27146. */
  27147. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27148. /**
  27149. * Billboard mode will apply to all axes
  27150. */
  27151. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27152. /**
  27153. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27154. */
  27155. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27156. /**
  27157. * Gets or sets base Assets URL
  27158. */
  27159. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27160. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27161. * Test order :
  27162. * Is the bounding sphere outside the frustum ?
  27163. * If not, are the bounding box vertices outside the frustum ?
  27164. * It not, then the cullable object is in the frustum.
  27165. */
  27166. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27167. /** Culling strategy : Bounding Sphere Only.
  27168. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27169. * It's also less accurate than the standard because some not visible objects can still be selected.
  27170. * Test : is the bounding sphere outside the frustum ?
  27171. * If not, then the cullable object is in the frustum.
  27172. */
  27173. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27174. /** Culling strategy : Optimistic Inclusion.
  27175. * This in an inclusion test first, then the standard exclusion test.
  27176. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27177. * 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.
  27178. * Anyway, it's as accurate as the standard strategy.
  27179. * Test :
  27180. * Is the cullable object bounding sphere center in the frustum ?
  27181. * If not, apply the default culling strategy.
  27182. */
  27183. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27184. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27185. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27186. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27187. * 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.
  27188. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27189. * Test :
  27190. * Is the cullable object bounding sphere center in the frustum ?
  27191. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27192. */
  27193. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27194. /**
  27195. * No logging while loading
  27196. */
  27197. Constants.SCENELOADER_NO_LOGGING = 0;
  27198. /**
  27199. * Minimal logging while loading
  27200. */
  27201. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27202. /**
  27203. * Summary logging while loading
  27204. */
  27205. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27206. /**
  27207. * Detailled logging while loading
  27208. */
  27209. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27210. return Constants;
  27211. }());
  27212. /***/ }),
  27213. /***/ "./Engines/engine.ts":
  27214. /*!***************************!*\
  27215. !*** ./Engines/engine.ts ***!
  27216. \***************************/
  27217. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27219. "use strict";
  27220. __webpack_require__.r(__webpack_exports__);
  27221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27226. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27227. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27228. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27229. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27230. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27231. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27232. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27233. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27234. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27235. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27236. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27237. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27238. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27239. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27240. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27241. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27242. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27243. /**
  27244. * Keeps track of all the buffer info used in engine.
  27245. */
  27246. var BufferPointer = /** @class */ (function () {
  27247. function BufferPointer() {
  27248. }
  27249. return BufferPointer;
  27250. }());
  27251. /**
  27252. * Interface for attribute information associated with buffer instanciation
  27253. */
  27254. var InstancingAttributeInfo = /** @class */ (function () {
  27255. function InstancingAttributeInfo() {
  27256. }
  27257. return InstancingAttributeInfo;
  27258. }());
  27259. /**
  27260. * Define options used to create a depth texture
  27261. */
  27262. var DepthTextureCreationOptions = /** @class */ (function () {
  27263. function DepthTextureCreationOptions() {
  27264. }
  27265. return DepthTextureCreationOptions;
  27266. }());
  27267. /**
  27268. * Class used to describe the capabilities of the engine relatively to the current browser
  27269. */
  27270. var EngineCapabilities = /** @class */ (function () {
  27271. function EngineCapabilities() {
  27272. }
  27273. return EngineCapabilities;
  27274. }());
  27275. /**
  27276. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27277. */
  27278. var Engine = /** @class */ (function () {
  27279. /**
  27280. * Creates a new engine
  27281. * @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
  27282. * @param antialias defines enable antialiasing (default: false)
  27283. * @param options defines further options to be sent to the getContext() function
  27284. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27285. */
  27286. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27287. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27288. var _this = this;
  27289. // Public members
  27290. /**
  27291. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27292. */
  27293. this.forcePOTTextures = false;
  27294. /**
  27295. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27296. */
  27297. this.isFullscreen = false;
  27298. /**
  27299. * Gets a boolean indicating if the pointer is currently locked
  27300. */
  27301. this.isPointerLock = false;
  27302. /**
  27303. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27304. */
  27305. this.cullBackFaces = true;
  27306. /**
  27307. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27308. */
  27309. this.renderEvenInBackground = true;
  27310. /**
  27311. * Gets or sets a boolean indicating that cache can be kept between frames
  27312. */
  27313. this.preventCacheWipeBetweenFrames = false;
  27314. /**
  27315. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27316. **/
  27317. this.enableOfflineSupport = false;
  27318. /**
  27319. * 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)
  27320. **/
  27321. this.disableManifestCheck = false;
  27322. /**
  27323. * Gets the list of created scenes
  27324. */
  27325. this.scenes = new Array();
  27326. /**
  27327. * Event raised when a new scene is created
  27328. */
  27329. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27330. /**
  27331. * Gets the list of created postprocesses
  27332. */
  27333. this.postProcesses = new Array();
  27334. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27335. this.validateShaderPrograms = false;
  27336. // Observables
  27337. /**
  27338. * Observable event triggered each time the rendering canvas is resized
  27339. */
  27340. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27341. /**
  27342. * Observable event triggered each time the canvas loses focus
  27343. */
  27344. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27345. /**
  27346. * Observable event triggered each time the canvas gains focus
  27347. */
  27348. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27349. /**
  27350. * Observable event triggered each time the canvas receives pointerout event
  27351. */
  27352. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27353. /**
  27354. * Observable event triggered before each texture is initialized
  27355. */
  27356. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27357. //WebVR
  27358. this._vrDisplay = undefined;
  27359. this._vrSupported = false;
  27360. this._vrExclusivePointerMode = false;
  27361. // Uniform buffers list
  27362. /**
  27363. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27364. */
  27365. this.disableUniformBuffers = false;
  27366. /** @hidden */
  27367. this._uniformBuffers = new Array();
  27368. // Observables
  27369. /**
  27370. * Observable raised when the engine begins a new frame
  27371. */
  27372. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27373. /**
  27374. * If set, will be used to request the next animation frame for the render loop
  27375. */
  27376. this.customAnimationFrameRequester = null;
  27377. /**
  27378. * Observable raised when the engine ends the current frame
  27379. */
  27380. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27381. /**
  27382. * Observable raised when the engine is about to compile a shader
  27383. */
  27384. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27385. /**
  27386. * Observable raised when the engine has jsut compiled a shader
  27387. */
  27388. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27389. this._windowIsBackground = false;
  27390. this._webGLVersion = 1.0;
  27391. /** @hidden */
  27392. this._badOS = false;
  27393. /** @hidden */
  27394. this._badDesktopOS = false;
  27395. /**
  27396. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27397. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27398. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27399. */
  27400. this.disableTextureBindingOptimization = false;
  27401. /**
  27402. * Observable signaled when VR display mode changes
  27403. */
  27404. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27405. /**
  27406. * Observable signaled when VR request present is complete
  27407. */
  27408. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27409. /**
  27410. * Observable signaled when VR request present starts
  27411. */
  27412. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27413. this._colorWrite = true;
  27414. /** @hidden */
  27415. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27416. /** @hidden */
  27417. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27418. this._renderingQueueLaunched = false;
  27419. this._activeRenderLoops = new Array();
  27420. // Deterministic lockstepMaxSteps
  27421. this._deterministicLockstep = false;
  27422. this._lockstepMaxSteps = 4;
  27423. // Lost context
  27424. /**
  27425. * Observable signaled when a context lost event is raised
  27426. */
  27427. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27428. /**
  27429. * Observable signaled when a context restored event is raised
  27430. */
  27431. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27432. this._contextWasLost = false;
  27433. this._doNotHandleContextLost = false;
  27434. // FPS
  27435. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  27436. this._fps = 60;
  27437. this._deltaTime = 0;
  27438. /**
  27439. * Turn this value on if you want to pause FPS computation when in background
  27440. */
  27441. this.disablePerformanceMonitorInBackground = false;
  27442. // States
  27443. /** @hidden */
  27444. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  27445. /** @hidden */
  27446. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  27447. /** @hidden */
  27448. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  27449. /** @hidden */
  27450. this._alphaMode = Engine.ALPHA_DISABLE;
  27451. // Cache
  27452. this._internalTexturesCache = new Array();
  27453. /** @hidden */
  27454. this._activeChannel = 0;
  27455. this._currentTextureChannel = -1;
  27456. /** @hidden */
  27457. this._boundTexturesCache = {};
  27458. this._compiledEffects = {};
  27459. this._vertexAttribArraysEnabled = [];
  27460. this._uintIndicesCurrentlySet = false;
  27461. this._currentBoundBuffer = new Array();
  27462. /** @hidden */
  27463. this._currentFramebuffer = null;
  27464. this._currentBufferPointers = new Array();
  27465. this._currentInstanceLocations = new Array();
  27466. this._currentInstanceBuffers = new Array();
  27467. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27468. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27469. this._vaoRecordInProgress = false;
  27470. this._mustWipeVertexAttributes = false;
  27471. this._nextFreeTextureSlots = new Array();
  27472. this._maxSimultaneousTextures = 0;
  27473. this._activeRequests = new Array();
  27474. // Hardware supported Compressed Textures
  27475. this._texturesSupported = new Array();
  27476. /**
  27477. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27478. */
  27479. this.premultipliedAlpha = true;
  27480. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27481. this._onVRFullScreenTriggered = function () {
  27482. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27483. //get the old size before we change
  27484. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27485. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27486. //get the width and height, change the render size
  27487. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27488. _this.setHardwareScalingLevel(1);
  27489. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27490. }
  27491. else {
  27492. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27493. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27494. }
  27495. };
  27496. this._unpackFlipYCached = null;
  27497. /**
  27498. * In case you are sharing the context with other applications, it might
  27499. * be interested to not cache the unpack flip y state to ensure a consistent
  27500. * value would be set.
  27501. */
  27502. this.enableUnpackFlipYCached = true;
  27503. this._boundUniforms = {};
  27504. // Register promises
  27505. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27506. var canvas = null;
  27507. Engine.Instances.push(this);
  27508. if (!canvasOrContext) {
  27509. return;
  27510. }
  27511. options = options || {};
  27512. if (canvasOrContext.getContext) {
  27513. canvas = canvasOrContext;
  27514. this._renderingCanvas = canvas;
  27515. if (antialias != null) {
  27516. options.antialias = antialias;
  27517. }
  27518. if (options.deterministicLockstep === undefined) {
  27519. options.deterministicLockstep = false;
  27520. }
  27521. if (options.lockstepMaxSteps === undefined) {
  27522. options.lockstepMaxSteps = 4;
  27523. }
  27524. if (options.preserveDrawingBuffer === undefined) {
  27525. options.preserveDrawingBuffer = false;
  27526. }
  27527. if (options.audioEngine === undefined) {
  27528. options.audioEngine = true;
  27529. }
  27530. if (options.stencil === undefined) {
  27531. options.stencil = true;
  27532. }
  27533. if (options.premultipliedAlpha === false) {
  27534. this.premultipliedAlpha = false;
  27535. }
  27536. this._deterministicLockstep = options.deterministicLockstep;
  27537. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27538. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27539. // Exceptions
  27540. if (navigator && navigator.userAgent) {
  27541. var ua = navigator.userAgent;
  27542. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27543. var exception = _a[_i];
  27544. var key = exception.key;
  27545. var targets = exception.targets;
  27546. if (ua.indexOf(key) > -1) {
  27547. if (exception.capture && exception.captureConstraint) {
  27548. var capture = exception.capture;
  27549. var constraint = exception.captureConstraint;
  27550. var regex = new RegExp(capture);
  27551. var matches = regex.exec(ua);
  27552. if (matches && matches.length > 0) {
  27553. var capturedValue = parseInt(matches[matches.length - 1]);
  27554. if (capturedValue >= constraint) {
  27555. continue;
  27556. }
  27557. }
  27558. }
  27559. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27560. var target = targets_1[_b];
  27561. switch (target) {
  27562. case "uniformBuffer":
  27563. this.disableUniformBuffers = true;
  27564. break;
  27565. case "textureBindingOptimization":
  27566. this.disableTextureBindingOptimization = true;
  27567. break;
  27568. }
  27569. }
  27570. }
  27571. }
  27572. }
  27573. // GL
  27574. if (!options.disableWebGL2Support) {
  27575. try {
  27576. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27577. if (this._gl) {
  27578. this._webGLVersion = 2.0;
  27579. // Prevent weird browsers to lie :-)
  27580. if (!this._gl.deleteQuery) {
  27581. this._webGLVersion = 1.0;
  27582. }
  27583. }
  27584. }
  27585. catch (e) {
  27586. // Do nothing
  27587. }
  27588. }
  27589. if (!this._gl) {
  27590. if (!canvas) {
  27591. throw new Error("The provided canvas is null or undefined.");
  27592. }
  27593. try {
  27594. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27595. }
  27596. catch (e) {
  27597. throw new Error("WebGL not supported");
  27598. }
  27599. }
  27600. if (!this._gl) {
  27601. throw new Error("WebGL not supported");
  27602. }
  27603. this._onCanvasFocus = function () {
  27604. _this.onCanvasFocusObservable.notifyObservers(_this);
  27605. };
  27606. this._onCanvasBlur = function () {
  27607. _this.onCanvasBlurObservable.notifyObservers(_this);
  27608. };
  27609. canvas.addEventListener("focus", this._onCanvasFocus);
  27610. canvas.addEventListener("blur", this._onCanvasBlur);
  27611. this._onBlur = function () {
  27612. if (_this.disablePerformanceMonitorInBackground) {
  27613. _this._performanceMonitor.disable();
  27614. }
  27615. _this._windowIsBackground = true;
  27616. };
  27617. this._onFocus = function () {
  27618. if (_this.disablePerformanceMonitorInBackground) {
  27619. _this._performanceMonitor.enable();
  27620. }
  27621. _this._windowIsBackground = false;
  27622. };
  27623. this._onCanvasPointerOut = function (ev) {
  27624. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27625. };
  27626. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27627. window.addEventListener("blur", this._onBlur);
  27628. window.addEventListener("focus", this._onFocus);
  27629. }
  27630. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27631. // Context lost
  27632. if (!this._doNotHandleContextLost) {
  27633. this._onContextLost = function (evt) {
  27634. evt.preventDefault();
  27635. _this._contextWasLost = true;
  27636. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27637. _this.onContextLostObservable.notifyObservers(_this);
  27638. };
  27639. this._onContextRestored = function () {
  27640. // Adding a timeout to avoid race condition at browser level
  27641. setTimeout(function () {
  27642. // Rebuild gl context
  27643. _this._initGLContext();
  27644. // Rebuild effects
  27645. _this._rebuildEffects();
  27646. // Rebuild textures
  27647. _this._rebuildInternalTextures();
  27648. // Rebuild buffers
  27649. _this._rebuildBuffers();
  27650. // Cache
  27651. _this.wipeCaches(true);
  27652. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27653. _this.onContextRestoredObservable.notifyObservers(_this);
  27654. _this._contextWasLost = false;
  27655. }, 0);
  27656. };
  27657. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27658. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27659. }
  27660. if (!options.doNotHandleTouchAction) {
  27661. this._disableTouchAction();
  27662. }
  27663. }
  27664. else {
  27665. this._gl = canvasOrContext;
  27666. this._renderingCanvas = this._gl.canvas;
  27667. if (this._gl.renderbufferStorageMultisample) {
  27668. this._webGLVersion = 2.0;
  27669. }
  27670. var attributes = this._gl.getContextAttributes();
  27671. if (attributes) {
  27672. options.stencil = attributes.stencil;
  27673. }
  27674. }
  27675. // Viewport
  27676. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27677. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27678. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27679. this.resize();
  27680. this._isStencilEnable = options.stencil ? true : false;
  27681. this._initGLContext();
  27682. if (canvas) {
  27683. // Fullscreen
  27684. this._onFullscreenChange = function () {
  27685. if (document.fullscreen !== undefined) {
  27686. _this.isFullscreen = document.fullscreen;
  27687. }
  27688. else if (document.mozFullScreen !== undefined) {
  27689. _this.isFullscreen = document.mozFullScreen;
  27690. }
  27691. else if (document.webkitIsFullScreen !== undefined) {
  27692. _this.isFullscreen = document.webkitIsFullScreen;
  27693. }
  27694. else if (document.msIsFullScreen !== undefined) {
  27695. _this.isFullscreen = document.msIsFullScreen;
  27696. }
  27697. // Pointer lock
  27698. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27699. canvas.requestPointerLock = canvas.requestPointerLock ||
  27700. canvas.msRequestPointerLock ||
  27701. canvas.mozRequestPointerLock ||
  27702. canvas.webkitRequestPointerLock;
  27703. if (canvas.requestPointerLock) {
  27704. canvas.requestPointerLock();
  27705. }
  27706. }
  27707. };
  27708. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27709. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27710. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27711. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27712. // Pointer lock
  27713. this._onPointerLockChange = function () {
  27714. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27715. document.webkitPointerLockElement === canvas ||
  27716. document.msPointerLockElement === canvas ||
  27717. document.pointerLockElement === canvas);
  27718. };
  27719. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27720. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27721. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27722. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27723. this._onVRDisplayPointerRestricted = function () {
  27724. if (canvas) {
  27725. canvas.requestPointerLock();
  27726. }
  27727. };
  27728. this._onVRDisplayPointerUnrestricted = function () {
  27729. document.exitPointerLock();
  27730. };
  27731. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27732. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27733. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27734. }
  27735. }
  27736. // Create Audio Engine if needed.
  27737. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27738. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27739. }
  27740. // Prepare buffer pointers
  27741. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27742. this._currentBufferPointers[i] = new BufferPointer();
  27743. }
  27744. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27745. // Load WebVR Devices
  27746. if (options.autoEnableWebVR) {
  27747. this.initWebVR();
  27748. }
  27749. // Detect if we are running on a faulty buggy OS.
  27750. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27751. // Detect if we are running on a faulty buggy desktop OS.
  27752. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27753. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27754. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27755. }
  27756. Object.defineProperty(Engine, "Instances", {
  27757. /** Gets the list of created engines */
  27758. get: function () {
  27759. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27760. },
  27761. enumerable: true,
  27762. configurable: true
  27763. });
  27764. Object.defineProperty(Engine, "LastCreatedEngine", {
  27765. /**
  27766. * Gets the latest created engine
  27767. */
  27768. get: function () {
  27769. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27770. },
  27771. enumerable: true,
  27772. configurable: true
  27773. });
  27774. Object.defineProperty(Engine, "LastCreatedScene", {
  27775. /**
  27776. * Gets the latest created scene
  27777. */
  27778. get: function () {
  27779. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27780. },
  27781. enumerable: true,
  27782. configurable: true
  27783. });
  27784. /**
  27785. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27786. * @param flag defines which part of the materials must be marked as dirty
  27787. * @param predicate defines a predicate used to filter which materials should be affected
  27788. */
  27789. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27790. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27791. var engine = Engine.Instances[engineIndex];
  27792. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27793. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27794. }
  27795. }
  27796. };
  27797. Object.defineProperty(Engine, "Version", {
  27798. /**
  27799. * Returns the current version of the framework
  27800. */
  27801. get: function () {
  27802. return "4.0.0-alpha.19";
  27803. },
  27804. enumerable: true,
  27805. configurable: true
  27806. });
  27807. Object.defineProperty(Engine.prototype, "description", {
  27808. /**
  27809. * Returns a string describing the current engine
  27810. */
  27811. get: function () {
  27812. var description = "WebGL" + this.webGLVersion;
  27813. if (this._caps.parallelShaderCompile) {
  27814. description += " - Parallel shader compilation";
  27815. }
  27816. return description;
  27817. },
  27818. enumerable: true,
  27819. configurable: true
  27820. });
  27821. Object.defineProperty(Engine, "ShadersRepository", {
  27822. /**
  27823. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27824. */
  27825. get: function () {
  27826. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  27827. },
  27828. set: function (value) {
  27829. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  27830. },
  27831. enumerable: true,
  27832. configurable: true
  27833. });
  27834. /**
  27835. * Method called to create the default loading screen.
  27836. * This can be overriden in your own app.
  27837. * @param canvas The rendering canvas element
  27838. * @returns The loading screen
  27839. */
  27840. Engine.DefaultLoadingScreenFactory = function (canvas) {
  27841. throw "Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen";
  27842. };
  27843. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  27844. /**
  27845. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27846. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27847. */
  27848. get: function () {
  27849. return this._vrExclusivePointerMode;
  27850. },
  27851. enumerable: true,
  27852. configurable: true
  27853. });
  27854. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  27855. /**
  27856. * Gets a boolean indicating that the engine supports uniform buffers
  27857. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27858. */
  27859. get: function () {
  27860. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  27861. },
  27862. enumerable: true,
  27863. configurable: true
  27864. });
  27865. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  27866. /**
  27867. * Gets a boolean indicating that only power of 2 textures are supported
  27868. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27869. */
  27870. get: function () {
  27871. return this._webGLVersion < 2 || this.forcePOTTextures;
  27872. },
  27873. enumerable: true,
  27874. configurable: true
  27875. });
  27876. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  27877. /**
  27878. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27880. */
  27881. get: function () {
  27882. return this._doNotHandleContextLost;
  27883. },
  27884. set: function (value) {
  27885. this._doNotHandleContextLost = value;
  27886. },
  27887. enumerable: true,
  27888. configurable: true
  27889. });
  27890. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  27891. /**
  27892. * Gets the performance monitor attached to this engine
  27893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27894. */
  27895. get: function () {
  27896. return this._performanceMonitor;
  27897. },
  27898. enumerable: true,
  27899. configurable: true
  27900. });
  27901. Object.defineProperty(Engine.prototype, "texturesSupported", {
  27902. /**
  27903. * Gets the list of texture formats supported
  27904. */
  27905. get: function () {
  27906. return this._texturesSupported;
  27907. },
  27908. enumerable: true,
  27909. configurable: true
  27910. });
  27911. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  27912. /**
  27913. * Gets the list of texture formats in use
  27914. */
  27915. get: function () {
  27916. return this._textureFormatInUse;
  27917. },
  27918. enumerable: true,
  27919. configurable: true
  27920. });
  27921. Object.defineProperty(Engine.prototype, "currentViewport", {
  27922. /**
  27923. * Gets the current viewport
  27924. */
  27925. get: function () {
  27926. return this._cachedViewport;
  27927. },
  27928. enumerable: true,
  27929. configurable: true
  27930. });
  27931. Object.defineProperty(Engine.prototype, "emptyTexture", {
  27932. /**
  27933. * Gets the default empty texture
  27934. */
  27935. get: function () {
  27936. if (!this._emptyTexture) {
  27937. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27938. }
  27939. return this._emptyTexture;
  27940. },
  27941. enumerable: true,
  27942. configurable: true
  27943. });
  27944. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  27945. /**
  27946. * Gets the default empty 3D texture
  27947. */
  27948. get: function () {
  27949. if (!this._emptyTexture3D) {
  27950. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27951. }
  27952. return this._emptyTexture3D;
  27953. },
  27954. enumerable: true,
  27955. configurable: true
  27956. });
  27957. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  27958. /**
  27959. * Gets the default empty cube texture
  27960. */
  27961. get: function () {
  27962. if (!this._emptyCubeTexture) {
  27963. var faceData = new Uint8Array(4);
  27964. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  27965. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27966. }
  27967. return this._emptyCubeTexture;
  27968. },
  27969. enumerable: true,
  27970. configurable: true
  27971. });
  27972. Engine.prototype._disableTouchAction = function () {
  27973. if (!this._renderingCanvas) {
  27974. return;
  27975. }
  27976. this._renderingCanvas.setAttribute("touch-action", "none");
  27977. this._renderingCanvas.style.touchAction = "none";
  27978. this._renderingCanvas.style.msTouchAction = "none";
  27979. };
  27980. Engine.prototype._rebuildInternalTextures = function () {
  27981. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  27982. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  27983. var internalTexture = currentState_1[_i];
  27984. internalTexture._rebuild();
  27985. }
  27986. };
  27987. Engine.prototype._rebuildEffects = function () {
  27988. for (var key in this._compiledEffects) {
  27989. var effect = this._compiledEffects[key];
  27990. effect._prepareEffect();
  27991. }
  27992. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  27993. };
  27994. /**
  27995. * Gets a boolean indicating if all created effects are ready
  27996. * @returns true if all effects are ready
  27997. */
  27998. Engine.prototype.areAllEffectsReady = function () {
  27999. for (var key in this._compiledEffects) {
  28000. var effect = this._compiledEffects[key];
  28001. if (!effect.isReady()) {
  28002. return false;
  28003. }
  28004. }
  28005. return true;
  28006. };
  28007. Engine.prototype._rebuildBuffers = function () {
  28008. // Index / Vertex
  28009. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28010. var scene = _a[_i];
  28011. scene.resetCachedMaterial();
  28012. scene._rebuildGeometries();
  28013. scene._rebuildTextures();
  28014. }
  28015. // Uniforms
  28016. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28017. var uniformBuffer = _c[_b];
  28018. uniformBuffer._rebuild();
  28019. }
  28020. };
  28021. Engine.prototype._initGLContext = function () {
  28022. // Caps
  28023. this._caps = new EngineCapabilities();
  28024. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28025. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28026. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28027. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28028. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28029. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28030. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28031. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28032. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28033. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28034. // Infos
  28035. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28036. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28037. if (rendererInfo != null) {
  28038. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28039. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28040. }
  28041. if (!this._glVendor) {
  28042. this._glVendor = "Unknown vendor";
  28043. }
  28044. if (!this._glRenderer) {
  28045. this._glRenderer = "Unknown renderer";
  28046. }
  28047. // Constants
  28048. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28049. if (this._gl.RGBA16F !== 0x881A) {
  28050. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28051. }
  28052. if (this._gl.RGBA32F !== 0x8814) {
  28053. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28054. }
  28055. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28056. this._gl.DEPTH24_STENCIL8 = 35056;
  28057. }
  28058. // Extensions
  28059. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28060. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28061. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28062. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28063. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28064. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28065. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28066. 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');
  28067. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28068. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28069. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28070. this._caps.highPrecisionShaderSupported = false;
  28071. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28072. if (this._caps.timerQuery) {
  28073. if (this._webGLVersion === 1) {
  28074. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28075. }
  28076. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28077. }
  28078. // Checks if some of the format renders first to allow the use of webgl inspector.
  28079. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28080. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28081. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28082. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28083. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28084. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28085. if (this._webGLVersion > 1) {
  28086. this._gl.HALF_FLOAT_OES = 0x140B;
  28087. }
  28088. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28089. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28090. // Draw buffers
  28091. if (this._webGLVersion > 1) {
  28092. this._caps.drawBuffersExtension = true;
  28093. }
  28094. else {
  28095. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28096. if (drawBuffersExtension !== null) {
  28097. this._caps.drawBuffersExtension = true;
  28098. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28099. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28100. for (var i = 0; i < 16; i++) {
  28101. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28102. }
  28103. }
  28104. else {
  28105. this._caps.drawBuffersExtension = false;
  28106. }
  28107. }
  28108. // Shader compiler threads
  28109. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28110. if (this._caps.parallelShaderCompile) {
  28111. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28112. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28113. }
  28114. // Depth Texture
  28115. if (this._webGLVersion > 1) {
  28116. this._caps.depthTextureExtension = true;
  28117. }
  28118. else {
  28119. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28120. if (depthTextureExtension != null) {
  28121. this._caps.depthTextureExtension = true;
  28122. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28123. }
  28124. }
  28125. // Vertex array object
  28126. if (this._webGLVersion > 1) {
  28127. this._caps.vertexArrayObject = true;
  28128. }
  28129. else {
  28130. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28131. if (vertexArrayObjectExtension != null) {
  28132. this._caps.vertexArrayObject = true;
  28133. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28134. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28135. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28136. }
  28137. else {
  28138. this._caps.vertexArrayObject = false;
  28139. }
  28140. }
  28141. // Instances count
  28142. if (this._webGLVersion > 1) {
  28143. this._caps.instancedArrays = true;
  28144. }
  28145. else {
  28146. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28147. if (instanceExtension != null) {
  28148. this._caps.instancedArrays = true;
  28149. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28150. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28151. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28152. }
  28153. else {
  28154. this._caps.instancedArrays = false;
  28155. }
  28156. }
  28157. // Intelligently add supported compressed formats in order to check for.
  28158. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28159. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28160. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28161. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28162. if (this._caps.astc) {
  28163. this.texturesSupported.push('-astc.ktx');
  28164. }
  28165. if (this._caps.s3tc) {
  28166. this.texturesSupported.push('-dxt.ktx');
  28167. }
  28168. if (this._caps.pvrtc) {
  28169. this.texturesSupported.push('-pvrtc.ktx');
  28170. }
  28171. if (this._caps.etc2) {
  28172. this.texturesSupported.push('-etc2.ktx');
  28173. }
  28174. if (this._caps.etc1) {
  28175. this.texturesSupported.push('-etc1.ktx');
  28176. }
  28177. if (this._gl.getShaderPrecisionFormat) {
  28178. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28179. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28180. if (vertex_highp && fragment_highp) {
  28181. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28182. }
  28183. }
  28184. // Depth buffer
  28185. this.setDepthBuffer(true);
  28186. this.setDepthFunctionToLessOrEqual();
  28187. this.setDepthWrite(true);
  28188. // Texture maps
  28189. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28190. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28191. this._nextFreeTextureSlots.push(slot);
  28192. }
  28193. };
  28194. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28195. /**
  28196. * Gets version of the current webGL context
  28197. */
  28198. get: function () {
  28199. return this._webGLVersion;
  28200. },
  28201. enumerable: true,
  28202. configurable: true
  28203. });
  28204. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28205. /**
  28206. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28207. */
  28208. get: function () {
  28209. return this._isStencilEnable;
  28210. },
  28211. enumerable: true,
  28212. configurable: true
  28213. });
  28214. Engine.prototype._prepareWorkingCanvas = function () {
  28215. if (this._workingCanvas) {
  28216. return;
  28217. }
  28218. this._workingCanvas = document.createElement("canvas");
  28219. var context = this._workingCanvas.getContext("2d");
  28220. if (context) {
  28221. this._workingContext = context;
  28222. }
  28223. };
  28224. /**
  28225. * Reset the texture cache to empty state
  28226. */
  28227. Engine.prototype.resetTextureCache = function () {
  28228. for (var key in this._boundTexturesCache) {
  28229. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28230. continue;
  28231. }
  28232. var boundTexture = this._boundTexturesCache[key];
  28233. if (boundTexture) {
  28234. this._removeDesignatedSlot(boundTexture);
  28235. }
  28236. this._boundTexturesCache[key] = null;
  28237. }
  28238. if (!this.disableTextureBindingOptimization) {
  28239. this._nextFreeTextureSlots = [];
  28240. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28241. this._nextFreeTextureSlots.push(slot);
  28242. }
  28243. }
  28244. this._currentTextureChannel = -1;
  28245. };
  28246. /**
  28247. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28249. * @returns true if engine is in deterministic lock step mode
  28250. */
  28251. Engine.prototype.isDeterministicLockStep = function () {
  28252. return this._deterministicLockstep;
  28253. };
  28254. /**
  28255. * Gets the max steps when engine is running in deterministic lock step
  28256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28257. * @returns the max steps
  28258. */
  28259. Engine.prototype.getLockstepMaxSteps = function () {
  28260. return this._lockstepMaxSteps;
  28261. };
  28262. /**
  28263. * Gets an object containing information about the current webGL context
  28264. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28265. */
  28266. Engine.prototype.getGlInfo = function () {
  28267. return {
  28268. vendor: this._glVendor,
  28269. renderer: this._glRenderer,
  28270. version: this._glVersion
  28271. };
  28272. };
  28273. /**
  28274. * Gets current aspect ratio
  28275. * @param camera defines the camera to use to get the aspect ratio
  28276. * @param useScreen defines if screen size must be used (or the current render target if any)
  28277. * @returns a number defining the aspect ratio
  28278. */
  28279. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28280. if (useScreen === void 0) { useScreen = false; }
  28281. var viewport = camera.viewport;
  28282. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28283. };
  28284. /**
  28285. * Gets current screen aspect ratio
  28286. * @returns a number defining the aspect ratio
  28287. */
  28288. Engine.prototype.getScreenAspectRatio = function () {
  28289. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28290. };
  28291. /**
  28292. * Gets the current render width
  28293. * @param useScreen defines if screen size must be used (or the current render target if any)
  28294. * @returns a number defining the current render width
  28295. */
  28296. Engine.prototype.getRenderWidth = function (useScreen) {
  28297. if (useScreen === void 0) { useScreen = false; }
  28298. if (!useScreen && this._currentRenderTarget) {
  28299. return this._currentRenderTarget.width;
  28300. }
  28301. return this._gl.drawingBufferWidth;
  28302. };
  28303. /**
  28304. * Gets the current render height
  28305. * @param useScreen defines if screen size must be used (or the current render target if any)
  28306. * @returns a number defining the current render height
  28307. */
  28308. Engine.prototype.getRenderHeight = function (useScreen) {
  28309. if (useScreen === void 0) { useScreen = false; }
  28310. if (!useScreen && this._currentRenderTarget) {
  28311. return this._currentRenderTarget.height;
  28312. }
  28313. return this._gl.drawingBufferHeight;
  28314. };
  28315. /**
  28316. * Gets the HTML canvas attached with the current webGL context
  28317. * @returns a HTML canvas
  28318. */
  28319. Engine.prototype.getRenderingCanvas = function () {
  28320. return this._renderingCanvas;
  28321. };
  28322. /**
  28323. * Gets the client rect of the HTML canvas attached with the current webGL context
  28324. * @returns a client rectanglee
  28325. */
  28326. Engine.prototype.getRenderingCanvasClientRect = function () {
  28327. if (!this._renderingCanvas) {
  28328. return null;
  28329. }
  28330. return this._renderingCanvas.getBoundingClientRect();
  28331. };
  28332. /**
  28333. * Defines the hardware scaling level.
  28334. * By default the hardware scaling level is computed from the window device ratio.
  28335. * 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.
  28336. * @param level defines the level to use
  28337. */
  28338. Engine.prototype.setHardwareScalingLevel = function (level) {
  28339. this._hardwareScalingLevel = level;
  28340. this.resize();
  28341. };
  28342. /**
  28343. * Gets the current hardware scaling level.
  28344. * By default the hardware scaling level is computed from the window device ratio.
  28345. * 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.
  28346. * @returns a number indicating the current hardware scaling level
  28347. */
  28348. Engine.prototype.getHardwareScalingLevel = function () {
  28349. return this._hardwareScalingLevel;
  28350. };
  28351. /**
  28352. * Gets the list of loaded textures
  28353. * @returns an array containing all loaded textures
  28354. */
  28355. Engine.prototype.getLoadedTexturesCache = function () {
  28356. return this._internalTexturesCache;
  28357. };
  28358. /**
  28359. * Gets the object containing all engine capabilities
  28360. * @returns the EngineCapabilities object
  28361. */
  28362. Engine.prototype.getCaps = function () {
  28363. return this._caps;
  28364. };
  28365. /**
  28366. * Gets the current depth function
  28367. * @returns a number defining the depth function
  28368. */
  28369. Engine.prototype.getDepthFunction = function () {
  28370. return this._depthCullingState.depthFunc;
  28371. };
  28372. /**
  28373. * Sets the current depth function
  28374. * @param depthFunc defines the function to use
  28375. */
  28376. Engine.prototype.setDepthFunction = function (depthFunc) {
  28377. this._depthCullingState.depthFunc = depthFunc;
  28378. };
  28379. /**
  28380. * Sets the current depth function to GREATER
  28381. */
  28382. Engine.prototype.setDepthFunctionToGreater = function () {
  28383. this._depthCullingState.depthFunc = this._gl.GREATER;
  28384. };
  28385. /**
  28386. * Sets the current depth function to GEQUAL
  28387. */
  28388. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  28389. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  28390. };
  28391. /**
  28392. * Sets the current depth function to LESS
  28393. */
  28394. Engine.prototype.setDepthFunctionToLess = function () {
  28395. this._depthCullingState.depthFunc = this._gl.LESS;
  28396. };
  28397. /**
  28398. * Sets the current depth function to LEQUAL
  28399. */
  28400. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  28401. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  28402. };
  28403. /**
  28404. * Gets a boolean indicating if stencil buffer is enabled
  28405. * @returns the current stencil buffer state
  28406. */
  28407. Engine.prototype.getStencilBuffer = function () {
  28408. return this._stencilState.stencilTest;
  28409. };
  28410. /**
  28411. * Enable or disable the stencil buffer
  28412. * @param enable defines if the stencil buffer must be enabled or disabled
  28413. */
  28414. Engine.prototype.setStencilBuffer = function (enable) {
  28415. this._stencilState.stencilTest = enable;
  28416. };
  28417. /**
  28418. * Gets the current stencil mask
  28419. * @returns a number defining the new stencil mask to use
  28420. */
  28421. Engine.prototype.getStencilMask = function () {
  28422. return this._stencilState.stencilMask;
  28423. };
  28424. /**
  28425. * Sets the current stencil mask
  28426. * @param mask defines the new stencil mask to use
  28427. */
  28428. Engine.prototype.setStencilMask = function (mask) {
  28429. this._stencilState.stencilMask = mask;
  28430. };
  28431. /**
  28432. * Gets the current stencil function
  28433. * @returns a number defining the stencil function to use
  28434. */
  28435. Engine.prototype.getStencilFunction = function () {
  28436. return this._stencilState.stencilFunc;
  28437. };
  28438. /**
  28439. * Gets the current stencil reference value
  28440. * @returns a number defining the stencil reference value to use
  28441. */
  28442. Engine.prototype.getStencilFunctionReference = function () {
  28443. return this._stencilState.stencilFuncRef;
  28444. };
  28445. /**
  28446. * Gets the current stencil mask
  28447. * @returns a number defining the stencil mask to use
  28448. */
  28449. Engine.prototype.getStencilFunctionMask = function () {
  28450. return this._stencilState.stencilFuncMask;
  28451. };
  28452. /**
  28453. * Sets the current stencil function
  28454. * @param stencilFunc defines the new stencil function to use
  28455. */
  28456. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28457. this._stencilState.stencilFunc = stencilFunc;
  28458. };
  28459. /**
  28460. * Sets the current stencil reference
  28461. * @param reference defines the new stencil reference to use
  28462. */
  28463. Engine.prototype.setStencilFunctionReference = function (reference) {
  28464. this._stencilState.stencilFuncRef = reference;
  28465. };
  28466. /**
  28467. * Sets the current stencil mask
  28468. * @param mask defines the new stencil mask to use
  28469. */
  28470. Engine.prototype.setStencilFunctionMask = function (mask) {
  28471. this._stencilState.stencilFuncMask = mask;
  28472. };
  28473. /**
  28474. * Gets the current stencil operation when stencil fails
  28475. * @returns a number defining stencil operation to use when stencil fails
  28476. */
  28477. Engine.prototype.getStencilOperationFail = function () {
  28478. return this._stencilState.stencilOpStencilFail;
  28479. };
  28480. /**
  28481. * Gets the current stencil operation when depth fails
  28482. * @returns a number defining stencil operation to use when depth fails
  28483. */
  28484. Engine.prototype.getStencilOperationDepthFail = function () {
  28485. return this._stencilState.stencilOpDepthFail;
  28486. };
  28487. /**
  28488. * Gets the current stencil operation when stencil passes
  28489. * @returns a number defining stencil operation to use when stencil passes
  28490. */
  28491. Engine.prototype.getStencilOperationPass = function () {
  28492. return this._stencilState.stencilOpStencilDepthPass;
  28493. };
  28494. /**
  28495. * Sets the stencil operation to use when stencil fails
  28496. * @param operation defines the stencil operation to use when stencil fails
  28497. */
  28498. Engine.prototype.setStencilOperationFail = function (operation) {
  28499. this._stencilState.stencilOpStencilFail = operation;
  28500. };
  28501. /**
  28502. * Sets the stencil operation to use when depth fails
  28503. * @param operation defines the stencil operation to use when depth fails
  28504. */
  28505. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28506. this._stencilState.stencilOpDepthFail = operation;
  28507. };
  28508. /**
  28509. * Sets the stencil operation to use when stencil passes
  28510. * @param operation defines the stencil operation to use when stencil passes
  28511. */
  28512. Engine.prototype.setStencilOperationPass = function (operation) {
  28513. this._stencilState.stencilOpStencilDepthPass = operation;
  28514. };
  28515. /**
  28516. * Sets a boolean indicating if the dithering state is enabled or disabled
  28517. * @param value defines the dithering state
  28518. */
  28519. Engine.prototype.setDitheringState = function (value) {
  28520. if (value) {
  28521. this._gl.enable(this._gl.DITHER);
  28522. }
  28523. else {
  28524. this._gl.disable(this._gl.DITHER);
  28525. }
  28526. };
  28527. /**
  28528. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28529. * @param value defines the rasterizer state
  28530. */
  28531. Engine.prototype.setRasterizerState = function (value) {
  28532. if (value) {
  28533. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28534. }
  28535. else {
  28536. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28537. }
  28538. };
  28539. /**
  28540. * stop executing a render loop function and remove it from the execution array
  28541. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28542. */
  28543. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28544. if (!renderFunction) {
  28545. this._activeRenderLoops = [];
  28546. return;
  28547. }
  28548. var index = this._activeRenderLoops.indexOf(renderFunction);
  28549. if (index >= 0) {
  28550. this._activeRenderLoops.splice(index, 1);
  28551. }
  28552. };
  28553. /** @hidden */
  28554. Engine.prototype._renderLoop = function () {
  28555. if (!this._contextWasLost) {
  28556. var shouldRender = true;
  28557. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28558. shouldRender = false;
  28559. }
  28560. if (shouldRender) {
  28561. // Start new frame
  28562. this.beginFrame();
  28563. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28564. var renderFunction = this._activeRenderLoops[index];
  28565. renderFunction();
  28566. }
  28567. // Present
  28568. this.endFrame();
  28569. }
  28570. }
  28571. if (this._activeRenderLoops.length > 0) {
  28572. // Register new frame
  28573. if (this.customAnimationFrameRequester) {
  28574. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28575. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28576. }
  28577. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28578. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28579. }
  28580. else {
  28581. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28582. }
  28583. }
  28584. else {
  28585. this._renderingQueueLaunched = false;
  28586. }
  28587. };
  28588. /**
  28589. * Register and execute a render loop. The engine can have more than one render function
  28590. * @param renderFunction defines the function to continuously execute
  28591. */
  28592. Engine.prototype.runRenderLoop = function (renderFunction) {
  28593. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28594. return;
  28595. }
  28596. this._activeRenderLoops.push(renderFunction);
  28597. if (!this._renderingQueueLaunched) {
  28598. this._renderingQueueLaunched = true;
  28599. this._bindedRenderFunction = this._renderLoop.bind(this);
  28600. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28601. }
  28602. };
  28603. /**
  28604. * Toggle full screen mode
  28605. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28606. */
  28607. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28608. if (this.isFullscreen) {
  28609. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28610. }
  28611. else {
  28612. this._pointerLockRequested = requestPointerLock;
  28613. if (this._renderingCanvas) {
  28614. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28615. }
  28616. }
  28617. };
  28618. /**
  28619. * Clear the current render buffer or the current render target (if any is set up)
  28620. * @param color defines the color to use
  28621. * @param backBuffer defines if the back buffer must be cleared
  28622. * @param depth defines if the depth buffer must be cleared
  28623. * @param stencil defines if the stencil buffer must be cleared
  28624. */
  28625. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28626. if (stencil === void 0) { stencil = false; }
  28627. this.applyStates();
  28628. var mode = 0;
  28629. if (backBuffer && color) {
  28630. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28631. mode |= this._gl.COLOR_BUFFER_BIT;
  28632. }
  28633. if (depth) {
  28634. this._gl.clearDepth(1.0);
  28635. mode |= this._gl.DEPTH_BUFFER_BIT;
  28636. }
  28637. if (stencil) {
  28638. this._gl.clearStencil(0);
  28639. mode |= this._gl.STENCIL_BUFFER_BIT;
  28640. }
  28641. this._gl.clear(mode);
  28642. };
  28643. /**
  28644. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28645. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28646. * @param y defines the y-coordinate of the corner of the clear rectangle
  28647. * @param width defines the width of the clear rectangle
  28648. * @param height defines the height of the clear rectangle
  28649. * @param clearColor defines the clear color
  28650. */
  28651. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28652. this.enableScissor(x, y, width, height);
  28653. this.clear(clearColor, true, true, true);
  28654. this.disableScissor();
  28655. };
  28656. /**
  28657. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28658. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28659. * @param y defines the y-coordinate of the corner of the clear rectangle
  28660. * @param width defines the width of the clear rectangle
  28661. * @param height defines the height of the clear rectangle
  28662. */
  28663. Engine.prototype.enableScissor = function (x, y, width, height) {
  28664. var gl = this._gl;
  28665. // Change state
  28666. gl.enable(gl.SCISSOR_TEST);
  28667. gl.scissor(x, y, width, height);
  28668. };
  28669. /**
  28670. * Disable previously set scissor test rectangle
  28671. */
  28672. Engine.prototype.disableScissor = function () {
  28673. var gl = this._gl;
  28674. gl.disable(gl.SCISSOR_TEST);
  28675. };
  28676. /** @hidden */
  28677. Engine.prototype._viewport = function (x, y, width, height) {
  28678. if (x !== this._viewportCached.x ||
  28679. y !== this._viewportCached.y ||
  28680. width !== this._viewportCached.z ||
  28681. height !== this._viewportCached.w) {
  28682. this._viewportCached.x = x;
  28683. this._viewportCached.y = y;
  28684. this._viewportCached.z = width;
  28685. this._viewportCached.w = height;
  28686. this._gl.viewport(x, y, width, height);
  28687. }
  28688. };
  28689. /**
  28690. * Set the WebGL's viewport
  28691. * @param viewport defines the viewport element to be used
  28692. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28693. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28694. */
  28695. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28696. var width = requiredWidth || this.getRenderWidth();
  28697. var height = requiredHeight || this.getRenderHeight();
  28698. var x = viewport.x || 0;
  28699. var y = viewport.y || 0;
  28700. this._cachedViewport = viewport;
  28701. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28702. };
  28703. /**
  28704. * Directly set the WebGL Viewport
  28705. * @param x defines the x coordinate of the viewport (in screen space)
  28706. * @param y defines the y coordinate of the viewport (in screen space)
  28707. * @param width defines the width of the viewport (in screen space)
  28708. * @param height defines the height of the viewport (in screen space)
  28709. * @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
  28710. */
  28711. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28712. var currentViewport = this._cachedViewport;
  28713. this._cachedViewport = null;
  28714. this._viewport(x, y, width, height);
  28715. return currentViewport;
  28716. };
  28717. /**
  28718. * Begin a new frame
  28719. */
  28720. Engine.prototype.beginFrame = function () {
  28721. this.onBeginFrameObservable.notifyObservers(this);
  28722. this._measureFps();
  28723. };
  28724. /**
  28725. * Enf the current frame
  28726. */
  28727. Engine.prototype.endFrame = function () {
  28728. // Force a flush in case we are using a bad OS.
  28729. if (this._badOS) {
  28730. this.flushFramebuffer();
  28731. }
  28732. // Submit frame to the vr device, if enabled
  28733. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28734. // TODO: We should only submit the frame if we read frameData successfully.
  28735. this._vrDisplay.submitFrame();
  28736. }
  28737. this.onEndFrameObservable.notifyObservers(this);
  28738. };
  28739. /**
  28740. * Resize the view according to the canvas' size
  28741. */
  28742. Engine.prototype.resize = function () {
  28743. // We're not resizing the size of the canvas while in VR mode & presenting
  28744. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28745. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28746. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28747. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28748. }
  28749. };
  28750. /**
  28751. * Force a specific size of the canvas
  28752. * @param width defines the new canvas' width
  28753. * @param height defines the new canvas' height
  28754. */
  28755. Engine.prototype.setSize = function (width, height) {
  28756. if (!this._renderingCanvas) {
  28757. return;
  28758. }
  28759. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28760. return;
  28761. }
  28762. this._renderingCanvas.width = width;
  28763. this._renderingCanvas.height = height;
  28764. for (var index = 0; index < this.scenes.length; index++) {
  28765. var scene = this.scenes[index];
  28766. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28767. var cam = scene.cameras[camIndex];
  28768. cam._currentRenderId = 0;
  28769. }
  28770. }
  28771. if (this.onResizeObservable.hasObservers) {
  28772. this.onResizeObservable.notifyObservers(this);
  28773. }
  28774. };
  28775. // WebVR functions
  28776. /**
  28777. * Gets a boolean indicating if a webVR device was detected
  28778. * @returns true if a webVR device was detected
  28779. */
  28780. Engine.prototype.isVRDevicePresent = function () {
  28781. return !!this._vrDisplay;
  28782. };
  28783. /**
  28784. * Gets the current webVR device
  28785. * @returns the current webVR device (or null)
  28786. */
  28787. Engine.prototype.getVRDevice = function () {
  28788. return this._vrDisplay;
  28789. };
  28790. /**
  28791. * Initializes a webVR display and starts listening to display change events
  28792. * The onVRDisplayChangedObservable will be notified upon these changes
  28793. * @returns The onVRDisplayChangedObservable
  28794. */
  28795. Engine.prototype.initWebVR = function () {
  28796. this.initWebVRAsync();
  28797. return this.onVRDisplayChangedObservable;
  28798. };
  28799. /**
  28800. * Initializes a webVR display and starts listening to display change events
  28801. * The onVRDisplayChangedObservable will be notified upon these changes
  28802. * @returns A promise containing a VRDisplay and if vr is supported
  28803. */
  28804. Engine.prototype.initWebVRAsync = function () {
  28805. var _this = this;
  28806. var notifyObservers = function () {
  28807. var eventArgs = {
  28808. vrDisplay: _this._vrDisplay,
  28809. vrSupported: _this._vrSupported
  28810. };
  28811. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  28812. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  28813. };
  28814. if (!this._onVrDisplayConnect) {
  28815. this._onVrDisplayConnect = function (event) {
  28816. _this._vrDisplay = event.display;
  28817. notifyObservers();
  28818. };
  28819. this._onVrDisplayDisconnect = function () {
  28820. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  28821. _this._vrDisplay = undefined;
  28822. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  28823. notifyObservers();
  28824. };
  28825. this._onVrDisplayPresentChange = function () {
  28826. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  28827. };
  28828. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28829. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  28830. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  28831. }
  28832. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  28833. this._webVRInitPromise.then(notifyObservers);
  28834. return this._webVRInitPromise;
  28835. };
  28836. /**
  28837. * Call this function to switch to webVR mode
  28838. * Will do nothing if webVR is not supported or if there is no webVR device
  28839. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28840. */
  28841. Engine.prototype.enableVR = function () {
  28842. var _this = this;
  28843. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  28844. var onResolved = function () {
  28845. _this.onVRRequestPresentComplete.notifyObservers(true);
  28846. _this._onVRFullScreenTriggered();
  28847. };
  28848. var onRejected = function () {
  28849. _this.onVRRequestPresentComplete.notifyObservers(false);
  28850. };
  28851. this.onVRRequestPresentStart.notifyObservers(this);
  28852. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  28853. }
  28854. };
  28855. /**
  28856. * Call this function to leave webVR mode
  28857. * Will do nothing if webVR is not supported or if there is no webVR device
  28858. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28859. */
  28860. Engine.prototype.disableVR = function () {
  28861. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28862. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  28863. }
  28864. };
  28865. Engine.prototype._getVRDisplaysAsync = function () {
  28866. var _this = this;
  28867. return new Promise(function (res) {
  28868. if (navigator.getVRDisplays) {
  28869. navigator.getVRDisplays().then(function (devices) {
  28870. _this._vrSupported = true;
  28871. // note that devices may actually be an empty array. This is fine;
  28872. // we expect this._vrDisplay to be undefined in this case.
  28873. _this._vrDisplay = devices[0];
  28874. res({
  28875. vrDisplay: _this._vrDisplay,
  28876. vrSupported: _this._vrSupported
  28877. });
  28878. });
  28879. }
  28880. else {
  28881. _this._vrDisplay = undefined;
  28882. _this._vrSupported = false;
  28883. res({
  28884. vrDisplay: _this._vrDisplay,
  28885. vrSupported: _this._vrSupported
  28886. });
  28887. }
  28888. });
  28889. };
  28890. /**
  28891. * Binds the frame buffer to the specified texture.
  28892. * @param texture The texture to render to or null for the default canvas
  28893. * @param faceIndex The face of the texture to render to in case of cube texture
  28894. * @param requiredWidth The width of the target to render to
  28895. * @param requiredHeight The height of the target to render to
  28896. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28897. * @param depthStencilTexture The depth stencil texture to use to render
  28898. * @param lodLevel defines le lod level to bind to the frame buffer
  28899. */
  28900. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  28901. if (lodLevel === void 0) { lodLevel = 0; }
  28902. if (this._currentRenderTarget) {
  28903. this.unBindFramebuffer(this._currentRenderTarget);
  28904. }
  28905. this._currentRenderTarget = texture;
  28906. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  28907. var gl = this._gl;
  28908. if (texture.isCube) {
  28909. if (faceIndex === undefined) {
  28910. faceIndex = 0;
  28911. }
  28912. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  28913. if (depthStencilTexture) {
  28914. if (depthStencilTexture._generateStencilBuffer) {
  28915. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28916. }
  28917. else {
  28918. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28919. }
  28920. }
  28921. }
  28922. if (this._cachedViewport && !forceFullscreenViewport) {
  28923. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  28924. }
  28925. else {
  28926. if (!requiredWidth) {
  28927. requiredWidth = texture.width;
  28928. if (lodLevel) {
  28929. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  28930. }
  28931. }
  28932. if (!requiredHeight) {
  28933. requiredHeight = texture.height;
  28934. if (lodLevel) {
  28935. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  28936. }
  28937. }
  28938. this._viewport(0, 0, requiredWidth, requiredHeight);
  28939. }
  28940. this.wipeCaches();
  28941. };
  28942. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  28943. if (this._currentFramebuffer !== framebuffer) {
  28944. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  28945. this._currentFramebuffer = framebuffer;
  28946. }
  28947. };
  28948. /**
  28949. * Unbind the current render target texture from the webGL context
  28950. * @param texture defines the render target texture to unbind
  28951. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28952. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28953. */
  28954. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  28955. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28956. this._currentRenderTarget = null;
  28957. // If MSAA, we need to bitblt back to main texture
  28958. var gl = this._gl;
  28959. if (texture._MSAAFramebuffer) {
  28960. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  28961. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  28962. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28963. }
  28964. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28965. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  28966. gl.generateMipmap(gl.TEXTURE_2D);
  28967. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28968. }
  28969. if (onBeforeUnbind) {
  28970. if (texture._MSAAFramebuffer) {
  28971. // Bind the correct framebuffer
  28972. this.bindUnboundFramebuffer(texture._framebuffer);
  28973. }
  28974. onBeforeUnbind();
  28975. }
  28976. this.bindUnboundFramebuffer(null);
  28977. };
  28978. /**
  28979. * Unbind a list of render target textures from the webGL context
  28980. * This is used only when drawBuffer extension or webGL2 are active
  28981. * @param textures defines the render target textures to unbind
  28982. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28983. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28984. */
  28985. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  28986. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28987. this._currentRenderTarget = null;
  28988. // If MSAA, we need to bitblt back to main texture
  28989. var gl = this._gl;
  28990. if (textures[0]._MSAAFramebuffer) {
  28991. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  28992. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  28993. var attachments = textures[0]._attachments;
  28994. if (!attachments) {
  28995. attachments = new Array(textures.length);
  28996. textures[0]._attachments = attachments;
  28997. }
  28998. for (var i = 0; i < textures.length; i++) {
  28999. var texture = textures[i];
  29000. for (var j = 0; j < attachments.length; j++) {
  29001. attachments[j] = gl.NONE;
  29002. }
  29003. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29004. gl.readBuffer(attachments[i]);
  29005. gl.drawBuffers(attachments);
  29006. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29007. }
  29008. for (var i = 0; i < attachments.length; i++) {
  29009. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29010. }
  29011. gl.drawBuffers(attachments);
  29012. }
  29013. for (var i = 0; i < textures.length; i++) {
  29014. var texture = textures[i];
  29015. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29016. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29017. gl.generateMipmap(gl.TEXTURE_2D);
  29018. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29019. }
  29020. }
  29021. if (onBeforeUnbind) {
  29022. if (textures[0]._MSAAFramebuffer) {
  29023. // Bind the correct framebuffer
  29024. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29025. }
  29026. onBeforeUnbind();
  29027. }
  29028. this.bindUnboundFramebuffer(null);
  29029. };
  29030. /**
  29031. * Force the mipmap generation for the given render target texture
  29032. * @param texture defines the render target texture to use
  29033. */
  29034. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29035. if (texture.generateMipMaps) {
  29036. var gl = this._gl;
  29037. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29038. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29039. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29040. }
  29041. };
  29042. /**
  29043. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29044. */
  29045. Engine.prototype.flushFramebuffer = function () {
  29046. this._gl.flush();
  29047. };
  29048. /**
  29049. * Unbind the current render target and bind the default framebuffer
  29050. */
  29051. Engine.prototype.restoreDefaultFramebuffer = function () {
  29052. if (this._currentRenderTarget) {
  29053. this.unBindFramebuffer(this._currentRenderTarget);
  29054. }
  29055. else {
  29056. this.bindUnboundFramebuffer(null);
  29057. }
  29058. if (this._cachedViewport) {
  29059. this.setViewport(this._cachedViewport);
  29060. }
  29061. this.wipeCaches();
  29062. };
  29063. // UBOs
  29064. /**
  29065. * Create an uniform buffer
  29066. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29067. * @param elements defines the content of the uniform buffer
  29068. * @returns the webGL uniform buffer
  29069. */
  29070. Engine.prototype.createUniformBuffer = function (elements) {
  29071. var ubo = this._gl.createBuffer();
  29072. if (!ubo) {
  29073. throw new Error("Unable to create uniform buffer");
  29074. }
  29075. this.bindUniformBuffer(ubo);
  29076. if (elements instanceof Float32Array) {
  29077. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29078. }
  29079. else {
  29080. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29081. }
  29082. this.bindUniformBuffer(null);
  29083. ubo.references = 1;
  29084. return ubo;
  29085. };
  29086. /**
  29087. * Create a dynamic uniform buffer
  29088. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29089. * @param elements defines the content of the uniform buffer
  29090. * @returns the webGL uniform buffer
  29091. */
  29092. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29093. var ubo = this._gl.createBuffer();
  29094. if (!ubo) {
  29095. throw new Error("Unable to create dynamic uniform buffer");
  29096. }
  29097. this.bindUniformBuffer(ubo);
  29098. if (elements instanceof Float32Array) {
  29099. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29100. }
  29101. else {
  29102. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29103. }
  29104. this.bindUniformBuffer(null);
  29105. ubo.references = 1;
  29106. return ubo;
  29107. };
  29108. /**
  29109. * Update an existing uniform buffer
  29110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29111. * @param uniformBuffer defines the target uniform buffer
  29112. * @param elements defines the content to update
  29113. * @param offset defines the offset in the uniform buffer where update should start
  29114. * @param count defines the size of the data to update
  29115. */
  29116. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29117. this.bindUniformBuffer(uniformBuffer);
  29118. if (offset === undefined) {
  29119. offset = 0;
  29120. }
  29121. if (count === undefined) {
  29122. if (elements instanceof Float32Array) {
  29123. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29124. }
  29125. else {
  29126. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29127. }
  29128. }
  29129. else {
  29130. if (elements instanceof Float32Array) {
  29131. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29132. }
  29133. else {
  29134. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29135. }
  29136. }
  29137. this.bindUniformBuffer(null);
  29138. };
  29139. // VBOs
  29140. Engine.prototype._resetVertexBufferBinding = function () {
  29141. this.bindArrayBuffer(null);
  29142. this._cachedVertexBuffers = null;
  29143. };
  29144. /**
  29145. * Creates a vertex buffer
  29146. * @param data the data for the vertex buffer
  29147. * @returns the new WebGL static buffer
  29148. */
  29149. Engine.prototype.createVertexBuffer = function (data) {
  29150. var vbo = this._gl.createBuffer();
  29151. if (!vbo) {
  29152. throw new Error("Unable to create vertex buffer");
  29153. }
  29154. this.bindArrayBuffer(vbo);
  29155. if (data instanceof Array) {
  29156. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29157. }
  29158. else {
  29159. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29160. }
  29161. this._resetVertexBufferBinding();
  29162. vbo.references = 1;
  29163. return vbo;
  29164. };
  29165. /**
  29166. * Creates a dynamic vertex buffer
  29167. * @param data the data for the dynamic vertex buffer
  29168. * @returns the new WebGL dynamic buffer
  29169. */
  29170. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29171. var vbo = this._gl.createBuffer();
  29172. if (!vbo) {
  29173. throw new Error("Unable to create dynamic vertex buffer");
  29174. }
  29175. this.bindArrayBuffer(vbo);
  29176. if (data instanceof Array) {
  29177. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29178. }
  29179. else {
  29180. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29181. }
  29182. this._resetVertexBufferBinding();
  29183. vbo.references = 1;
  29184. return vbo;
  29185. };
  29186. /**
  29187. * Update a dynamic index buffer
  29188. * @param indexBuffer defines the target index buffer
  29189. * @param indices defines the data to update
  29190. * @param offset defines the offset in the target index buffer where update should start
  29191. */
  29192. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29193. if (offset === void 0) { offset = 0; }
  29194. // Force cache update
  29195. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29196. this.bindIndexBuffer(indexBuffer);
  29197. var arrayBuffer;
  29198. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29199. arrayBuffer = indices;
  29200. }
  29201. else {
  29202. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29203. }
  29204. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29205. this._resetIndexBufferBinding();
  29206. };
  29207. /**
  29208. * Updates a dynamic vertex buffer.
  29209. * @param vertexBuffer the vertex buffer to update
  29210. * @param data the data used to update the vertex buffer
  29211. * @param byteOffset the byte offset of the data
  29212. * @param byteLength the byte length of the data
  29213. */
  29214. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29215. this.bindArrayBuffer(vertexBuffer);
  29216. if (byteOffset === undefined) {
  29217. byteOffset = 0;
  29218. }
  29219. if (byteLength === undefined) {
  29220. if (data instanceof Array) {
  29221. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29222. }
  29223. else {
  29224. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29225. }
  29226. }
  29227. else {
  29228. if (data instanceof Array) {
  29229. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29230. }
  29231. else {
  29232. if (data instanceof ArrayBuffer) {
  29233. data = new Uint8Array(data, byteOffset, byteLength);
  29234. }
  29235. else {
  29236. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29237. }
  29238. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29239. }
  29240. }
  29241. this._resetVertexBufferBinding();
  29242. };
  29243. Engine.prototype._resetIndexBufferBinding = function () {
  29244. this.bindIndexBuffer(null);
  29245. this._cachedIndexBuffer = null;
  29246. };
  29247. /**
  29248. * Creates a new index buffer
  29249. * @param indices defines the content of the index buffer
  29250. * @param updatable defines if the index buffer must be updatable
  29251. * @returns a new webGL buffer
  29252. */
  29253. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29254. var vbo = this._gl.createBuffer();
  29255. if (!vbo) {
  29256. throw new Error("Unable to create index buffer");
  29257. }
  29258. this.bindIndexBuffer(vbo);
  29259. // Check for 32 bits indices
  29260. var arrayBuffer;
  29261. var need32Bits = false;
  29262. if (indices instanceof Uint16Array) {
  29263. arrayBuffer = indices;
  29264. }
  29265. else {
  29266. //check 32 bit support
  29267. if (this._caps.uintIndices) {
  29268. if (indices instanceof Uint32Array) {
  29269. arrayBuffer = indices;
  29270. need32Bits = true;
  29271. }
  29272. else {
  29273. //number[] or Int32Array, check if 32 bit is necessary
  29274. for (var index = 0; index < indices.length; index++) {
  29275. if (indices[index] > 65535) {
  29276. need32Bits = true;
  29277. break;
  29278. }
  29279. }
  29280. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29281. }
  29282. }
  29283. else {
  29284. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29285. arrayBuffer = new Uint16Array(indices);
  29286. }
  29287. }
  29288. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29289. this._resetIndexBufferBinding();
  29290. vbo.references = 1;
  29291. vbo.is32Bits = need32Bits;
  29292. return vbo;
  29293. };
  29294. /**
  29295. * Bind a webGL buffer to the webGL context
  29296. * @param buffer defines the buffer to bind
  29297. */
  29298. Engine.prototype.bindArrayBuffer = function (buffer) {
  29299. if (!this._vaoRecordInProgress) {
  29300. this._unbindVertexArrayObject();
  29301. }
  29302. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  29303. };
  29304. /**
  29305. * Bind an uniform buffer to the current webGL context
  29306. * @param buffer defines the buffer to bind
  29307. */
  29308. Engine.prototype.bindUniformBuffer = function (buffer) {
  29309. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  29310. };
  29311. /**
  29312. * Bind a buffer to the current webGL context at a given location
  29313. * @param buffer defines the buffer to bind
  29314. * @param location defines the index where to bind the buffer
  29315. */
  29316. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  29317. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  29318. };
  29319. /**
  29320. * Bind a specific block at a given index in a specific shader program
  29321. * @param shaderProgram defines the shader program
  29322. * @param blockName defines the block name
  29323. * @param index defines the index where to bind the block
  29324. */
  29325. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  29326. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  29327. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  29328. };
  29329. Engine.prototype.bindIndexBuffer = function (buffer) {
  29330. if (!this._vaoRecordInProgress) {
  29331. this._unbindVertexArrayObject();
  29332. }
  29333. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  29334. };
  29335. Engine.prototype.bindBuffer = function (buffer, target) {
  29336. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  29337. this._gl.bindBuffer(target, buffer);
  29338. this._currentBoundBuffer[target] = buffer;
  29339. }
  29340. };
  29341. /**
  29342. * update the bound buffer with the given data
  29343. * @param data defines the data to update
  29344. */
  29345. Engine.prototype.updateArrayBuffer = function (data) {
  29346. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29347. };
  29348. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  29349. var pointer = this._currentBufferPointers[indx];
  29350. var changed = false;
  29351. if (!pointer.active) {
  29352. changed = true;
  29353. pointer.active = true;
  29354. pointer.index = indx;
  29355. pointer.size = size;
  29356. pointer.type = type;
  29357. pointer.normalized = normalized;
  29358. pointer.stride = stride;
  29359. pointer.offset = offset;
  29360. pointer.buffer = buffer;
  29361. }
  29362. else {
  29363. if (pointer.buffer !== buffer) {
  29364. pointer.buffer = buffer;
  29365. changed = true;
  29366. }
  29367. if (pointer.size !== size) {
  29368. pointer.size = size;
  29369. changed = true;
  29370. }
  29371. if (pointer.type !== type) {
  29372. pointer.type = type;
  29373. changed = true;
  29374. }
  29375. if (pointer.normalized !== normalized) {
  29376. pointer.normalized = normalized;
  29377. changed = true;
  29378. }
  29379. if (pointer.stride !== stride) {
  29380. pointer.stride = stride;
  29381. changed = true;
  29382. }
  29383. if (pointer.offset !== offset) {
  29384. pointer.offset = offset;
  29385. changed = true;
  29386. }
  29387. }
  29388. if (changed || this._vaoRecordInProgress) {
  29389. this.bindArrayBuffer(buffer);
  29390. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  29391. }
  29392. };
  29393. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  29394. if (indexBuffer == null) {
  29395. return;
  29396. }
  29397. if (this._cachedIndexBuffer !== indexBuffer) {
  29398. this._cachedIndexBuffer = indexBuffer;
  29399. this.bindIndexBuffer(indexBuffer);
  29400. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  29401. }
  29402. };
  29403. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  29404. var attributes = effect.getAttributesNames();
  29405. if (!this._vaoRecordInProgress) {
  29406. this._unbindVertexArrayObject();
  29407. }
  29408. this.unbindAllAttributes();
  29409. for (var index = 0; index < attributes.length; index++) {
  29410. var order = effect.getAttributeLocation(index);
  29411. if (order >= 0) {
  29412. var vertexBuffer = vertexBuffers[attributes[index]];
  29413. if (!vertexBuffer) {
  29414. continue;
  29415. }
  29416. this._gl.enableVertexAttribArray(order);
  29417. if (!this._vaoRecordInProgress) {
  29418. this._vertexAttribArraysEnabled[order] = true;
  29419. }
  29420. var buffer = vertexBuffer.getBuffer();
  29421. if (buffer) {
  29422. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  29423. if (vertexBuffer.getIsInstanced()) {
  29424. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  29425. if (!this._vaoRecordInProgress) {
  29426. this._currentInstanceLocations.push(order);
  29427. this._currentInstanceBuffers.push(buffer);
  29428. }
  29429. }
  29430. }
  29431. }
  29432. }
  29433. };
  29434. /**
  29435. * Records a vertex array object
  29436. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29437. * @param vertexBuffers defines the list of vertex buffers to store
  29438. * @param indexBuffer defines the index buffer to store
  29439. * @param effect defines the effect to store
  29440. * @returns the new vertex array object
  29441. */
  29442. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  29443. var vao = this._gl.createVertexArray();
  29444. this._vaoRecordInProgress = true;
  29445. this._gl.bindVertexArray(vao);
  29446. this._mustWipeVertexAttributes = true;
  29447. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29448. this.bindIndexBuffer(indexBuffer);
  29449. this._vaoRecordInProgress = false;
  29450. this._gl.bindVertexArray(null);
  29451. return vao;
  29452. };
  29453. /**
  29454. * Bind a specific vertex array object
  29455. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29456. * @param vertexArrayObject defines the vertex array object to bind
  29457. * @param indexBuffer defines the index buffer to bind
  29458. */
  29459. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29460. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29461. this._cachedVertexArrayObject = vertexArrayObject;
  29462. this._gl.bindVertexArray(vertexArrayObject);
  29463. this._cachedVertexBuffers = null;
  29464. this._cachedIndexBuffer = null;
  29465. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29466. this._mustWipeVertexAttributes = true;
  29467. }
  29468. };
  29469. /**
  29470. * Bind webGl buffers directly to the webGL context
  29471. * @param vertexBuffer defines the vertex buffer to bind
  29472. * @param indexBuffer defines the index buffer to bind
  29473. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29474. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29475. * @param effect defines the effect associated with the vertex buffer
  29476. */
  29477. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29478. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29479. this._cachedVertexBuffers = vertexBuffer;
  29480. this._cachedEffectForVertexBuffers = effect;
  29481. var attributesCount = effect.getAttributesCount();
  29482. this._unbindVertexArrayObject();
  29483. this.unbindAllAttributes();
  29484. var offset = 0;
  29485. for (var index = 0; index < attributesCount; index++) {
  29486. if (index < vertexDeclaration.length) {
  29487. var order = effect.getAttributeLocation(index);
  29488. if (order >= 0) {
  29489. this._gl.enableVertexAttribArray(order);
  29490. this._vertexAttribArraysEnabled[order] = true;
  29491. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29492. }
  29493. offset += vertexDeclaration[index] * 4;
  29494. }
  29495. }
  29496. }
  29497. this._bindIndexBufferWithCache(indexBuffer);
  29498. };
  29499. Engine.prototype._unbindVertexArrayObject = function () {
  29500. if (!this._cachedVertexArrayObject) {
  29501. return;
  29502. }
  29503. this._cachedVertexArrayObject = null;
  29504. this._gl.bindVertexArray(null);
  29505. };
  29506. /**
  29507. * Bind a list of vertex buffers to the webGL context
  29508. * @param vertexBuffers defines the list of vertex buffers to bind
  29509. * @param indexBuffer defines the index buffer to bind
  29510. * @param effect defines the effect associated with the vertex buffers
  29511. */
  29512. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29513. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29514. this._cachedVertexBuffers = vertexBuffers;
  29515. this._cachedEffectForVertexBuffers = effect;
  29516. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29517. }
  29518. this._bindIndexBufferWithCache(indexBuffer);
  29519. };
  29520. /**
  29521. * Unbind all instance attributes
  29522. */
  29523. Engine.prototype.unbindInstanceAttributes = function () {
  29524. var boundBuffer;
  29525. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29526. var instancesBuffer = this._currentInstanceBuffers[i];
  29527. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29528. boundBuffer = instancesBuffer;
  29529. this.bindArrayBuffer(instancesBuffer);
  29530. }
  29531. var offsetLocation = this._currentInstanceLocations[i];
  29532. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29533. }
  29534. this._currentInstanceBuffers.length = 0;
  29535. this._currentInstanceLocations.length = 0;
  29536. };
  29537. /**
  29538. * Release and free the memory of a vertex array object
  29539. * @param vao defines the vertex array object to delete
  29540. */
  29541. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29542. this._gl.deleteVertexArray(vao);
  29543. };
  29544. /** @hidden */
  29545. Engine.prototype._releaseBuffer = function (buffer) {
  29546. buffer.references--;
  29547. if (buffer.references === 0) {
  29548. this._gl.deleteBuffer(buffer);
  29549. return true;
  29550. }
  29551. return false;
  29552. };
  29553. /**
  29554. * Creates a webGL buffer to use with instanciation
  29555. * @param capacity defines the size of the buffer
  29556. * @returns the webGL buffer
  29557. */
  29558. Engine.prototype.createInstancesBuffer = function (capacity) {
  29559. var buffer = this._gl.createBuffer();
  29560. if (!buffer) {
  29561. throw new Error("Unable to create instance buffer");
  29562. }
  29563. buffer.capacity = capacity;
  29564. this.bindArrayBuffer(buffer);
  29565. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29566. return buffer;
  29567. };
  29568. /**
  29569. * Delete a webGL buffer used with instanciation
  29570. * @param buffer defines the webGL buffer to delete
  29571. */
  29572. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29573. this._gl.deleteBuffer(buffer);
  29574. };
  29575. /**
  29576. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29577. * @param instancesBuffer defines the webGL buffer to update and bind
  29578. * @param data defines the data to store in the buffer
  29579. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29580. */
  29581. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29582. this.bindArrayBuffer(instancesBuffer);
  29583. if (data) {
  29584. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29585. }
  29586. if (offsetLocations[0].index !== undefined) {
  29587. var stride = 0;
  29588. for (var i = 0; i < offsetLocations.length; i++) {
  29589. var ai = offsetLocations[i];
  29590. stride += ai.attributeSize * 4;
  29591. }
  29592. for (var i = 0; i < offsetLocations.length; i++) {
  29593. var ai = offsetLocations[i];
  29594. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29595. this._gl.enableVertexAttribArray(ai.index);
  29596. this._vertexAttribArraysEnabled[ai.index] = true;
  29597. }
  29598. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29599. this._gl.vertexAttribDivisor(ai.index, 1);
  29600. this._currentInstanceLocations.push(ai.index);
  29601. this._currentInstanceBuffers.push(instancesBuffer);
  29602. }
  29603. }
  29604. else {
  29605. for (var index = 0; index < 4; index++) {
  29606. var offsetLocation = offsetLocations[index];
  29607. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29608. this._gl.enableVertexAttribArray(offsetLocation);
  29609. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29610. }
  29611. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29612. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29613. this._currentInstanceLocations.push(offsetLocation);
  29614. this._currentInstanceBuffers.push(instancesBuffer);
  29615. }
  29616. }
  29617. };
  29618. /**
  29619. * Apply all cached states (depth, culling, stencil and alpha)
  29620. */
  29621. Engine.prototype.applyStates = function () {
  29622. this._depthCullingState.apply(this._gl);
  29623. this._stencilState.apply(this._gl);
  29624. this._alphaState.apply(this._gl);
  29625. };
  29626. /**
  29627. * Send a draw order
  29628. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29629. * @param indexStart defines the starting index
  29630. * @param indexCount defines the number of index to draw
  29631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29632. */
  29633. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29634. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29635. };
  29636. /**
  29637. * Draw a list of points
  29638. * @param verticesStart defines the index of first vertex to draw
  29639. * @param verticesCount defines the count of vertices to draw
  29640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29641. */
  29642. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29643. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29644. };
  29645. /**
  29646. * Draw a list of unindexed primitives
  29647. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29648. * @param verticesStart defines the index of first vertex to draw
  29649. * @param verticesCount defines the count of vertices to draw
  29650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29651. */
  29652. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29653. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29654. };
  29655. /**
  29656. * Draw a list of indexed primitives
  29657. * @param fillMode defines the primitive to use
  29658. * @param indexStart defines the starting index
  29659. * @param indexCount defines the number of index to draw
  29660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29661. */
  29662. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29663. // Apply states
  29664. this.applyStates();
  29665. this._drawCalls.addCount(1, false);
  29666. // Render
  29667. var drawMode = this._drawMode(fillMode);
  29668. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29669. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29670. if (instancesCount) {
  29671. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29672. }
  29673. else {
  29674. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29675. }
  29676. };
  29677. /**
  29678. * Draw a list of unindexed primitives
  29679. * @param fillMode defines the primitive to use
  29680. * @param verticesStart defines the index of first vertex to draw
  29681. * @param verticesCount defines the count of vertices to draw
  29682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29683. */
  29684. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29685. // Apply states
  29686. this.applyStates();
  29687. this._drawCalls.addCount(1, false);
  29688. var drawMode = this._drawMode(fillMode);
  29689. if (instancesCount) {
  29690. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29691. }
  29692. else {
  29693. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29694. }
  29695. };
  29696. Engine.prototype._drawMode = function (fillMode) {
  29697. switch (fillMode) {
  29698. // Triangle views
  29699. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29700. return this._gl.TRIANGLES;
  29701. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29702. return this._gl.POINTS;
  29703. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29704. return this._gl.LINES;
  29705. // Draw modes
  29706. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29707. return this._gl.POINTS;
  29708. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29709. return this._gl.LINES;
  29710. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29711. return this._gl.LINE_LOOP;
  29712. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29713. return this._gl.LINE_STRIP;
  29714. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29715. return this._gl.TRIANGLE_STRIP;
  29716. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29717. return this._gl.TRIANGLE_FAN;
  29718. default:
  29719. return this._gl.TRIANGLES;
  29720. }
  29721. };
  29722. // Shaders
  29723. /** @hidden */
  29724. Engine.prototype._releaseEffect = function (effect) {
  29725. if (this._compiledEffects[effect._key]) {
  29726. delete this._compiledEffects[effect._key];
  29727. this._deleteProgram(effect.getProgram());
  29728. }
  29729. };
  29730. /** @hidden */
  29731. Engine.prototype._deleteProgram = function (program) {
  29732. if (program) {
  29733. program.__SPECTOR_rebuildProgram = null;
  29734. if (program.transformFeedback) {
  29735. this.deleteTransformFeedback(program.transformFeedback);
  29736. program.transformFeedback = null;
  29737. }
  29738. this._gl.deleteProgram(program);
  29739. }
  29740. };
  29741. /**
  29742. * Create a new effect (used to store vertex/fragment shaders)
  29743. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29744. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29745. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29746. * @param samplers defines an array of string used to represent textures
  29747. * @param defines defines the string containing the defines to use to compile the shaders
  29748. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29749. * @param onCompiled defines a function to call when the effect creation is successful
  29750. * @param onError defines a function to call when the effect creation has failed
  29751. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29752. * @returns the new Effect
  29753. */
  29754. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29755. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29756. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29757. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29758. if (this._compiledEffects[name]) {
  29759. var compiledEffect = this._compiledEffects[name];
  29760. if (onCompiled && compiledEffect.isReady()) {
  29761. onCompiled(compiledEffect);
  29762. }
  29763. return compiledEffect;
  29764. }
  29765. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29766. effect._key = name;
  29767. this._compiledEffects[name] = effect;
  29768. return effect;
  29769. };
  29770. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29771. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29772. };
  29773. Engine.prototype._compileRawShader = function (source, type) {
  29774. var gl = this._gl;
  29775. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29776. if (!shader) {
  29777. throw new Error("Something went wrong while compile the shader.");
  29778. }
  29779. gl.shaderSource(shader, source);
  29780. gl.compileShader(shader);
  29781. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29782. var log = gl.getShaderInfoLog(shader);
  29783. if (log) {
  29784. throw new Error(log);
  29785. }
  29786. }
  29787. return shader;
  29788. };
  29789. /**
  29790. * Directly creates a webGL program
  29791. * @param vertexCode defines the vertex shader code to use
  29792. * @param fragmentCode defines the fragment shader code to use
  29793. * @param context defines the webGL context to use (if not set, the current one will be used)
  29794. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29795. * @returns the new webGL program
  29796. */
  29797. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  29798. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29799. context = context || this._gl;
  29800. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  29801. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  29802. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29803. };
  29804. /**
  29805. * Creates a webGL program
  29806. * @param vertexCode defines the vertex shader code to use
  29807. * @param fragmentCode defines the fragment shader code to use
  29808. * @param defines defines the string containing the defines to use to compile the shaders
  29809. * @param context defines the webGL context to use (if not set, the current one will be used)
  29810. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29811. * @returns the new webGL program
  29812. */
  29813. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  29814. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29815. context = context || this._gl;
  29816. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  29817. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  29818. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  29819. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  29820. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29821. this.onAfterShaderCompilationObservable.notifyObservers(this);
  29822. return program;
  29823. };
  29824. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  29825. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29826. var shaderProgram = context.createProgram();
  29827. if (!shaderProgram) {
  29828. throw new Error("Unable to create program");
  29829. }
  29830. context.attachShader(shaderProgram, vertexShader);
  29831. context.attachShader(shaderProgram, fragmentShader);
  29832. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29833. var transformFeedback = this.createTransformFeedback();
  29834. this.bindTransformFeedback(transformFeedback);
  29835. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  29836. shaderProgram.transformFeedback = transformFeedback;
  29837. }
  29838. context.linkProgram(shaderProgram);
  29839. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29840. this.bindTransformFeedback(null);
  29841. }
  29842. shaderProgram.context = context;
  29843. shaderProgram.vertexShader = vertexShader;
  29844. shaderProgram.fragmentShader = fragmentShader;
  29845. if (!this._caps.parallelShaderCompile) {
  29846. this._finalizeProgram(shaderProgram);
  29847. }
  29848. else {
  29849. shaderProgram.isParallelCompiled = true;
  29850. }
  29851. return shaderProgram;
  29852. };
  29853. Engine.prototype._finalizeProgram = function (shaderProgram) {
  29854. var context = shaderProgram.context;
  29855. var vertexShader = shaderProgram.vertexShader;
  29856. var fragmentShader = shaderProgram.fragmentShader;
  29857. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  29858. if (!linked) {
  29859. var error = context.getProgramInfoLog(shaderProgram);
  29860. if (error) {
  29861. throw new Error(error);
  29862. }
  29863. }
  29864. if (this.validateShaderPrograms) {
  29865. context.validateProgram(shaderProgram);
  29866. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  29867. if (!validated) {
  29868. var error = context.getProgramInfoLog(shaderProgram);
  29869. if (error) {
  29870. throw new Error(error);
  29871. }
  29872. }
  29873. }
  29874. context.deleteShader(vertexShader);
  29875. context.deleteShader(fragmentShader);
  29876. shaderProgram.context = undefined;
  29877. shaderProgram.vertexShader = undefined;
  29878. shaderProgram.fragmentShader = undefined;
  29879. if (shaderProgram.onCompiled) {
  29880. shaderProgram.onCompiled();
  29881. shaderProgram.onCompiled = undefined;
  29882. }
  29883. };
  29884. /** @hidden */
  29885. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  29886. if (!shaderProgram.isParallelCompiled) {
  29887. return true;
  29888. }
  29889. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  29890. this._finalizeProgram(shaderProgram);
  29891. return true;
  29892. }
  29893. return false;
  29894. };
  29895. /** @hidden */
  29896. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  29897. if (!shaderProgram.isParallelCompiled) {
  29898. action();
  29899. return;
  29900. }
  29901. shaderProgram.onCompiled = action;
  29902. };
  29903. /**
  29904. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29905. * @param shaderProgram defines the webGL program to use
  29906. * @param uniformsNames defines the list of uniform names
  29907. * @returns an array of webGL uniform locations
  29908. */
  29909. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  29910. var results = new Array();
  29911. for (var index = 0; index < uniformsNames.length; index++) {
  29912. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  29913. }
  29914. return results;
  29915. };
  29916. /**
  29917. * Gets the lsit of active attributes for a given webGL program
  29918. * @param shaderProgram defines the webGL program to use
  29919. * @param attributesNames defines the list of attribute names to get
  29920. * @returns an array of indices indicating the offset of each attribute
  29921. */
  29922. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  29923. var results = [];
  29924. for (var index = 0; index < attributesNames.length; index++) {
  29925. try {
  29926. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  29927. }
  29928. catch (e) {
  29929. results.push(-1);
  29930. }
  29931. }
  29932. return results;
  29933. };
  29934. /**
  29935. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29936. * @param effect defines the effect to activate
  29937. */
  29938. Engine.prototype.enableEffect = function (effect) {
  29939. if (!effect || effect === this._currentEffect) {
  29940. return;
  29941. }
  29942. // Use program
  29943. this.bindSamplers(effect);
  29944. this._currentEffect = effect;
  29945. if (effect.onBind) {
  29946. effect.onBind(effect);
  29947. }
  29948. if (effect._onBindObservable) {
  29949. effect._onBindObservable.notifyObservers(effect);
  29950. }
  29951. };
  29952. /**
  29953. * Set the value of an uniform to an array of int32
  29954. * @param uniform defines the webGL uniform location where to store the value
  29955. * @param array defines the array of int32 to store
  29956. */
  29957. Engine.prototype.setIntArray = function (uniform, array) {
  29958. if (!uniform) {
  29959. return;
  29960. }
  29961. this._gl.uniform1iv(uniform, array);
  29962. };
  29963. /**
  29964. * Set the value of an uniform to an array of int32 (stored as vec2)
  29965. * @param uniform defines the webGL uniform location where to store the value
  29966. * @param array defines the array of int32 to store
  29967. */
  29968. Engine.prototype.setIntArray2 = function (uniform, array) {
  29969. if (!uniform || array.length % 2 !== 0) {
  29970. return;
  29971. }
  29972. this._gl.uniform2iv(uniform, array);
  29973. };
  29974. /**
  29975. * Set the value of an uniform to an array of int32 (stored as vec3)
  29976. * @param uniform defines the webGL uniform location where to store the value
  29977. * @param array defines the array of int32 to store
  29978. */
  29979. Engine.prototype.setIntArray3 = function (uniform, array) {
  29980. if (!uniform || array.length % 3 !== 0) {
  29981. return;
  29982. }
  29983. this._gl.uniform3iv(uniform, array);
  29984. };
  29985. /**
  29986. * Set the value of an uniform to an array of int32 (stored as vec4)
  29987. * @param uniform defines the webGL uniform location where to store the value
  29988. * @param array defines the array of int32 to store
  29989. */
  29990. Engine.prototype.setIntArray4 = function (uniform, array) {
  29991. if (!uniform || array.length % 4 !== 0) {
  29992. return;
  29993. }
  29994. this._gl.uniform4iv(uniform, array);
  29995. };
  29996. /**
  29997. * Set the value of an uniform to an array of float32
  29998. * @param uniform defines the webGL uniform location where to store the value
  29999. * @param array defines the array of float32 to store
  30000. */
  30001. Engine.prototype.setFloatArray = function (uniform, array) {
  30002. if (!uniform) {
  30003. return;
  30004. }
  30005. this._gl.uniform1fv(uniform, array);
  30006. };
  30007. /**
  30008. * Set the value of an uniform to an array of float32 (stored as vec2)
  30009. * @param uniform defines the webGL uniform location where to store the value
  30010. * @param array defines the array of float32 to store
  30011. */
  30012. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30013. if (!uniform || array.length % 2 !== 0) {
  30014. return;
  30015. }
  30016. this._gl.uniform2fv(uniform, array);
  30017. };
  30018. /**
  30019. * Set the value of an uniform to an array of float32 (stored as vec3)
  30020. * @param uniform defines the webGL uniform location where to store the value
  30021. * @param array defines the array of float32 to store
  30022. */
  30023. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30024. if (!uniform || array.length % 3 !== 0) {
  30025. return;
  30026. }
  30027. this._gl.uniform3fv(uniform, array);
  30028. };
  30029. /**
  30030. * Set the value of an uniform to an array of float32 (stored as vec4)
  30031. * @param uniform defines the webGL uniform location where to store the value
  30032. * @param array defines the array of float32 to store
  30033. */
  30034. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30035. if (!uniform || array.length % 4 !== 0) {
  30036. return;
  30037. }
  30038. this._gl.uniform4fv(uniform, array);
  30039. };
  30040. /**
  30041. * Set the value of an uniform to an array of number
  30042. * @param uniform defines the webGL uniform location where to store the value
  30043. * @param array defines the array of number to store
  30044. */
  30045. Engine.prototype.setArray = function (uniform, array) {
  30046. if (!uniform) {
  30047. return;
  30048. }
  30049. this._gl.uniform1fv(uniform, array);
  30050. };
  30051. /**
  30052. * Set the value of an uniform to an array of number (stored as vec2)
  30053. * @param uniform defines the webGL uniform location where to store the value
  30054. * @param array defines the array of number to store
  30055. */
  30056. Engine.prototype.setArray2 = function (uniform, array) {
  30057. if (!uniform || array.length % 2 !== 0) {
  30058. return;
  30059. }
  30060. this._gl.uniform2fv(uniform, array);
  30061. };
  30062. /**
  30063. * Set the value of an uniform to an array of number (stored as vec3)
  30064. * @param uniform defines the webGL uniform location where to store the value
  30065. * @param array defines the array of number to store
  30066. */
  30067. Engine.prototype.setArray3 = function (uniform, array) {
  30068. if (!uniform || array.length % 3 !== 0) {
  30069. return;
  30070. }
  30071. this._gl.uniform3fv(uniform, array);
  30072. };
  30073. /**
  30074. * Set the value of an uniform to an array of number (stored as vec4)
  30075. * @param uniform defines the webGL uniform location where to store the value
  30076. * @param array defines the array of number to store
  30077. */
  30078. Engine.prototype.setArray4 = function (uniform, array) {
  30079. if (!uniform || array.length % 4 !== 0) {
  30080. return;
  30081. }
  30082. this._gl.uniform4fv(uniform, array);
  30083. };
  30084. /**
  30085. * Set the value of an uniform to an array of float32 (stored as matrices)
  30086. * @param uniform defines the webGL uniform location where to store the value
  30087. * @param matrices defines the array of float32 to store
  30088. */
  30089. Engine.prototype.setMatrices = function (uniform, matrices) {
  30090. if (!uniform) {
  30091. return;
  30092. }
  30093. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30094. };
  30095. /**
  30096. * Set the value of an uniform to a matrix
  30097. * @param uniform defines the webGL uniform location where to store the value
  30098. * @param matrix defines the matrix to store
  30099. */
  30100. Engine.prototype.setMatrix = function (uniform, matrix) {
  30101. if (!uniform) {
  30102. return;
  30103. }
  30104. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30105. };
  30106. /**
  30107. * Set the value of an uniform to a matrix (3x3)
  30108. * @param uniform defines the webGL uniform location where to store the value
  30109. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30110. */
  30111. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30112. if (!uniform) {
  30113. return;
  30114. }
  30115. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30116. };
  30117. /**
  30118. * Set the value of an uniform to a matrix (2x2)
  30119. * @param uniform defines the webGL uniform location where to store the value
  30120. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30121. */
  30122. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30123. if (!uniform) {
  30124. return;
  30125. }
  30126. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30127. };
  30128. /**
  30129. * Set the value of an uniform to a number (int)
  30130. * @param uniform defines the webGL uniform location where to store the value
  30131. * @param value defines the int number to store
  30132. */
  30133. Engine.prototype.setInt = function (uniform, value) {
  30134. if (!uniform) {
  30135. return;
  30136. }
  30137. this._gl.uniform1i(uniform, value);
  30138. };
  30139. /**
  30140. * Set the value of an uniform to a number (float)
  30141. * @param uniform defines the webGL uniform location where to store the value
  30142. * @param value defines the float number to store
  30143. */
  30144. Engine.prototype.setFloat = function (uniform, value) {
  30145. if (!uniform) {
  30146. return;
  30147. }
  30148. this._gl.uniform1f(uniform, value);
  30149. };
  30150. /**
  30151. * Set the value of an uniform to a vec2
  30152. * @param uniform defines the webGL uniform location where to store the value
  30153. * @param x defines the 1st component of the value
  30154. * @param y defines the 2nd component of the value
  30155. */
  30156. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30157. if (!uniform) {
  30158. return;
  30159. }
  30160. this._gl.uniform2f(uniform, x, y);
  30161. };
  30162. /**
  30163. * Set the value of an uniform to a vec3
  30164. * @param uniform defines the webGL uniform location where to store the value
  30165. * @param x defines the 1st component of the value
  30166. * @param y defines the 2nd component of the value
  30167. * @param z defines the 3rd component of the value
  30168. */
  30169. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30170. if (!uniform) {
  30171. return;
  30172. }
  30173. this._gl.uniform3f(uniform, x, y, z);
  30174. };
  30175. /**
  30176. * Set the value of an uniform to a boolean
  30177. * @param uniform defines the webGL uniform location where to store the value
  30178. * @param bool defines the boolean to store
  30179. */
  30180. Engine.prototype.setBool = function (uniform, bool) {
  30181. if (!uniform) {
  30182. return;
  30183. }
  30184. this._gl.uniform1i(uniform, bool);
  30185. };
  30186. /**
  30187. * Set the value of an uniform to a vec4
  30188. * @param uniform defines the webGL uniform location where to store the value
  30189. * @param x defines the 1st component of the value
  30190. * @param y defines the 2nd component of the value
  30191. * @param z defines the 3rd component of the value
  30192. * @param w defines the 4th component of the value
  30193. */
  30194. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30195. if (!uniform) {
  30196. return;
  30197. }
  30198. this._gl.uniform4f(uniform, x, y, z, w);
  30199. };
  30200. /**
  30201. * Set the value of an uniform to a Color3
  30202. * @param uniform defines the webGL uniform location where to store the value
  30203. * @param color3 defines the color to store
  30204. */
  30205. Engine.prototype.setColor3 = function (uniform, color3) {
  30206. if (!uniform) {
  30207. return;
  30208. }
  30209. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30210. };
  30211. /**
  30212. * Set the value of an uniform to a Color3 and an alpha value
  30213. * @param uniform defines the webGL uniform location where to store the value
  30214. * @param color3 defines the color to store
  30215. * @param alpha defines the alpha component to store
  30216. */
  30217. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30218. if (!uniform) {
  30219. return;
  30220. }
  30221. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30222. };
  30223. /**
  30224. * Sets a Color4 on a uniform variable
  30225. * @param uniform defines the uniform location
  30226. * @param color4 defines the value to be set
  30227. */
  30228. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30229. if (!uniform) {
  30230. return;
  30231. }
  30232. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30233. };
  30234. // States
  30235. /**
  30236. * Set various states to the webGL context
  30237. * @param culling defines backface culling state
  30238. * @param zOffset defines the value to apply to zOffset (0 by default)
  30239. * @param force defines if states must be applied even if cache is up to date
  30240. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30241. */
  30242. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30243. if (zOffset === void 0) { zOffset = 0; }
  30244. if (reverseSide === void 0) { reverseSide = false; }
  30245. // Culling
  30246. if (this._depthCullingState.cull !== culling || force) {
  30247. this._depthCullingState.cull = culling;
  30248. }
  30249. // Cull face
  30250. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30251. if (this._depthCullingState.cullFace !== cullFace || force) {
  30252. this._depthCullingState.cullFace = cullFace;
  30253. }
  30254. // Z offset
  30255. this.setZOffset(zOffset);
  30256. // Front face
  30257. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30258. if (this._depthCullingState.frontFace !== frontFace || force) {
  30259. this._depthCullingState.frontFace = frontFace;
  30260. }
  30261. };
  30262. /**
  30263. * Set the z offset to apply to current rendering
  30264. * @param value defines the offset to apply
  30265. */
  30266. Engine.prototype.setZOffset = function (value) {
  30267. this._depthCullingState.zOffset = value;
  30268. };
  30269. /**
  30270. * Gets the current value of the zOffset
  30271. * @returns the current zOffset state
  30272. */
  30273. Engine.prototype.getZOffset = function () {
  30274. return this._depthCullingState.zOffset;
  30275. };
  30276. /**
  30277. * Enable or disable depth buffering
  30278. * @param enable defines the state to set
  30279. */
  30280. Engine.prototype.setDepthBuffer = function (enable) {
  30281. this._depthCullingState.depthTest = enable;
  30282. };
  30283. /**
  30284. * Gets a boolean indicating if depth writing is enabled
  30285. * @returns the current depth writing state
  30286. */
  30287. Engine.prototype.getDepthWrite = function () {
  30288. return this._depthCullingState.depthMask;
  30289. };
  30290. /**
  30291. * Enable or disable depth writing
  30292. * @param enable defines the state to set
  30293. */
  30294. Engine.prototype.setDepthWrite = function (enable) {
  30295. this._depthCullingState.depthMask = enable;
  30296. };
  30297. /**
  30298. * Enable or disable color writing
  30299. * @param enable defines the state to set
  30300. */
  30301. Engine.prototype.setColorWrite = function (enable) {
  30302. this._gl.colorMask(enable, enable, enable, enable);
  30303. this._colorWrite = enable;
  30304. };
  30305. /**
  30306. * Gets a boolean indicating if color writing is enabled
  30307. * @returns the current color writing state
  30308. */
  30309. Engine.prototype.getColorWrite = function () {
  30310. return this._colorWrite;
  30311. };
  30312. /**
  30313. * Sets alpha constants used by some alpha blending modes
  30314. * @param r defines the red component
  30315. * @param g defines the green component
  30316. * @param b defines the blue component
  30317. * @param a defines the alpha component
  30318. */
  30319. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  30320. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  30321. };
  30322. /**
  30323. * Sets the current alpha mode
  30324. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30325. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30326. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30327. */
  30328. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  30329. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  30330. if (this._alphaMode === mode) {
  30331. return;
  30332. }
  30333. switch (mode) {
  30334. case Engine.ALPHA_DISABLE:
  30335. this._alphaState.alphaBlend = false;
  30336. break;
  30337. case Engine.ALPHA_PREMULTIPLIED:
  30338. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30339. this._alphaState.alphaBlend = true;
  30340. break;
  30341. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  30342. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30343. this._alphaState.alphaBlend = true;
  30344. break;
  30345. case Engine.ALPHA_COMBINE:
  30346. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30347. this._alphaState.alphaBlend = true;
  30348. break;
  30349. case Engine.ALPHA_ONEONE:
  30350. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30351. this._alphaState.alphaBlend = true;
  30352. break;
  30353. case Engine.ALPHA_ADD:
  30354. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30355. this._alphaState.alphaBlend = true;
  30356. break;
  30357. case Engine.ALPHA_SUBTRACT:
  30358. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30359. this._alphaState.alphaBlend = true;
  30360. break;
  30361. case Engine.ALPHA_MULTIPLY:
  30362. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  30363. this._alphaState.alphaBlend = true;
  30364. break;
  30365. case Engine.ALPHA_MAXIMIZED:
  30366. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30367. this._alphaState.alphaBlend = true;
  30368. break;
  30369. case Engine.ALPHA_INTERPOLATE:
  30370. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  30371. this._alphaState.alphaBlend = true;
  30372. break;
  30373. case Engine.ALPHA_SCREENMODE:
  30374. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30375. this._alphaState.alphaBlend = true;
  30376. break;
  30377. }
  30378. if (!noDepthWriteChange) {
  30379. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  30380. }
  30381. this._alphaMode = mode;
  30382. };
  30383. /**
  30384. * Gets the current alpha mode
  30385. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30386. * @returns the current alpha mode
  30387. */
  30388. Engine.prototype.getAlphaMode = function () {
  30389. return this._alphaMode;
  30390. };
  30391. // Textures
  30392. /**
  30393. * Clears the list of texture accessible through engine.
  30394. * This can help preventing texture load conflict due to name collision.
  30395. */
  30396. Engine.prototype.clearInternalTexturesCache = function () {
  30397. this._internalTexturesCache = [];
  30398. };
  30399. /**
  30400. * Force the entire cache to be cleared
  30401. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30402. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30403. */
  30404. Engine.prototype.wipeCaches = function (bruteForce) {
  30405. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  30406. return;
  30407. }
  30408. this._currentEffect = null;
  30409. this._viewportCached.x = 0;
  30410. this._viewportCached.y = 0;
  30411. this._viewportCached.z = 0;
  30412. this._viewportCached.w = 0;
  30413. if (bruteForce) {
  30414. this.resetTextureCache();
  30415. this._currentProgram = null;
  30416. this._stencilState.reset();
  30417. this._depthCullingState.reset();
  30418. this.setDepthFunctionToLessOrEqual();
  30419. this._alphaState.reset();
  30420. this._unpackFlipYCached = null;
  30421. }
  30422. this._resetVertexBufferBinding();
  30423. this._cachedIndexBuffer = null;
  30424. this._cachedEffectForVertexBuffers = null;
  30425. this._unbindVertexArrayObject();
  30426. this.bindIndexBuffer(null);
  30427. };
  30428. /**
  30429. * Set the compressed texture format to use, based on the formats you have, and the formats
  30430. * supported by the hardware / browser.
  30431. *
  30432. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30433. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30434. * to API arguments needed to compressed textures. This puts the burden on the container
  30435. * generator to house the arcane code for determining these for current & future formats.
  30436. *
  30437. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30438. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30439. *
  30440. * Note: The result of this call is not taken into account when a texture is base64.
  30441. *
  30442. * @param formatsAvailable defines the list of those format families you have created
  30443. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30444. *
  30445. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30446. * @returns The extension selected.
  30447. */
  30448. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  30449. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  30450. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  30451. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  30452. return this._textureFormatInUse = this._texturesSupported[i];
  30453. }
  30454. }
  30455. }
  30456. // actively set format to nothing, to allow this to be called more than once
  30457. // and possibly fail the 2nd time
  30458. this._textureFormatInUse = null;
  30459. return null;
  30460. };
  30461. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30462. var gl = this._gl;
  30463. var magFilter = gl.NEAREST;
  30464. var minFilter = gl.NEAREST;
  30465. switch (samplingMode) {
  30466. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30467. magFilter = gl.LINEAR;
  30468. if (generateMipMaps) {
  30469. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30470. }
  30471. else {
  30472. minFilter = gl.LINEAR;
  30473. }
  30474. break;
  30475. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30476. magFilter = gl.LINEAR;
  30477. if (generateMipMaps) {
  30478. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30479. }
  30480. else {
  30481. minFilter = gl.LINEAR;
  30482. }
  30483. break;
  30484. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30485. magFilter = gl.NEAREST;
  30486. if (generateMipMaps) {
  30487. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30488. }
  30489. else {
  30490. minFilter = gl.NEAREST;
  30491. }
  30492. break;
  30493. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30494. magFilter = gl.NEAREST;
  30495. if (generateMipMaps) {
  30496. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30497. }
  30498. else {
  30499. minFilter = gl.NEAREST;
  30500. }
  30501. break;
  30502. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30503. magFilter = gl.NEAREST;
  30504. if (generateMipMaps) {
  30505. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30506. }
  30507. else {
  30508. minFilter = gl.LINEAR;
  30509. }
  30510. break;
  30511. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30512. magFilter = gl.NEAREST;
  30513. if (generateMipMaps) {
  30514. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30515. }
  30516. else {
  30517. minFilter = gl.LINEAR;
  30518. }
  30519. break;
  30520. case Engine.TEXTURE_NEAREST_LINEAR:
  30521. magFilter = gl.NEAREST;
  30522. minFilter = gl.LINEAR;
  30523. break;
  30524. case Engine.TEXTURE_NEAREST_NEAREST:
  30525. magFilter = gl.NEAREST;
  30526. minFilter = gl.NEAREST;
  30527. break;
  30528. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30529. magFilter = gl.LINEAR;
  30530. if (generateMipMaps) {
  30531. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30532. }
  30533. else {
  30534. minFilter = gl.NEAREST;
  30535. }
  30536. break;
  30537. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30538. magFilter = gl.LINEAR;
  30539. if (generateMipMaps) {
  30540. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30541. }
  30542. else {
  30543. minFilter = gl.NEAREST;
  30544. }
  30545. break;
  30546. case Engine.TEXTURE_LINEAR_LINEAR:
  30547. magFilter = gl.LINEAR;
  30548. minFilter = gl.LINEAR;
  30549. break;
  30550. case Engine.TEXTURE_LINEAR_NEAREST:
  30551. magFilter = gl.LINEAR;
  30552. minFilter = gl.NEAREST;
  30553. break;
  30554. }
  30555. return {
  30556. min: minFilter,
  30557. mag: magFilter
  30558. };
  30559. };
  30560. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30561. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30562. var img;
  30563. var onload = function () {
  30564. loadedImages[index] = img;
  30565. loadedImages._internalCount++;
  30566. if (scene) {
  30567. scene._removePendingData(img);
  30568. }
  30569. if (loadedImages._internalCount === 6) {
  30570. onfinish(loadedImages);
  30571. }
  30572. };
  30573. var onerror = function (message, exception) {
  30574. if (scene) {
  30575. scene._removePendingData(img);
  30576. }
  30577. if (onErrorCallBack) {
  30578. onErrorCallBack(message, exception);
  30579. }
  30580. };
  30581. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30582. if (scene) {
  30583. scene._addPendingData(img);
  30584. }
  30585. };
  30586. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30587. if (onError === void 0) { onError = null; }
  30588. var loadedImages = [];
  30589. loadedImages._internalCount = 0;
  30590. for (var index = 0; index < 6; index++) {
  30591. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30592. }
  30593. };
  30594. /** @hidden */
  30595. Engine.prototype._createTexture = function () {
  30596. var texture = this._gl.createTexture();
  30597. if (!texture) {
  30598. throw new Error("Unable to create texture");
  30599. }
  30600. return texture;
  30601. };
  30602. /**
  30603. * Usually called from Texture.ts.
  30604. * Passed information to create a WebGLTexture
  30605. * @param urlArg defines a value which contains one of the following:
  30606. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30607. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30608. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30609. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30610. * @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)
  30611. * @param scene needed for loading to the correct scene
  30612. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30613. * @param onLoad optional callback to be called upon successful completion
  30614. * @param onError optional callback to be called upon failure
  30615. * @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
  30616. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30617. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30618. * @param forcedExtension defines the extension to use to pick the right loader
  30619. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30620. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30621. */
  30622. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30623. var _this = this;
  30624. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30625. if (onLoad === void 0) { onLoad = null; }
  30626. if (onError === void 0) { onError = null; }
  30627. if (buffer === void 0) { buffer = null; }
  30628. if (fallback === void 0) { fallback = null; }
  30629. if (format === void 0) { format = null; }
  30630. if (forcedExtension === void 0) { forcedExtension = null; }
  30631. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30632. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30633. var fromData = url.substr(0, 5) === "data:";
  30634. var fromBlob = url.substr(0, 5) === "blob:";
  30635. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30636. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30637. // establish the file extension, if possible
  30638. var lastDot = url.lastIndexOf('.');
  30639. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30640. var loader = null;
  30641. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30642. var availableLoader = _a[_i];
  30643. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30644. loader = availableLoader;
  30645. break;
  30646. }
  30647. }
  30648. if (loader) {
  30649. url = loader.transformUrl(url, this._textureFormatInUse);
  30650. }
  30651. if (scene) {
  30652. scene._addPendingData(texture);
  30653. }
  30654. texture.url = url;
  30655. texture.generateMipMaps = !noMipmap;
  30656. texture.samplingMode = samplingMode;
  30657. texture.invertY = invertY;
  30658. if (!this._doNotHandleContextLost) {
  30659. // Keep a link to the buffer only if we plan to handle context lost
  30660. texture._buffer = buffer;
  30661. }
  30662. var onLoadObserver = null;
  30663. if (onLoad && !fallback) {
  30664. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30665. }
  30666. if (!fallback) {
  30667. this._internalTexturesCache.push(texture);
  30668. }
  30669. var onInternalError = function (message, exception) {
  30670. if (scene) {
  30671. scene._removePendingData(texture);
  30672. }
  30673. var customFallback = false;
  30674. if (loader) {
  30675. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30676. if (fallbackUrl) {
  30677. // Add Back
  30678. customFallback = true;
  30679. excludeLoaders.push(loader);
  30680. _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");
  30681. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30682. }
  30683. }
  30684. if (!customFallback) {
  30685. if (onLoadObserver) {
  30686. texture.onLoadedObservable.remove(onLoadObserver);
  30687. }
  30688. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30689. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30690. }
  30691. }
  30692. if (onError) {
  30693. onError(message || "Unknown error", exception);
  30694. }
  30695. };
  30696. // processing for non-image formats
  30697. if (loader) {
  30698. var callback = function (data) {
  30699. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30700. if (loadFailed) {
  30701. onInternalError("TextureLoader failed to load data");
  30702. }
  30703. else {
  30704. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30705. done();
  30706. return false;
  30707. }, samplingMode);
  30708. }
  30709. });
  30710. };
  30711. if (!buffer) {
  30712. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30713. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30714. });
  30715. }
  30716. else {
  30717. callback(buffer);
  30718. }
  30719. }
  30720. else {
  30721. var onload = function (img) {
  30722. if (fromBlob && !_this._doNotHandleContextLost) {
  30723. // We need to store the image if we need to rebuild the texture
  30724. // in case of a webgl context lost
  30725. texture._buffer = img;
  30726. }
  30727. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30728. var gl = _this._gl;
  30729. var isPot = (img.width === potWidth && img.height === potHeight);
  30730. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30731. if (isPot) {
  30732. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30733. return false;
  30734. }
  30735. var maxTextureSize = _this._caps.maxTextureSize;
  30736. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30737. _this._prepareWorkingCanvas();
  30738. if (!_this._workingCanvas || !_this._workingContext) {
  30739. return false;
  30740. }
  30741. _this._workingCanvas.width = potWidth;
  30742. _this._workingCanvas.height = potHeight;
  30743. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30744. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30745. texture.width = potWidth;
  30746. texture.height = potHeight;
  30747. return false;
  30748. }
  30749. else {
  30750. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30751. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30752. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30753. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30754. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30755. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30756. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30757. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30758. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30759. _this._releaseTexture(source_1);
  30760. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30761. continuationCallback();
  30762. });
  30763. }
  30764. return true;
  30765. }, samplingMode);
  30766. };
  30767. if (!fromData || isBase64) {
  30768. if (buffer instanceof HTMLImageElement) {
  30769. onload(buffer);
  30770. }
  30771. else {
  30772. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30773. }
  30774. }
  30775. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30776. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30777. }
  30778. else {
  30779. onload(buffer);
  30780. }
  30781. }
  30782. return texture;
  30783. };
  30784. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30785. var _this = this;
  30786. var rtt = this.createRenderTargetTexture({
  30787. width: destination.width,
  30788. height: destination.height,
  30789. }, {
  30790. generateMipMaps: false,
  30791. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30792. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30793. generateDepthBuffer: false,
  30794. generateStencilBuffer: false
  30795. });
  30796. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  30797. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  30798. }
  30799. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  30800. _this._rescalePostProcess.onApply = function (effect) {
  30801. effect._bindTexture("textureSampler", source);
  30802. };
  30803. var hostingScene = scene;
  30804. if (!hostingScene) {
  30805. hostingScene = _this.scenes[_this.scenes.length - 1];
  30806. }
  30807. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  30808. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  30809. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  30810. _this.unBindFramebuffer(rtt);
  30811. _this._releaseTexture(rtt);
  30812. if (onComplete) {
  30813. onComplete();
  30814. }
  30815. });
  30816. };
  30817. /**
  30818. * Update a raw texture
  30819. * @param texture defines the texture to update
  30820. * @param data defines the data to store in the texture
  30821. * @param format defines the format of the data
  30822. * @param invertY defines if data must be stored with Y axis inverted
  30823. * @param compression defines the compression used (null by default)
  30824. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30825. */
  30826. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  30827. if (compression === void 0) { compression = null; }
  30828. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30829. if (!texture) {
  30830. return;
  30831. }
  30832. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  30833. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  30834. // babylon's internalFormat but gl's texImage2D format
  30835. var internalFormat = this._getInternalFormat(format);
  30836. var textureType = this._getWebGLTextureType(type);
  30837. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30838. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  30839. if (!this._doNotHandleContextLost) {
  30840. texture._bufferView = data;
  30841. texture.format = format;
  30842. texture.type = type;
  30843. texture.invertY = invertY;
  30844. texture._compression = compression;
  30845. }
  30846. if (texture.width % 4 !== 0) {
  30847. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  30848. }
  30849. if (compression && data) {
  30850. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  30851. }
  30852. else {
  30853. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  30854. }
  30855. if (texture.generateMipMaps) {
  30856. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30857. }
  30858. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30859. // this.resetTextureCache();
  30860. texture.isReady = true;
  30861. };
  30862. /**
  30863. * Creates a raw texture
  30864. * @param data defines the data to store in the texture
  30865. * @param width defines the width of the texture
  30866. * @param height defines the height of the texture
  30867. * @param format defines the format of the data
  30868. * @param generateMipMaps defines if the engine should generate the mip levels
  30869. * @param invertY defines if data must be stored with Y axis inverted
  30870. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30871. * @param compression defines the compression used (null by default)
  30872. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30873. * @returns the raw texture inside an InternalTexture
  30874. */
  30875. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  30876. if (compression === void 0) { compression = null; }
  30877. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30878. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  30879. texture.baseWidth = width;
  30880. texture.baseHeight = height;
  30881. texture.width = width;
  30882. texture.height = height;
  30883. texture.format = format;
  30884. texture.generateMipMaps = generateMipMaps;
  30885. texture.samplingMode = samplingMode;
  30886. texture.invertY = invertY;
  30887. texture._compression = compression;
  30888. texture.type = type;
  30889. if (!this._doNotHandleContextLost) {
  30890. texture._bufferView = data;
  30891. }
  30892. this.updateRawTexture(texture, data, format, invertY, compression, type);
  30893. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30894. // Filters
  30895. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30896. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  30897. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30898. if (generateMipMaps) {
  30899. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30900. }
  30901. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30902. this._internalTexturesCache.push(texture);
  30903. return texture;
  30904. };
  30905. /** @hidden */
  30906. Engine.prototype._unpackFlipY = function (value) {
  30907. if (this._unpackFlipYCached !== value) {
  30908. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  30909. if (this.enableUnpackFlipYCached) {
  30910. this._unpackFlipYCached = value;
  30911. }
  30912. }
  30913. };
  30914. /** @hidden */
  30915. Engine.prototype._getUnpackAlignement = function () {
  30916. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  30917. };
  30918. /**
  30919. * Creates a dynamic texture
  30920. * @param width defines the width of the texture
  30921. * @param height defines the height of the texture
  30922. * @param generateMipMaps defines if the engine should generate the mip levels
  30923. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30924. * @returns the dynamic texture inside an InternalTexture
  30925. */
  30926. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  30927. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  30928. texture.baseWidth = width;
  30929. texture.baseHeight = height;
  30930. if (generateMipMaps) {
  30931. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  30932. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  30933. }
  30934. // this.resetTextureCache();
  30935. texture.width = width;
  30936. texture.height = height;
  30937. texture.isReady = false;
  30938. texture.generateMipMaps = generateMipMaps;
  30939. texture.samplingMode = samplingMode;
  30940. this.updateTextureSamplingMode(samplingMode, texture);
  30941. this._internalTexturesCache.push(texture);
  30942. return texture;
  30943. };
  30944. /**
  30945. * Update the sampling mode of a given texture
  30946. * @param samplingMode defines the required sampling mode
  30947. * @param texture defines the texture to update
  30948. */
  30949. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  30950. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  30951. if (texture.isCube) {
  30952. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30953. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30954. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30955. }
  30956. else if (texture.is3D) {
  30957. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30958. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30959. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  30960. }
  30961. else {
  30962. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30963. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30964. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30965. }
  30966. texture.samplingMode = samplingMode;
  30967. };
  30968. /**
  30969. * Update the content of a dynamic texture
  30970. * @param texture defines the texture to update
  30971. * @param canvas defines the canvas containing the source
  30972. * @param invertY defines if data must be stored with Y axis inverted
  30973. * @param premulAlpha defines if alpha is stored as premultiplied
  30974. * @param format defines the format of the data
  30975. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30976. */
  30977. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  30978. if (premulAlpha === void 0) { premulAlpha = false; }
  30979. if (forceBindTexture === void 0) { forceBindTexture = false; }
  30980. if (!texture) {
  30981. return;
  30982. }
  30983. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  30984. this._unpackFlipY(invertY);
  30985. if (premulAlpha) {
  30986. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  30987. }
  30988. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  30989. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  30990. if (texture.generateMipMaps) {
  30991. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30992. }
  30993. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30994. if (premulAlpha) {
  30995. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  30996. }
  30997. texture.isReady = true;
  30998. };
  30999. /**
  31000. * Update a video texture
  31001. * @param texture defines the texture to update
  31002. * @param video defines the video element to use
  31003. * @param invertY defines if data must be stored with Y axis inverted
  31004. */
  31005. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31006. if (!texture || texture._isDisabled) {
  31007. return;
  31008. }
  31009. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31010. this._unpackFlipY(!invertY); // Video are upside down by default
  31011. try {
  31012. // Testing video texture support
  31013. if (this._videoTextureSupported === undefined) {
  31014. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31015. if (this._gl.getError() !== 0) {
  31016. this._videoTextureSupported = false;
  31017. }
  31018. else {
  31019. this._videoTextureSupported = true;
  31020. }
  31021. }
  31022. // Copy video through the current working canvas if video texture is not supported
  31023. if (!this._videoTextureSupported) {
  31024. if (!texture._workingCanvas) {
  31025. texture._workingCanvas = document.createElement("canvas");
  31026. var context = texture._workingCanvas.getContext("2d");
  31027. if (!context) {
  31028. throw new Error("Unable to get 2d context");
  31029. }
  31030. texture._workingContext = context;
  31031. texture._workingCanvas.width = texture.width;
  31032. texture._workingCanvas.height = texture.height;
  31033. }
  31034. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31035. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31036. }
  31037. else {
  31038. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31039. }
  31040. if (texture.generateMipMaps) {
  31041. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31042. }
  31043. if (!wasPreviouslyBound) {
  31044. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31045. }
  31046. // this.resetTextureCache();
  31047. texture.isReady = true;
  31048. }
  31049. catch (ex) {
  31050. // Something unexpected
  31051. // Let's disable the texture
  31052. texture._isDisabled = true;
  31053. }
  31054. };
  31055. /**
  31056. * Updates a depth texture Comparison Mode and Function.
  31057. * If the comparison Function is equal to 0, the mode will be set to none.
  31058. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31059. * @param texture The texture to set the comparison function for
  31060. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31061. */
  31062. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31063. if (this.webGLVersion === 1) {
  31064. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31065. return;
  31066. }
  31067. var gl = this._gl;
  31068. if (texture.isCube) {
  31069. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31070. if (comparisonFunction === 0) {
  31071. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31072. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31073. }
  31074. else {
  31075. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31076. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31077. }
  31078. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31079. }
  31080. else {
  31081. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31082. if (comparisonFunction === 0) {
  31083. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31084. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31085. }
  31086. else {
  31087. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31088. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31089. }
  31090. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31091. }
  31092. texture._comparisonFunction = comparisonFunction;
  31093. };
  31094. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31095. var width = size.width || size;
  31096. var height = size.height || size;
  31097. internalTexture.baseWidth = width;
  31098. internalTexture.baseHeight = height;
  31099. internalTexture.width = width;
  31100. internalTexture.height = height;
  31101. internalTexture.isReady = true;
  31102. internalTexture.samples = 1;
  31103. internalTexture.generateMipMaps = false;
  31104. internalTexture._generateDepthBuffer = true;
  31105. internalTexture._generateStencilBuffer = generateStencil;
  31106. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31107. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31108. internalTexture._comparisonFunction = comparisonFunction;
  31109. var gl = this._gl;
  31110. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31111. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31112. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31113. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31114. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31115. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31116. if (comparisonFunction === 0) {
  31117. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31118. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31119. }
  31120. else {
  31121. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31122. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31123. }
  31124. };
  31125. /**
  31126. * Creates a depth stencil texture.
  31127. * This is only available in WebGL 2 or with the depth texture extension available.
  31128. * @param size The size of face edge in the texture.
  31129. * @param options The options defining the texture.
  31130. * @returns The texture
  31131. */
  31132. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31133. if (options.isCube) {
  31134. var width = size.width || size;
  31135. return this._createDepthStencilCubeTexture(width, options);
  31136. }
  31137. else {
  31138. return this._createDepthStencilTexture(size, options);
  31139. }
  31140. };
  31141. /**
  31142. * Creates a depth stencil texture.
  31143. * This is only available in WebGL 2 or with the depth texture extension available.
  31144. * @param size The size of face edge in the texture.
  31145. * @param options The options defining the texture.
  31146. * @returns The texture
  31147. */
  31148. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31149. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31150. if (!this._caps.depthTextureExtension) {
  31151. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31152. return internalTexture;
  31153. }
  31154. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31155. var gl = this._gl;
  31156. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31157. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31158. if (this.webGLVersion > 1) {
  31159. if (internalOptions.generateStencil) {
  31160. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31161. }
  31162. else {
  31163. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31164. }
  31165. }
  31166. else {
  31167. if (internalOptions.generateStencil) {
  31168. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31169. }
  31170. else {
  31171. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31172. }
  31173. }
  31174. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31175. return internalTexture;
  31176. };
  31177. /**
  31178. * Creates a depth stencil cube texture.
  31179. * This is only available in WebGL 2.
  31180. * @param size The size of face edge in the cube texture.
  31181. * @param options The options defining the cube texture.
  31182. * @returns The cube texture
  31183. */
  31184. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31185. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31186. internalTexture.isCube = true;
  31187. if (this.webGLVersion === 1) {
  31188. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31189. return internalTexture;
  31190. }
  31191. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31192. var gl = this._gl;
  31193. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31194. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31195. // Create the depth/stencil buffer
  31196. for (var face = 0; face < 6; face++) {
  31197. if (internalOptions.generateStencil) {
  31198. 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);
  31199. }
  31200. else {
  31201. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31202. }
  31203. }
  31204. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31205. return internalTexture;
  31206. };
  31207. /**
  31208. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31209. * @param renderTarget The render target to set the frame buffer for
  31210. */
  31211. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31212. // Create the framebuffer
  31213. var internalTexture = renderTarget.getInternalTexture();
  31214. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31215. return;
  31216. }
  31217. var gl = this._gl;
  31218. var depthStencilTexture = renderTarget.depthStencilTexture;
  31219. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31220. if (depthStencilTexture.isCube) {
  31221. if (depthStencilTexture._generateStencilBuffer) {
  31222. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31223. }
  31224. else {
  31225. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31226. }
  31227. }
  31228. else {
  31229. if (depthStencilTexture._generateStencilBuffer) {
  31230. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31231. }
  31232. else {
  31233. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31234. }
  31235. }
  31236. this.bindUnboundFramebuffer(null);
  31237. };
  31238. /**
  31239. * Creates a new render target texture
  31240. * @param size defines the size of the texture
  31241. * @param options defines the options used to create the texture
  31242. * @returns a new render target texture stored in an InternalTexture
  31243. */
  31244. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31245. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31246. if (options !== undefined && typeof options === "object") {
  31247. fullOptions.generateMipMaps = options.generateMipMaps;
  31248. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31249. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31250. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31251. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31252. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31253. }
  31254. else {
  31255. fullOptions.generateMipMaps = options;
  31256. fullOptions.generateDepthBuffer = true;
  31257. fullOptions.generateStencilBuffer = false;
  31258. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31259. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31260. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31261. }
  31262. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31263. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31264. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31265. }
  31266. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31267. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31268. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31269. }
  31270. var gl = this._gl;
  31271. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31272. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31273. var width = size.width || size;
  31274. var height = size.height || size;
  31275. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31276. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31277. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31278. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31279. }
  31280. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31281. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31282. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31283. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31284. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31285. // Create the framebuffer
  31286. var currentFrameBuffer = this._currentFramebuffer;
  31287. var framebuffer = gl.createFramebuffer();
  31288. this.bindUnboundFramebuffer(framebuffer);
  31289. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31290. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31291. if (fullOptions.generateMipMaps) {
  31292. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31293. }
  31294. // Unbind
  31295. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31296. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31297. this.bindUnboundFramebuffer(currentFrameBuffer);
  31298. texture._framebuffer = framebuffer;
  31299. texture.baseWidth = width;
  31300. texture.baseHeight = height;
  31301. texture.width = width;
  31302. texture.height = height;
  31303. texture.isReady = true;
  31304. texture.samples = 1;
  31305. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  31306. texture.samplingMode = fullOptions.samplingMode;
  31307. texture.type = fullOptions.type;
  31308. texture.format = fullOptions.format;
  31309. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31310. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  31311. // this.resetTextureCache();
  31312. this._internalTexturesCache.push(texture);
  31313. return texture;
  31314. };
  31315. /**
  31316. * Create a multi render target texture
  31317. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31318. * @param size defines the size of the texture
  31319. * @param options defines the creation options
  31320. * @returns the cube texture as an InternalTexture
  31321. */
  31322. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  31323. var generateMipMaps = false;
  31324. var generateDepthBuffer = true;
  31325. var generateStencilBuffer = false;
  31326. var generateDepthTexture = false;
  31327. var textureCount = 1;
  31328. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  31329. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31330. var types = new Array();
  31331. var samplingModes = new Array();
  31332. if (options !== undefined) {
  31333. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  31334. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31335. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  31336. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  31337. textureCount = options.textureCount || 1;
  31338. if (options.types) {
  31339. types = options.types;
  31340. }
  31341. if (options.samplingModes) {
  31342. samplingModes = options.samplingModes;
  31343. }
  31344. }
  31345. var gl = this._gl;
  31346. // Create the framebuffer
  31347. var framebuffer = gl.createFramebuffer();
  31348. this.bindUnboundFramebuffer(framebuffer);
  31349. var width = size.width || size;
  31350. var height = size.height || size;
  31351. var textures = [];
  31352. var attachments = [];
  31353. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  31354. for (var i = 0; i < textureCount; i++) {
  31355. var samplingMode = samplingModes[i] || defaultSamplingMode;
  31356. var type = types[i] || defaultType;
  31357. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31358. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31359. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31360. }
  31361. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31362. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31363. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31364. }
  31365. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31366. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31367. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31368. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31369. }
  31370. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31371. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31372. textures.push(texture);
  31373. attachments.push(attachment);
  31374. gl.activeTexture(gl["TEXTURE" + i]);
  31375. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  31376. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31377. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31378. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31379. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31380. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  31381. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31382. if (generateMipMaps) {
  31383. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31384. }
  31385. // Unbind
  31386. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31387. texture._framebuffer = framebuffer;
  31388. texture._depthStencilBuffer = depthStencilBuffer;
  31389. texture.baseWidth = width;
  31390. texture.baseHeight = height;
  31391. texture.width = width;
  31392. texture.height = height;
  31393. texture.isReady = true;
  31394. texture.samples = 1;
  31395. texture.generateMipMaps = generateMipMaps;
  31396. texture.samplingMode = samplingMode;
  31397. texture.type = type;
  31398. texture._generateDepthBuffer = generateDepthBuffer;
  31399. texture._generateStencilBuffer = generateStencilBuffer;
  31400. texture._attachments = attachments;
  31401. this._internalTexturesCache.push(texture);
  31402. }
  31403. if (generateDepthTexture && this._caps.depthTextureExtension) {
  31404. // Depth texture
  31405. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31406. gl.activeTexture(gl.TEXTURE0);
  31407. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  31408. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  31409. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  31410. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31411. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31412. 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);
  31413. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  31414. depthTexture._framebuffer = framebuffer;
  31415. depthTexture.baseWidth = width;
  31416. depthTexture.baseHeight = height;
  31417. depthTexture.width = width;
  31418. depthTexture.height = height;
  31419. depthTexture.isReady = true;
  31420. depthTexture.samples = 1;
  31421. depthTexture.generateMipMaps = generateMipMaps;
  31422. depthTexture.samplingMode = gl.NEAREST;
  31423. depthTexture._generateDepthBuffer = generateDepthBuffer;
  31424. depthTexture._generateStencilBuffer = generateStencilBuffer;
  31425. textures.push(depthTexture);
  31426. this._internalTexturesCache.push(depthTexture);
  31427. }
  31428. gl.drawBuffers(attachments);
  31429. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31430. this.bindUnboundFramebuffer(null);
  31431. this.resetTextureCache();
  31432. return textures;
  31433. };
  31434. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  31435. if (samples === void 0) { samples = 1; }
  31436. var depthStencilBuffer = null;
  31437. var gl = this._gl;
  31438. // Create the depth/stencil buffer
  31439. if (generateStencilBuffer) {
  31440. depthStencilBuffer = gl.createRenderbuffer();
  31441. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31442. if (samples > 1) {
  31443. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  31444. }
  31445. else {
  31446. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  31447. }
  31448. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31449. }
  31450. else if (generateDepthBuffer) {
  31451. depthStencilBuffer = gl.createRenderbuffer();
  31452. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31453. if (samples > 1) {
  31454. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31455. }
  31456. else {
  31457. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31458. }
  31459. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31460. }
  31461. return depthStencilBuffer;
  31462. };
  31463. /**
  31464. * Updates the sample count of a render target texture
  31465. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31466. * @param texture defines the texture to update
  31467. * @param samples defines the sample count to set
  31468. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31469. */
  31470. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31471. if (this.webGLVersion < 2 || !texture) {
  31472. return 1;
  31473. }
  31474. if (texture.samples === samples) {
  31475. return samples;
  31476. }
  31477. var gl = this._gl;
  31478. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31479. // Dispose previous render buffers
  31480. if (texture._depthStencilBuffer) {
  31481. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31482. texture._depthStencilBuffer = null;
  31483. }
  31484. if (texture._MSAAFramebuffer) {
  31485. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31486. texture._MSAAFramebuffer = null;
  31487. }
  31488. if (texture._MSAARenderBuffer) {
  31489. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31490. texture._MSAARenderBuffer = null;
  31491. }
  31492. if (samples > 1) {
  31493. var framebuffer = gl.createFramebuffer();
  31494. if (!framebuffer) {
  31495. throw new Error("Unable to create multi sampled framebuffer");
  31496. }
  31497. texture._MSAAFramebuffer = framebuffer;
  31498. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31499. var colorRenderbuffer = gl.createRenderbuffer();
  31500. if (!colorRenderbuffer) {
  31501. throw new Error("Unable to create multi sampled framebuffer");
  31502. }
  31503. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31504. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31505. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31506. texture._MSAARenderBuffer = colorRenderbuffer;
  31507. }
  31508. else {
  31509. this.bindUnboundFramebuffer(texture._framebuffer);
  31510. }
  31511. texture.samples = samples;
  31512. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31513. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31514. this.bindUnboundFramebuffer(null);
  31515. return samples;
  31516. };
  31517. /**
  31518. * Update the sample count for a given multiple render target texture
  31519. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31520. * @param textures defines the textures to update
  31521. * @param samples defines the sample count to set
  31522. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31523. */
  31524. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31525. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31526. return 1;
  31527. }
  31528. if (textures[0].samples === samples) {
  31529. return samples;
  31530. }
  31531. var gl = this._gl;
  31532. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31533. // Dispose previous render buffers
  31534. if (textures[0]._depthStencilBuffer) {
  31535. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31536. textures[0]._depthStencilBuffer = null;
  31537. }
  31538. if (textures[0]._MSAAFramebuffer) {
  31539. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31540. textures[0]._MSAAFramebuffer = null;
  31541. }
  31542. for (var i = 0; i < textures.length; i++) {
  31543. if (textures[i]._MSAARenderBuffer) {
  31544. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31545. textures[i]._MSAARenderBuffer = null;
  31546. }
  31547. }
  31548. if (samples > 1) {
  31549. var framebuffer = gl.createFramebuffer();
  31550. if (!framebuffer) {
  31551. throw new Error("Unable to create multi sampled framebuffer");
  31552. }
  31553. this.bindUnboundFramebuffer(framebuffer);
  31554. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31555. var attachments = [];
  31556. for (var i = 0; i < textures.length; i++) {
  31557. var texture = textures[i];
  31558. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31559. var colorRenderbuffer = gl.createRenderbuffer();
  31560. if (!colorRenderbuffer) {
  31561. throw new Error("Unable to create multi sampled framebuffer");
  31562. }
  31563. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31564. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31565. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31566. texture._MSAAFramebuffer = framebuffer;
  31567. texture._MSAARenderBuffer = colorRenderbuffer;
  31568. texture.samples = samples;
  31569. texture._depthStencilBuffer = depthStencilBuffer;
  31570. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31571. attachments.push(attachment);
  31572. }
  31573. gl.drawBuffers(attachments);
  31574. }
  31575. else {
  31576. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31577. }
  31578. this.bindUnboundFramebuffer(null);
  31579. return samples;
  31580. };
  31581. /** @hidden */
  31582. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31583. if (faceIndex === void 0) { faceIndex = 0; }
  31584. if (lod === void 0) { lod = 0; }
  31585. var gl = this._gl;
  31586. var target = gl.TEXTURE_2D;
  31587. if (texture.isCube) {
  31588. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31589. }
  31590. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31591. };
  31592. /** @hidden */
  31593. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31594. if (faceIndex === void 0) { faceIndex = 0; }
  31595. if (lod === void 0) { lod = 0; }
  31596. var gl = this._gl;
  31597. var textureType = this._getWebGLTextureType(texture.type);
  31598. var format = this._getInternalFormat(texture.format);
  31599. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31600. this._unpackFlipY(texture.invertY);
  31601. var target = gl.TEXTURE_2D;
  31602. if (texture.isCube) {
  31603. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31604. }
  31605. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31606. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31607. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31608. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31609. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31610. };
  31611. /** @hidden */
  31612. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31613. if (faceIndex === void 0) { faceIndex = 0; }
  31614. if (lod === void 0) { lod = 0; }
  31615. var gl = this._gl;
  31616. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31617. this._bindTextureDirectly(bindTarget, texture, true);
  31618. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31619. this._bindTextureDirectly(bindTarget, null, true);
  31620. };
  31621. /** @hidden */
  31622. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31623. if (faceIndex === void 0) { faceIndex = 0; }
  31624. if (lod === void 0) { lod = 0; }
  31625. var gl = this._gl;
  31626. var textureType = this._getWebGLTextureType(texture.type);
  31627. var format = this._getInternalFormat(texture.format);
  31628. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31629. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31630. this._bindTextureDirectly(bindTarget, texture, true);
  31631. this._unpackFlipY(texture.invertY);
  31632. var target = gl.TEXTURE_2D;
  31633. if (texture.isCube) {
  31634. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31635. }
  31636. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31637. this._bindTextureDirectly(bindTarget, null, true);
  31638. };
  31639. /**
  31640. * Creates a new render target cube texture
  31641. * @param size defines the size of the texture
  31642. * @param options defines the options used to create the texture
  31643. * @returns a new render target cube texture stored in an InternalTexture
  31644. */
  31645. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31646. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ generateMipMaps: true, generateDepthBuffer: true, generateStencilBuffer: false, type: Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode: Engine.TEXTURE_TRILINEAR_SAMPLINGMODE, format: Engine.TEXTUREFORMAT_RGBA }, options);
  31647. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31648. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31649. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31650. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31651. }
  31652. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31653. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31654. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31655. }
  31656. var gl = this._gl;
  31657. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31658. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31659. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31660. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31661. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31662. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31663. }
  31664. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31665. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31666. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31667. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31668. for (var face = 0; face < 6; face++) {
  31669. 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);
  31670. }
  31671. // Create the framebuffer
  31672. var framebuffer = gl.createFramebuffer();
  31673. this.bindUnboundFramebuffer(framebuffer);
  31674. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31675. // MipMaps
  31676. if (fullOptions.generateMipMaps) {
  31677. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31678. }
  31679. // Unbind
  31680. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31681. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31682. this.bindUnboundFramebuffer(null);
  31683. texture._framebuffer = framebuffer;
  31684. texture.width = size;
  31685. texture.height = size;
  31686. texture.isReady = true;
  31687. texture.isCube = true;
  31688. texture.samples = 1;
  31689. texture.generateMipMaps = fullOptions.generateMipMaps;
  31690. texture.samplingMode = fullOptions.samplingMode;
  31691. texture.type = fullOptions.type;
  31692. texture.format = fullOptions.format;
  31693. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31694. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31695. this._internalTexturesCache.push(texture);
  31696. return texture;
  31697. };
  31698. /**
  31699. * Creates a cube texture
  31700. * @param rootUrl defines the url where the files to load is located
  31701. * @param scene defines the current scene
  31702. * @param files defines the list of files to load (1 per face)
  31703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31704. * @param onLoad defines an optional callback raised when the texture is loaded
  31705. * @param onError defines an optional callback raised if there is an issue to load the texture
  31706. * @param format defines the format of the data
  31707. * @param forcedExtension defines the extension to use to pick the right loader
  31708. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31709. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31710. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31711. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31712. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31713. * @returns the cube texture as an InternalTexture
  31714. */
  31715. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31716. var _this = this;
  31717. if (onLoad === void 0) { onLoad = null; }
  31718. if (onError === void 0) { onError = null; }
  31719. if (forcedExtension === void 0) { forcedExtension = null; }
  31720. if (createPolynomials === void 0) { createPolynomials = false; }
  31721. if (lodScale === void 0) { lodScale = 0; }
  31722. if (lodOffset === void 0) { lodOffset = 0; }
  31723. if (fallback === void 0) { fallback = null; }
  31724. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31725. var gl = this._gl;
  31726. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31727. texture.isCube = true;
  31728. texture.url = rootUrl;
  31729. texture.generateMipMaps = !noMipmap;
  31730. texture._lodGenerationScale = lodScale;
  31731. texture._lodGenerationOffset = lodOffset;
  31732. if (!this._doNotHandleContextLost) {
  31733. texture._extension = forcedExtension;
  31734. texture._files = files;
  31735. }
  31736. var lastDot = rootUrl.lastIndexOf('.');
  31737. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31738. var loader = null;
  31739. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31740. var availableLoader = _a[_i];
  31741. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31742. loader = availableLoader;
  31743. break;
  31744. }
  31745. }
  31746. var onInternalError = function (request, exception) {
  31747. if (loader) {
  31748. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31749. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  31750. if (fallbackUrl) {
  31751. excludeLoaders.push(loader);
  31752. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31753. return;
  31754. }
  31755. }
  31756. if (onError && request) {
  31757. onError(request.status + " " + request.statusText, exception);
  31758. }
  31759. };
  31760. if (loader) {
  31761. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31762. var onloaddata = function (data) {
  31763. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31764. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31765. };
  31766. if (files && files.length === 6) {
  31767. if (loader.supportCascades) {
  31768. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31769. }
  31770. else if (onError) {
  31771. onError("Textures type does not support cascades.");
  31772. }
  31773. }
  31774. else {
  31775. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31776. }
  31777. }
  31778. else {
  31779. if (!files) {
  31780. throw new Error("Cannot load cubemap because files were not defined");
  31781. }
  31782. this._cascadeLoadImgs(scene, function (imgs) {
  31783. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31784. var height = width;
  31785. _this._prepareWorkingCanvas();
  31786. if (!_this._workingCanvas || !_this._workingContext) {
  31787. return;
  31788. }
  31789. _this._workingCanvas.width = width;
  31790. _this._workingCanvas.height = height;
  31791. var faces = [
  31792. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31793. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31794. ];
  31795. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31796. _this._unpackFlipY(false);
  31797. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  31798. for (var index = 0; index < faces.length; index++) {
  31799. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  31800. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31801. }
  31802. if (!noMipmap) {
  31803. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31804. }
  31805. _this._setCubeMapTextureParams(!noMipmap);
  31806. texture.width = width;
  31807. texture.height = height;
  31808. texture.isReady = true;
  31809. if (format) {
  31810. texture.format = format;
  31811. }
  31812. texture.onLoadedObservable.notifyObservers(texture);
  31813. texture.onLoadedObservable.clear();
  31814. if (onLoad) {
  31815. onLoad();
  31816. }
  31817. }, files, onError);
  31818. }
  31819. this._internalTexturesCache.push(texture);
  31820. return texture;
  31821. };
  31822. /**
  31823. * @hidden
  31824. */
  31825. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  31826. var gl = this._gl;
  31827. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31828. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  31829. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31830. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31831. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31832. // this.resetTextureCache();
  31833. };
  31834. /**
  31835. * Update a raw cube texture
  31836. * @param texture defines the texture to udpdate
  31837. * @param data defines the data to store
  31838. * @param format defines the data format
  31839. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31840. * @param invertY defines if data must be stored with Y axis inverted
  31841. * @param compression defines the compression used (null by default)
  31842. * @param level defines which level of the texture to update
  31843. */
  31844. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  31845. if (compression === void 0) { compression = null; }
  31846. if (level === void 0) { level = 0; }
  31847. texture._bufferViewArray = data;
  31848. texture.format = format;
  31849. texture.type = type;
  31850. texture.invertY = invertY;
  31851. texture._compression = compression;
  31852. var gl = this._gl;
  31853. var textureType = this._getWebGLTextureType(type);
  31854. var internalFormat = this._getInternalFormat(format);
  31855. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  31856. var needConversion = false;
  31857. if (internalFormat === gl.RGB) {
  31858. internalFormat = gl.RGBA;
  31859. needConversion = true;
  31860. }
  31861. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31862. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31863. if (texture.width % 4 !== 0) {
  31864. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  31865. }
  31866. // Data are known to be in +X +Y +Z -X -Y -Z
  31867. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31868. var faceData = data[faceIndex];
  31869. if (compression) {
  31870. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  31871. }
  31872. else {
  31873. if (needConversion) {
  31874. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  31875. }
  31876. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  31877. }
  31878. }
  31879. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31880. if (isPot && texture.generateMipMaps && level === 0) {
  31881. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31882. }
  31883. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31884. // this.resetTextureCache();
  31885. texture.isReady = true;
  31886. };
  31887. /**
  31888. * Creates a new raw cube texture
  31889. * @param data defines the array of data to use to create each face
  31890. * @param size defines the size of the textures
  31891. * @param format defines the format of the data
  31892. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31893. * @param generateMipMaps defines if the engine should generate the mip levels
  31894. * @param invertY defines if data must be stored with Y axis inverted
  31895. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31896. * @param compression defines the compression used (null by default)
  31897. * @returns the cube texture as an InternalTexture
  31898. */
  31899. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  31900. if (compression === void 0) { compression = null; }
  31901. var gl = this._gl;
  31902. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  31903. texture.isCube = true;
  31904. texture.format = format;
  31905. texture.type = type;
  31906. if (!this._doNotHandleContextLost) {
  31907. texture._bufferViewArray = data;
  31908. }
  31909. var textureType = this._getWebGLTextureType(type);
  31910. var internalFormat = this._getInternalFormat(format);
  31911. if (internalFormat === gl.RGB) {
  31912. internalFormat = gl.RGBA;
  31913. }
  31914. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  31915. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  31916. generateMipMaps = false;
  31917. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31918. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  31919. }
  31920. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  31921. generateMipMaps = false;
  31922. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31923. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  31924. }
  31925. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  31926. generateMipMaps = false;
  31927. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  31928. }
  31929. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  31930. generateMipMaps = false;
  31931. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  31932. }
  31933. var width = size;
  31934. var height = width;
  31935. texture.width = width;
  31936. texture.height = height;
  31937. // Double check on POT to generate Mips.
  31938. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31939. if (!isPot) {
  31940. generateMipMaps = false;
  31941. }
  31942. // Upload data if needed. The texture won't be ready until then.
  31943. if (data) {
  31944. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  31945. }
  31946. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31947. // Filters
  31948. if (data && generateMipMaps) {
  31949. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31950. }
  31951. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31952. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31953. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31954. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31955. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31956. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31957. texture.generateMipMaps = generateMipMaps;
  31958. return texture;
  31959. };
  31960. /**
  31961. * Creates a new raw cube texture from a specified url
  31962. * @param url defines the url where the data is located
  31963. * @param scene defines the current scene
  31964. * @param size defines the size of the textures
  31965. * @param format defines the format of the data
  31966. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31967. * @param noMipmap defines if the engine should avoid generating the mip levels
  31968. * @param callback defines a callback used to extract texture data from loaded data
  31969. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  31970. * @param onLoad defines a callback called when texture is loaded
  31971. * @param onError defines a callback called if there is an error
  31972. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31973. * @param invertY defines if data must be stored with Y axis inverted
  31974. * @returns the cube texture as an InternalTexture
  31975. */
  31976. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  31977. var _this = this;
  31978. if (onLoad === void 0) { onLoad = null; }
  31979. if (onError === void 0) { onError = null; }
  31980. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31981. if (invertY === void 0) { invertY = false; }
  31982. var gl = this._gl;
  31983. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  31984. scene._addPendingData(texture);
  31985. texture.url = url;
  31986. this._internalTexturesCache.push(texture);
  31987. var onerror = function (request, exception) {
  31988. scene._removePendingData(texture);
  31989. if (onError && request) {
  31990. onError(request.status + " " + request.statusText, exception);
  31991. }
  31992. };
  31993. var internalCallback = function (data) {
  31994. var width = texture.width;
  31995. var faceDataArrays = callback(data);
  31996. if (!faceDataArrays) {
  31997. return;
  31998. }
  31999. if (mipmapGenerator) {
  32000. var textureType = _this._getWebGLTextureType(type);
  32001. var internalFormat = _this._getInternalFormat(format);
  32002. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32003. var needConversion = false;
  32004. if (internalFormat === gl.RGB) {
  32005. internalFormat = gl.RGBA;
  32006. needConversion = true;
  32007. }
  32008. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32009. _this._unpackFlipY(false);
  32010. var mipData = mipmapGenerator(faceDataArrays);
  32011. for (var level = 0; level < mipData.length; level++) {
  32012. var mipSize = width >> level;
  32013. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32014. var mipFaceData = mipData[level][faceIndex];
  32015. if (needConversion) {
  32016. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32017. }
  32018. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32019. }
  32020. }
  32021. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32022. }
  32023. else {
  32024. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32025. }
  32026. texture.isReady = true;
  32027. // this.resetTextureCache();
  32028. scene._removePendingData(texture);
  32029. if (onLoad) {
  32030. onLoad();
  32031. }
  32032. };
  32033. this._loadFile(url, function (data) {
  32034. internalCallback(data);
  32035. }, undefined, scene.offlineProvider, true, onerror);
  32036. return texture;
  32037. };
  32038. /**
  32039. * Update a raw 3D texture
  32040. * @param texture defines the texture to update
  32041. * @param data defines the data to store
  32042. * @param format defines the data format
  32043. * @param invertY defines if data must be stored with Y axis inverted
  32044. * @param compression defines the used compression (can be null)
  32045. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32046. */
  32047. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32048. if (compression === void 0) { compression = null; }
  32049. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32050. var internalType = this._getWebGLTextureType(textureType);
  32051. var internalFormat = this._getInternalFormat(format);
  32052. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32053. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32054. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32055. if (!this._doNotHandleContextLost) {
  32056. texture._bufferView = data;
  32057. texture.format = format;
  32058. texture.invertY = invertY;
  32059. texture._compression = compression;
  32060. }
  32061. if (texture.width % 4 !== 0) {
  32062. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32063. }
  32064. if (compression && data) {
  32065. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32066. }
  32067. else {
  32068. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32069. }
  32070. if (texture.generateMipMaps) {
  32071. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32072. }
  32073. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32074. // this.resetTextureCache();
  32075. texture.isReady = true;
  32076. };
  32077. /**
  32078. * Creates a new raw 3D texture
  32079. * @param data defines the data used to create the texture
  32080. * @param width defines the width of the texture
  32081. * @param height defines the height of the texture
  32082. * @param depth defines the depth of the texture
  32083. * @param format defines the format of the texture
  32084. * @param generateMipMaps defines if the engine must generate mip levels
  32085. * @param invertY defines if data must be stored with Y axis inverted
  32086. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32087. * @param compression defines the compressed used (can be null)
  32088. * @param textureType defines the compressed used (can be null)
  32089. * @returns a new raw 3D texture (stored in an InternalTexture)
  32090. */
  32091. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32092. if (compression === void 0) { compression = null; }
  32093. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32094. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32095. texture.baseWidth = width;
  32096. texture.baseHeight = height;
  32097. texture.baseDepth = depth;
  32098. texture.width = width;
  32099. texture.height = height;
  32100. texture.depth = depth;
  32101. texture.format = format;
  32102. texture.type = textureType;
  32103. texture.generateMipMaps = generateMipMaps;
  32104. texture.samplingMode = samplingMode;
  32105. texture.is3D = true;
  32106. if (!this._doNotHandleContextLost) {
  32107. texture._bufferView = data;
  32108. }
  32109. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32110. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32111. // Filters
  32112. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32113. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32114. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32115. if (generateMipMaps) {
  32116. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32117. }
  32118. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32119. this._internalTexturesCache.push(texture);
  32120. return texture;
  32121. };
  32122. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32123. var gl = this._gl;
  32124. if (!gl) {
  32125. return;
  32126. }
  32127. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32128. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32129. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32130. if (!noMipmap && !isCompressed) {
  32131. gl.generateMipmap(gl.TEXTURE_2D);
  32132. }
  32133. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32134. // this.resetTextureCache();
  32135. if (scene) {
  32136. scene._removePendingData(texture);
  32137. }
  32138. texture.onLoadedObservable.notifyObservers(texture);
  32139. texture.onLoadedObservable.clear();
  32140. };
  32141. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32142. var _this = this;
  32143. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32144. var maxTextureSize = this.getCaps().maxTextureSize;
  32145. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32146. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32147. var gl = this._gl;
  32148. if (!gl) {
  32149. return;
  32150. }
  32151. if (!texture._webGLTexture) {
  32152. // this.resetTextureCache();
  32153. if (scene) {
  32154. scene._removePendingData(texture);
  32155. }
  32156. return;
  32157. }
  32158. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32159. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32160. texture.baseWidth = width;
  32161. texture.baseHeight = height;
  32162. texture.width = potWidth;
  32163. texture.height = potHeight;
  32164. texture.isReady = true;
  32165. if (processFunction(potWidth, potHeight, function () {
  32166. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32167. })) {
  32168. // Returning as texture needs extra async steps
  32169. return;
  32170. }
  32171. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32172. };
  32173. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32174. // Create new RGBA data container.
  32175. var rgbaData;
  32176. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32177. rgbaData = new Float32Array(width * height * 4);
  32178. }
  32179. else {
  32180. rgbaData = new Uint32Array(width * height * 4);
  32181. }
  32182. // Convert each pixel.
  32183. for (var x = 0; x < width; x++) {
  32184. for (var y = 0; y < height; y++) {
  32185. var index = (y * width + x) * 3;
  32186. var newIndex = (y * width + x) * 4;
  32187. // Map Old Value to new value.
  32188. rgbaData[newIndex + 0] = rgbData[index + 0];
  32189. rgbaData[newIndex + 1] = rgbData[index + 1];
  32190. rgbaData[newIndex + 2] = rgbData[index + 2];
  32191. // Add fully opaque alpha channel.
  32192. rgbaData[newIndex + 3] = 1;
  32193. }
  32194. }
  32195. return rgbaData;
  32196. };
  32197. /** @hidden */
  32198. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32199. var gl = this._gl;
  32200. if (texture._framebuffer) {
  32201. gl.deleteFramebuffer(texture._framebuffer);
  32202. texture._framebuffer = null;
  32203. }
  32204. if (texture._depthStencilBuffer) {
  32205. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32206. texture._depthStencilBuffer = null;
  32207. }
  32208. if (texture._MSAAFramebuffer) {
  32209. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32210. texture._MSAAFramebuffer = null;
  32211. }
  32212. if (texture._MSAARenderBuffer) {
  32213. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32214. texture._MSAARenderBuffer = null;
  32215. }
  32216. };
  32217. /** @hidden */
  32218. Engine.prototype._releaseTexture = function (texture) {
  32219. var gl = this._gl;
  32220. this._releaseFramebufferObjects(texture);
  32221. gl.deleteTexture(texture._webGLTexture);
  32222. // Unbind channels
  32223. this.unbindAllTextures();
  32224. var index = this._internalTexturesCache.indexOf(texture);
  32225. if (index !== -1) {
  32226. this._internalTexturesCache.splice(index, 1);
  32227. }
  32228. // Integrated fixed lod samplers.
  32229. if (texture._lodTextureHigh) {
  32230. texture._lodTextureHigh.dispose();
  32231. }
  32232. if (texture._lodTextureMid) {
  32233. texture._lodTextureMid.dispose();
  32234. }
  32235. if (texture._lodTextureLow) {
  32236. texture._lodTextureLow.dispose();
  32237. }
  32238. // Set output texture of post process to null if the texture has been released/disposed
  32239. this.scenes.forEach(function (scene) {
  32240. scene.postProcesses.forEach(function (postProcess) {
  32241. if (postProcess._outputTexture == texture) {
  32242. postProcess._outputTexture = null;
  32243. }
  32244. });
  32245. scene.cameras.forEach(function (camera) {
  32246. camera._postProcesses.forEach(function (postProcess) {
  32247. if (postProcess) {
  32248. if (postProcess._outputTexture == texture) {
  32249. postProcess._outputTexture = null;
  32250. }
  32251. }
  32252. });
  32253. });
  32254. });
  32255. };
  32256. Engine.prototype.setProgram = function (program) {
  32257. if (this._currentProgram !== program) {
  32258. this._gl.useProgram(program);
  32259. this._currentProgram = program;
  32260. }
  32261. };
  32262. /**
  32263. * Binds an effect to the webGL context
  32264. * @param effect defines the effect to bind
  32265. */
  32266. Engine.prototype.bindSamplers = function (effect) {
  32267. this.setProgram(effect.getProgram());
  32268. var samplers = effect.getSamplers();
  32269. for (var index = 0; index < samplers.length; index++) {
  32270. var uniform = effect.getUniform(samplers[index]);
  32271. if (uniform) {
  32272. this._boundUniforms[index] = uniform;
  32273. }
  32274. }
  32275. this._currentEffect = null;
  32276. };
  32277. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32278. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32279. return;
  32280. }
  32281. // Remove
  32282. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32283. // Bind last to it
  32284. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32285. // Bind to dummy
  32286. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32287. };
  32288. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32289. if (!internalTexture) {
  32290. return -1;
  32291. }
  32292. internalTexture._initialSlot = channel;
  32293. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32294. if (channel !== internalTexture._designatedSlot) {
  32295. this._textureCollisions.addCount(1, false);
  32296. }
  32297. }
  32298. else {
  32299. if (channel !== internalTexture._designatedSlot) {
  32300. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32301. return internalTexture._designatedSlot;
  32302. }
  32303. else {
  32304. // No slot for this texture, let's pick a new one (if we find a free slot)
  32305. if (this._nextFreeTextureSlots.length) {
  32306. return this._nextFreeTextureSlots[0];
  32307. }
  32308. // We need to recycle the oldest bound texture, sorry.
  32309. this._textureCollisions.addCount(1, false);
  32310. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  32311. }
  32312. }
  32313. }
  32314. return channel;
  32315. };
  32316. Engine.prototype._linkTrackers = function (previous, next) {
  32317. previous.next = next;
  32318. next.previous = previous;
  32319. };
  32320. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  32321. var currentSlot = internalTexture._designatedSlot;
  32322. if (currentSlot === -1) {
  32323. return -1;
  32324. }
  32325. internalTexture._designatedSlot = -1;
  32326. if (this.disableTextureBindingOptimization) {
  32327. return -1;
  32328. }
  32329. // Remove from bound list
  32330. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32331. // Free the slot
  32332. this._boundTexturesCache[currentSlot] = null;
  32333. this._nextFreeTextureSlots.push(currentSlot);
  32334. return currentSlot;
  32335. };
  32336. Engine.prototype._activateCurrentTexture = function () {
  32337. if (this._currentTextureChannel !== this._activeChannel) {
  32338. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  32339. this._currentTextureChannel = this._activeChannel;
  32340. }
  32341. };
  32342. /** @hidden */
  32343. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  32344. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  32345. if (force === void 0) { force = false; }
  32346. var wasPreviouslyBound = false;
  32347. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  32348. this._activeChannel = texture._designatedSlot;
  32349. }
  32350. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  32351. var isTextureForRendering = texture && texture._initialSlot > -1;
  32352. if (currentTextureBound !== texture || force) {
  32353. if (currentTextureBound) {
  32354. this._removeDesignatedSlot(currentTextureBound);
  32355. }
  32356. this._activateCurrentTexture();
  32357. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  32358. this._boundTexturesCache[this._activeChannel] = texture;
  32359. if (texture) {
  32360. if (!this.disableTextureBindingOptimization) {
  32361. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  32362. if (slotIndex > -1) {
  32363. this._nextFreeTextureSlots.splice(slotIndex, 1);
  32364. }
  32365. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  32366. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  32367. }
  32368. texture._designatedSlot = this._activeChannel;
  32369. }
  32370. }
  32371. else if (forTextureDataUpdate) {
  32372. wasPreviouslyBound = true;
  32373. this._activateCurrentTexture();
  32374. }
  32375. if (isTextureForRendering && !forTextureDataUpdate) {
  32376. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  32377. }
  32378. return wasPreviouslyBound;
  32379. };
  32380. /** @hidden */
  32381. Engine.prototype._bindTexture = function (channel, texture) {
  32382. if (channel < 0) {
  32383. return;
  32384. }
  32385. if (texture) {
  32386. channel = this._getCorrectTextureChannel(channel, texture);
  32387. }
  32388. this._activeChannel = channel;
  32389. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  32390. };
  32391. /**
  32392. * Sets a texture to the webGL context from a postprocess
  32393. * @param channel defines the channel to use
  32394. * @param postProcess defines the source postprocess
  32395. */
  32396. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  32397. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  32398. };
  32399. /**
  32400. * Binds the output of the passed in post process to the texture channel specified
  32401. * @param channel The channel the texture should be bound to
  32402. * @param postProcess The post process which's output should be bound
  32403. */
  32404. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  32405. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  32406. };
  32407. /**
  32408. * Unbind all textures from the webGL context
  32409. */
  32410. Engine.prototype.unbindAllTextures = function () {
  32411. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  32412. this._activeChannel = channel;
  32413. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32414. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32415. if (this.webGLVersion > 1) {
  32416. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32417. }
  32418. }
  32419. };
  32420. /**
  32421. * Sets a texture to the according uniform.
  32422. * @param channel The texture channel
  32423. * @param uniform The uniform to set
  32424. * @param texture The texture to apply
  32425. */
  32426. Engine.prototype.setTexture = function (channel, uniform, texture) {
  32427. if (channel < 0) {
  32428. return;
  32429. }
  32430. if (uniform) {
  32431. this._boundUniforms[channel] = uniform;
  32432. }
  32433. this._setTexture(channel, texture);
  32434. };
  32435. /**
  32436. * Sets a depth stencil texture from a render target to the according uniform.
  32437. * @param channel The texture channel
  32438. * @param uniform The uniform to set
  32439. * @param texture The render target texture containing the depth stencil texture to apply
  32440. */
  32441. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  32442. if (channel < 0) {
  32443. return;
  32444. }
  32445. if (uniform) {
  32446. this._boundUniforms[channel] = uniform;
  32447. }
  32448. if (!texture || !texture.depthStencilTexture) {
  32449. this._setTexture(channel, null);
  32450. }
  32451. else {
  32452. this._setTexture(channel, texture, false, true);
  32453. }
  32454. };
  32455. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32456. var uniform = this._boundUniforms[sourceSlot];
  32457. if (uniform._currentState === destination) {
  32458. return;
  32459. }
  32460. this._gl.uniform1i(uniform, destination);
  32461. uniform._currentState = destination;
  32462. };
  32463. Engine.prototype._getTextureWrapMode = function (mode) {
  32464. switch (mode) {
  32465. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32466. return this._gl.REPEAT;
  32467. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32468. return this._gl.CLAMP_TO_EDGE;
  32469. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32470. return this._gl.MIRRORED_REPEAT;
  32471. }
  32472. return this._gl.REPEAT;
  32473. };
  32474. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32475. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32476. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32477. // Not ready?
  32478. if (!texture) {
  32479. if (this._boundTexturesCache[channel] != null) {
  32480. this._activeChannel = channel;
  32481. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32482. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32483. if (this.webGLVersion > 1) {
  32484. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32485. }
  32486. }
  32487. return false;
  32488. }
  32489. // Video
  32490. if (texture.video) {
  32491. this._activeChannel = channel;
  32492. texture.update();
  32493. }
  32494. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32495. texture.delayLoad();
  32496. return false;
  32497. }
  32498. var internalTexture;
  32499. if (depthStencilTexture) {
  32500. internalTexture = texture.depthStencilTexture;
  32501. }
  32502. else if (texture.isReady()) {
  32503. internalTexture = texture.getInternalTexture();
  32504. }
  32505. else if (texture.isCube) {
  32506. internalTexture = this.emptyCubeTexture;
  32507. }
  32508. else if (texture.is3D) {
  32509. internalTexture = this.emptyTexture3D;
  32510. }
  32511. else {
  32512. internalTexture = this.emptyTexture;
  32513. }
  32514. if (!isPartOfTextureArray) {
  32515. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32516. }
  32517. var needToBind = true;
  32518. if (this._boundTexturesCache[channel] === internalTexture) {
  32519. this._moveBoundTextureOnTop(internalTexture);
  32520. if (!isPartOfTextureArray) {
  32521. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32522. }
  32523. needToBind = false;
  32524. }
  32525. this._activeChannel = channel;
  32526. if (internalTexture && internalTexture.is3D) {
  32527. if (needToBind) {
  32528. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32529. }
  32530. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32531. internalTexture._cachedWrapU = texture.wrapU;
  32532. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32533. }
  32534. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32535. internalTexture._cachedWrapV = texture.wrapV;
  32536. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32537. }
  32538. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32539. internalTexture._cachedWrapR = texture.wrapR;
  32540. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32541. }
  32542. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32543. }
  32544. else if (internalTexture && internalTexture.isCube) {
  32545. if (needToBind) {
  32546. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32547. }
  32548. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32549. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32550. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32551. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32552. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32553. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32554. }
  32555. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32556. }
  32557. else {
  32558. if (needToBind) {
  32559. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32560. }
  32561. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32562. internalTexture._cachedWrapU = texture.wrapU;
  32563. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32564. }
  32565. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32566. internalTexture._cachedWrapV = texture.wrapV;
  32567. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32568. }
  32569. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32570. }
  32571. return true;
  32572. };
  32573. /**
  32574. * Sets an array of texture to the webGL context
  32575. * @param channel defines the channel where the texture array must be set
  32576. * @param uniform defines the associated uniform location
  32577. * @param textures defines the array of textures to bind
  32578. */
  32579. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32580. if (channel < 0 || !uniform) {
  32581. return;
  32582. }
  32583. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32584. this._textureUnits = new Int32Array(textures.length);
  32585. }
  32586. for (var i = 0; i < textures.length; i++) {
  32587. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32588. }
  32589. this._gl.uniform1iv(uniform, this._textureUnits);
  32590. for (var index = 0; index < textures.length; index++) {
  32591. this._setTexture(this._textureUnits[index], textures[index], true);
  32592. }
  32593. };
  32594. /** @hidden */
  32595. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32596. var internalTexture = texture.getInternalTexture();
  32597. if (!internalTexture) {
  32598. return;
  32599. }
  32600. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32601. var value = texture.anisotropicFilteringLevel;
  32602. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32603. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32604. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32605. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32606. }
  32607. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32608. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32609. internalTexture._cachedAnisotropicFilteringLevel = value;
  32610. }
  32611. };
  32612. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32613. this._bindTextureDirectly(target, texture, true, true);
  32614. this._gl.texParameterf(target, parameter, value);
  32615. };
  32616. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32617. if (texture) {
  32618. this._bindTextureDirectly(target, texture, true, true);
  32619. }
  32620. this._gl.texParameteri(target, parameter, value);
  32621. };
  32622. /**
  32623. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32624. * @param x defines the x coordinate of the rectangle where pixels must be read
  32625. * @param y defines the y coordinate of the rectangle where pixels must be read
  32626. * @param width defines the width of the rectangle where pixels must be read
  32627. * @param height defines the height of the rectangle where pixels must be read
  32628. * @returns a Uint8Array containing RGBA colors
  32629. */
  32630. Engine.prototype.readPixels = function (x, y, width, height) {
  32631. var data = new Uint8Array(height * width * 4);
  32632. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32633. return data;
  32634. };
  32635. /**
  32636. * Add an externaly attached data from its key.
  32637. * This method call will fail and return false, if such key already exists.
  32638. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32639. * @param key the unique key that identifies the data
  32640. * @param data the data object to associate to the key for this Engine instance
  32641. * @return true if no such key were already present and the data was added successfully, false otherwise
  32642. */
  32643. Engine.prototype.addExternalData = function (key, data) {
  32644. if (!this._externalData) {
  32645. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32646. }
  32647. return this._externalData.add(key, data);
  32648. };
  32649. /**
  32650. * Get an externaly attached data from its key
  32651. * @param key the unique key that identifies the data
  32652. * @return the associated data, if present (can be null), or undefined if not present
  32653. */
  32654. Engine.prototype.getExternalData = function (key) {
  32655. if (!this._externalData) {
  32656. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32657. }
  32658. return this._externalData.get(key);
  32659. };
  32660. /**
  32661. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32662. * @param key the unique key that identifies the data
  32663. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32664. * @return the associated data, can be null if the factory returned null.
  32665. */
  32666. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32667. if (!this._externalData) {
  32668. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32669. }
  32670. return this._externalData.getOrAddWithFactory(key, factory);
  32671. };
  32672. /**
  32673. * Remove an externaly attached data from the Engine instance
  32674. * @param key the unique key that identifies the data
  32675. * @return true if the data was successfully removed, false if it doesn't exist
  32676. */
  32677. Engine.prototype.removeExternalData = function (key) {
  32678. if (!this._externalData) {
  32679. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32680. }
  32681. return this._externalData.remove(key);
  32682. };
  32683. /**
  32684. * Unbind all vertex attributes from the webGL context
  32685. */
  32686. Engine.prototype.unbindAllAttributes = function () {
  32687. if (this._mustWipeVertexAttributes) {
  32688. this._mustWipeVertexAttributes = false;
  32689. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32690. this._gl.disableVertexAttribArray(i);
  32691. this._vertexAttribArraysEnabled[i] = false;
  32692. this._currentBufferPointers[i].active = false;
  32693. }
  32694. return;
  32695. }
  32696. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32697. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32698. continue;
  32699. }
  32700. this._gl.disableVertexAttribArray(i);
  32701. this._vertexAttribArraysEnabled[i] = false;
  32702. this._currentBufferPointers[i].active = false;
  32703. }
  32704. };
  32705. /**
  32706. * 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
  32707. */
  32708. Engine.prototype.releaseEffects = function () {
  32709. for (var name in this._compiledEffects) {
  32710. this._deleteProgram(this._compiledEffects[name]._program);
  32711. }
  32712. this._compiledEffects = {};
  32713. };
  32714. /**
  32715. * Dispose and release all associated resources
  32716. */
  32717. Engine.prototype.dispose = function () {
  32718. this.hideLoadingUI();
  32719. this.stopRenderLoop();
  32720. this.onNewSceneAddedObservable.clear();
  32721. // Release postProcesses
  32722. while (this.postProcesses.length) {
  32723. this.postProcesses[0].dispose();
  32724. }
  32725. // Empty texture
  32726. if (this._emptyTexture) {
  32727. this._releaseTexture(this._emptyTexture);
  32728. this._emptyTexture = null;
  32729. }
  32730. if (this._emptyCubeTexture) {
  32731. this._releaseTexture(this._emptyCubeTexture);
  32732. this._emptyCubeTexture = null;
  32733. }
  32734. // Rescale PP
  32735. if (this._rescalePostProcess) {
  32736. this._rescalePostProcess.dispose();
  32737. }
  32738. // Release scenes
  32739. while (this.scenes.length) {
  32740. this.scenes[0].dispose();
  32741. }
  32742. // Release audio engine
  32743. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32744. Engine.audioEngine.dispose();
  32745. }
  32746. // Release effects
  32747. this.releaseEffects();
  32748. // Unbind
  32749. this.unbindAllAttributes();
  32750. this._boundUniforms = [];
  32751. if (this._dummyFramebuffer) {
  32752. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32753. }
  32754. //WebVR
  32755. this.disableVR();
  32756. // Events
  32757. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32758. window.removeEventListener("blur", this._onBlur);
  32759. window.removeEventListener("focus", this._onFocus);
  32760. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32761. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32762. if (this._renderingCanvas) {
  32763. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32764. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32765. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32766. if (!this._doNotHandleContextLost) {
  32767. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32768. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32769. }
  32770. }
  32771. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32772. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32773. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32774. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32775. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32776. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32777. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32778. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32779. if (this._onVrDisplayConnect) {
  32780. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32781. if (this._onVrDisplayDisconnect) {
  32782. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32783. }
  32784. if (this._onVrDisplayPresentChange) {
  32785. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32786. }
  32787. this._onVrDisplayConnect = null;
  32788. this._onVrDisplayDisconnect = null;
  32789. }
  32790. }
  32791. // Remove from Instances
  32792. var index = Engine.Instances.indexOf(this);
  32793. if (index >= 0) {
  32794. Engine.Instances.splice(index, 1);
  32795. }
  32796. this._workingCanvas = null;
  32797. this._workingContext = null;
  32798. this._currentBufferPointers = [];
  32799. this._renderingCanvas = null;
  32800. this._currentProgram = null;
  32801. this._bindedRenderFunction = null;
  32802. this.onResizeObservable.clear();
  32803. this.onCanvasBlurObservable.clear();
  32804. this.onCanvasFocusObservable.clear();
  32805. this.onCanvasPointerOutObservable.clear();
  32806. this.onBeginFrameObservable.clear();
  32807. this.onEndFrameObservable.clear();
  32808. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  32809. // Abort active requests
  32810. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  32811. var request = _a[_i];
  32812. request.abort();
  32813. }
  32814. };
  32815. // Loading screen
  32816. /**
  32817. * Display the loading screen
  32818. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32819. */
  32820. Engine.prototype.displayLoadingUI = function () {
  32821. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32822. return;
  32823. }
  32824. var loadingScreen = this.loadingScreen;
  32825. if (loadingScreen) {
  32826. loadingScreen.displayLoadingUI();
  32827. }
  32828. };
  32829. /**
  32830. * Hide the loading screen
  32831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32832. */
  32833. Engine.prototype.hideLoadingUI = function () {
  32834. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32835. return;
  32836. }
  32837. var loadingScreen = this.loadingScreen;
  32838. if (loadingScreen) {
  32839. loadingScreen.hideLoadingUI();
  32840. }
  32841. };
  32842. Object.defineProperty(Engine.prototype, "loadingScreen", {
  32843. /**
  32844. * Gets the current loading screen object
  32845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32846. */
  32847. get: function () {
  32848. if (!this._loadingScreen && this._renderingCanvas) {
  32849. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  32850. }
  32851. return this._loadingScreen;
  32852. },
  32853. /**
  32854. * Sets the current loading screen object
  32855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32856. */
  32857. set: function (loadingScreen) {
  32858. this._loadingScreen = loadingScreen;
  32859. },
  32860. enumerable: true,
  32861. configurable: true
  32862. });
  32863. Object.defineProperty(Engine.prototype, "loadingUIText", {
  32864. /**
  32865. * Sets the current loading screen text
  32866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32867. */
  32868. set: function (text) {
  32869. this.loadingScreen.loadingUIText = text;
  32870. },
  32871. enumerable: true,
  32872. configurable: true
  32873. });
  32874. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  32875. /**
  32876. * Sets the current loading screen background color
  32877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32878. */
  32879. set: function (color) {
  32880. this.loadingScreen.loadingUIBackgroundColor = color;
  32881. },
  32882. enumerable: true,
  32883. configurable: true
  32884. });
  32885. /**
  32886. * Attach a new callback raised when context lost event is fired
  32887. * @param callback defines the callback to call
  32888. */
  32889. Engine.prototype.attachContextLostEvent = function (callback) {
  32890. if (this._renderingCanvas) {
  32891. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  32892. }
  32893. };
  32894. /**
  32895. * Attach a new callback raised when context restored event is fired
  32896. * @param callback defines the callback to call
  32897. */
  32898. Engine.prototype.attachContextRestoredEvent = function (callback) {
  32899. if (this._renderingCanvas) {
  32900. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  32901. }
  32902. };
  32903. /**
  32904. * Gets the source code of the vertex shader associated with a specific webGL program
  32905. * @param program defines the program to use
  32906. * @returns a string containing the source code of the vertex shader associated with the program
  32907. */
  32908. Engine.prototype.getVertexShaderSource = function (program) {
  32909. var shaders = this._gl.getAttachedShaders(program);
  32910. if (!shaders) {
  32911. return null;
  32912. }
  32913. return this._gl.getShaderSource(shaders[0]);
  32914. };
  32915. /**
  32916. * Gets the source code of the fragment shader associated with a specific webGL program
  32917. * @param program defines the program to use
  32918. * @returns a string containing the source code of the fragment shader associated with the program
  32919. */
  32920. Engine.prototype.getFragmentShaderSource = function (program) {
  32921. var shaders = this._gl.getAttachedShaders(program);
  32922. if (!shaders) {
  32923. return null;
  32924. }
  32925. return this._gl.getShaderSource(shaders[1]);
  32926. };
  32927. /**
  32928. * Get the current error code of the webGL context
  32929. * @returns the error code
  32930. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32931. */
  32932. Engine.prototype.getError = function () {
  32933. return this._gl.getError();
  32934. };
  32935. // FPS
  32936. /**
  32937. * Gets the current framerate
  32938. * @returns a number representing the framerate
  32939. */
  32940. Engine.prototype.getFps = function () {
  32941. return this._fps;
  32942. };
  32943. /**
  32944. * Gets the time spent between current and previous frame
  32945. * @returns a number representing the delta time in ms
  32946. */
  32947. Engine.prototype.getDeltaTime = function () {
  32948. return this._deltaTime;
  32949. };
  32950. Engine.prototype._measureFps = function () {
  32951. this._performanceMonitor.sampleFrame();
  32952. this._fps = this._performanceMonitor.averageFPS;
  32953. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  32954. };
  32955. /** @hidden */
  32956. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  32957. if (faceIndex === void 0) { faceIndex = -1; }
  32958. if (level === void 0) { level = 0; }
  32959. if (buffer === void 0) { buffer = null; }
  32960. var gl = this._gl;
  32961. if (!this._dummyFramebuffer) {
  32962. var dummy = gl.createFramebuffer();
  32963. if (!dummy) {
  32964. throw new Error("Unable to create dummy framebuffer");
  32965. }
  32966. this._dummyFramebuffer = dummy;
  32967. }
  32968. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  32969. if (faceIndex > -1) {
  32970. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  32971. }
  32972. else {
  32973. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  32974. }
  32975. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  32976. switch (readType) {
  32977. case gl.UNSIGNED_BYTE:
  32978. if (!buffer) {
  32979. buffer = new Uint8Array(4 * width * height);
  32980. }
  32981. readType = gl.UNSIGNED_BYTE;
  32982. break;
  32983. default:
  32984. if (!buffer) {
  32985. buffer = new Float32Array(4 * width * height);
  32986. }
  32987. readType = gl.FLOAT;
  32988. break;
  32989. }
  32990. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  32991. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  32992. return buffer;
  32993. };
  32994. Engine.prototype._canRenderToFloatFramebuffer = function () {
  32995. if (this._webGLVersion > 1) {
  32996. return this._caps.colorBufferFloat;
  32997. }
  32998. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  32999. };
  33000. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33001. if (this._webGLVersion > 1) {
  33002. return this._caps.colorBufferFloat;
  33003. }
  33004. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33005. };
  33006. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33007. Engine.prototype._canRenderToFramebuffer = function (type) {
  33008. var gl = this._gl;
  33009. //clear existing errors
  33010. while (gl.getError() !== gl.NO_ERROR) { }
  33011. var successful = true;
  33012. var texture = gl.createTexture();
  33013. gl.bindTexture(gl.TEXTURE_2D, texture);
  33014. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33015. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33016. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33017. var fb = gl.createFramebuffer();
  33018. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33019. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33020. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33021. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33022. successful = successful && (gl.getError() === gl.NO_ERROR);
  33023. //try render by clearing frame buffer's color buffer
  33024. if (successful) {
  33025. gl.clear(gl.COLOR_BUFFER_BIT);
  33026. successful = successful && (gl.getError() === gl.NO_ERROR);
  33027. }
  33028. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33029. if (successful) {
  33030. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33031. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33032. var readFormat = gl.RGBA;
  33033. var readType = gl.UNSIGNED_BYTE;
  33034. var buffer = new Uint8Array(4);
  33035. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33036. successful = successful && (gl.getError() === gl.NO_ERROR);
  33037. }
  33038. //clean up
  33039. gl.deleteTexture(texture);
  33040. gl.deleteFramebuffer(fb);
  33041. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33042. //clear accumulated errors
  33043. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33044. return successful;
  33045. };
  33046. /** @hidden */
  33047. Engine.prototype._getWebGLTextureType = function (type) {
  33048. if (this._webGLVersion === 1) {
  33049. switch (type) {
  33050. case Engine.TEXTURETYPE_FLOAT:
  33051. return this._gl.FLOAT;
  33052. case Engine.TEXTURETYPE_HALF_FLOAT:
  33053. return this._gl.HALF_FLOAT_OES;
  33054. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33055. return this._gl.UNSIGNED_BYTE;
  33056. }
  33057. return this._gl.UNSIGNED_BYTE;
  33058. }
  33059. switch (type) {
  33060. case Engine.TEXTURETYPE_BYTE:
  33061. return this._gl.BYTE;
  33062. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33063. return this._gl.UNSIGNED_BYTE;
  33064. case Engine.TEXTURETYPE_SHORT:
  33065. return this._gl.SHORT;
  33066. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33067. return this._gl.UNSIGNED_SHORT;
  33068. case Engine.TEXTURETYPE_INT:
  33069. return this._gl.INT;
  33070. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33071. return this._gl.UNSIGNED_INT;
  33072. case Engine.TEXTURETYPE_FLOAT:
  33073. return this._gl.FLOAT;
  33074. case Engine.TEXTURETYPE_HALF_FLOAT:
  33075. return this._gl.HALF_FLOAT;
  33076. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33077. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33078. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33079. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33080. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33081. return this._gl.UNSIGNED_SHORT_5_6_5;
  33082. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33083. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33084. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33085. return this._gl.UNSIGNED_INT_24_8;
  33086. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33087. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33088. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33089. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33090. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33091. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33092. }
  33093. return this._gl.UNSIGNED_BYTE;
  33094. };
  33095. Engine.prototype._getInternalFormat = function (format) {
  33096. var internalFormat = this._gl.RGBA;
  33097. switch (format) {
  33098. case Engine.TEXTUREFORMAT_ALPHA:
  33099. internalFormat = this._gl.ALPHA;
  33100. break;
  33101. case Engine.TEXTUREFORMAT_LUMINANCE:
  33102. internalFormat = this._gl.LUMINANCE;
  33103. break;
  33104. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33105. internalFormat = this._gl.LUMINANCE_ALPHA;
  33106. break;
  33107. case Engine.TEXTUREFORMAT_RED:
  33108. internalFormat = this._gl.RED;
  33109. break;
  33110. case Engine.TEXTUREFORMAT_RG:
  33111. internalFormat = this._gl.RG;
  33112. break;
  33113. case Engine.TEXTUREFORMAT_RGB:
  33114. internalFormat = this._gl.RGB;
  33115. break;
  33116. case Engine.TEXTUREFORMAT_RGBA:
  33117. internalFormat = this._gl.RGBA;
  33118. break;
  33119. }
  33120. if (this._webGLVersion > 1) {
  33121. switch (format) {
  33122. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33123. internalFormat = this._gl.RED_INTEGER;
  33124. break;
  33125. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33126. internalFormat = this._gl.RG_INTEGER;
  33127. break;
  33128. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33129. internalFormat = this._gl.RGB_INTEGER;
  33130. break;
  33131. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33132. internalFormat = this._gl.RGBA_INTEGER;
  33133. break;
  33134. }
  33135. }
  33136. return internalFormat;
  33137. };
  33138. /** @hidden */
  33139. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33140. if (this._webGLVersion === 1) {
  33141. if (format !== undefined) {
  33142. switch (format) {
  33143. case Engine.TEXTUREFORMAT_ALPHA:
  33144. return this._gl.ALPHA;
  33145. case Engine.TEXTUREFORMAT_LUMINANCE:
  33146. return this._gl.LUMINANCE;
  33147. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33148. return this._gl.LUMINANCE_ALPHA;
  33149. }
  33150. }
  33151. return this._gl.RGBA;
  33152. }
  33153. switch (type) {
  33154. case Engine.TEXTURETYPE_BYTE:
  33155. switch (format) {
  33156. case Engine.TEXTUREFORMAT_RED:
  33157. return this._gl.R8_SNORM;
  33158. case Engine.TEXTUREFORMAT_RG:
  33159. return this._gl.RG8_SNORM;
  33160. case Engine.TEXTUREFORMAT_RGB:
  33161. return this._gl.RGB8_SNORM;
  33162. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33163. return this._gl.R8I;
  33164. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33165. return this._gl.RG8I;
  33166. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33167. return this._gl.RGB8I;
  33168. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33169. return this._gl.RGBA8I;
  33170. default:
  33171. return this._gl.RGBA8_SNORM;
  33172. }
  33173. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33174. switch (format) {
  33175. case Engine.TEXTUREFORMAT_RED:
  33176. return this._gl.R8;
  33177. case Engine.TEXTUREFORMAT_RG:
  33178. return this._gl.RG8;
  33179. case Engine.TEXTUREFORMAT_RGB:
  33180. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33181. case Engine.TEXTUREFORMAT_RGBA:
  33182. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33183. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33184. return this._gl.R8UI;
  33185. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33186. return this._gl.RG8UI;
  33187. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33188. return this._gl.RGB8UI;
  33189. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33190. return this._gl.RGBA8UI;
  33191. default:
  33192. return this._gl.RGBA8;
  33193. }
  33194. case Engine.TEXTURETYPE_SHORT:
  33195. switch (format) {
  33196. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33197. return this._gl.R16I;
  33198. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33199. return this._gl.RG16I;
  33200. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33201. return this._gl.RGB16I;
  33202. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33203. return this._gl.RGBA16I;
  33204. default:
  33205. return this._gl.RGBA16I;
  33206. }
  33207. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33208. switch (format) {
  33209. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33210. return this._gl.R16UI;
  33211. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33212. return this._gl.RG16UI;
  33213. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33214. return this._gl.RGB16UI;
  33215. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33216. return this._gl.RGBA16UI;
  33217. default:
  33218. return this._gl.RGBA16UI;
  33219. }
  33220. case Engine.TEXTURETYPE_INT:
  33221. switch (format) {
  33222. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33223. return this._gl.R32I;
  33224. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33225. return this._gl.RG32I;
  33226. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33227. return this._gl.RGB32I;
  33228. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33229. return this._gl.RGBA32I;
  33230. default:
  33231. return this._gl.RGBA32I;
  33232. }
  33233. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33234. switch (format) {
  33235. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33236. return this._gl.R32UI;
  33237. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33238. return this._gl.RG32UI;
  33239. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33240. return this._gl.RGB32UI;
  33241. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33242. return this._gl.RGBA32UI;
  33243. default:
  33244. return this._gl.RGBA32UI;
  33245. }
  33246. case Engine.TEXTURETYPE_FLOAT:
  33247. switch (format) {
  33248. case Engine.TEXTUREFORMAT_RED:
  33249. return this._gl.R32F; // By default. Other possibility is R16F.
  33250. case Engine.TEXTUREFORMAT_RG:
  33251. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33252. case Engine.TEXTUREFORMAT_RGB:
  33253. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33254. case Engine.TEXTUREFORMAT_RGBA:
  33255. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33256. default:
  33257. return this._gl.RGBA32F;
  33258. }
  33259. case Engine.TEXTURETYPE_HALF_FLOAT:
  33260. switch (format) {
  33261. case Engine.TEXTUREFORMAT_RED:
  33262. return this._gl.R16F;
  33263. case Engine.TEXTUREFORMAT_RG:
  33264. return this._gl.RG16F;
  33265. case Engine.TEXTUREFORMAT_RGB:
  33266. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33267. case Engine.TEXTUREFORMAT_RGBA:
  33268. return this._gl.RGBA16F;
  33269. default:
  33270. return this._gl.RGBA16F;
  33271. }
  33272. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33273. return this._gl.RGB565;
  33274. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33275. return this._gl.R11F_G11F_B10F;
  33276. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33277. return this._gl.RGB9_E5;
  33278. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33279. return this._gl.RGBA4;
  33280. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33281. return this._gl.RGB5_A1;
  33282. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33283. switch (format) {
  33284. case Engine.TEXTUREFORMAT_RGBA:
  33285. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33286. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33287. return this._gl.RGB10_A2UI;
  33288. default:
  33289. return this._gl.RGB10_A2;
  33290. }
  33291. }
  33292. return this._gl.RGBA8;
  33293. };
  33294. /** @hidden */
  33295. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33296. if (type === Engine.TEXTURETYPE_FLOAT) {
  33297. return this._gl.RGBA32F;
  33298. }
  33299. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33300. return this._gl.RGBA16F;
  33301. }
  33302. return this._gl.RGBA8;
  33303. };
  33304. /** @hidden */
  33305. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  33306. var _this = this;
  33307. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  33308. this._activeRequests.push(request);
  33309. request.onCompleteObservable.add(function (request) {
  33310. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  33311. });
  33312. return request;
  33313. };
  33314. /** @hidden */
  33315. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  33316. var _this = this;
  33317. return new Promise(function (resolve, reject) {
  33318. _this._loadFile(url, function (data) {
  33319. resolve(data);
  33320. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  33321. reject(exception);
  33322. });
  33323. });
  33324. };
  33325. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  33326. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  33327. var onload = function (data) {
  33328. loadedFiles[index] = data;
  33329. loadedFiles._internalCount++;
  33330. if (loadedFiles._internalCount === 6) {
  33331. onfinish(loadedFiles);
  33332. }
  33333. };
  33334. var onerror = function (request, exception) {
  33335. if (onErrorCallBack && request) {
  33336. onErrorCallBack(request.status + " " + request.statusText, exception);
  33337. }
  33338. };
  33339. this._loadFile(url, onload, undefined, undefined, true, onerror);
  33340. };
  33341. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  33342. if (onError === void 0) { onError = null; }
  33343. var loadedFiles = [];
  33344. loadedFiles._internalCount = 0;
  33345. for (var index = 0; index < 6; index++) {
  33346. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  33347. }
  33348. };
  33349. // Statics
  33350. /**
  33351. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33352. * @returns true if the engine can be created
  33353. * @ignorenaming
  33354. */
  33355. Engine.isSupported = function () {
  33356. try {
  33357. var tempcanvas = document.createElement("canvas");
  33358. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  33359. return gl != null && !!window.WebGLRenderingContext;
  33360. }
  33361. catch (e) {
  33362. return false;
  33363. }
  33364. };
  33365. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33366. Engine.ExceptionList = [
  33367. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  33368. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33369. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33370. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33371. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33372. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  33373. ];
  33374. /**
  33375. * Hidden
  33376. */
  33377. Engine._TextureLoaders = [];
  33378. // Const statics
  33379. /** Defines that alpha blending is disabled */
  33380. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  33381. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33382. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  33383. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33384. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  33385. /** Defines that alpha blending to DEST - SRC * DEST */
  33386. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  33387. /** Defines that alpha blending to SRC * DEST */
  33388. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  33389. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33390. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  33391. /** Defines that alpha blending to SRC + DEST */
  33392. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  33393. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33394. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  33395. /**
  33396. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33397. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33398. */
  33399. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  33400. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33401. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  33402. /**
  33403. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33404. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33405. */
  33406. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  33407. /** Defines that the ressource is not delayed*/
  33408. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  33409. /** Defines that the ressource was successfully delay loaded */
  33410. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  33411. /** Defines that the ressource is currently delay loading */
  33412. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  33413. /** Defines that the ressource is delayed and has not started loading */
  33414. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  33415. // Depht or Stencil test Constants.
  33416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33417. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  33418. /** 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 */
  33419. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  33420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33421. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  33422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33423. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  33424. /** 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 */
  33425. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  33426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33427. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  33428. /** 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 */
  33429. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  33430. /** 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 */
  33431. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  33432. // Stencil Actions Constants.
  33433. /** Passed to stencilOperation to specify that stencil value must be kept */
  33434. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  33435. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33436. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  33437. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33438. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  33439. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33440. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  33441. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33442. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  33443. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33444. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  33445. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33446. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  33447. /** Texture is not repeating outside of 0..1 UVs */
  33448. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  33449. /** Texture is repeating outside of 0..1 UVs */
  33450. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  33451. /** Texture is repeating and mirrored */
  33452. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  33453. /** ALPHA */
  33454. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33455. /** LUMINANCE */
  33456. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33457. /** LUMINANCE_ALPHA */
  33458. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33459. /** RGB */
  33460. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33461. /** RGBA */
  33462. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33463. /** RED */
  33464. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33465. /** RED (2nd reference) */
  33466. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33467. /** RG */
  33468. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33469. /** RED_INTEGER */
  33470. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33471. /** RED_INTEGER (2nd reference) */
  33472. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33473. /** RG_INTEGER */
  33474. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33475. /** RGB_INTEGER */
  33476. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33477. /** RGBA_INTEGER */
  33478. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33479. /** UNSIGNED_BYTE */
  33480. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33481. /** UNSIGNED_BYTE (2nd reference) */
  33482. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33483. /** FLOAT */
  33484. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33485. /** HALF_FLOAT */
  33486. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33487. /** BYTE */
  33488. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33489. /** SHORT */
  33490. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33491. /** UNSIGNED_SHORT */
  33492. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33493. /** INT */
  33494. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33495. /** UNSIGNED_INT */
  33496. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33497. /** UNSIGNED_SHORT_4_4_4_4 */
  33498. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33499. /** UNSIGNED_SHORT_5_5_5_1 */
  33500. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33501. /** UNSIGNED_SHORT_5_6_5 */
  33502. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33503. /** UNSIGNED_INT_2_10_10_10_REV */
  33504. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33505. /** UNSIGNED_INT_24_8 */
  33506. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33507. /** UNSIGNED_INT_10F_11F_11F_REV */
  33508. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33509. /** UNSIGNED_INT_5_9_9_9_REV */
  33510. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33511. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33512. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33513. /** nearest is mag = nearest and min = nearest and mip = linear */
  33514. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33515. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33516. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33517. /** Trilinear is mag = linear and min = linear and mip = linear */
  33518. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33519. /** nearest is mag = nearest and min = nearest and mip = linear */
  33520. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33521. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33522. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33523. /** Trilinear is mag = linear and min = linear and mip = linear */
  33524. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33525. /** mag = nearest and min = nearest and mip = nearest */
  33526. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33527. /** mag = nearest and min = linear and mip = nearest */
  33528. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33529. /** mag = nearest and min = linear and mip = linear */
  33530. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33531. /** mag = nearest and min = linear and mip = none */
  33532. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33533. /** mag = nearest and min = nearest and mip = none */
  33534. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33535. /** mag = linear and min = nearest and mip = nearest */
  33536. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33537. /** mag = linear and min = nearest and mip = linear */
  33538. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33539. /** mag = linear and min = linear and mip = none */
  33540. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33541. /** mag = linear and min = nearest and mip = none */
  33542. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33543. /** Explicit coordinates mode */
  33544. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33545. /** Spherical coordinates mode */
  33546. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33547. /** Planar coordinates mode */
  33548. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33549. /** Cubic coordinates mode */
  33550. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33551. /** Projection coordinates mode */
  33552. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33553. /** Skybox coordinates mode */
  33554. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33555. /** Inverse Cubic coordinates mode */
  33556. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33557. /** Equirectangular coordinates mode */
  33558. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33559. /** Equirectangular Fixed coordinates mode */
  33560. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33561. /** Equirectangular Fixed Mirrored coordinates mode */
  33562. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33563. // Texture rescaling mode
  33564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33565. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33567. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33569. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33570. // Updatable statics so stick with vars here
  33571. /**
  33572. * Gets or sets the epsilon value used by collision engine
  33573. */
  33574. Engine.CollisionsEpsilon = 0.001;
  33575. /**
  33576. * Method called to create the default rescale post process on each engine.
  33577. */
  33578. Engine._RescalePostProcessFactory = null;
  33579. return Engine;
  33580. }());
  33581. /***/ }),
  33582. /***/ "./Engines/engineStore.ts":
  33583. /*!********************************!*\
  33584. !*** ./Engines/engineStore.ts ***!
  33585. \********************************/
  33586. /*! exports provided: EngineStore */
  33587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33588. "use strict";
  33589. __webpack_require__.r(__webpack_exports__);
  33590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33591. /**
  33592. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33593. * during the life time of the application.
  33594. */
  33595. var EngineStore = /** @class */ (function () {
  33596. function EngineStore() {
  33597. }
  33598. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33599. /**
  33600. * Gets the latest created engine
  33601. */
  33602. get: function () {
  33603. if (this.Instances.length === 0) {
  33604. return null;
  33605. }
  33606. return this.Instances[this.Instances.length - 1];
  33607. },
  33608. enumerable: true,
  33609. configurable: true
  33610. });
  33611. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33612. /**
  33613. * Gets the latest created scene
  33614. */
  33615. get: function () {
  33616. var lastCreatedEngine = this.LastCreatedEngine;
  33617. if (!lastCreatedEngine) {
  33618. return null;
  33619. }
  33620. if (lastCreatedEngine.scenes.length === 0) {
  33621. return null;
  33622. }
  33623. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33624. },
  33625. enumerable: true,
  33626. configurable: true
  33627. });
  33628. /** Gets the list of created engines */
  33629. EngineStore.Instances = new Array();
  33630. return EngineStore;
  33631. }());
  33632. /***/ }),
  33633. /***/ "./Engines/index.ts":
  33634. /*!**************************!*\
  33635. !*** ./Engines/index.ts ***!
  33636. \**************************/
  33637. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33639. "use strict";
  33640. __webpack_require__.r(__webpack_exports__);
  33641. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33643. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33648. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33650. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33653. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33656. /***/ }),
  33657. /***/ "./Engines/nullEngine.ts":
  33658. /*!*******************************!*\
  33659. !*** ./Engines/nullEngine.ts ***!
  33660. \*******************************/
  33661. /*! exports provided: NullEngineOptions, NullEngine */
  33662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33663. "use strict";
  33664. __webpack_require__.r(__webpack_exports__);
  33665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33667. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33668. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33669. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33670. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33671. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33672. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33673. /**
  33674. * Options to create the null engine
  33675. */
  33676. var NullEngineOptions = /** @class */ (function () {
  33677. function NullEngineOptions() {
  33678. /**
  33679. * Render width (Default: 512)
  33680. */
  33681. this.renderWidth = 512;
  33682. /**
  33683. * Render height (Default: 256)
  33684. */
  33685. this.renderHeight = 256;
  33686. /**
  33687. * Texture size (Default: 512)
  33688. */
  33689. this.textureSize = 512;
  33690. /**
  33691. * If delta time between frames should be constant
  33692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33693. */
  33694. this.deterministicLockstep = false;
  33695. /**
  33696. * Maximum about of steps between frames (Default: 4)
  33697. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33698. */
  33699. this.lockstepMaxSteps = 4;
  33700. }
  33701. return NullEngineOptions;
  33702. }());
  33703. /**
  33704. * The null engine class provides support for headless version of babylon.js.
  33705. * This can be used in server side scenario or for testing purposes
  33706. */
  33707. var NullEngine = /** @class */ (function (_super) {
  33708. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33709. function NullEngine(options) {
  33710. if (options === void 0) { options = new NullEngineOptions(); }
  33711. var _this = _super.call(this, null) || this;
  33712. if (options.deterministicLockstep === undefined) {
  33713. options.deterministicLockstep = false;
  33714. }
  33715. if (options.lockstepMaxSteps === undefined) {
  33716. options.lockstepMaxSteps = 4;
  33717. }
  33718. _this._options = options;
  33719. // Init caps
  33720. // We consider we are on a webgl1 capable device
  33721. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33722. _this._caps.maxTexturesImageUnits = 16;
  33723. _this._caps.maxVertexTextureImageUnits = 16;
  33724. _this._caps.maxTextureSize = 512;
  33725. _this._caps.maxCubemapTextureSize = 512;
  33726. _this._caps.maxRenderTextureSize = 512;
  33727. _this._caps.maxVertexAttribs = 16;
  33728. _this._caps.maxVaryingVectors = 16;
  33729. _this._caps.maxFragmentUniformVectors = 16;
  33730. _this._caps.maxVertexUniformVectors = 16;
  33731. // Extensions
  33732. _this._caps.standardDerivatives = false;
  33733. _this._caps.astc = null;
  33734. _this._caps.s3tc = null;
  33735. _this._caps.pvrtc = null;
  33736. _this._caps.etc1 = null;
  33737. _this._caps.etc2 = null;
  33738. _this._caps.textureAnisotropicFilterExtension = null;
  33739. _this._caps.maxAnisotropy = 0;
  33740. _this._caps.uintIndices = false;
  33741. _this._caps.fragmentDepthSupported = false;
  33742. _this._caps.highPrecisionShaderSupported = true;
  33743. _this._caps.colorBufferFloat = false;
  33744. _this._caps.textureFloat = false;
  33745. _this._caps.textureFloatLinearFiltering = false;
  33746. _this._caps.textureFloatRender = false;
  33747. _this._caps.textureHalfFloat = false;
  33748. _this._caps.textureHalfFloatLinearFiltering = false;
  33749. _this._caps.textureHalfFloatRender = false;
  33750. _this._caps.textureLOD = false;
  33751. _this._caps.drawBuffersExtension = false;
  33752. _this._caps.depthTextureExtension = false;
  33753. _this._caps.vertexArrayObject = false;
  33754. _this._caps.instancedArrays = false;
  33755. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33756. // Wrappers
  33757. if (typeof URL === "undefined") {
  33758. URL = {
  33759. createObjectURL: function () { },
  33760. revokeObjectURL: function () { }
  33761. };
  33762. }
  33763. if (typeof Blob === "undefined") {
  33764. Blob = function () { };
  33765. }
  33766. return _this;
  33767. }
  33768. /**
  33769. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33770. */
  33771. NullEngine.prototype.isDeterministicLockStep = function () {
  33772. return this._options.deterministicLockstep;
  33773. };
  33774. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33775. NullEngine.prototype.getLockstepMaxSteps = function () {
  33776. return this._options.lockstepMaxSteps;
  33777. };
  33778. /**
  33779. * Sets hardware scaling, used to save performance if needed
  33780. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33781. */
  33782. NullEngine.prototype.getHardwareScalingLevel = function () {
  33783. return 1.0;
  33784. };
  33785. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33786. return {
  33787. capacity: 0,
  33788. references: 1,
  33789. is32Bits: false
  33790. };
  33791. };
  33792. NullEngine.prototype.createIndexBuffer = function (indices) {
  33793. return {
  33794. capacity: 0,
  33795. references: 1,
  33796. is32Bits: false
  33797. };
  33798. };
  33799. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  33800. if (stencil === void 0) { stencil = false; }
  33801. };
  33802. NullEngine.prototype.getRenderWidth = function (useScreen) {
  33803. if (useScreen === void 0) { useScreen = false; }
  33804. if (!useScreen && this._currentRenderTarget) {
  33805. return this._currentRenderTarget.width;
  33806. }
  33807. return this._options.renderWidth;
  33808. };
  33809. NullEngine.prototype.getRenderHeight = function (useScreen) {
  33810. if (useScreen === void 0) { useScreen = false; }
  33811. if (!useScreen && this._currentRenderTarget) {
  33812. return this._currentRenderTarget.height;
  33813. }
  33814. return this._options.renderHeight;
  33815. };
  33816. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  33817. this._cachedViewport = viewport;
  33818. };
  33819. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  33820. return {
  33821. transformFeedback: null,
  33822. __SPECTOR_rebuildProgram: null,
  33823. isParallelCompiled: false
  33824. };
  33825. };
  33826. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  33827. return [];
  33828. };
  33829. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  33830. return [];
  33831. };
  33832. NullEngine.prototype.bindSamplers = function (effect) {
  33833. this._currentEffect = null;
  33834. };
  33835. NullEngine.prototype.enableEffect = function (effect) {
  33836. this._currentEffect = effect;
  33837. if (effect.onBind) {
  33838. effect.onBind(effect);
  33839. }
  33840. if (effect._onBindObservable) {
  33841. effect._onBindObservable.notifyObservers(effect);
  33842. }
  33843. };
  33844. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  33845. if (zOffset === void 0) { zOffset = 0; }
  33846. if (reverseSide === void 0) { reverseSide = false; }
  33847. };
  33848. NullEngine.prototype.setIntArray = function (uniform, array) {
  33849. };
  33850. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  33851. };
  33852. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  33853. };
  33854. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  33855. };
  33856. NullEngine.prototype.setFloatArray = function (uniform, array) {
  33857. };
  33858. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  33859. };
  33860. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  33861. };
  33862. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  33863. };
  33864. NullEngine.prototype.setArray = function (uniform, array) {
  33865. };
  33866. NullEngine.prototype.setArray2 = function (uniform, array) {
  33867. };
  33868. NullEngine.prototype.setArray3 = function (uniform, array) {
  33869. };
  33870. NullEngine.prototype.setArray4 = function (uniform, array) {
  33871. };
  33872. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  33873. };
  33874. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  33875. };
  33876. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  33877. };
  33878. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  33879. };
  33880. NullEngine.prototype.setFloat = function (uniform, value) {
  33881. };
  33882. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  33883. };
  33884. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  33885. };
  33886. NullEngine.prototype.setBool = function (uniform, bool) {
  33887. };
  33888. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  33889. };
  33890. NullEngine.prototype.setColor3 = function (uniform, color3) {
  33891. };
  33892. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  33893. };
  33894. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  33895. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  33896. if (this._alphaMode === mode) {
  33897. return;
  33898. }
  33899. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33900. if (!noDepthWriteChange) {
  33901. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33902. }
  33903. this._alphaMode = mode;
  33904. };
  33905. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  33906. };
  33907. NullEngine.prototype.wipeCaches = function (bruteForce) {
  33908. if (this.preventCacheWipeBetweenFrames) {
  33909. return;
  33910. }
  33911. this.resetTextureCache();
  33912. this._currentEffect = null;
  33913. if (bruteForce) {
  33914. this._currentProgram = null;
  33915. this._stencilState.reset();
  33916. this._depthCullingState.reset();
  33917. this._alphaState.reset();
  33918. }
  33919. this._cachedVertexBuffers = null;
  33920. this._cachedIndexBuffer = null;
  33921. this._cachedEffectForVertexBuffers = null;
  33922. };
  33923. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  33924. };
  33925. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  33926. };
  33927. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  33928. };
  33929. /** @hidden */
  33930. NullEngine.prototype._createTexture = function () {
  33931. return {};
  33932. };
  33933. /** @hidden */
  33934. NullEngine.prototype._releaseTexture = function (texture) {
  33935. };
  33936. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  33937. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33938. if (onLoad === void 0) { onLoad = null; }
  33939. if (onError === void 0) { onError = null; }
  33940. if (buffer === void 0) { buffer = null; }
  33941. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  33942. var url = String(urlArg);
  33943. texture.url = url;
  33944. texture.generateMipMaps = !noMipmap;
  33945. texture.samplingMode = samplingMode;
  33946. texture.invertY = invertY;
  33947. texture.baseWidth = this._options.textureSize;
  33948. texture.baseHeight = this._options.textureSize;
  33949. texture.width = this._options.textureSize;
  33950. texture.height = this._options.textureSize;
  33951. if (format) {
  33952. texture.format = format;
  33953. }
  33954. texture.isReady = true;
  33955. if (onLoad) {
  33956. onLoad();
  33957. }
  33958. this._internalTexturesCache.push(texture);
  33959. return texture;
  33960. };
  33961. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  33962. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  33963. if (options !== undefined && typeof options === "object") {
  33964. fullOptions.generateMipMaps = options.generateMipMaps;
  33965. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  33966. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  33967. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  33968. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  33969. }
  33970. else {
  33971. fullOptions.generateMipMaps = options;
  33972. fullOptions.generateDepthBuffer = true;
  33973. fullOptions.generateStencilBuffer = false;
  33974. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33975. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33976. }
  33977. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  33978. var width = size.width || size;
  33979. var height = size.height || size;
  33980. texture._depthStencilBuffer = {};
  33981. texture._framebuffer = {};
  33982. texture.baseWidth = width;
  33983. texture.baseHeight = height;
  33984. texture.width = width;
  33985. texture.height = height;
  33986. texture.isReady = true;
  33987. texture.samples = 1;
  33988. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  33989. texture.samplingMode = fullOptions.samplingMode;
  33990. texture.type = fullOptions.type;
  33991. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  33992. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  33993. this._internalTexturesCache.push(texture);
  33994. return texture;
  33995. };
  33996. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  33997. texture.samplingMode = samplingMode;
  33998. };
  33999. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34000. if (this._currentRenderTarget) {
  34001. this.unBindFramebuffer(this._currentRenderTarget);
  34002. }
  34003. this._currentRenderTarget = texture;
  34004. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34005. if (this._cachedViewport && !forceFullscreenViewport) {
  34006. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34007. }
  34008. };
  34009. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34010. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34011. this._currentRenderTarget = null;
  34012. if (onBeforeUnbind) {
  34013. if (texture._MSAAFramebuffer) {
  34014. this._currentFramebuffer = texture._framebuffer;
  34015. }
  34016. onBeforeUnbind();
  34017. }
  34018. this._currentFramebuffer = null;
  34019. };
  34020. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34021. var vbo = {
  34022. capacity: 1,
  34023. references: 1,
  34024. is32Bits: false
  34025. };
  34026. return vbo;
  34027. };
  34028. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34029. if (premulAlpha === void 0) { premulAlpha = false; }
  34030. };
  34031. NullEngine.prototype.areAllEffectsReady = function () {
  34032. return true;
  34033. };
  34034. /**
  34035. * @hidden
  34036. * Get the current error code of the webGL context
  34037. * @returns the error code
  34038. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34039. */
  34040. NullEngine.prototype.getError = function () {
  34041. return 0;
  34042. };
  34043. /** @hidden */
  34044. NullEngine.prototype._getUnpackAlignement = function () {
  34045. return 1;
  34046. };
  34047. /** @hidden */
  34048. NullEngine.prototype._unpackFlipY = function (value) {
  34049. };
  34050. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34051. if (offset === void 0) { offset = 0; }
  34052. };
  34053. /**
  34054. * Updates a dynamic vertex buffer.
  34055. * @param vertexBuffer the vertex buffer to update
  34056. * @param data the data used to update the vertex buffer
  34057. * @param byteOffset the byte offset of the data (optional)
  34058. * @param byteLength the byte length of the data (optional)
  34059. */
  34060. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34061. };
  34062. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34063. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34064. this._boundTexturesCache[this._activeChannel] = texture;
  34065. return true;
  34066. }
  34067. return false;
  34068. };
  34069. /** @hidden */
  34070. NullEngine.prototype._bindTexture = function (channel, texture) {
  34071. if (channel < 0) {
  34072. return;
  34073. }
  34074. this._bindTextureDirectly(0, texture);
  34075. };
  34076. /** @hidden */
  34077. NullEngine.prototype._releaseBuffer = function (buffer) {
  34078. buffer.references--;
  34079. if (buffer.references === 0) {
  34080. return true;
  34081. }
  34082. return false;
  34083. };
  34084. NullEngine.prototype.releaseEffects = function () {
  34085. };
  34086. NullEngine.prototype.displayLoadingUI = function () {
  34087. };
  34088. NullEngine.prototype.hideLoadingUI = function () {
  34089. };
  34090. /** @hidden */
  34091. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34092. if (faceIndex === void 0) { faceIndex = 0; }
  34093. if (lod === void 0) { lod = 0; }
  34094. };
  34095. /** @hidden */
  34096. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34097. if (faceIndex === void 0) { faceIndex = 0; }
  34098. if (lod === void 0) { lod = 0; }
  34099. };
  34100. /** @hidden */
  34101. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34102. if (faceIndex === void 0) { faceIndex = 0; }
  34103. if (lod === void 0) { lod = 0; }
  34104. };
  34105. /** @hidden */
  34106. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34107. if (faceIndex === void 0) { faceIndex = 0; }
  34108. if (lod === void 0) { lod = 0; }
  34109. };
  34110. return NullEngine;
  34111. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34112. /***/ }),
  34113. /***/ "./Events/clipboardEvents.ts":
  34114. /*!***********************************!*\
  34115. !*** ./Events/clipboardEvents.ts ***!
  34116. \***********************************/
  34117. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34119. "use strict";
  34120. __webpack_require__.r(__webpack_exports__);
  34121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34123. /**
  34124. * Gather the list of clipboard event types as constants.
  34125. */
  34126. var ClipboardEventTypes = /** @class */ (function () {
  34127. function ClipboardEventTypes() {
  34128. }
  34129. /**
  34130. * The clipboard event is fired when a copy command is active (pressed).
  34131. */
  34132. ClipboardEventTypes.COPY = 0x01; //
  34133. /**
  34134. * The clipboard event is fired when a cut command is active (pressed).
  34135. */
  34136. ClipboardEventTypes.CUT = 0x02;
  34137. /**
  34138. * The clipboard event is fired when a paste command is active (pressed).
  34139. */
  34140. ClipboardEventTypes.PASTE = 0x03;
  34141. return ClipboardEventTypes;
  34142. }());
  34143. /**
  34144. * This class is used to store clipboard related info for the onClipboardObservable event.
  34145. */
  34146. var ClipboardInfo = /** @class */ (function () {
  34147. /**
  34148. *Creates an instance of ClipboardInfo.
  34149. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34150. * @param event Defines the related dom event
  34151. */
  34152. function ClipboardInfo(
  34153. /**
  34154. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34155. */
  34156. type,
  34157. /**
  34158. * Defines the related dom event
  34159. */
  34160. event) {
  34161. this.type = type;
  34162. this.event = event;
  34163. }
  34164. /**
  34165. * Get the clipboard event's type from the keycode.
  34166. * @param keyCode Defines the keyCode for the current keyboard event.
  34167. * @return {number}
  34168. */
  34169. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34170. var charCode = keyCode;
  34171. //TODO: add codes for extended ASCII
  34172. switch (charCode) {
  34173. case 67: return ClipboardEventTypes.COPY;
  34174. case 86: return ClipboardEventTypes.PASTE;
  34175. case 88: return ClipboardEventTypes.CUT;
  34176. default: return -1;
  34177. }
  34178. };
  34179. return ClipboardInfo;
  34180. }());
  34181. /***/ }),
  34182. /***/ "./Events/index.ts":
  34183. /*!*************************!*\
  34184. !*** ./Events/index.ts ***!
  34185. \*************************/
  34186. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34188. "use strict";
  34189. __webpack_require__.r(__webpack_exports__);
  34190. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34194. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34199. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34202. /***/ }),
  34203. /***/ "./Events/keyboardEvents.ts":
  34204. /*!**********************************!*\
  34205. !*** ./Events/keyboardEvents.ts ***!
  34206. \**********************************/
  34207. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34209. "use strict";
  34210. __webpack_require__.r(__webpack_exports__);
  34211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34215. /**
  34216. * Gather the list of keyboard event types as constants.
  34217. */
  34218. var KeyboardEventTypes = /** @class */ (function () {
  34219. function KeyboardEventTypes() {
  34220. }
  34221. /**
  34222. * The keydown event is fired when a key becomes active (pressed).
  34223. */
  34224. KeyboardEventTypes.KEYDOWN = 0x01;
  34225. /**
  34226. * The keyup event is fired when a key has been released.
  34227. */
  34228. KeyboardEventTypes.KEYUP = 0x02;
  34229. return KeyboardEventTypes;
  34230. }());
  34231. /**
  34232. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34233. */
  34234. var KeyboardInfo = /** @class */ (function () {
  34235. /**
  34236. * Instantiates a new keyboard info.
  34237. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34238. * @param type Defines the type of event (KeyboardEventTypes)
  34239. * @param event Defines the related dom event
  34240. */
  34241. function KeyboardInfo(
  34242. /**
  34243. * Defines the type of event (KeyboardEventTypes)
  34244. */
  34245. type,
  34246. /**
  34247. * Defines the related dom event
  34248. */
  34249. event) {
  34250. this.type = type;
  34251. this.event = event;
  34252. }
  34253. return KeyboardInfo;
  34254. }());
  34255. /**
  34256. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34257. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34258. */
  34259. var KeyboardInfoPre = /** @class */ (function (_super) {
  34260. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34261. /**
  34262. * Instantiates a new keyboard pre info.
  34263. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34264. * @param type Defines the type of event (KeyboardEventTypes)
  34265. * @param event Defines the related dom event
  34266. */
  34267. function KeyboardInfoPre(
  34268. /**
  34269. * Defines the type of event (KeyboardEventTypes)
  34270. */
  34271. type,
  34272. /**
  34273. * Defines the related dom event
  34274. */
  34275. event) {
  34276. var _this = _super.call(this, type, event) || this;
  34277. _this.type = type;
  34278. _this.event = event;
  34279. _this.skipOnPointerObservable = false;
  34280. return _this;
  34281. }
  34282. return KeyboardInfoPre;
  34283. }(KeyboardInfo));
  34284. /***/ }),
  34285. /***/ "./Events/pointerEvents.ts":
  34286. /*!*********************************!*\
  34287. !*** ./Events/pointerEvents.ts ***!
  34288. \*********************************/
  34289. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34291. "use strict";
  34292. __webpack_require__.r(__webpack_exports__);
  34293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34297. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34299. /**
  34300. * Gather the list of pointer event types as constants.
  34301. */
  34302. var PointerEventTypes = /** @class */ (function () {
  34303. function PointerEventTypes() {
  34304. }
  34305. /**
  34306. * 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.
  34307. */
  34308. PointerEventTypes.POINTERDOWN = 0x01;
  34309. /**
  34310. * The pointerup event is fired when a pointer is no longer active.
  34311. */
  34312. PointerEventTypes.POINTERUP = 0x02;
  34313. /**
  34314. * The pointermove event is fired when a pointer changes coordinates.
  34315. */
  34316. PointerEventTypes.POINTERMOVE = 0x04;
  34317. /**
  34318. * The pointerwheel event is fired when a mouse wheel has been rotated.
  34319. */
  34320. PointerEventTypes.POINTERWHEEL = 0x08;
  34321. /**
  34322. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  34323. */
  34324. PointerEventTypes.POINTERPICK = 0x10;
  34325. /**
  34326. * The pointertap event is fired when a the object has been touched and released without drag.
  34327. */
  34328. PointerEventTypes.POINTERTAP = 0x20;
  34329. /**
  34330. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  34331. */
  34332. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  34333. return PointerEventTypes;
  34334. }());
  34335. /**
  34336. * Base class of pointer info types.
  34337. */
  34338. var PointerInfoBase = /** @class */ (function () {
  34339. /**
  34340. * Instantiates the base class of pointers info.
  34341. * @param type Defines the type of event (PointerEventTypes)
  34342. * @param event Defines the related dom event
  34343. */
  34344. function PointerInfoBase(
  34345. /**
  34346. * Defines the type of event (PointerEventTypes)
  34347. */
  34348. type,
  34349. /**
  34350. * Defines the related dom event
  34351. */
  34352. event) {
  34353. this.type = type;
  34354. this.event = event;
  34355. }
  34356. return PointerInfoBase;
  34357. }());
  34358. /**
  34359. * This class is used to store pointer related info for the onPrePointerObservable event.
  34360. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  34361. */
  34362. var PointerInfoPre = /** @class */ (function (_super) {
  34363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  34364. /**
  34365. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  34366. * @param type Defines the type of event (PointerEventTypes)
  34367. * @param event Defines the related dom event
  34368. * @param localX Defines the local x coordinates of the pointer when the event occured
  34369. * @param localY Defines the local y coordinates of the pointer when the event occured
  34370. */
  34371. function PointerInfoPre(type, event, localX, localY) {
  34372. var _this = _super.call(this, type, event) || this;
  34373. /**
  34374. * Ray from a pointer if availible (eg. 6dof controller)
  34375. */
  34376. _this.ray = null;
  34377. _this.skipOnPointerObservable = false;
  34378. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  34379. return _this;
  34380. }
  34381. return PointerInfoPre;
  34382. }(PointerInfoBase));
  34383. /**
  34384. * This type contains all the data related to a pointer event in Babylon.js.
  34385. * 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.
  34386. */
  34387. var PointerInfo = /** @class */ (function (_super) {
  34388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  34389. /**
  34390. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  34391. * @param type Defines the type of event (PointerEventTypes)
  34392. * @param event Defines the related dom event
  34393. * @param pickInfo Defines the picking info associated to the info (if any)\
  34394. */
  34395. function PointerInfo(type, event,
  34396. /**
  34397. * Defines the picking info associated to the info (if any)\
  34398. */
  34399. pickInfo) {
  34400. var _this = _super.call(this, type, event) || this;
  34401. _this.pickInfo = pickInfo;
  34402. return _this;
  34403. }
  34404. return PointerInfo;
  34405. }(PointerInfoBase));
  34406. /***/ }),
  34407. /***/ "./Gamepads/Controllers/daydreamController.ts":
  34408. /*!****************************************************!*\
  34409. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  34410. \****************************************************/
  34411. /*! exports provided: DaydreamController */
  34412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34413. "use strict";
  34414. __webpack_require__.r(__webpack_exports__);
  34415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  34416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34417. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34418. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34419. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34420. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34421. /**
  34422. * Google Daydream controller
  34423. */
  34424. var DaydreamController = /** @class */ (function (_super) {
  34425. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  34426. /**
  34427. * Creates a new DaydreamController from a gamepad
  34428. * @param vrGamepad the gamepad that the controller should be created from
  34429. */
  34430. function DaydreamController(vrGamepad) {
  34431. var _this = _super.call(this, vrGamepad) || this;
  34432. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  34433. return _this;
  34434. }
  34435. /**
  34436. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34437. * @param scene scene in which to add meshes
  34438. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34439. */
  34440. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34441. var _this = this;
  34442. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  34443. _this._defaultModel = newMeshes[1];
  34444. _this.attachToMesh(_this._defaultModel);
  34445. if (meshLoaded) {
  34446. meshLoaded(_this._defaultModel);
  34447. }
  34448. });
  34449. };
  34450. /**
  34451. * Called once for each button that changed state since the last frame
  34452. * @param buttonIdx Which button index changed
  34453. * @param state New state of the button
  34454. * @param changes Which properties on the state changed since last frame
  34455. */
  34456. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34457. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34458. if (buttonIdx === 0) {
  34459. var observable = this.onTriggerStateChangedObservable;
  34460. if (observable) {
  34461. observable.notifyObservers(state);
  34462. }
  34463. }
  34464. else {
  34465. // If the app or home buttons are ever made available
  34466. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34467. }
  34468. };
  34469. /**
  34470. * Base Url for the controller model.
  34471. */
  34472. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34473. /**
  34474. * File name for the controller model.
  34475. */
  34476. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34477. /**
  34478. * Gamepad Id prefix used to identify Daydream Controller.
  34479. */
  34480. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34481. return DaydreamController;
  34482. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34483. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34484. canCreate: function (gamepadInfo) {
  34485. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34486. },
  34487. create: function (gamepadInfo) {
  34488. return new DaydreamController(gamepadInfo);
  34489. }
  34490. });
  34491. /***/ }),
  34492. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34493. /*!**************************************************!*\
  34494. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34495. \**************************************************/
  34496. /*! exports provided: GearVRController */
  34497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34498. "use strict";
  34499. __webpack_require__.r(__webpack_exports__);
  34500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34502. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34503. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34504. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34505. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34506. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34507. /**
  34508. * Gear VR Controller
  34509. */
  34510. var GearVRController = /** @class */ (function (_super) {
  34511. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34512. /**
  34513. * Creates a new GearVRController from a gamepad
  34514. * @param vrGamepad the gamepad that the controller should be created from
  34515. */
  34516. function GearVRController(vrGamepad) {
  34517. var _this = _super.call(this, vrGamepad) || this;
  34518. _this._buttonIndexToObservableNameMap = [
  34519. 'onTrackpadChangedObservable',
  34520. 'onTriggerStateChangedObservable' // Trigger
  34521. ];
  34522. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34523. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34524. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34525. _this._disableTrackPosition(_this._calculatedPosition);
  34526. return _this;
  34527. }
  34528. /**
  34529. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34530. * @param scene scene in which to add meshes
  34531. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34532. */
  34533. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34534. var _this = this;
  34535. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34536. // Offset the controller so it will rotate around the users wrist
  34537. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34538. newMeshes[1].parent = mesh;
  34539. newMeshes[1].position.z = -0.15;
  34540. _this._defaultModel = mesh;
  34541. _this.attachToMesh(_this._defaultModel);
  34542. if (meshLoaded) {
  34543. meshLoaded(_this._defaultModel);
  34544. }
  34545. });
  34546. };
  34547. /**
  34548. * Called once for each button that changed state since the last frame
  34549. * @param buttonIdx Which button index changed
  34550. * @param state New state of the button
  34551. * @param changes Which properties on the state changed since last frame
  34552. */
  34553. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34554. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34555. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34556. // Only emit events for buttons that we know how to map from index to observable
  34557. var observable = this[observableName];
  34558. if (observable) {
  34559. observable.notifyObservers(state);
  34560. }
  34561. }
  34562. };
  34563. /**
  34564. * Base Url for the controller model.
  34565. */
  34566. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34567. /**
  34568. * File name for the controller model.
  34569. */
  34570. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34571. /**
  34572. * Gamepad Id prefix used to identify this controller.
  34573. */
  34574. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34575. return GearVRController;
  34576. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34577. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34578. canCreate: function (gamepadInfo) {
  34579. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34580. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34581. },
  34582. create: function (gamepadInfo) {
  34583. return new GearVRController(gamepadInfo);
  34584. }
  34585. });
  34586. /***/ }),
  34587. /***/ "./Gamepads/Controllers/genericController.ts":
  34588. /*!***************************************************!*\
  34589. !*** ./Gamepads/Controllers/genericController.ts ***!
  34590. \***************************************************/
  34591. /*! exports provided: GenericController */
  34592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34593. "use strict";
  34594. __webpack_require__.r(__webpack_exports__);
  34595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34596. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34597. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34598. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34599. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34600. /**
  34601. * Generic Controller
  34602. */
  34603. var GenericController = /** @class */ (function (_super) {
  34604. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34605. /**
  34606. * Creates a new GenericController from a gamepad
  34607. * @param vrGamepad the gamepad that the controller should be created from
  34608. */
  34609. function GenericController(vrGamepad) {
  34610. return _super.call(this, vrGamepad) || this;
  34611. }
  34612. /**
  34613. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34614. * @param scene scene in which to add meshes
  34615. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34616. */
  34617. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34618. var _this = this;
  34619. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34620. _this._defaultModel = newMeshes[1];
  34621. _this.attachToMesh(_this._defaultModel);
  34622. if (meshLoaded) {
  34623. meshLoaded(_this._defaultModel);
  34624. }
  34625. });
  34626. };
  34627. /**
  34628. * Called once for each button that changed state since the last frame
  34629. * @param buttonIdx Which button index changed
  34630. * @param state New state of the button
  34631. * @param changes Which properties on the state changed since last frame
  34632. */
  34633. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34634. console.log("Button id: " + buttonIdx + "state: ");
  34635. console.dir(state);
  34636. };
  34637. /**
  34638. * Base Url for the controller model.
  34639. */
  34640. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34641. /**
  34642. * File name for the controller model.
  34643. */
  34644. GenericController.MODEL_FILENAME = 'generic.babylon';
  34645. return GenericController;
  34646. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34647. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34648. /***/ }),
  34649. /***/ "./Gamepads/Controllers/index.ts":
  34650. /*!***************************************!*\
  34651. !*** ./Gamepads/Controllers/index.ts ***!
  34652. \***************************************/
  34653. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34655. "use strict";
  34656. __webpack_require__.r(__webpack_exports__);
  34657. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34659. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34661. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34663. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34665. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34669. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34671. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34673. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34675. /***/ }),
  34676. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34677. /*!*******************************************************!*\
  34678. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34679. \*******************************************************/
  34680. /*! exports provided: OculusTouchController */
  34681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34682. "use strict";
  34683. __webpack_require__.r(__webpack_exports__);
  34684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34685. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34686. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34687. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34688. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34689. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34690. /**
  34691. * Oculus Touch Controller
  34692. */
  34693. var OculusTouchController = /** @class */ (function (_super) {
  34694. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34695. /**
  34696. * Creates a new OculusTouchController from a gamepad
  34697. * @param vrGamepad the gamepad that the controller should be created from
  34698. */
  34699. function OculusTouchController(vrGamepad) {
  34700. var _this = _super.call(this, vrGamepad) || this;
  34701. /**
  34702. * Fired when the secondary trigger on this controller is modified
  34703. */
  34704. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34705. /**
  34706. * Fired when the thumb rest on this controller is modified
  34707. */
  34708. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34709. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34710. return _this;
  34711. }
  34712. /**
  34713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34714. * @param scene scene in which to add meshes
  34715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34716. */
  34717. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34718. var _this = this;
  34719. var meshName;
  34720. // Hand
  34721. if (this.hand === 'left') {
  34722. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34723. }
  34724. else { // Right is the default if no hand is specified
  34725. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34726. }
  34727. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34728. /*
  34729. Parent Mesh name: oculus_touch_left
  34730. - body
  34731. - trigger
  34732. - thumbstick
  34733. - grip
  34734. - button_y
  34735. - button_x
  34736. - button_enter
  34737. */
  34738. _this._defaultModel = newMeshes[1];
  34739. _this.attachToMesh(_this._defaultModel);
  34740. if (meshLoaded) {
  34741. meshLoaded(_this._defaultModel);
  34742. }
  34743. });
  34744. };
  34745. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34746. /**
  34747. * Fired when the A button on this controller is modified
  34748. */
  34749. get: function () {
  34750. if (this.hand === 'right') {
  34751. return this.onMainButtonStateChangedObservable;
  34752. }
  34753. else {
  34754. throw new Error('No A button on left hand');
  34755. }
  34756. },
  34757. enumerable: true,
  34758. configurable: true
  34759. });
  34760. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34761. /**
  34762. * Fired when the B button on this controller is modified
  34763. */
  34764. get: function () {
  34765. if (this.hand === 'right') {
  34766. return this.onSecondaryButtonStateChangedObservable;
  34767. }
  34768. else {
  34769. throw new Error('No B button on left hand');
  34770. }
  34771. },
  34772. enumerable: true,
  34773. configurable: true
  34774. });
  34775. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34776. /**
  34777. * Fired when the X button on this controller is modified
  34778. */
  34779. get: function () {
  34780. if (this.hand === 'left') {
  34781. return this.onMainButtonStateChangedObservable;
  34782. }
  34783. else {
  34784. throw new Error('No X button on right hand');
  34785. }
  34786. },
  34787. enumerable: true,
  34788. configurable: true
  34789. });
  34790. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34791. /**
  34792. * Fired when the Y button on this controller is modified
  34793. */
  34794. get: function () {
  34795. if (this.hand === 'left') {
  34796. return this.onSecondaryButtonStateChangedObservable;
  34797. }
  34798. else {
  34799. throw new Error('No Y button on right hand');
  34800. }
  34801. },
  34802. enumerable: true,
  34803. configurable: true
  34804. });
  34805. /**
  34806. * Called once for each button that changed state since the last frame
  34807. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34808. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34809. * 2) secondary trigger (same)
  34810. * 3) A (right) X (left), touch, pressed = value
  34811. * 4) B / Y
  34812. * 5) thumb rest
  34813. * @param buttonIdx Which button index changed
  34814. * @param state New state of the button
  34815. * @param changes Which properties on the state changed since last frame
  34816. */
  34817. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34818. var notifyObject = state; //{ state: state, changes: changes };
  34819. var triggerDirection = this.hand === 'right' ? -1 : 1;
  34820. switch (buttonIdx) {
  34821. case 0:
  34822. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34823. return;
  34824. case 1: // index trigger
  34825. if (this._defaultModel) {
  34826. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  34827. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  34828. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  34829. }
  34830. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34831. return;
  34832. case 2: // secondary trigger
  34833. if (this._defaultModel) {
  34834. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  34835. }
  34836. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  34837. return;
  34838. case 3:
  34839. if (this._defaultModel) {
  34840. if (notifyObject.pressed) {
  34841. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  34842. }
  34843. else {
  34844. (this._defaultModel.getChildren()[1]).position.y = 0;
  34845. }
  34846. }
  34847. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34848. return;
  34849. case 4:
  34850. if (this._defaultModel) {
  34851. if (notifyObject.pressed) {
  34852. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34853. }
  34854. else {
  34855. (this._defaultModel.getChildren()[2]).position.y = 0;
  34856. }
  34857. }
  34858. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34859. return;
  34860. case 5:
  34861. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  34862. return;
  34863. }
  34864. };
  34865. /**
  34866. * Base Url for the controller model.
  34867. */
  34868. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  34869. /**
  34870. * File name for the left controller model.
  34871. */
  34872. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  34873. /**
  34874. * File name for the right controller model.
  34875. */
  34876. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  34877. return OculusTouchController;
  34878. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34879. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34880. canCreate: function (gamepadInfo) {
  34881. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  34882. },
  34883. create: function (gamepadInfo) {
  34884. return new OculusTouchController(gamepadInfo);
  34885. }
  34886. });
  34887. /***/ }),
  34888. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  34889. /*!*******************************************************!*\
  34890. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  34891. \*******************************************************/
  34892. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  34893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34894. "use strict";
  34895. __webpack_require__.r(__webpack_exports__);
  34896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  34897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  34898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  34899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34900. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34901. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34902. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  34903. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  34904. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  34905. /**
  34906. * Defines the types of pose enabled controllers that are supported
  34907. */
  34908. var PoseEnabledControllerType;
  34909. (function (PoseEnabledControllerType) {
  34910. /**
  34911. * HTC Vive
  34912. */
  34913. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  34914. /**
  34915. * Oculus Rift
  34916. */
  34917. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  34918. /**
  34919. * Windows mixed reality
  34920. */
  34921. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  34922. /**
  34923. * Samsung gear VR
  34924. */
  34925. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  34926. /**
  34927. * Google Daydream
  34928. */
  34929. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  34930. /**
  34931. * Generic
  34932. */
  34933. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  34934. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  34935. /**
  34936. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34937. */
  34938. var PoseEnabledControllerHelper = /** @class */ (function () {
  34939. function PoseEnabledControllerHelper() {
  34940. }
  34941. /**
  34942. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34943. * @param vrGamepad the gamepad to initialized
  34944. * @returns a vr controller of the type the gamepad identified as
  34945. */
  34946. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  34947. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  34948. var factory = _a[_i];
  34949. if (factory.canCreate(vrGamepad)) {
  34950. return factory.create(vrGamepad);
  34951. }
  34952. }
  34953. if (this._DefaultControllerFactory) {
  34954. return this._DefaultControllerFactory(vrGamepad);
  34955. }
  34956. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  34957. };
  34958. /** @hidden */
  34959. PoseEnabledControllerHelper._ControllerFactories = [];
  34960. /** @hidden */
  34961. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  34962. return PoseEnabledControllerHelper;
  34963. }());
  34964. /**
  34965. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34966. */
  34967. var PoseEnabledController = /** @class */ (function (_super) {
  34968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  34969. /**
  34970. * Creates a new PoseEnabledController from a gamepad
  34971. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34972. */
  34973. function PoseEnabledController(browserGamepad) {
  34974. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  34975. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  34976. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34977. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34978. /**
  34979. * The device position in babylon space
  34980. */
  34981. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34982. /**
  34983. * The device rotation in babylon space
  34984. */
  34985. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34986. /**
  34987. * The scale factor of the device in babylon space
  34988. */
  34989. _this.deviceScaleFactor = 1;
  34990. // Used to convert 6dof controllers to 3dof
  34991. _this._trackPosition = true;
  34992. _this._maxRotationDistFromHeadset = Math.PI / 5;
  34993. _this._draggedRoomRotation = 0;
  34994. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34995. /**
  34996. * Internal, matrix used to convert room space to babylon space
  34997. * @hidden
  34998. */
  34999. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35000. /**
  35001. * Node to be used when casting a ray from the controller
  35002. * @hidden
  35003. */
  35004. _this._pointingPoseNode = null;
  35005. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35006. /**
  35007. * @hidden
  35008. */
  35009. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35010. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35011. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35012. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35013. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35014. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35015. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35016. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35017. return _this;
  35018. }
  35019. /**
  35020. * @hidden
  35021. */
  35022. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35023. if (this._trackPosition) {
  35024. this._calculatedPosition.copyFrom(fixedPosition);
  35025. this._trackPosition = false;
  35026. }
  35027. };
  35028. /**
  35029. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35030. */
  35031. PoseEnabledController.prototype.update = function () {
  35032. _super.prototype.update.call(this);
  35033. this._updatePoseAndMesh();
  35034. };
  35035. /**
  35036. * Updates only the pose device and mesh without doing any button event checking
  35037. */
  35038. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35039. var pose = this.browserGamepad.pose;
  35040. this.updateFromDevice(pose);
  35041. 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) {
  35042. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35043. camera._computeDevicePosition();
  35044. this._deviceToWorld.setTranslation(camera.devicePosition);
  35045. if (camera.deviceRotationQuaternion) {
  35046. var camera = camera;
  35047. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35048. // Find the radian distance away that the headset is from the controllers rotation
  35049. 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));
  35050. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35051. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35052. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35053. this._draggedRoomRotation += rotationAmount;
  35054. // Rotate controller around headset
  35055. var sin = Math.sin(-rotationAmount);
  35056. var cos = Math.cos(-rotationAmount);
  35057. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35058. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35059. }
  35060. }
  35061. }
  35062. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35063. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35064. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35065. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35066. if (this._mesh) {
  35067. this._mesh.position.copyFrom(this.devicePosition);
  35068. if (this._mesh.rotationQuaternion) {
  35069. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35070. }
  35071. }
  35072. };
  35073. /**
  35074. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35075. * @param poseData raw pose fromthe device
  35076. */
  35077. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35078. if (poseData) {
  35079. this.rawPose = poseData;
  35080. if (poseData.position) {
  35081. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35082. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35083. this._deviceRoomPosition.z *= -1;
  35084. }
  35085. if (this._trackPosition) {
  35086. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35087. }
  35088. this._calculatedPosition.addInPlace(this.position);
  35089. }
  35090. var pose = this.rawPose;
  35091. if (poseData.orientation && pose.orientation) {
  35092. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35093. if (this._mesh) {
  35094. if (this._mesh.getScene().useRightHandedSystem) {
  35095. this._deviceRoomRotationQuaternion.z *= -1;
  35096. this._deviceRoomRotationQuaternion.w *= -1;
  35097. }
  35098. else {
  35099. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35100. }
  35101. }
  35102. // if the camera is set, rotate to the camera's rotation
  35103. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35104. }
  35105. }
  35106. };
  35107. /**
  35108. * Attaches a mesh to the controller
  35109. * @param mesh the mesh to be attached
  35110. */
  35111. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35112. if (this._mesh) {
  35113. this._mesh.parent = null;
  35114. }
  35115. this._mesh = mesh;
  35116. if (this._poseControlledCamera) {
  35117. this._mesh.parent = this._poseControlledCamera;
  35118. }
  35119. if (!this._mesh.rotationQuaternion) {
  35120. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35121. }
  35122. // 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
  35123. this._updatePoseAndMesh();
  35124. if (this._pointingPoseNode) {
  35125. var parents = [];
  35126. var obj = this._pointingPoseNode;
  35127. while (obj.parent) {
  35128. parents.push(obj.parent);
  35129. obj = obj.parent;
  35130. }
  35131. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35132. }
  35133. this._meshAttachedObservable.notifyObservers(mesh);
  35134. };
  35135. /**
  35136. * Attaches the controllers mesh to a camera
  35137. * @param camera the camera the mesh should be attached to
  35138. */
  35139. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35140. this._poseControlledCamera = camera;
  35141. if (this._mesh) {
  35142. this._mesh.parent = this._poseControlledCamera;
  35143. }
  35144. };
  35145. /**
  35146. * Disposes of the controller
  35147. */
  35148. PoseEnabledController.prototype.dispose = function () {
  35149. if (this._mesh) {
  35150. this._mesh.dispose();
  35151. }
  35152. this._mesh = null;
  35153. _super.prototype.dispose.call(this);
  35154. };
  35155. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35156. /**
  35157. * The mesh that is attached to the controller
  35158. */
  35159. get: function () {
  35160. return this._mesh;
  35161. },
  35162. enumerable: true,
  35163. configurable: true
  35164. });
  35165. /**
  35166. * Gets the ray of the controller in the direction the controller is pointing
  35167. * @param length the length the resulting ray should be
  35168. * @returns a ray in the direction the controller is pointing
  35169. */
  35170. PoseEnabledController.prototype.getForwardRay = function (length) {
  35171. if (length === void 0) { length = 100; }
  35172. if (!this.mesh) {
  35173. 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);
  35174. }
  35175. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35176. var origin = m.getTranslation();
  35177. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35178. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35179. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35180. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35181. };
  35182. /**
  35183. * Name of the child mesh that can be used to cast a ray from the controller
  35184. */
  35185. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35186. return PoseEnabledController;
  35187. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35188. /***/ }),
  35189. /***/ "./Gamepads/Controllers/viveController.ts":
  35190. /*!************************************************!*\
  35191. !*** ./Gamepads/Controllers/viveController.ts ***!
  35192. \************************************************/
  35193. /*! exports provided: ViveController */
  35194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35195. "use strict";
  35196. __webpack_require__.r(__webpack_exports__);
  35197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35199. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35200. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35201. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35202. /**
  35203. * Vive Controller
  35204. */
  35205. var ViveController = /** @class */ (function (_super) {
  35206. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35207. /**
  35208. * Creates a new ViveController from a gamepad
  35209. * @param vrGamepad the gamepad that the controller should be created from
  35210. */
  35211. function ViveController(vrGamepad) {
  35212. var _this = _super.call(this, vrGamepad) || this;
  35213. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35214. _this._invertLeftStickY = true;
  35215. return _this;
  35216. }
  35217. /**
  35218. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35219. * @param scene scene in which to add meshes
  35220. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35221. */
  35222. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35223. var _this = this;
  35224. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35225. /*
  35226. Parent Mesh name: ViveWand
  35227. - body
  35228. - r_gripper
  35229. - l_gripper
  35230. - menu_button
  35231. - system_button
  35232. - trackpad
  35233. - trigger
  35234. - LED
  35235. */
  35236. _this._defaultModel = newMeshes[1];
  35237. _this.attachToMesh(_this._defaultModel);
  35238. if (meshLoaded) {
  35239. meshLoaded(_this._defaultModel);
  35240. }
  35241. });
  35242. };
  35243. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35244. /**
  35245. * Fired when the left button on this controller is modified
  35246. */
  35247. get: function () {
  35248. return this.onMainButtonStateChangedObservable;
  35249. },
  35250. enumerable: true,
  35251. configurable: true
  35252. });
  35253. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35254. /**
  35255. * Fired when the right button on this controller is modified
  35256. */
  35257. get: function () {
  35258. return this.onMainButtonStateChangedObservable;
  35259. },
  35260. enumerable: true,
  35261. configurable: true
  35262. });
  35263. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35264. /**
  35265. * Fired when the menu button on this controller is modified
  35266. */
  35267. get: function () {
  35268. return this.onSecondaryButtonStateChangedObservable;
  35269. },
  35270. enumerable: true,
  35271. configurable: true
  35272. });
  35273. /**
  35274. * Called once for each button that changed state since the last frame
  35275. * Vive mapping:
  35276. * 0: touchpad
  35277. * 1: trigger
  35278. * 2: left AND right buttons
  35279. * 3: menu button
  35280. * @param buttonIdx Which button index changed
  35281. * @param state New state of the button
  35282. * @param changes Which properties on the state changed since last frame
  35283. */
  35284. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35285. var notifyObject = state; //{ state: state, changes: changes };
  35286. switch (buttonIdx) {
  35287. case 0:
  35288. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35289. return;
  35290. case 1: // index trigger
  35291. if (this._defaultModel) {
  35292. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35293. }
  35294. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35295. return;
  35296. case 2: // left AND right button
  35297. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35298. return;
  35299. case 3:
  35300. if (this._defaultModel) {
  35301. if (notifyObject.pressed) {
  35302. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35303. }
  35304. else {
  35305. (this._defaultModel.getChildren()[2]).position.y = 0;
  35306. }
  35307. }
  35308. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35309. return;
  35310. }
  35311. };
  35312. /**
  35313. * Base Url for the controller model.
  35314. */
  35315. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  35316. /**
  35317. * File name for the controller model.
  35318. */
  35319. ViveController.MODEL_FILENAME = 'wand.babylon';
  35320. return ViveController;
  35321. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35322. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35323. canCreate: function (gamepadInfo) {
  35324. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  35325. },
  35326. create: function (gamepadInfo) {
  35327. return new ViveController(gamepadInfo);
  35328. }
  35329. });
  35330. /***/ }),
  35331. /***/ "./Gamepads/Controllers/webVRController.ts":
  35332. /*!*************************************************!*\
  35333. !*** ./Gamepads/Controllers/webVRController.ts ***!
  35334. \*************************************************/
  35335. /*! exports provided: WebVRController */
  35336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35337. "use strict";
  35338. __webpack_require__.r(__webpack_exports__);
  35339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  35340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35341. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35342. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35343. /**
  35344. * Defines the WebVRController object that represents controllers tracked in 3D space
  35345. */
  35346. var WebVRController = /** @class */ (function (_super) {
  35347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  35348. /**
  35349. * Creates a new WebVRController from a gamepad
  35350. * @param vrGamepad the gamepad that the WebVRController should be created from
  35351. */
  35352. function WebVRController(vrGamepad) {
  35353. var _this = _super.call(this, vrGamepad) || this;
  35354. // Observables
  35355. /**
  35356. * Fired when the trigger state has changed
  35357. */
  35358. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35359. /**
  35360. * Fired when the main button state has changed
  35361. */
  35362. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35363. /**
  35364. * Fired when the secondary button state has changed
  35365. */
  35366. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35367. /**
  35368. * Fired when the pad state has changed
  35369. */
  35370. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35371. /**
  35372. * Fired when controllers stick values have changed
  35373. */
  35374. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35375. /**
  35376. * X and Y axis corrisponding to the controllers joystick
  35377. */
  35378. _this.pad = { x: 0, y: 0 };
  35379. // avoid GC, store state in a tmp object
  35380. _this._changes = {
  35381. pressChanged: false,
  35382. touchChanged: false,
  35383. valueChanged: false,
  35384. changed: false
  35385. };
  35386. _this._buttons = new Array(vrGamepad.buttons.length);
  35387. _this.hand = vrGamepad.hand;
  35388. return _this;
  35389. }
  35390. /**
  35391. * Fired when a controller button's state has changed
  35392. * @param callback the callback containing the button that was modified
  35393. */
  35394. WebVRController.prototype.onButtonStateChange = function (callback) {
  35395. this._onButtonStateChange = callback;
  35396. };
  35397. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  35398. /**
  35399. * The default controller model for the controller
  35400. */
  35401. get: function () {
  35402. return this._defaultModel;
  35403. },
  35404. enumerable: true,
  35405. configurable: true
  35406. });
  35407. /**
  35408. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35409. */
  35410. WebVRController.prototype.update = function () {
  35411. _super.prototype.update.call(this);
  35412. for (var index = 0; index < this._buttons.length; index++) {
  35413. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  35414. }
  35415. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  35416. this.pad.x = this.leftStick.x;
  35417. this.pad.y = this.leftStick.y;
  35418. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  35419. }
  35420. };
  35421. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  35422. if (!newState) {
  35423. newState = {
  35424. pressed: false,
  35425. touched: false,
  35426. value: 0
  35427. };
  35428. }
  35429. if (!currentState) {
  35430. this._buttons[buttonIndex] = {
  35431. pressed: newState.pressed,
  35432. touched: newState.touched,
  35433. value: newState.value
  35434. };
  35435. return;
  35436. }
  35437. this._checkChanges(newState, currentState);
  35438. if (this._changes.changed) {
  35439. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  35440. this._handleButtonChange(buttonIndex, newState, this._changes);
  35441. }
  35442. this._buttons[buttonIndex].pressed = newState.pressed;
  35443. this._buttons[buttonIndex].touched = newState.touched;
  35444. // oculus triggers are never 0, thou not touched.
  35445. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  35446. };
  35447. WebVRController.prototype._checkChanges = function (newState, currentState) {
  35448. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  35449. this._changes.touchChanged = newState.touched !== currentState.touched;
  35450. this._changes.valueChanged = newState.value !== currentState.value;
  35451. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  35452. return this._changes;
  35453. };
  35454. /**
  35455. * Disposes of th webVRCOntroller
  35456. */
  35457. WebVRController.prototype.dispose = function () {
  35458. _super.prototype.dispose.call(this);
  35459. this.onTriggerStateChangedObservable.clear();
  35460. this.onMainButtonStateChangedObservable.clear();
  35461. this.onSecondaryButtonStateChangedObservable.clear();
  35462. this.onPadStateChangedObservable.clear();
  35463. this.onPadValuesChangedObservable.clear();
  35464. };
  35465. return WebVRController;
  35466. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35467. /***/ }),
  35468. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35469. /*!*********************************************************!*\
  35470. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35471. \*********************************************************/
  35472. /*! exports provided: WindowsMotionController */
  35473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35474. "use strict";
  35475. __webpack_require__.r(__webpack_exports__);
  35476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35478. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35479. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35480. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35481. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35482. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35483. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35484. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35485. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35486. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35487. /**
  35488. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35489. */
  35490. var LoadedMeshInfo = /** @class */ (function () {
  35491. function LoadedMeshInfo() {
  35492. /**
  35493. * Map of the button meshes contained in the controller
  35494. */
  35495. this.buttonMeshes = {};
  35496. /**
  35497. * Map of the axis meshes contained in the controller
  35498. */
  35499. this.axisMeshes = {};
  35500. }
  35501. return LoadedMeshInfo;
  35502. }());
  35503. /**
  35504. * Defines the WindowsMotionController object that the state of the windows motion controller
  35505. */
  35506. var WindowsMotionController = /** @class */ (function (_super) {
  35507. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35508. /**
  35509. * Creates a new WindowsMotionController from a gamepad
  35510. * @param vrGamepad the gamepad that the controller should be created from
  35511. */
  35512. function WindowsMotionController(vrGamepad) {
  35513. var _this = _super.call(this, vrGamepad) || this;
  35514. _this._mapping = {
  35515. // Semantic button names
  35516. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35517. // A mapping of the button name to glTF model node name
  35518. // that should be transformed by button value.
  35519. buttonMeshNames: {
  35520. 'trigger': 'SELECT',
  35521. 'menu': 'MENU',
  35522. 'grip': 'GRASP',
  35523. 'thumbstick': 'THUMBSTICK_PRESS',
  35524. 'trackpad': 'TOUCHPAD_PRESS'
  35525. },
  35526. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35527. buttonObservableNames: {
  35528. 'trigger': 'onTriggerStateChangedObservable',
  35529. 'menu': 'onSecondaryButtonStateChangedObservable',
  35530. 'grip': 'onMainButtonStateChangedObservable',
  35531. 'thumbstick': 'onPadStateChangedObservable',
  35532. 'trackpad': 'onTrackpadChangedObservable'
  35533. },
  35534. // A mapping of the axis name to glTF model node name
  35535. // that should be transformed by axis value.
  35536. // This array mirrors the browserGamepad.axes array, such that
  35537. // the mesh corresponding to axis 0 is in this array index 0.
  35538. axisMeshNames: [
  35539. 'THUMBSTICK_X',
  35540. 'THUMBSTICK_Y',
  35541. 'TOUCHPAD_TOUCH_X',
  35542. 'TOUCHPAD_TOUCH_Y'
  35543. ],
  35544. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35545. };
  35546. /**
  35547. * Fired when the trackpad on this controller is clicked
  35548. */
  35549. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35550. /**
  35551. * Fired when the trackpad on this controller is modified
  35552. */
  35553. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35554. /**
  35555. * The current x and y values of this controller's trackpad
  35556. */
  35557. _this.trackpad = { x: 0, y: 0 };
  35558. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35559. _this._loadedMeshInfo = null;
  35560. return _this;
  35561. }
  35562. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35563. /**
  35564. * Fired when the trigger on this controller is modified
  35565. */
  35566. get: function () {
  35567. return this.onTriggerStateChangedObservable;
  35568. },
  35569. enumerable: true,
  35570. configurable: true
  35571. });
  35572. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35573. /**
  35574. * Fired when the menu button on this controller is modified
  35575. */
  35576. get: function () {
  35577. return this.onSecondaryButtonStateChangedObservable;
  35578. },
  35579. enumerable: true,
  35580. configurable: true
  35581. });
  35582. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35583. /**
  35584. * Fired when the grip button on this controller is modified
  35585. */
  35586. get: function () {
  35587. return this.onMainButtonStateChangedObservable;
  35588. },
  35589. enumerable: true,
  35590. configurable: true
  35591. });
  35592. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35593. /**
  35594. * Fired when the thumbstick button on this controller is modified
  35595. */
  35596. get: function () {
  35597. return this.onPadStateChangedObservable;
  35598. },
  35599. enumerable: true,
  35600. configurable: true
  35601. });
  35602. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35603. /**
  35604. * Fired when the touchpad button on this controller is modified
  35605. */
  35606. get: function () {
  35607. return this.onTrackpadChangedObservable;
  35608. },
  35609. enumerable: true,
  35610. configurable: true
  35611. });
  35612. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35613. /**
  35614. * Fired when the touchpad values on this controller are modified
  35615. */
  35616. get: function () {
  35617. return this.onTrackpadValuesChangedObservable;
  35618. },
  35619. enumerable: true,
  35620. configurable: true
  35621. });
  35622. WindowsMotionController.prototype._updateTrackpad = function () {
  35623. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35624. this.trackpad.x = this.browserGamepad["axes"][2];
  35625. this.trackpad.y = this.browserGamepad["axes"][3];
  35626. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35627. }
  35628. };
  35629. /**
  35630. * Called once per frame by the engine.
  35631. */
  35632. WindowsMotionController.prototype.update = function () {
  35633. _super.prototype.update.call(this);
  35634. if (this.browserGamepad.axes) {
  35635. this._updateTrackpad();
  35636. // Only need to animate axes if there is a loaded mesh
  35637. if (this._loadedMeshInfo) {
  35638. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35639. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35640. }
  35641. }
  35642. }
  35643. };
  35644. /**
  35645. * Called once for each button that changed state since the last frame
  35646. * @param buttonIdx Which button index changed
  35647. * @param state New state of the button
  35648. * @param changes Which properties on the state changed since last frame
  35649. */
  35650. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35651. var buttonName = this._mapping.buttons[buttonIdx];
  35652. if (!buttonName) {
  35653. return;
  35654. }
  35655. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35656. this._updateTrackpad();
  35657. // Only emit events for buttons that we know how to map from index to name
  35658. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35659. if (observable) {
  35660. observable.notifyObservers(state);
  35661. }
  35662. this._lerpButtonTransform(buttonName, state.value);
  35663. };
  35664. /**
  35665. * Moves the buttons on the controller mesh based on their current state
  35666. * @param buttonName the name of the button to move
  35667. * @param buttonValue the value of the button which determines the buttons new position
  35668. */
  35669. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35670. // If there is no loaded mesh, there is nothing to transform.
  35671. if (!this._loadedMeshInfo) {
  35672. return;
  35673. }
  35674. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35675. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35676. return;
  35677. }
  35678. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35679. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35680. };
  35681. /**
  35682. * Moves the axis on the controller mesh based on its current state
  35683. * @param axis the index of the axis
  35684. * @param axisValue the value of the axis which determines the meshes new position
  35685. * @hidden
  35686. */
  35687. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35688. if (!this._loadedMeshInfo) {
  35689. return;
  35690. }
  35691. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35692. if (!meshInfo) {
  35693. return;
  35694. }
  35695. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35696. return;
  35697. }
  35698. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35699. var lerpValue = axisValue * 0.5 + 0.5;
  35700. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35701. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35702. };
  35703. /**
  35704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35705. * @param scene scene in which to add meshes
  35706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35707. */
  35708. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35709. var _this = this;
  35710. if (forceDefault === void 0) { forceDefault = false; }
  35711. var path;
  35712. var filename;
  35713. // Checking if GLB loader is present
  35714. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35715. // Determine the device specific folder based on the ID suffix
  35716. var device = 'default';
  35717. if (this.id && !forceDefault) {
  35718. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35719. device = ((match && match[0]) || device);
  35720. }
  35721. // Hand
  35722. if (this.hand === 'left') {
  35723. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35724. }
  35725. else { // Right is the default if no hand is specified
  35726. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35727. }
  35728. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35729. }
  35730. else {
  35731. _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");
  35732. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35733. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35734. }
  35735. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35736. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35737. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35738. if (!_this._loadedMeshInfo) {
  35739. return;
  35740. }
  35741. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35742. _this.attachToMesh(_this._defaultModel);
  35743. if (meshLoaded) {
  35744. meshLoaded(_this._defaultModel);
  35745. }
  35746. }, null, function (scene, message) {
  35747. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35748. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35749. if (!forceDefault) {
  35750. _this.initControllerMesh(scene, meshLoaded, true);
  35751. }
  35752. });
  35753. };
  35754. /**
  35755. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35756. * can be transformed by button presses and axes values, based on this._mapping.
  35757. *
  35758. * @param scene scene in which the meshes exist
  35759. * @param meshes list of meshes that make up the controller model to process
  35760. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35761. */
  35762. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35763. var loadedMeshInfo = null;
  35764. // Create a new mesh to contain the glTF hierarchy
  35765. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35766. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35767. var childMesh = null;
  35768. for (var i = 0; i < meshes.length; i++) {
  35769. var mesh = meshes[i];
  35770. if (!mesh.parent) {
  35771. // Exclude controller meshes from picking results
  35772. mesh.isPickable = false;
  35773. // Handle root node, attach to the new parentMesh
  35774. childMesh = mesh;
  35775. break;
  35776. }
  35777. }
  35778. if (childMesh) {
  35779. childMesh.setParent(parentMesh);
  35780. // Create our mesh info. Note that this method will always return non-null.
  35781. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35782. }
  35783. else {
  35784. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35785. }
  35786. return loadedMeshInfo;
  35787. };
  35788. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35789. var loadedMeshInfo = new LoadedMeshInfo();
  35790. var i;
  35791. loadedMeshInfo.rootNode = rootNode;
  35792. // Reset the caches
  35793. loadedMeshInfo.buttonMeshes = {};
  35794. loadedMeshInfo.axisMeshes = {};
  35795. // Button Meshes
  35796. for (i = 0; i < this._mapping.buttons.length; i++) {
  35797. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  35798. if (!buttonMeshName) {
  35799. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  35800. continue;
  35801. }
  35802. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  35803. if (!buttonMesh) {
  35804. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  35805. continue;
  35806. }
  35807. var buttonMeshInfo = {
  35808. index: i,
  35809. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  35810. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  35811. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  35812. };
  35813. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  35814. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  35815. }
  35816. else {
  35817. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  35818. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  35819. '(VALUE: ' + !!buttonMeshInfo.value +
  35820. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  35821. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  35822. ')');
  35823. }
  35824. }
  35825. // Axis Meshes
  35826. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  35827. var axisMeshName = this._mapping.axisMeshNames[i];
  35828. if (!axisMeshName) {
  35829. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  35830. continue;
  35831. }
  35832. var axisMesh = getChildByName(rootNode, axisMeshName);
  35833. if (!axisMesh) {
  35834. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  35835. continue;
  35836. }
  35837. var axisMeshInfo = {
  35838. index: i,
  35839. value: getImmediateChildByName(axisMesh, 'VALUE'),
  35840. min: getImmediateChildByName(axisMesh, 'MIN'),
  35841. max: getImmediateChildByName(axisMesh, 'MAX')
  35842. };
  35843. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  35844. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  35845. }
  35846. else {
  35847. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  35848. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  35849. '(VALUE: ' + !!axisMeshInfo.value +
  35850. ', MIN: ' + !!axisMeshInfo.min +
  35851. ', MAX:' + !!axisMeshInfo.max +
  35852. ')');
  35853. }
  35854. }
  35855. // Pointing Ray
  35856. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  35857. if (!loadedMeshInfo.pointingPoseNode) {
  35858. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  35859. }
  35860. else {
  35861. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  35862. }
  35863. return loadedMeshInfo;
  35864. // Look through all children recursively. This will return null if no mesh exists with the given name.
  35865. function getChildByName(node, name) {
  35866. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  35867. }
  35868. // Look through only immediate children. This will return null if no mesh exists with the given name.
  35869. function getImmediateChildByName(node, name) {
  35870. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  35871. }
  35872. };
  35873. /**
  35874. * Gets the ray of the controller in the direction the controller is pointing
  35875. * @param length the length the resulting ray should be
  35876. * @returns a ray in the direction the controller is pointing
  35877. */
  35878. WindowsMotionController.prototype.getForwardRay = function (length) {
  35879. if (length === void 0) { length = 100; }
  35880. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  35881. return _super.prototype.getForwardRay.call(this, length);
  35882. }
  35883. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  35884. var origin = m.getTranslation();
  35885. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  35886. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  35887. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  35888. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  35889. };
  35890. /**
  35891. * Disposes of the controller
  35892. */
  35893. WindowsMotionController.prototype.dispose = function () {
  35894. _super.prototype.dispose.call(this);
  35895. this.onTrackpadChangedObservable.clear();
  35896. };
  35897. /**
  35898. * The base url used to load the left and right controller models
  35899. */
  35900. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  35901. /**
  35902. * The name of the left controller model file
  35903. */
  35904. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  35905. /**
  35906. * The name of the right controller model file
  35907. */
  35908. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  35909. /**
  35910. * The controller name prefix for this controller type
  35911. */
  35912. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  35913. /**
  35914. * The controller id pattern for this controller type
  35915. */
  35916. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  35917. return WindowsMotionController;
  35918. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  35919. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35920. canCreate: function (gamepadInfo) {
  35921. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  35922. },
  35923. create: function (gamepadInfo) {
  35924. return new WindowsMotionController(gamepadInfo);
  35925. }
  35926. });
  35927. /***/ }),
  35928. /***/ "./Gamepads/gamepad.ts":
  35929. /*!*****************************!*\
  35930. !*** ./Gamepads/gamepad.ts ***!
  35931. \*****************************/
  35932. /*! exports provided: StickValues, Gamepad, GenericPad */
  35933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35934. "use strict";
  35935. __webpack_require__.r(__webpack_exports__);
  35936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  35937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  35938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  35939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35940. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35941. /**
  35942. * Represents a gamepad control stick position
  35943. */
  35944. var StickValues = /** @class */ (function () {
  35945. /**
  35946. * Initializes the gamepad x and y control stick values
  35947. * @param x The x component of the gamepad control stick value
  35948. * @param y The y component of the gamepad control stick value
  35949. */
  35950. function StickValues(
  35951. /**
  35952. * The x component of the control stick
  35953. */
  35954. x,
  35955. /**
  35956. * The y component of the control stick
  35957. */
  35958. y) {
  35959. this.x = x;
  35960. this.y = y;
  35961. }
  35962. return StickValues;
  35963. }());
  35964. /**
  35965. * Represents a gamepad
  35966. */
  35967. var Gamepad = /** @class */ (function () {
  35968. /**
  35969. * Initializes the gamepad
  35970. * @param id The id of the gamepad
  35971. * @param index The index of the gamepad
  35972. * @param browserGamepad The browser gamepad
  35973. * @param leftStickX The x component of the left joystick
  35974. * @param leftStickY The y component of the left joystick
  35975. * @param rightStickX The x component of the right joystick
  35976. * @param rightStickY The y component of the right joystick
  35977. */
  35978. function Gamepad(
  35979. /**
  35980. * The id of the gamepad
  35981. */
  35982. id,
  35983. /**
  35984. * The index of the gamepad
  35985. */
  35986. index,
  35987. /**
  35988. * The browser gamepad
  35989. */
  35990. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  35991. if (leftStickX === void 0) { leftStickX = 0; }
  35992. if (leftStickY === void 0) { leftStickY = 1; }
  35993. if (rightStickX === void 0) { rightStickX = 2; }
  35994. if (rightStickY === void 0) { rightStickY = 3; }
  35995. this.id = id;
  35996. this.index = index;
  35997. this.browserGamepad = browserGamepad;
  35998. this._leftStick = { x: 0, y: 0 };
  35999. this._rightStick = { x: 0, y: 0 };
  36000. /** @hidden */
  36001. this._isConnected = true;
  36002. /**
  36003. * Specifies whether the left control stick should be Y-inverted
  36004. */
  36005. this._invertLeftStickY = false;
  36006. this.type = Gamepad.GAMEPAD;
  36007. this._leftStickAxisX = leftStickX;
  36008. this._leftStickAxisY = leftStickY;
  36009. this._rightStickAxisX = rightStickX;
  36010. this._rightStickAxisY = rightStickY;
  36011. if (this.browserGamepad.axes.length >= 2) {
  36012. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36013. }
  36014. if (this.browserGamepad.axes.length >= 4) {
  36015. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36016. }
  36017. }
  36018. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36019. /**
  36020. * Specifies if the gamepad has been connected
  36021. */
  36022. get: function () {
  36023. return this._isConnected;
  36024. },
  36025. enumerable: true,
  36026. configurable: true
  36027. });
  36028. /**
  36029. * Callback triggered when the left joystick has changed
  36030. * @param callback
  36031. */
  36032. Gamepad.prototype.onleftstickchanged = function (callback) {
  36033. this._onleftstickchanged = callback;
  36034. };
  36035. /**
  36036. * Callback triggered when the right joystick has changed
  36037. * @param callback
  36038. */
  36039. Gamepad.prototype.onrightstickchanged = function (callback) {
  36040. this._onrightstickchanged = callback;
  36041. };
  36042. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36043. /**
  36044. * Gets the left joystick
  36045. */
  36046. get: function () {
  36047. return this._leftStick;
  36048. },
  36049. /**
  36050. * Sets the left joystick values
  36051. */
  36052. set: function (newValues) {
  36053. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36054. this._onleftstickchanged(newValues);
  36055. }
  36056. this._leftStick = newValues;
  36057. },
  36058. enumerable: true,
  36059. configurable: true
  36060. });
  36061. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36062. /**
  36063. * Gets the right joystick
  36064. */
  36065. get: function () {
  36066. return this._rightStick;
  36067. },
  36068. /**
  36069. * Sets the right joystick value
  36070. */
  36071. set: function (newValues) {
  36072. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36073. this._onrightstickchanged(newValues);
  36074. }
  36075. this._rightStick = newValues;
  36076. },
  36077. enumerable: true,
  36078. configurable: true
  36079. });
  36080. /**
  36081. * Updates the gamepad joystick positions
  36082. */
  36083. Gamepad.prototype.update = function () {
  36084. if (this._leftStick) {
  36085. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36086. if (this._invertLeftStickY) {
  36087. this.leftStick.y *= -1;
  36088. }
  36089. }
  36090. if (this._rightStick) {
  36091. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36092. }
  36093. };
  36094. /**
  36095. * Disposes the gamepad
  36096. */
  36097. Gamepad.prototype.dispose = function () {
  36098. };
  36099. /**
  36100. * Represents a gamepad controller
  36101. */
  36102. Gamepad.GAMEPAD = 0;
  36103. /**
  36104. * Represents a generic controller
  36105. */
  36106. Gamepad.GENERIC = 1;
  36107. /**
  36108. * Represents an XBox controller
  36109. */
  36110. Gamepad.XBOX = 2;
  36111. /**
  36112. * Represents a pose-enabled controller
  36113. */
  36114. Gamepad.POSE_ENABLED = 3;
  36115. return Gamepad;
  36116. }());
  36117. /**
  36118. * Represents a generic gamepad
  36119. */
  36120. var GenericPad = /** @class */ (function (_super) {
  36121. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36122. /**
  36123. * Initializes the generic gamepad
  36124. * @param id The id of the generic gamepad
  36125. * @param index The index of the generic gamepad
  36126. * @param browserGamepad The browser gamepad
  36127. */
  36128. function GenericPad(id, index, browserGamepad) {
  36129. var _this = _super.call(this, id, index, browserGamepad) || this;
  36130. /**
  36131. * Observable triggered when a button has been pressed
  36132. */
  36133. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36134. /**
  36135. * Observable triggered when a button has been released
  36136. */
  36137. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36138. _this.type = Gamepad.GENERIC;
  36139. _this._buttons = new Array(browserGamepad.buttons.length);
  36140. return _this;
  36141. }
  36142. /**
  36143. * Callback triggered when a button has been pressed
  36144. * @param callback Called when a button has been pressed
  36145. */
  36146. GenericPad.prototype.onbuttondown = function (callback) {
  36147. this._onbuttondown = callback;
  36148. };
  36149. /**
  36150. * Callback triggered when a button has been released
  36151. * @param callback Called when a button has been released
  36152. */
  36153. GenericPad.prototype.onbuttonup = function (callback) {
  36154. this._onbuttonup = callback;
  36155. };
  36156. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36157. if (newValue !== currentValue) {
  36158. if (newValue === 1) {
  36159. if (this._onbuttondown) {
  36160. this._onbuttondown(buttonIndex);
  36161. }
  36162. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36163. }
  36164. if (newValue === 0) {
  36165. if (this._onbuttonup) {
  36166. this._onbuttonup(buttonIndex);
  36167. }
  36168. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36169. }
  36170. }
  36171. return newValue;
  36172. };
  36173. /**
  36174. * Updates the generic gamepad
  36175. */
  36176. GenericPad.prototype.update = function () {
  36177. _super.prototype.update.call(this);
  36178. for (var index = 0; index < this._buttons.length; index++) {
  36179. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36180. }
  36181. };
  36182. /**
  36183. * Disposes the generic gamepad
  36184. */
  36185. GenericPad.prototype.dispose = function () {
  36186. _super.prototype.dispose.call(this);
  36187. this.onButtonDownObservable.clear();
  36188. this.onButtonUpObservable.clear();
  36189. };
  36190. return GenericPad;
  36191. }(Gamepad));
  36192. /***/ }),
  36193. /***/ "./Gamepads/gamepadManager.ts":
  36194. /*!************************************!*\
  36195. !*** ./Gamepads/gamepadManager.ts ***!
  36196. \************************************/
  36197. /*! exports provided: GamepadManager */
  36198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36199. "use strict";
  36200. __webpack_require__.r(__webpack_exports__);
  36201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36202. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36203. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36204. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36205. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36206. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36207. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36208. /**
  36209. * Manager for handling gamepads
  36210. */
  36211. var GamepadManager = /** @class */ (function () {
  36212. /**
  36213. * Initializes the gamepad manager
  36214. * @param _scene BabylonJS scene
  36215. */
  36216. function GamepadManager(_scene) {
  36217. var _this = this;
  36218. this._scene = _scene;
  36219. this._babylonGamepads = [];
  36220. this._oneGamepadConnected = false;
  36221. /** @hidden */
  36222. this._isMonitoring = false;
  36223. /**
  36224. * observable to be triggered when the gamepad controller has been disconnected
  36225. */
  36226. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36227. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36228. this._gamepadEventSupported = false;
  36229. }
  36230. else {
  36231. this._gamepadEventSupported = 'GamepadEvent' in window;
  36232. this._gamepadSupport = (navigator.getGamepads ||
  36233. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36234. }
  36235. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36236. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36237. for (var i in _this._babylonGamepads) {
  36238. var gamepad = _this._babylonGamepads[i];
  36239. if (gamepad && gamepad._isConnected) {
  36240. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36241. }
  36242. }
  36243. });
  36244. this._onGamepadConnectedEvent = function (evt) {
  36245. var gamepad = evt.gamepad;
  36246. if (gamepad.index in _this._babylonGamepads) {
  36247. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36248. return;
  36249. }
  36250. }
  36251. var newGamepad;
  36252. if (_this._babylonGamepads[gamepad.index]) {
  36253. newGamepad = _this._babylonGamepads[gamepad.index];
  36254. newGamepad.browserGamepad = gamepad;
  36255. newGamepad._isConnected = true;
  36256. }
  36257. else {
  36258. newGamepad = _this._addNewGamepad(gamepad);
  36259. }
  36260. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36261. _this._startMonitoringGamepads();
  36262. };
  36263. this._onGamepadDisconnectedEvent = function (evt) {
  36264. var gamepad = evt.gamepad;
  36265. // Remove the gamepad from the list of gamepads to monitor.
  36266. for (var i in _this._babylonGamepads) {
  36267. if (_this._babylonGamepads[i].index === gamepad.index) {
  36268. var disconnectedGamepad = _this._babylonGamepads[i];
  36269. disconnectedGamepad._isConnected = false;
  36270. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36271. break;
  36272. }
  36273. }
  36274. };
  36275. if (this._gamepadSupport) {
  36276. //first add already-connected gamepads
  36277. this._updateGamepadObjects();
  36278. if (this._babylonGamepads.length) {
  36279. this._startMonitoringGamepads();
  36280. }
  36281. // Checking if the gamepad connected event is supported (like in Firefox)
  36282. if (this._gamepadEventSupported) {
  36283. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36284. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36285. }
  36286. else {
  36287. this._startMonitoringGamepads();
  36288. }
  36289. }
  36290. }
  36291. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36292. /**
  36293. * The gamepads in the game pad manager
  36294. */
  36295. get: function () {
  36296. return this._babylonGamepads;
  36297. },
  36298. enumerable: true,
  36299. configurable: true
  36300. });
  36301. /**
  36302. * Get the gamepad controllers based on type
  36303. * @param type The type of gamepad controller
  36304. * @returns Nullable gamepad
  36305. */
  36306. GamepadManager.prototype.getGamepadByType = function (type) {
  36307. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  36308. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  36309. var gamepad = _a[_i];
  36310. if (gamepad && gamepad.type === type) {
  36311. return gamepad;
  36312. }
  36313. }
  36314. return null;
  36315. };
  36316. /**
  36317. * Disposes the gamepad manager
  36318. */
  36319. GamepadManager.prototype.dispose = function () {
  36320. if (this._gamepadEventSupported) {
  36321. if (this._onGamepadConnectedEvent) {
  36322. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  36323. }
  36324. if (this._onGamepadDisconnectedEvent) {
  36325. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  36326. }
  36327. this._onGamepadConnectedEvent = null;
  36328. this._onGamepadDisconnectedEvent = null;
  36329. }
  36330. this._babylonGamepads.forEach(function (gamepad) {
  36331. gamepad.dispose();
  36332. });
  36333. this.onGamepadConnectedObservable.clear();
  36334. this.onGamepadDisconnectedObservable.clear();
  36335. this._oneGamepadConnected = false;
  36336. this._stopMonitoringGamepads();
  36337. this._babylonGamepads = [];
  36338. };
  36339. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  36340. if (!this._oneGamepadConnected) {
  36341. this._oneGamepadConnected = true;
  36342. }
  36343. var newGamepad;
  36344. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  36345. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  36346. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  36347. }
  36348. // if pose is supported, use the (WebVR) pose enabled controller
  36349. else if (gamepad.pose) {
  36350. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  36351. }
  36352. else {
  36353. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  36354. }
  36355. this._babylonGamepads[newGamepad.index] = newGamepad;
  36356. return newGamepad;
  36357. };
  36358. GamepadManager.prototype._startMonitoringGamepads = function () {
  36359. if (!this._isMonitoring) {
  36360. this._isMonitoring = true;
  36361. //back-comp
  36362. if (!this._scene) {
  36363. this._checkGamepadsStatus();
  36364. }
  36365. }
  36366. };
  36367. GamepadManager.prototype._stopMonitoringGamepads = function () {
  36368. this._isMonitoring = false;
  36369. };
  36370. /** @hidden */
  36371. GamepadManager.prototype._checkGamepadsStatus = function () {
  36372. var _this = this;
  36373. // Hack to be compatible Chrome
  36374. this._updateGamepadObjects();
  36375. for (var i in this._babylonGamepads) {
  36376. var gamepad = this._babylonGamepads[i];
  36377. if (!gamepad || !gamepad.isConnected) {
  36378. continue;
  36379. }
  36380. gamepad.update();
  36381. }
  36382. if (this._isMonitoring && !this._scene) {
  36383. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  36384. }
  36385. };
  36386. // This function is called only on Chrome, which does not properly support
  36387. // connection/disconnection events and forces you to recopy again the gamepad object
  36388. GamepadManager.prototype._updateGamepadObjects = function () {
  36389. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  36390. for (var i = 0; i < gamepads.length; i++) {
  36391. var gamepad = gamepads[i];
  36392. if (gamepad) {
  36393. if (!this._babylonGamepads[gamepad.index]) {
  36394. var newGamepad = this._addNewGamepad(gamepad);
  36395. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36396. }
  36397. else {
  36398. // Forced to copy again this object for Chrome for unknown reason
  36399. this._babylonGamepads[i].browserGamepad = gamepad;
  36400. if (!this._babylonGamepads[i].isConnected) {
  36401. this._babylonGamepads[i]._isConnected = true;
  36402. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  36403. }
  36404. }
  36405. }
  36406. }
  36407. };
  36408. return GamepadManager;
  36409. }());
  36410. /***/ }),
  36411. /***/ "./Gamepads/gamepadSceneComponent.ts":
  36412. /*!*******************************************!*\
  36413. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  36414. \*******************************************/
  36415. /*! exports provided: GamepadSystemSceneComponent */
  36416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36417. "use strict";
  36418. __webpack_require__.r(__webpack_exports__);
  36419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  36420. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  36421. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  36422. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36423. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  36424. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  36425. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  36426. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  36427. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  36428. get: function () {
  36429. if (!this._gamepadManager) {
  36430. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  36431. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  36432. if (!component) {
  36433. component = new GamepadSystemSceneComponent(this);
  36434. this._addComponent(component);
  36435. }
  36436. }
  36437. return this._gamepadManager;
  36438. },
  36439. enumerable: true,
  36440. configurable: true
  36441. });
  36442. /**
  36443. * Adds a gamepad to the free camera inputs manager
  36444. */
  36445. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  36446. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  36447. return this;
  36448. };
  36449. /**
  36450. * Adds a gamepad to the arc rotate camera inputs manager
  36451. */
  36452. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  36453. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  36454. return this;
  36455. };
  36456. /**
  36457. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36458. */
  36459. var GamepadSystemSceneComponent = /** @class */ (function () {
  36460. /**
  36461. * Creates a new instance of the component for the given scene
  36462. * @param scene Defines the scene to register the component in
  36463. */
  36464. function GamepadSystemSceneComponent(scene) {
  36465. /**
  36466. * The component name helpfull to identify the component in the list of scene components.
  36467. */
  36468. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36469. this.scene = scene;
  36470. }
  36471. /**
  36472. * Registers the component in a given scene
  36473. */
  36474. GamepadSystemSceneComponent.prototype.register = function () {
  36475. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36476. };
  36477. /**
  36478. * Rebuilds the elements related to this component in case of
  36479. * context lost for instance.
  36480. */
  36481. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36482. // Nothing to do for gamepads
  36483. };
  36484. /**
  36485. * Disposes the component and the associated ressources
  36486. */
  36487. GamepadSystemSceneComponent.prototype.dispose = function () {
  36488. var gamepadManager = this.scene._gamepadManager;
  36489. if (gamepadManager) {
  36490. gamepadManager.dispose();
  36491. this.scene._gamepadManager = null;
  36492. }
  36493. };
  36494. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36495. var gamepadManager = this.scene._gamepadManager;
  36496. if (gamepadManager && gamepadManager._isMonitoring) {
  36497. gamepadManager._checkGamepadsStatus();
  36498. }
  36499. };
  36500. return GamepadSystemSceneComponent;
  36501. }());
  36502. /***/ }),
  36503. /***/ "./Gamepads/index.ts":
  36504. /*!***************************!*\
  36505. !*** ./Gamepads/index.ts ***!
  36506. \***************************/
  36507. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36509. "use strict";
  36510. __webpack_require__.r(__webpack_exports__);
  36511. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36522. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36526. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36528. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36530. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36534. /***/ }),
  36535. /***/ "./Gamepads/xboxGamepad.ts":
  36536. /*!*********************************!*\
  36537. !*** ./Gamepads/xboxGamepad.ts ***!
  36538. \*********************************/
  36539. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36541. "use strict";
  36542. __webpack_require__.r(__webpack_exports__);
  36543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36546. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36547. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36548. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36549. /**
  36550. * Defines supported buttons for XBox360 compatible gamepads
  36551. */
  36552. var Xbox360Button;
  36553. (function (Xbox360Button) {
  36554. /** A */
  36555. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36556. /** B */
  36557. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36558. /** X */
  36559. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36560. /** Y */
  36561. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36562. /** Start */
  36563. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36564. /** Back */
  36565. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36566. /** Left button */
  36567. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36568. /** Right button */
  36569. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36570. /** Left stick */
  36571. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36572. /** Right stick */
  36573. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36574. })(Xbox360Button || (Xbox360Button = {}));
  36575. /** Defines values for XBox360 DPad */
  36576. var Xbox360Dpad;
  36577. (function (Xbox360Dpad) {
  36578. /** Up */
  36579. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36580. /** Down */
  36581. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36582. /** Left */
  36583. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36584. /** Right */
  36585. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36586. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36587. /**
  36588. * Defines a XBox360 gamepad
  36589. */
  36590. var Xbox360Pad = /** @class */ (function (_super) {
  36591. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36592. /**
  36593. * Creates a new XBox360 gamepad object
  36594. * @param id defines the id of this gamepad
  36595. * @param index defines its index
  36596. * @param gamepad defines the internal HTML gamepad object
  36597. * @param xboxOne defines if it is a XBox One gamepad
  36598. */
  36599. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36600. if (xboxOne === void 0) { xboxOne = false; }
  36601. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36602. _this._leftTrigger = 0;
  36603. _this._rightTrigger = 0;
  36604. /** Observable raised when a button is pressed */
  36605. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36606. /** Observable raised when a button is released */
  36607. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36608. /** Observable raised when a pad is pressed */
  36609. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36610. /** Observable raised when a pad is released */
  36611. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36612. _this._buttonA = 0;
  36613. _this._buttonB = 0;
  36614. _this._buttonX = 0;
  36615. _this._buttonY = 0;
  36616. _this._buttonBack = 0;
  36617. _this._buttonStart = 0;
  36618. _this._buttonLB = 0;
  36619. _this._buttonRB = 0;
  36620. _this._buttonLeftStick = 0;
  36621. _this._buttonRightStick = 0;
  36622. _this._dPadUp = 0;
  36623. _this._dPadDown = 0;
  36624. _this._dPadLeft = 0;
  36625. _this._dPadRight = 0;
  36626. _this._isXboxOnePad = false;
  36627. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36628. _this._isXboxOnePad = xboxOne;
  36629. return _this;
  36630. }
  36631. /**
  36632. * Defines the callback to call when left trigger is pressed
  36633. * @param callback defines the callback to use
  36634. */
  36635. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36636. this._onlefttriggerchanged = callback;
  36637. };
  36638. /**
  36639. * Defines the callback to call when right trigger is pressed
  36640. * @param callback defines the callback to use
  36641. */
  36642. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36643. this._onrighttriggerchanged = callback;
  36644. };
  36645. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36646. /**
  36647. * Gets the left trigger value
  36648. */
  36649. get: function () {
  36650. return this._leftTrigger;
  36651. },
  36652. /**
  36653. * Sets the left trigger value
  36654. */
  36655. set: function (newValue) {
  36656. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36657. this._onlefttriggerchanged(newValue);
  36658. }
  36659. this._leftTrigger = newValue;
  36660. },
  36661. enumerable: true,
  36662. configurable: true
  36663. });
  36664. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36665. /**
  36666. * Gets the right trigger value
  36667. */
  36668. get: function () {
  36669. return this._rightTrigger;
  36670. },
  36671. /**
  36672. * Sets the right trigger value
  36673. */
  36674. set: function (newValue) {
  36675. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36676. this._onrighttriggerchanged(newValue);
  36677. }
  36678. this._rightTrigger = newValue;
  36679. },
  36680. enumerable: true,
  36681. configurable: true
  36682. });
  36683. /**
  36684. * Defines the callback to call when a button is pressed
  36685. * @param callback defines the callback to use
  36686. */
  36687. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36688. this._onbuttondown = callback;
  36689. };
  36690. /**
  36691. * Defines the callback to call when a button is released
  36692. * @param callback defines the callback to use
  36693. */
  36694. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36695. this._onbuttonup = callback;
  36696. };
  36697. /**
  36698. * Defines the callback to call when a pad is pressed
  36699. * @param callback defines the callback to use
  36700. */
  36701. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36702. this._ondpaddown = callback;
  36703. };
  36704. /**
  36705. * Defines the callback to call when a pad is released
  36706. * @param callback defines the callback to use
  36707. */
  36708. Xbox360Pad.prototype.ondpadup = function (callback) {
  36709. this._ondpadup = callback;
  36710. };
  36711. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36712. if (newValue !== currentValue) {
  36713. if (newValue === 1) {
  36714. if (this._onbuttondown) {
  36715. this._onbuttondown(buttonType);
  36716. }
  36717. this.onButtonDownObservable.notifyObservers(buttonType);
  36718. }
  36719. if (newValue === 0) {
  36720. if (this._onbuttonup) {
  36721. this._onbuttonup(buttonType);
  36722. }
  36723. this.onButtonUpObservable.notifyObservers(buttonType);
  36724. }
  36725. }
  36726. return newValue;
  36727. };
  36728. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36729. if (newValue !== currentValue) {
  36730. if (newValue === 1) {
  36731. if (this._ondpaddown) {
  36732. this._ondpaddown(buttonType);
  36733. }
  36734. this.onPadDownObservable.notifyObservers(buttonType);
  36735. }
  36736. if (newValue === 0) {
  36737. if (this._ondpadup) {
  36738. this._ondpadup(buttonType);
  36739. }
  36740. this.onPadUpObservable.notifyObservers(buttonType);
  36741. }
  36742. }
  36743. return newValue;
  36744. };
  36745. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36746. /**
  36747. * Gets the value of the `A` button
  36748. */
  36749. get: function () {
  36750. return this._buttonA;
  36751. },
  36752. /**
  36753. * Sets the value of the `A` button
  36754. */
  36755. set: function (value) {
  36756. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36757. },
  36758. enumerable: true,
  36759. configurable: true
  36760. });
  36761. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36762. /**
  36763. * Gets the value of the `B` button
  36764. */
  36765. get: function () {
  36766. return this._buttonB;
  36767. },
  36768. /**
  36769. * Sets the value of the `B` button
  36770. */
  36771. set: function (value) {
  36772. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36773. },
  36774. enumerable: true,
  36775. configurable: true
  36776. });
  36777. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36778. /**
  36779. * Gets the value of the `X` button
  36780. */
  36781. get: function () {
  36782. return this._buttonX;
  36783. },
  36784. /**
  36785. * Sets the value of the `X` button
  36786. */
  36787. set: function (value) {
  36788. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36789. },
  36790. enumerable: true,
  36791. configurable: true
  36792. });
  36793. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36794. /**
  36795. * Gets the value of the `Y` button
  36796. */
  36797. get: function () {
  36798. return this._buttonY;
  36799. },
  36800. /**
  36801. * Sets the value of the `Y` button
  36802. */
  36803. set: function (value) {
  36804. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  36805. },
  36806. enumerable: true,
  36807. configurable: true
  36808. });
  36809. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  36810. /**
  36811. * Gets the value of the `Start` button
  36812. */
  36813. get: function () {
  36814. return this._buttonStart;
  36815. },
  36816. /**
  36817. * Sets the value of the `Start` button
  36818. */
  36819. set: function (value) {
  36820. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  36821. },
  36822. enumerable: true,
  36823. configurable: true
  36824. });
  36825. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  36826. /**
  36827. * Gets the value of the `Back` button
  36828. */
  36829. get: function () {
  36830. return this._buttonBack;
  36831. },
  36832. /**
  36833. * Sets the value of the `Back` button
  36834. */
  36835. set: function (value) {
  36836. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  36837. },
  36838. enumerable: true,
  36839. configurable: true
  36840. });
  36841. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  36842. /**
  36843. * Gets the value of the `Left` button
  36844. */
  36845. get: function () {
  36846. return this._buttonLB;
  36847. },
  36848. /**
  36849. * Sets the value of the `Left` button
  36850. */
  36851. set: function (value) {
  36852. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  36853. },
  36854. enumerable: true,
  36855. configurable: true
  36856. });
  36857. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  36858. /**
  36859. * Gets the value of the `Right` button
  36860. */
  36861. get: function () {
  36862. return this._buttonRB;
  36863. },
  36864. /**
  36865. * Sets the value of the `Right` button
  36866. */
  36867. set: function (value) {
  36868. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  36869. },
  36870. enumerable: true,
  36871. configurable: true
  36872. });
  36873. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  36874. /**
  36875. * Gets the value of the Left joystick
  36876. */
  36877. get: function () {
  36878. return this._buttonLeftStick;
  36879. },
  36880. /**
  36881. * Sets the value of the Left joystick
  36882. */
  36883. set: function (value) {
  36884. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  36885. },
  36886. enumerable: true,
  36887. configurable: true
  36888. });
  36889. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  36890. /**
  36891. * Gets the value of the Right joystick
  36892. */
  36893. get: function () {
  36894. return this._buttonRightStick;
  36895. },
  36896. /**
  36897. * Sets the value of the Right joystick
  36898. */
  36899. set: function (value) {
  36900. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  36901. },
  36902. enumerable: true,
  36903. configurable: true
  36904. });
  36905. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  36906. /**
  36907. * Gets the value of D-pad up
  36908. */
  36909. get: function () {
  36910. return this._dPadUp;
  36911. },
  36912. /**
  36913. * Sets the value of D-pad up
  36914. */
  36915. set: function (value) {
  36916. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  36917. },
  36918. enumerable: true,
  36919. configurable: true
  36920. });
  36921. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  36922. /**
  36923. * Gets the value of D-pad down
  36924. */
  36925. get: function () {
  36926. return this._dPadDown;
  36927. },
  36928. /**
  36929. * Sets the value of D-pad down
  36930. */
  36931. set: function (value) {
  36932. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  36933. },
  36934. enumerable: true,
  36935. configurable: true
  36936. });
  36937. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  36938. /**
  36939. * Gets the value of D-pad left
  36940. */
  36941. get: function () {
  36942. return this._dPadLeft;
  36943. },
  36944. /**
  36945. * Sets the value of D-pad left
  36946. */
  36947. set: function (value) {
  36948. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  36949. },
  36950. enumerable: true,
  36951. configurable: true
  36952. });
  36953. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  36954. /**
  36955. * Gets the value of D-pad right
  36956. */
  36957. get: function () {
  36958. return this._dPadRight;
  36959. },
  36960. /**
  36961. * Sets the value of D-pad right
  36962. */
  36963. set: function (value) {
  36964. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  36965. },
  36966. enumerable: true,
  36967. configurable: true
  36968. });
  36969. /**
  36970. * Force the gamepad to synchronize with device values
  36971. */
  36972. Xbox360Pad.prototype.update = function () {
  36973. _super.prototype.update.call(this);
  36974. if (this._isXboxOnePad) {
  36975. this.buttonA = this.browserGamepad.buttons[0].value;
  36976. this.buttonB = this.browserGamepad.buttons[1].value;
  36977. this.buttonX = this.browserGamepad.buttons[2].value;
  36978. this.buttonY = this.browserGamepad.buttons[3].value;
  36979. this.buttonLB = this.browserGamepad.buttons[4].value;
  36980. this.buttonRB = this.browserGamepad.buttons[5].value;
  36981. this.leftTrigger = this.browserGamepad.axes[2];
  36982. this.rightTrigger = this.browserGamepad.axes[5];
  36983. this.buttonBack = this.browserGamepad.buttons[9].value;
  36984. this.buttonStart = this.browserGamepad.buttons[8].value;
  36985. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  36986. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  36987. this.dPadUp = this.browserGamepad.buttons[11].value;
  36988. this.dPadDown = this.browserGamepad.buttons[12].value;
  36989. this.dPadLeft = this.browserGamepad.buttons[13].value;
  36990. this.dPadRight = this.browserGamepad.buttons[14].value;
  36991. }
  36992. else {
  36993. this.buttonA = this.browserGamepad.buttons[0].value;
  36994. this.buttonB = this.browserGamepad.buttons[1].value;
  36995. this.buttonX = this.browserGamepad.buttons[2].value;
  36996. this.buttonY = this.browserGamepad.buttons[3].value;
  36997. this.buttonLB = this.browserGamepad.buttons[4].value;
  36998. this.buttonRB = this.browserGamepad.buttons[5].value;
  36999. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37000. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37001. this.buttonBack = this.browserGamepad.buttons[8].value;
  37002. this.buttonStart = this.browserGamepad.buttons[9].value;
  37003. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37004. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37005. this.dPadUp = this.browserGamepad.buttons[12].value;
  37006. this.dPadDown = this.browserGamepad.buttons[13].value;
  37007. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37008. this.dPadRight = this.browserGamepad.buttons[15].value;
  37009. }
  37010. };
  37011. /**
  37012. * Disposes the gamepad
  37013. */
  37014. Xbox360Pad.prototype.dispose = function () {
  37015. _super.prototype.dispose.call(this);
  37016. this.onButtonDownObservable.clear();
  37017. this.onButtonUpObservable.clear();
  37018. this.onPadDownObservable.clear();
  37019. this.onPadUpObservable.clear();
  37020. };
  37021. return Xbox360Pad;
  37022. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37023. /***/ }),
  37024. /***/ "./Gizmos/axisDragGizmo.ts":
  37025. /*!*********************************!*\
  37026. !*** ./Gizmos/axisDragGizmo.ts ***!
  37027. \*********************************/
  37028. /*! exports provided: AxisDragGizmo */
  37029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37030. "use strict";
  37031. __webpack_require__.r(__webpack_exports__);
  37032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37033. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37034. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37035. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37036. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37037. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37038. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37039. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37040. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37041. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37042. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37043. /**
  37044. * Single axis drag gizmo
  37045. */
  37046. var AxisDragGizmo = /** @class */ (function (_super) {
  37047. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37048. /**
  37049. * Creates an AxisDragGizmo
  37050. * @param gizmoLayer The utility layer the gizmo will be added to
  37051. * @param dragAxis The axis which the gizmo will be able to drag on
  37052. * @param color The color of the gizmo
  37053. */
  37054. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37055. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37056. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37057. var _this = _super.call(this, gizmoLayer) || this;
  37058. _this._pointerObserver = null;
  37059. /**
  37060. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37061. */
  37062. _this.snapDistance = 0;
  37063. /**
  37064. * Event that fires each time the gizmo snaps to a new location.
  37065. * * snapDistance is the the change in distance
  37066. */
  37067. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37068. // Create Material
  37069. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37070. coloredMaterial.disableLighting = true;
  37071. coloredMaterial.emissiveColor = color;
  37072. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37073. hoverMaterial.disableLighting = true;
  37074. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37075. // Build mesh on root node
  37076. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37077. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37078. arrow.scaling.scaleInPlace(1 / 3);
  37079. arrow.parent = _this._rootMesh;
  37080. var currentSnapDragDistance = 0;
  37081. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37082. var tmpSnapEvent = { snapDistance: 0 };
  37083. // Add drag behavior to handle events when the gizmo is dragged
  37084. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37085. _this.dragBehavior.moveAttached = false;
  37086. _this._rootMesh.addBehavior(_this.dragBehavior);
  37087. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37088. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37089. _this.dragBehavior.onDragObservable.add(function (event) {
  37090. if (_this.attachedMesh) {
  37091. // Convert delta to local translation if it has a parent
  37092. if (_this.attachedMesh.parent) {
  37093. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37094. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37095. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37096. }
  37097. else {
  37098. localDelta.copyFrom(event.delta);
  37099. }
  37100. // Snapping logic
  37101. if (_this.snapDistance == 0) {
  37102. _this.attachedMesh.position.addInPlace(localDelta);
  37103. }
  37104. else {
  37105. currentSnapDragDistance += event.dragDistance;
  37106. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37107. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37108. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37109. localDelta.normalizeToRef(tmpVector);
  37110. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37111. _this.attachedMesh.position.addInPlace(tmpVector);
  37112. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37113. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37114. }
  37115. }
  37116. }
  37117. });
  37118. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37119. if (_this._customMeshSet) {
  37120. return;
  37121. }
  37122. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37123. var material = isHovered ? hoverMaterial : coloredMaterial;
  37124. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37125. m.material = material;
  37126. if (m.color) {
  37127. m.color = material.emissiveColor;
  37128. }
  37129. });
  37130. });
  37131. return _this;
  37132. }
  37133. /** @hidden */
  37134. AxisDragGizmo._CreateArrow = function (scene, material) {
  37135. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37136. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37137. var line = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__["LinesBuilder"].CreateLines("line", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, scene);
  37138. line.color = material.emissiveColor;
  37139. cylinder.parent = arrow;
  37140. line.parent = arrow;
  37141. // Position arrow pointing in its drag axis
  37142. cylinder.scaling.scaleInPlace(0.05);
  37143. cylinder.material = material;
  37144. cylinder.rotation.x = Math.PI / 2;
  37145. cylinder.position.z += 0.3;
  37146. line.scaling.scaleInPlace(0.26);
  37147. line.rotation.x = Math.PI / 2;
  37148. line.material = material;
  37149. return arrow;
  37150. };
  37151. /** @hidden */
  37152. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37153. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37154. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37155. var mesh = _a[_i];
  37156. var childInstance = mesh.createInstance(mesh.name);
  37157. childInstance.parent = instance;
  37158. }
  37159. return instance;
  37160. };
  37161. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37162. if (this.dragBehavior) {
  37163. this.dragBehavior.enabled = value ? true : false;
  37164. }
  37165. };
  37166. /**
  37167. * Disposes of the gizmo
  37168. */
  37169. AxisDragGizmo.prototype.dispose = function () {
  37170. this.onSnapObservable.clear();
  37171. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37172. this.dragBehavior.detach();
  37173. _super.prototype.dispose.call(this);
  37174. };
  37175. return AxisDragGizmo;
  37176. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37177. /***/ }),
  37178. /***/ "./Gizmos/axisScaleGizmo.ts":
  37179. /*!**********************************!*\
  37180. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37181. \**********************************/
  37182. /*! exports provided: AxisScaleGizmo */
  37183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37184. "use strict";
  37185. __webpack_require__.r(__webpack_exports__);
  37186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37187. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37188. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37189. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37190. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37191. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37192. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37193. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37194. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37195. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37196. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37197. /**
  37198. * Single axis scale gizmo
  37199. */
  37200. var AxisScaleGizmo = /** @class */ (function (_super) {
  37201. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37202. /**
  37203. * Creates an AxisScaleGizmo
  37204. * @param gizmoLayer The utility layer the gizmo will be added to
  37205. * @param dragAxis The axis which the gizmo will be able to scale on
  37206. * @param color The color of the gizmo
  37207. */
  37208. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37209. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37210. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37211. var _this = _super.call(this, gizmoLayer) || this;
  37212. _this._pointerObserver = null;
  37213. /**
  37214. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37215. */
  37216. _this.snapDistance = 0;
  37217. /**
  37218. * Event that fires each time the gizmo snaps to a new location.
  37219. * * snapDistance is the the change in distance
  37220. */
  37221. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37222. /**
  37223. * If the scaling operation should be done on all axis (default: false)
  37224. */
  37225. _this.uniformScaling = false;
  37226. // Create Material
  37227. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37228. _this._coloredMaterial.disableLighting = true;
  37229. _this._coloredMaterial.emissiveColor = color;
  37230. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37231. hoverMaterial.disableLighting = true;
  37232. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37233. // Build mesh on root node
  37234. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37235. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37236. var arrowTail = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__["LinesBuilder"].CreateLines("yPosMesh", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, gizmoLayer.utilityLayerScene);
  37237. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37238. arrow.addChild(arrowMesh);
  37239. arrow.addChild(arrowTail);
  37240. // Position arrow pointing in its drag axis
  37241. arrowMesh.scaling.scaleInPlace(0.1);
  37242. arrowMesh.material = _this._coloredMaterial;
  37243. arrowMesh.rotation.x = Math.PI / 2;
  37244. arrowMesh.position.z += 0.3;
  37245. arrowTail.scaling.scaleInPlace(0.26);
  37246. arrowTail.rotation.x = Math.PI / 2;
  37247. arrowTail.material = _this._coloredMaterial;
  37248. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37249. _this._rootMesh.addChild(arrow);
  37250. arrow.scaling.scaleInPlace(1 / 3);
  37251. // Add drag behavior to handle events when the gizmo is dragged
  37252. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37253. _this.dragBehavior.moveAttached = false;
  37254. _this._rootMesh.addBehavior(_this.dragBehavior);
  37255. var currentSnapDragDistance = 0;
  37256. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37257. var tmpSnapEvent = { snapDistance: 0 };
  37258. _this.dragBehavior.onDragObservable.add(function (event) {
  37259. if (_this.attachedMesh) {
  37260. // Snapping logic
  37261. var snapped = false;
  37262. var dragSteps = 0;
  37263. if (_this.uniformScaling) {
  37264. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37265. if (tmpVector.y < 0) {
  37266. tmpVector.scaleInPlace(-1);
  37267. }
  37268. }
  37269. else {
  37270. tmpVector.copyFrom(dragAxis);
  37271. }
  37272. if (_this.snapDistance == 0) {
  37273. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37274. }
  37275. else {
  37276. currentSnapDragDistance += event.dragDistance;
  37277. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37278. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37279. if (currentSnapDragDistance < 0) {
  37280. dragSteps *= -1;
  37281. }
  37282. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37283. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37284. snapped = true;
  37285. }
  37286. else {
  37287. tmpVector.scaleInPlace(0);
  37288. }
  37289. }
  37290. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37291. if (snapped) {
  37292. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37293. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37294. }
  37295. }
  37296. });
  37297. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37298. if (_this._customMeshSet) {
  37299. return;
  37300. }
  37301. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37302. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  37303. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37304. m.material = material;
  37305. if (m.color) {
  37306. m.color = material.emissiveColor;
  37307. }
  37308. });
  37309. });
  37310. return _this;
  37311. }
  37312. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  37313. if (this.dragBehavior) {
  37314. this.dragBehavior.enabled = value ? true : false;
  37315. }
  37316. };
  37317. /**
  37318. * Disposes of the gizmo
  37319. */
  37320. AxisScaleGizmo.prototype.dispose = function () {
  37321. this.onSnapObservable.clear();
  37322. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37323. this.dragBehavior.detach();
  37324. _super.prototype.dispose.call(this);
  37325. };
  37326. /**
  37327. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37328. * @param mesh The mesh to replace the default mesh of the gizmo
  37329. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  37330. */
  37331. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  37332. var _this = this;
  37333. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  37334. _super.prototype.setCustomMesh.call(this, mesh);
  37335. if (useGizmoMaterial) {
  37336. this._rootMesh.getChildMeshes().forEach(function (m) {
  37337. m.material = _this._coloredMaterial;
  37338. if (m.color) {
  37339. m.color = _this._coloredMaterial.emissiveColor;
  37340. }
  37341. });
  37342. this._customMeshSet = false;
  37343. }
  37344. };
  37345. return AxisScaleGizmo;
  37346. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37347. /***/ }),
  37348. /***/ "./Gizmos/boundingBoxGizmo.ts":
  37349. /*!************************************!*\
  37350. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  37351. \************************************/
  37352. /*! exports provided: BoundingBoxGizmo */
  37353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37354. "use strict";
  37355. __webpack_require__.r(__webpack_exports__);
  37356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  37357. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37358. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37359. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37360. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37361. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37362. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37363. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  37364. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37365. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37366. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37367. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37368. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37369. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37370. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  37371. /**
  37372. * Bounding box gizmo
  37373. */
  37374. var BoundingBoxGizmo = /** @class */ (function (_super) {
  37375. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  37376. /**
  37377. * Creates an BoundingBoxGizmo
  37378. * @param gizmoLayer The utility layer the gizmo will be added to
  37379. * @param color The color of the gizmo
  37380. */
  37381. function BoundingBoxGizmo(color, gizmoLayer) {
  37382. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  37383. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  37384. var _this = _super.call(this, gizmoLayer) || this;
  37385. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  37386. _this._renderObserver = null;
  37387. _this._pointerObserver = null;
  37388. _this._scaleDragSpeed = 0.2;
  37389. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37390. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  37391. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  37392. /**
  37393. * 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)
  37394. */
  37395. _this.ignoreChildren = false;
  37396. /**
  37397. * 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)
  37398. */
  37399. _this.includeChildPredicate = null;
  37400. /**
  37401. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  37402. */
  37403. _this.rotationSphereSize = 0.1;
  37404. /**
  37405. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  37406. */
  37407. _this.scaleBoxSize = 0.1;
  37408. /**
  37409. * 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)
  37410. */
  37411. _this.fixedDragMeshScreenSize = false;
  37412. /**
  37413. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  37414. */
  37415. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  37416. /**
  37417. * Fired when a rotation sphere or scale box is dragged
  37418. */
  37419. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37420. /**
  37421. * Fired when a scale box is dragged
  37422. */
  37423. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37424. /**
  37425. * Fired when a scale box drag is ended
  37426. */
  37427. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37428. /**
  37429. * Fired when a rotation sphere is dragged
  37430. */
  37431. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37432. /**
  37433. * Fired when a rotation sphere drag is ended
  37434. */
  37435. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37436. /**
  37437. * 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)
  37438. */
  37439. _this.scalePivot = null;
  37440. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  37441. // Dragging
  37442. _this._dragMesh = null;
  37443. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  37444. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  37445. _this._updateScale = false;
  37446. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  37447. // Create Materials
  37448. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37449. coloredMaterial.disableLighting = true;
  37450. coloredMaterial.emissiveColor = color;
  37451. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37452. hoverColoredMaterial.disableLighting = true;
  37453. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  37454. // Build bounding box out of lines
  37455. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37456. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37457. var lines = [];
  37458. 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));
  37459. 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));
  37460. 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));
  37461. 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));
  37462. 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));
  37463. 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));
  37464. 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));
  37465. 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));
  37466. 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));
  37467. 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));
  37468. 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));
  37469. 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));
  37470. lines.forEach(function (l) {
  37471. l.color = color;
  37472. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37473. l.isPickable = false;
  37474. _this._lineBoundingBox.addChild(l);
  37475. });
  37476. _this._rootMesh.addChild(_this._lineBoundingBox);
  37477. // Create rotation spheres
  37478. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37479. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37480. var _loop_1 = function (i_1) {
  37481. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37482. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37483. sphere.material = coloredMaterial;
  37484. // Drag behavior
  37485. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  37486. _dragBehavior.moveAttached = false;
  37487. _dragBehavior.updateDragPlane = false;
  37488. sphere.addBehavior(_dragBehavior);
  37489. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37490. var totalTurnAmountOfDrag = 0;
  37491. _dragBehavior.onDragStartObservable.add(function () {
  37492. startingTurnDirection.copyFrom(sphere.forward);
  37493. totalTurnAmountOfDrag = 0;
  37494. });
  37495. _dragBehavior.onDragObservable.add(function (event) {
  37496. _this.onRotationSphereDragObservable.notifyObservers({});
  37497. if (_this.attachedMesh) {
  37498. var originalParent = _this.attachedMesh.parent;
  37499. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37500. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37501. return;
  37502. }
  37503. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37504. var worldDragDirection = startingTurnDirection;
  37505. // Project the world right on to the drag plane
  37506. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37507. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37508. // project drag delta on to the resulting drag axis and rotate based on that
  37509. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37510. // Make rotation relative to size of mesh.
  37511. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37512. // Rotate based on axis
  37513. if (!_this.attachedMesh.rotationQuaternion) {
  37514. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37515. }
  37516. if (!_this._anchorMesh.rotationQuaternion) {
  37517. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37518. }
  37519. // Do not allow the object to turn more than a full circle
  37520. totalTurnAmountOfDrag += projectDist;
  37521. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37522. if (i_1 >= 8) {
  37523. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37524. }
  37525. else if (i_1 >= 4) {
  37526. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37527. }
  37528. else {
  37529. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37530. }
  37531. // Rotate around center of bounding box
  37532. _this._anchorMesh.addChild(_this.attachedMesh);
  37533. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37534. _this._anchorMesh.removeChild(_this.attachedMesh);
  37535. _this.attachedMesh.setParent(originalParent);
  37536. }
  37537. _this.updateBoundingBox();
  37538. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37539. }
  37540. _this._updateDummy();
  37541. });
  37542. // Selection/deselection
  37543. _dragBehavior.onDragStartObservable.add(function () {
  37544. _this.onDragStartObservable.notifyObservers({});
  37545. _this._selectNode(sphere);
  37546. });
  37547. _dragBehavior.onDragEndObservable.add(function () {
  37548. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37549. _this._selectNode(null);
  37550. _this._updateDummy();
  37551. });
  37552. this_1._rotateSpheresParent.addChild(sphere);
  37553. };
  37554. var this_1 = this, _dragBehavior;
  37555. for (var i_1 = 0; i_1 < 12; i_1++) {
  37556. _loop_1(i_1);
  37557. }
  37558. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37559. // Create scale cubes
  37560. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37561. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37562. for (var i = 0; i < 2; i++) {
  37563. for (var j = 0; j < 2; j++) {
  37564. var _loop_2 = function () {
  37565. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37566. box.material = coloredMaterial;
  37567. // Dragging logic
  37568. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37569. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37570. _dragBehavior.moveAttached = false;
  37571. box.addBehavior(_dragBehavior);
  37572. _dragBehavior.onDragObservable.add(function (event) {
  37573. _this.onScaleBoxDragObservable.notifyObservers({});
  37574. if (_this.attachedMesh) {
  37575. var originalParent = _this.attachedMesh.parent;
  37576. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37577. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37578. return;
  37579. }
  37580. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37581. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37582. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37583. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37584. _this.updateBoundingBox();
  37585. if (_this.scalePivot) {
  37586. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37587. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37588. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37589. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37590. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37591. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37592. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37593. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37594. }
  37595. else {
  37596. // Scale from the position of the opposite corner
  37597. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37598. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37599. }
  37600. _this._anchorMesh.addChild(_this.attachedMesh);
  37601. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37602. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37603. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37604. }
  37605. _this._anchorMesh.removeChild(_this.attachedMesh);
  37606. _this.attachedMesh.setParent(originalParent);
  37607. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37608. }
  37609. _this._updateDummy();
  37610. });
  37611. // Selection/deselection
  37612. _dragBehavior.onDragStartObservable.add(function () {
  37613. _this.onDragStartObservable.notifyObservers({});
  37614. _this._selectNode(box);
  37615. });
  37616. _dragBehavior.onDragEndObservable.add(function () {
  37617. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37618. _this._selectNode(null);
  37619. _this._updateDummy();
  37620. });
  37621. this_2._scaleBoxesParent.addChild(box);
  37622. };
  37623. var this_2 = this, _dragBehavior;
  37624. for (var k = 0; k < 2; k++) {
  37625. _loop_2();
  37626. }
  37627. }
  37628. }
  37629. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37630. // Hover color change
  37631. var pointerIds = new Array();
  37632. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37633. if (!pointerIds[pointerInfo.event.pointerId]) {
  37634. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37635. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37636. pointerIds[pointerInfo.event.pointerId] = mesh;
  37637. mesh.material = hoverColoredMaterial;
  37638. }
  37639. });
  37640. }
  37641. else {
  37642. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37643. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37644. delete pointerIds[pointerInfo.event.pointerId];
  37645. }
  37646. }
  37647. });
  37648. // Update bounding box positions
  37649. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37650. // Only update the bouding box if scaling has changed
  37651. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37652. _this.updateBoundingBox();
  37653. }
  37654. else if (_this.fixedDragMeshScreenSize) {
  37655. _this._updateRotationSpheres();
  37656. _this._updateScaleBoxes();
  37657. }
  37658. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37659. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37660. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37661. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37662. }
  37663. });
  37664. _this.updateBoundingBox();
  37665. return _this;
  37666. }
  37667. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37668. var _this = this;
  37669. if (value) {
  37670. // Reset anchor mesh to match attached mesh's scale
  37671. // This is needed to avoid invalid box/sphere position on first drag
  37672. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37673. var originalParent = value.parent;
  37674. this._anchorMesh.addChild(value);
  37675. this._anchorMesh.removeChild(value);
  37676. value.setParent(originalParent);
  37677. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  37678. this.updateBoundingBox();
  37679. value.getChildMeshes(false).forEach(function (m) {
  37680. m.markAsDirty("scaling");
  37681. });
  37682. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37683. _this._updateDummy();
  37684. });
  37685. }
  37686. };
  37687. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37688. this._rotateSpheresParent.getChildMeshes()
  37689. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37690. m.isVisible = (!selectedMesh || m == selectedMesh);
  37691. });
  37692. };
  37693. /**
  37694. * Updates the bounding box information for the Gizmo
  37695. */
  37696. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37697. if (this.attachedMesh) {
  37698. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37699. var originalParent = this.attachedMesh.parent;
  37700. this.attachedMesh.setParent(null);
  37701. this._update();
  37702. // Rotate based on axis
  37703. if (!this.attachedMesh.rotationQuaternion) {
  37704. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37705. }
  37706. if (!this._anchorMesh.rotationQuaternion) {
  37707. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37708. }
  37709. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37710. // Store original position and reset mesh to origin before computing the bounding box
  37711. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37712. this._tmpVector.copyFrom(this.attachedMesh.position);
  37713. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37714. this.attachedMesh.position.set(0, 0, 0);
  37715. // Update bounding dimensions/positions
  37716. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37717. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37718. // Update gizmo to match bounding box scaling and rotation
  37719. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37720. 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);
  37721. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37722. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37723. this._lineBoundingBox.computeWorldMatrix();
  37724. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37725. // restore position/rotation values
  37726. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37727. this.attachedMesh.position.copyFrom(this._tmpVector);
  37728. this.attachedMesh.setParent(originalParent);
  37729. }
  37730. this._updateRotationSpheres();
  37731. this._updateScaleBoxes();
  37732. if (this.attachedMesh) {
  37733. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37734. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37735. }
  37736. };
  37737. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37738. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37739. for (var i = 0; i < 3; i++) {
  37740. for (var j = 0; j < 2; j++) {
  37741. for (var k = 0; k < 2; k++) {
  37742. var index = ((i * 4) + (j * 2)) + k;
  37743. if (i == 0) {
  37744. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37745. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37746. 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));
  37747. }
  37748. if (i == 1) {
  37749. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37750. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37751. 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));
  37752. }
  37753. if (i == 2) {
  37754. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37755. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37756. 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));
  37757. }
  37758. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37759. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37760. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37761. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37762. }
  37763. else {
  37764. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37765. }
  37766. }
  37767. }
  37768. }
  37769. };
  37770. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37771. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37772. for (var i = 0; i < 2; i++) {
  37773. for (var j = 0; j < 2; j++) {
  37774. for (var k = 0; k < 2; k++) {
  37775. var index = ((i * 4) + (j * 2)) + k;
  37776. if (scaleBoxes[index]) {
  37777. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37778. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37779. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37780. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37781. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37782. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37783. }
  37784. else {
  37785. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37786. }
  37787. }
  37788. }
  37789. }
  37790. }
  37791. };
  37792. /**
  37793. * Enables rotation on the specified axis and disables rotation on the others
  37794. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37795. */
  37796. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  37797. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  37798. if (i < 4) {
  37799. m.setEnabled(axis.indexOf("x") != -1);
  37800. }
  37801. else if (i < 8) {
  37802. m.setEnabled(axis.indexOf("y") != -1);
  37803. }
  37804. else {
  37805. m.setEnabled(axis.indexOf("z") != -1);
  37806. }
  37807. });
  37808. };
  37809. /**
  37810. * Enables/disables scaling
  37811. * @param enable if scaling should be enabled
  37812. */
  37813. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  37814. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  37815. m.setEnabled(enable);
  37816. });
  37817. };
  37818. BoundingBoxGizmo.prototype._updateDummy = function () {
  37819. if (this._dragMesh) {
  37820. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  37821. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  37822. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  37823. }
  37824. };
  37825. /**
  37826. * Enables a pointer drag behavior on the bounding box of the gizmo
  37827. */
  37828. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  37829. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  37830. this._dragMesh.visibility = 0;
  37831. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37832. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  37833. this._dragMesh.addBehavior(this.pointerDragBehavior);
  37834. };
  37835. /**
  37836. * Disposes of the gizmo
  37837. */
  37838. BoundingBoxGizmo.prototype.dispose = function () {
  37839. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37840. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  37841. this._lineBoundingBox.dispose();
  37842. this._rotateSpheresParent.dispose();
  37843. this._scaleBoxesParent.dispose();
  37844. if (this._dragMesh) {
  37845. this._dragMesh.dispose();
  37846. }
  37847. _super.prototype.dispose.call(this);
  37848. };
  37849. /**
  37850. * 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)
  37851. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  37852. * @returns the bounding box mesh with the passed in mesh as a child
  37853. */
  37854. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  37855. var makeNotPickable = function (root) {
  37856. root.isPickable = false;
  37857. root.getChildMeshes().forEach(function (c) {
  37858. makeNotPickable(c);
  37859. });
  37860. };
  37861. makeNotPickable(mesh);
  37862. // Reset position to get boudning box from origin with no rotation
  37863. if (!mesh.rotationQuaternion) {
  37864. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  37865. }
  37866. var oldPos = mesh.position.clone();
  37867. var oldRot = mesh.rotationQuaternion.clone();
  37868. mesh.rotationQuaternion.set(0, 0, 0, 1);
  37869. mesh.position.set(0, 0, 0);
  37870. // Update bounding dimensions/positions
  37871. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  37872. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  37873. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  37874. // Adjust scale to avoid undefined behavior when adding child
  37875. if (box.scaling.y === 0) {
  37876. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37877. }
  37878. if (box.scaling.x === 0) {
  37879. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37880. }
  37881. if (box.scaling.z === 0) {
  37882. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37883. }
  37884. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  37885. // Restore original positions
  37886. mesh.addChild(box);
  37887. mesh.rotationQuaternion.copyFrom(oldRot);
  37888. mesh.position.copyFrom(oldPos);
  37889. // Reverse parenting
  37890. mesh.removeChild(box);
  37891. box.addChild(mesh);
  37892. box.visibility = 0;
  37893. return box;
  37894. };
  37895. /**
  37896. * CustomMeshes are not supported by this gizmo
  37897. * @param mesh The mesh to replace the default mesh of the gizmo
  37898. */
  37899. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  37900. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  37901. };
  37902. return BoundingBoxGizmo;
  37903. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  37904. /***/ }),
  37905. /***/ "./Gizmos/gizmo.ts":
  37906. /*!*************************!*\
  37907. !*** ./Gizmos/gizmo.ts ***!
  37908. \*************************/
  37909. /*! exports provided: Gizmo */
  37910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37911. "use strict";
  37912. __webpack_require__.r(__webpack_exports__);
  37913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  37914. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37915. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37916. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37917. /**
  37918. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  37919. */
  37920. var Gizmo = /** @class */ (function () {
  37921. /**
  37922. * Creates a gizmo
  37923. * @param gizmoLayer The utility layer the gizmo will be added to
  37924. */
  37925. function Gizmo(
  37926. /** The utility layer the gizmo will be added to */
  37927. gizmoLayer) {
  37928. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37929. var _this = this;
  37930. this.gizmoLayer = gizmoLayer;
  37931. /**
  37932. * Ratio for the scale of the gizmo (Default: 1)
  37933. */
  37934. this.scaleRatio = 1;
  37935. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  37936. /**
  37937. * If a custom mesh has been set (Default: false)
  37938. */
  37939. this._customMeshSet = false;
  37940. /**
  37941. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  37942. */
  37943. this.updateGizmoRotationToMatchAttachedMesh = true;
  37944. /**
  37945. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  37946. */
  37947. this.updateGizmoPositionToMatchAttachedMesh = true;
  37948. /**
  37949. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  37950. */
  37951. this._updateScale = true;
  37952. this._interactionsEnabled = true;
  37953. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  37954. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  37955. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  37956. _this._update();
  37957. });
  37958. this.attachedMesh = null;
  37959. }
  37960. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  37961. /**
  37962. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  37963. * * When set, interactions will be enabled
  37964. */
  37965. get: function () {
  37966. return this._attachedMesh;
  37967. },
  37968. set: function (value) {
  37969. this._attachedMesh = value;
  37970. this._rootMesh.setEnabled(value ? true : false);
  37971. this._attachedMeshChanged(value);
  37972. },
  37973. enumerable: true,
  37974. configurable: true
  37975. });
  37976. /**
  37977. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37978. * @param mesh The mesh to replace the default mesh of the gizmo
  37979. */
  37980. Gizmo.prototype.setCustomMesh = function (mesh) {
  37981. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  37982. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  37983. }
  37984. this._rootMesh.getChildMeshes().forEach(function (c) {
  37985. c.dispose();
  37986. });
  37987. mesh.parent = this._rootMesh;
  37988. this._customMeshSet = true;
  37989. };
  37990. Gizmo.prototype._attachedMeshChanged = function (value) {
  37991. };
  37992. /**
  37993. * @hidden
  37994. * Updates the gizmo to match the attached mesh's position/rotation
  37995. */
  37996. Gizmo.prototype._update = function () {
  37997. if (this.attachedMesh) {
  37998. if (this.updateGizmoRotationToMatchAttachedMesh) {
  37999. if (!this._rootMesh.rotationQuaternion) {
  38000. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38001. }
  38002. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38003. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38004. if (this.attachedMesh.scaling.x < 0) {
  38005. this.attachedMesh.scaling.x *= -1;
  38006. }
  38007. if (this.attachedMesh.scaling.y < 0) {
  38008. this.attachedMesh.scaling.y *= -1;
  38009. }
  38010. if (this.attachedMesh.scaling.z < 0) {
  38011. this.attachedMesh.scaling.z *= -1;
  38012. }
  38013. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38014. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38015. this.attachedMesh.computeWorldMatrix();
  38016. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38017. }
  38018. else if (this._rootMesh.rotationQuaternion) {
  38019. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38020. }
  38021. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38022. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38023. }
  38024. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38025. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38026. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38027. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38028. }
  38029. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38030. var dist = this._tempVector.length() * this.scaleRatio;
  38031. this._rootMesh.scaling.set(dist, dist, dist);
  38032. }
  38033. }
  38034. };
  38035. /**
  38036. * Disposes of the gizmo
  38037. */
  38038. Gizmo.prototype.dispose = function () {
  38039. this._rootMesh.dispose();
  38040. if (this._beforeRenderObserver) {
  38041. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38042. }
  38043. };
  38044. return Gizmo;
  38045. }());
  38046. /***/ }),
  38047. /***/ "./Gizmos/gizmoManager.ts":
  38048. /*!********************************!*\
  38049. !*** ./Gizmos/gizmoManager.ts ***!
  38050. \********************************/
  38051. /*! exports provided: GizmoManager */
  38052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38053. "use strict";
  38054. __webpack_require__.r(__webpack_exports__);
  38055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38056. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38057. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38058. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38059. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38060. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38061. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38062. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38063. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38064. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38065. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38066. /**
  38067. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38068. */
  38069. var GizmoManager = /** @class */ (function () {
  38070. /**
  38071. * Instatiates a gizmo manager
  38072. * @param scene the scene to overlay the gizmos on top of
  38073. */
  38074. function GizmoManager(scene) {
  38075. var _this = this;
  38076. this.scene = scene;
  38077. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38078. this.clearGizmoOnEmptyPointerEvent = false;
  38079. /** Fires an event when the manager is attached to a mesh */
  38080. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38081. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38082. this._pointerObserver = null;
  38083. this._attachedMesh = null;
  38084. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38085. /**
  38086. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38087. */
  38088. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38089. /**
  38090. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38091. */
  38092. this.attachableMeshes = null;
  38093. /**
  38094. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38095. */
  38096. this.usePointerToAttachGizmos = true;
  38097. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38098. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38099. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38100. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38101. // Instatiate/dispose gizmos based on pointer actions
  38102. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38103. if (!_this.usePointerToAttachGizmos) {
  38104. return;
  38105. }
  38106. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38107. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38108. var node = pointerInfo.pickInfo.pickedMesh;
  38109. if (_this.attachableMeshes == null) {
  38110. // Attach to the most parent node
  38111. while (node && node.parent != null) {
  38112. node = node.parent;
  38113. }
  38114. }
  38115. else {
  38116. // Attach to the parent node that is an attachableMesh
  38117. var found = false;
  38118. _this.attachableMeshes.forEach(function (mesh) {
  38119. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38120. node = mesh;
  38121. found = true;
  38122. }
  38123. });
  38124. if (!found) {
  38125. node = null;
  38126. }
  38127. }
  38128. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38129. if (_this._attachedMesh != node) {
  38130. _this.attachToMesh(node);
  38131. }
  38132. }
  38133. else {
  38134. if (_this.clearGizmoOnEmptyPointerEvent) {
  38135. _this.attachToMesh(null);
  38136. }
  38137. }
  38138. }
  38139. else {
  38140. if (_this.clearGizmoOnEmptyPointerEvent) {
  38141. _this.attachToMesh(null);
  38142. }
  38143. }
  38144. }
  38145. });
  38146. }
  38147. /**
  38148. * Attaches a set of gizmos to the specified mesh
  38149. * @param mesh The mesh the gizmo's should be attached to
  38150. */
  38151. GizmoManager.prototype.attachToMesh = function (mesh) {
  38152. if (this._attachedMesh) {
  38153. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38154. }
  38155. this._attachedMesh = mesh;
  38156. for (var key in this.gizmos) {
  38157. var gizmo = (this.gizmos[key]);
  38158. if (gizmo && this._gizmosEnabled[key]) {
  38159. gizmo.attachedMesh = mesh;
  38160. }
  38161. }
  38162. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38163. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38164. }
  38165. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38166. };
  38167. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38168. get: function () {
  38169. return this._gizmosEnabled.positionGizmo;
  38170. },
  38171. /**
  38172. * If the position gizmo is enabled
  38173. */
  38174. set: function (value) {
  38175. if (value) {
  38176. if (!this.gizmos.positionGizmo) {
  38177. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38178. }
  38179. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38180. }
  38181. else if (this.gizmos.positionGizmo) {
  38182. this.gizmos.positionGizmo.attachedMesh = null;
  38183. }
  38184. this._gizmosEnabled.positionGizmo = value;
  38185. },
  38186. enumerable: true,
  38187. configurable: true
  38188. });
  38189. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38190. get: function () {
  38191. return this._gizmosEnabled.rotationGizmo;
  38192. },
  38193. /**
  38194. * If the rotation gizmo is enabled
  38195. */
  38196. set: function (value) {
  38197. if (value) {
  38198. if (!this.gizmos.rotationGizmo) {
  38199. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38200. }
  38201. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38202. }
  38203. else if (this.gizmos.rotationGizmo) {
  38204. this.gizmos.rotationGizmo.attachedMesh = null;
  38205. }
  38206. this._gizmosEnabled.rotationGizmo = value;
  38207. },
  38208. enumerable: true,
  38209. configurable: true
  38210. });
  38211. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38212. get: function () {
  38213. return this._gizmosEnabled.scaleGizmo;
  38214. },
  38215. /**
  38216. * If the scale gizmo is enabled
  38217. */
  38218. set: function (value) {
  38219. if (value) {
  38220. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38221. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38222. }
  38223. else if (this.gizmos.scaleGizmo) {
  38224. this.gizmos.scaleGizmo.attachedMesh = null;
  38225. }
  38226. this._gizmosEnabled.scaleGizmo = value;
  38227. },
  38228. enumerable: true,
  38229. configurable: true
  38230. });
  38231. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38232. get: function () {
  38233. return this._gizmosEnabled.boundingBoxGizmo;
  38234. },
  38235. /**
  38236. * If the boundingBox gizmo is enabled
  38237. */
  38238. set: function (value) {
  38239. if (value) {
  38240. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38241. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38242. if (this._attachedMesh) {
  38243. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38244. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38245. }
  38246. }
  38247. else if (this.gizmos.boundingBoxGizmo) {
  38248. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38249. }
  38250. this._gizmosEnabled.boundingBoxGizmo = value;
  38251. },
  38252. enumerable: true,
  38253. configurable: true
  38254. });
  38255. /**
  38256. * Disposes of the gizmo manager
  38257. */
  38258. GizmoManager.prototype.dispose = function () {
  38259. this.scene.onPointerObservable.remove(this._pointerObserver);
  38260. for (var key in this.gizmos) {
  38261. var gizmo = (this.gizmos[key]);
  38262. if (gizmo) {
  38263. gizmo.dispose();
  38264. }
  38265. }
  38266. this._defaultKeepDepthUtilityLayer.dispose();
  38267. this._defaultUtilityLayer.dispose();
  38268. this.boundingBoxDragBehavior.detach();
  38269. this.onAttachedToMeshObservable.clear();
  38270. };
  38271. return GizmoManager;
  38272. }());
  38273. /***/ }),
  38274. /***/ "./Gizmos/index.ts":
  38275. /*!*************************!*\
  38276. !*** ./Gizmos/index.ts ***!
  38277. \*************************/
  38278. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo */
  38279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38280. "use strict";
  38281. __webpack_require__.r(__webpack_exports__);
  38282. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38284. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38286. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38288. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38290. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  38291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  38292. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  38294. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  38296. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  38298. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  38300. /***/ }),
  38301. /***/ "./Gizmos/planeRotationGizmo.ts":
  38302. /*!**************************************!*\
  38303. !*** ./Gizmos/planeRotationGizmo.ts ***!
  38304. \**************************************/
  38305. /*! exports provided: PlaneRotationGizmo */
  38306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38307. "use strict";
  38308. __webpack_require__.r(__webpack_exports__);
  38309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  38310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38311. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38313. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38314. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38315. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38316. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38317. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38318. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38319. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38320. /**
  38321. * Single plane rotation gizmo
  38322. */
  38323. var PlaneRotationGizmo = /** @class */ (function (_super) {
  38324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  38325. /**
  38326. * Creates a PlaneRotationGizmo
  38327. * @param gizmoLayer The utility layer the gizmo will be added to
  38328. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  38329. * @param color The color of the gizmo
  38330. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38331. */
  38332. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  38333. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38334. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38335. if (tessellation === void 0) { tessellation = 32; }
  38336. var _this = _super.call(this, gizmoLayer) || this;
  38337. _this._pointerObserver = null;
  38338. /**
  38339. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  38340. */
  38341. _this.snapDistance = 0;
  38342. /**
  38343. * Event that fires each time the gizmo snaps to a new location.
  38344. * * snapDistance is the the change in distance
  38345. */
  38346. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38347. // Create Material
  38348. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38349. coloredMaterial.disableLighting = true;
  38350. coloredMaterial.emissiveColor = color;
  38351. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38352. hoverMaterial.disableLighting = true;
  38353. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38354. // Build mesh on root node
  38355. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38356. // Create circle out of lines
  38357. var radius = 0.8;
  38358. var points = new Array();
  38359. for (var i = 0; i < tessellation; i++) {
  38360. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  38361. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  38362. }
  38363. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  38364. rotationMesh.color = coloredMaterial.emissiveColor;
  38365. // Position arrow pointing in its drag axis
  38366. rotationMesh.scaling.scaleInPlace(0.26);
  38367. rotationMesh.material = coloredMaterial;
  38368. rotationMesh.rotation.x = Math.PI / 2;
  38369. parentMesh.addChild(rotationMesh);
  38370. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  38371. _this._rootMesh.addChild(parentMesh);
  38372. parentMesh.scaling.scaleInPlace(1 / 3);
  38373. // Add drag behavior to handle events when the gizmo is dragged
  38374. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  38375. _this.dragBehavior.moveAttached = false;
  38376. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  38377. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  38378. _this._rootMesh.addBehavior(_this.dragBehavior);
  38379. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38380. _this.dragBehavior.onDragStartObservable.add(function (e) {
  38381. if (_this.attachedMesh) {
  38382. lastDragPosition.copyFrom(e.dragPlanePoint);
  38383. }
  38384. });
  38385. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38386. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38387. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38388. var tmpSnapEvent = { snapDistance: 0 };
  38389. var currentSnapDragDistance = 0;
  38390. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38391. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38392. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38393. _this.dragBehavior.onDragObservable.add(function (event) {
  38394. if (_this.attachedMesh) {
  38395. if (!_this.attachedMesh.rotationQuaternion) {
  38396. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38397. }
  38398. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  38399. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  38400. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  38401. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  38402. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  38403. var angle = Math.atan2(cross.length(), dot);
  38404. planeNormalTowardsCamera.copyFrom(planeNormal);
  38405. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  38406. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38407. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  38408. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  38409. }
  38410. // Flip up vector depending on which side the camera is on
  38411. if (gizmoLayer.utilityLayerScene.activeCamera) {
  38412. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  38413. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  38414. planeNormalTowardsCamera.scaleInPlace(-1);
  38415. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  38416. }
  38417. }
  38418. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  38419. if (halfCircleSide) {
  38420. angle = -angle;
  38421. }
  38422. // Snapping logic
  38423. var snapped = false;
  38424. if (_this.snapDistance != 0) {
  38425. currentSnapDragDistance += angle;
  38426. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38427. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38428. if (currentSnapDragDistance < 0) {
  38429. dragSteps *= -1;
  38430. }
  38431. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38432. angle = _this.snapDistance * dragSteps;
  38433. snapped = true;
  38434. }
  38435. else {
  38436. angle = 0;
  38437. }
  38438. }
  38439. // If the mesh has a parent, convert needed world rotation to local rotation
  38440. tmpMatrix.reset();
  38441. if (_this.attachedMesh.parent) {
  38442. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38443. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  38444. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  38445. }
  38446. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  38447. var quaternionCoefficient = Math.sin(angle / 2);
  38448. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  38449. // 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
  38450. if (tmpMatrix.determinant() > 0) {
  38451. amountToRotate.toEulerAnglesToRef(tmpVector);
  38452. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  38453. }
  38454. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38455. // Rotate selected mesh quaternion over fixed axis
  38456. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  38457. }
  38458. else {
  38459. // Rotate selected mesh quaternion over rotated axis
  38460. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38461. }
  38462. lastDragPosition.copyFrom(event.dragPlanePoint);
  38463. if (snapped) {
  38464. tmpSnapEvent.snapDistance = angle;
  38465. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38466. }
  38467. }
  38468. });
  38469. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38470. if (_this._customMeshSet) {
  38471. return;
  38472. }
  38473. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38474. var material = isHovered ? hoverMaterial : coloredMaterial;
  38475. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38476. m.material = material;
  38477. if (m.color) {
  38478. m.color = material.emissiveColor;
  38479. }
  38480. });
  38481. });
  38482. return _this;
  38483. }
  38484. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38485. if (this.dragBehavior) {
  38486. this.dragBehavior.enabled = value ? true : false;
  38487. }
  38488. };
  38489. /**
  38490. * Disposes of the gizmo
  38491. */
  38492. PlaneRotationGizmo.prototype.dispose = function () {
  38493. this.onSnapObservable.clear();
  38494. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38495. this.dragBehavior.detach();
  38496. _super.prototype.dispose.call(this);
  38497. };
  38498. return PlaneRotationGizmo;
  38499. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38500. /***/ }),
  38501. /***/ "./Gizmos/positionGizmo.ts":
  38502. /*!*********************************!*\
  38503. !*** ./Gizmos/positionGizmo.ts ***!
  38504. \*********************************/
  38505. /*! exports provided: PositionGizmo */
  38506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38507. "use strict";
  38508. __webpack_require__.r(__webpack_exports__);
  38509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  38510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38511. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38512. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38513. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38514. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38515. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38516. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38517. /**
  38518. * Gizmo that enables dragging a mesh along 3 axis
  38519. */
  38520. var PositionGizmo = /** @class */ (function (_super) {
  38521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38522. /**
  38523. * Creates a PositionGizmo
  38524. * @param gizmoLayer The utility layer the gizmo will be added to
  38525. */
  38526. function PositionGizmo(gizmoLayer) {
  38527. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38528. var _this = _super.call(this, gizmoLayer) || this;
  38529. /** Fires an event when any of it's sub gizmos are dragged */
  38530. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38531. /** Fires an event when any of it's sub gizmos are released from dragging */
  38532. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38533. _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);
  38534. _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);
  38535. _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);
  38536. // Relay drag events
  38537. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38538. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38539. _this.onDragStartObservable.notifyObservers({});
  38540. });
  38541. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38542. _this.onDragEndObservable.notifyObservers({});
  38543. });
  38544. });
  38545. _this.attachedMesh = null;
  38546. return _this;
  38547. }
  38548. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38549. set: function (mesh) {
  38550. if (this.xGizmo) {
  38551. this.xGizmo.attachedMesh = mesh;
  38552. this.yGizmo.attachedMesh = mesh;
  38553. this.zGizmo.attachedMesh = mesh;
  38554. }
  38555. },
  38556. enumerable: true,
  38557. configurable: true
  38558. });
  38559. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38560. get: function () {
  38561. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38562. },
  38563. set: function (value) {
  38564. if (this.xGizmo) {
  38565. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38566. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38567. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38568. }
  38569. },
  38570. enumerable: true,
  38571. configurable: true
  38572. });
  38573. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38574. get: function () {
  38575. return this.xGizmo.snapDistance;
  38576. },
  38577. /**
  38578. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38579. */
  38580. set: function (value) {
  38581. if (this.xGizmo) {
  38582. this.xGizmo.snapDistance = value;
  38583. this.yGizmo.snapDistance = value;
  38584. this.zGizmo.snapDistance = value;
  38585. }
  38586. },
  38587. enumerable: true,
  38588. configurable: true
  38589. });
  38590. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38591. get: function () {
  38592. return this.xGizmo.scaleRatio;
  38593. },
  38594. /**
  38595. * Ratio for the scale of the gizmo (Default: 1)
  38596. */
  38597. set: function (value) {
  38598. if (this.xGizmo) {
  38599. this.xGizmo.scaleRatio = value;
  38600. this.yGizmo.scaleRatio = value;
  38601. this.zGizmo.scaleRatio = value;
  38602. }
  38603. },
  38604. enumerable: true,
  38605. configurable: true
  38606. });
  38607. /**
  38608. * Disposes of the gizmo
  38609. */
  38610. PositionGizmo.prototype.dispose = function () {
  38611. this.xGizmo.dispose();
  38612. this.yGizmo.dispose();
  38613. this.zGizmo.dispose();
  38614. this.onDragStartObservable.clear();
  38615. this.onDragEndObservable.clear();
  38616. };
  38617. /**
  38618. * CustomMeshes are not supported by this gizmo
  38619. * @param mesh The mesh to replace the default mesh of the gizmo
  38620. */
  38621. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38622. _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)");
  38623. };
  38624. return PositionGizmo;
  38625. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38626. /***/ }),
  38627. /***/ "./Gizmos/rotationGizmo.ts":
  38628. /*!*********************************!*\
  38629. !*** ./Gizmos/rotationGizmo.ts ***!
  38630. \*********************************/
  38631. /*! exports provided: RotationGizmo */
  38632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38633. "use strict";
  38634. __webpack_require__.r(__webpack_exports__);
  38635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38636. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38637. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38638. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38639. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38640. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38641. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38642. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38643. /**
  38644. * Gizmo that enables rotating a mesh along 3 axis
  38645. */
  38646. var RotationGizmo = /** @class */ (function (_super) {
  38647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38648. /**
  38649. * Creates a RotationGizmo
  38650. * @param gizmoLayer The utility layer the gizmo will be added to
  38651. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38652. */
  38653. function RotationGizmo(gizmoLayer, tessellation) {
  38654. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38655. if (tessellation === void 0) { tessellation = 32; }
  38656. var _this = _super.call(this, gizmoLayer) || this;
  38657. /** Fires an event when any of it's sub gizmos are dragged */
  38658. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38659. /** Fires an event when any of it's sub gizmos are released from dragging */
  38660. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38661. _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);
  38662. _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);
  38663. _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);
  38664. // Relay drag events
  38665. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38666. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38667. _this.onDragStartObservable.notifyObservers({});
  38668. });
  38669. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38670. _this.onDragEndObservable.notifyObservers({});
  38671. });
  38672. });
  38673. _this.attachedMesh = null;
  38674. return _this;
  38675. }
  38676. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38677. set: function (mesh) {
  38678. if (this.xGizmo) {
  38679. this.xGizmo.attachedMesh = mesh;
  38680. this.yGizmo.attachedMesh = mesh;
  38681. this.zGizmo.attachedMesh = mesh;
  38682. }
  38683. },
  38684. enumerable: true,
  38685. configurable: true
  38686. });
  38687. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38688. get: function () {
  38689. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38690. },
  38691. set: function (value) {
  38692. if (this.xGizmo) {
  38693. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38694. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38695. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38696. }
  38697. },
  38698. enumerable: true,
  38699. configurable: true
  38700. });
  38701. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38702. get: function () {
  38703. return this.xGizmo.snapDistance;
  38704. },
  38705. /**
  38706. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38707. */
  38708. set: function (value) {
  38709. if (this.xGizmo) {
  38710. this.xGizmo.snapDistance = value;
  38711. this.yGizmo.snapDistance = value;
  38712. this.zGizmo.snapDistance = value;
  38713. }
  38714. },
  38715. enumerable: true,
  38716. configurable: true
  38717. });
  38718. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  38719. get: function () {
  38720. return this.xGizmo.scaleRatio;
  38721. },
  38722. /**
  38723. * Ratio for the scale of the gizmo (Default: 1)
  38724. */
  38725. set: function (value) {
  38726. if (this.xGizmo) {
  38727. this.xGizmo.scaleRatio = value;
  38728. this.yGizmo.scaleRatio = value;
  38729. this.zGizmo.scaleRatio = value;
  38730. }
  38731. },
  38732. enumerable: true,
  38733. configurable: true
  38734. });
  38735. /**
  38736. * Disposes of the gizmo
  38737. */
  38738. RotationGizmo.prototype.dispose = function () {
  38739. this.xGizmo.dispose();
  38740. this.yGizmo.dispose();
  38741. this.zGizmo.dispose();
  38742. this.onDragStartObservable.clear();
  38743. this.onDragEndObservable.clear();
  38744. };
  38745. /**
  38746. * CustomMeshes are not supported by this gizmo
  38747. * @param mesh The mesh to replace the default mesh of the gizmo
  38748. */
  38749. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  38750. _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)");
  38751. };
  38752. return RotationGizmo;
  38753. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38754. /***/ }),
  38755. /***/ "./Gizmos/scaleGizmo.ts":
  38756. /*!******************************!*\
  38757. !*** ./Gizmos/scaleGizmo.ts ***!
  38758. \******************************/
  38759. /*! exports provided: ScaleGizmo */
  38760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38761. "use strict";
  38762. __webpack_require__.r(__webpack_exports__);
  38763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  38764. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38765. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38766. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38767. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38768. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  38769. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38770. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38771. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38772. /**
  38773. * Gizmo that enables scaling a mesh along 3 axis
  38774. */
  38775. var ScaleGizmo = /** @class */ (function (_super) {
  38776. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  38777. /**
  38778. * Creates a ScaleGizmo
  38779. * @param gizmoLayer The utility layer the gizmo will be added to
  38780. */
  38781. function ScaleGizmo(gizmoLayer) {
  38782. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38783. var _this = _super.call(this, gizmoLayer) || this;
  38784. /** Fires an event when any of it's sub gizmos are dragged */
  38785. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38786. /** Fires an event when any of it's sub gizmos are released from dragging */
  38787. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38788. _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);
  38789. _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);
  38790. _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);
  38791. // Create uniform scale gizmo
  38792. _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);
  38793. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  38794. _this.uniformScaleGizmo.uniformScaling = true;
  38795. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38796. uniformScalingMesh.scaling.scaleInPlace(0.02);
  38797. uniformScalingMesh.visibility = 0;
  38798. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38799. octahedron.scaling.scaleInPlace(0.007);
  38800. uniformScalingMesh.addChild(octahedron);
  38801. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  38802. // Relay drag events
  38803. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  38804. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38805. _this.onDragStartObservable.notifyObservers({});
  38806. });
  38807. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38808. _this.onDragEndObservable.notifyObservers({});
  38809. });
  38810. });
  38811. _this.attachedMesh = null;
  38812. return _this;
  38813. }
  38814. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  38815. set: function (mesh) {
  38816. if (this.xGizmo) {
  38817. this.xGizmo.attachedMesh = mesh;
  38818. this.yGizmo.attachedMesh = mesh;
  38819. this.zGizmo.attachedMesh = mesh;
  38820. this.uniformScaleGizmo.attachedMesh = mesh;
  38821. }
  38822. },
  38823. enumerable: true,
  38824. configurable: true
  38825. });
  38826. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38827. get: function () {
  38828. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38829. },
  38830. set: function (value) {
  38831. if (!value) {
  38832. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  38833. }
  38834. if (this.xGizmo) {
  38835. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38836. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38837. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38838. }
  38839. },
  38840. enumerable: true,
  38841. configurable: true
  38842. });
  38843. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  38844. get: function () {
  38845. return this.xGizmo.snapDistance;
  38846. },
  38847. /**
  38848. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38849. */
  38850. set: function (value) {
  38851. if (this.xGizmo) {
  38852. this.xGizmo.snapDistance = value;
  38853. this.yGizmo.snapDistance = value;
  38854. this.zGizmo.snapDistance = value;
  38855. this.uniformScaleGizmo.snapDistance = value;
  38856. }
  38857. },
  38858. enumerable: true,
  38859. configurable: true
  38860. });
  38861. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  38862. get: function () {
  38863. return this.xGizmo.scaleRatio;
  38864. },
  38865. /**
  38866. * Ratio for the scale of the gizmo (Default: 1)
  38867. */
  38868. set: function (value) {
  38869. if (this.xGizmo) {
  38870. this.xGizmo.scaleRatio = value;
  38871. this.yGizmo.scaleRatio = value;
  38872. this.zGizmo.scaleRatio = value;
  38873. this.uniformScaleGizmo.scaleRatio = value;
  38874. }
  38875. },
  38876. enumerable: true,
  38877. configurable: true
  38878. });
  38879. /**
  38880. * Disposes of the gizmo
  38881. */
  38882. ScaleGizmo.prototype.dispose = function () {
  38883. this.xGizmo.dispose();
  38884. this.yGizmo.dispose();
  38885. this.zGizmo.dispose();
  38886. this.uniformScaleGizmo.dispose();
  38887. this.onDragStartObservable.clear();
  38888. this.onDragEndObservable.clear();
  38889. };
  38890. return ScaleGizmo;
  38891. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  38892. /***/ }),
  38893. /***/ "./Helpers/environmentHelper.ts":
  38894. /*!**************************************!*\
  38895. !*** ./Helpers/environmentHelper.ts ***!
  38896. \**************************************/
  38897. /*! exports provided: EnvironmentHelper */
  38898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38899. "use strict";
  38900. __webpack_require__.r(__webpack_exports__);
  38901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  38902. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38903. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38904. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  38905. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38906. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38907. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  38908. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38909. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  38910. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  38911. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38912. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  38913. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  38914. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38915. /**
  38916. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  38917. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  38918. * It also helps with the default setup of your imageProcessing configuration.
  38919. */
  38920. var EnvironmentHelper = /** @class */ (function () {
  38921. /**
  38922. * constructor
  38923. * @param options Defines the options we want to customize the helper
  38924. * @param scene The scene to add the material to
  38925. */
  38926. function EnvironmentHelper(options, scene) {
  38927. var _this = this;
  38928. this._errorHandler = function (message, exception) {
  38929. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  38930. };
  38931. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  38932. this._scene = scene;
  38933. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38934. this._setupBackground();
  38935. this._setupImageProcessing();
  38936. }
  38937. /**
  38938. * Creates the default options for the helper.
  38939. */
  38940. EnvironmentHelper._getDefaultOptions = function () {
  38941. return {
  38942. createGround: true,
  38943. groundSize: 15,
  38944. groundTexture: this._groundTextureCDNUrl,
  38945. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38946. groundOpacity: 0.9,
  38947. enableGroundShadow: true,
  38948. groundShadowLevel: 0.5,
  38949. enableGroundMirror: false,
  38950. groundMirrorSizeRatio: 0.3,
  38951. groundMirrorBlurKernel: 64,
  38952. groundMirrorAmount: 1,
  38953. groundMirrorFresnelWeight: 1,
  38954. groundMirrorFallOffDistance: 0,
  38955. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  38956. groundYBias: 0.00001,
  38957. createSkybox: true,
  38958. skyboxSize: 20,
  38959. skyboxTexture: this._skyboxTextureCDNUrl,
  38960. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38961. backgroundYRotation: 0,
  38962. sizeAuto: true,
  38963. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  38964. setupImageProcessing: true,
  38965. environmentTexture: this._environmentTextureCDNUrl,
  38966. cameraExposure: 0.8,
  38967. cameraContrast: 1.2,
  38968. toneMappingEnabled: true,
  38969. };
  38970. };
  38971. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  38972. /**
  38973. * Gets the root mesh created by the helper.
  38974. */
  38975. get: function () {
  38976. return this._rootMesh;
  38977. },
  38978. enumerable: true,
  38979. configurable: true
  38980. });
  38981. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  38982. /**
  38983. * Gets the skybox created by the helper.
  38984. */
  38985. get: function () {
  38986. return this._skybox;
  38987. },
  38988. enumerable: true,
  38989. configurable: true
  38990. });
  38991. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  38992. /**
  38993. * Gets the skybox texture created by the helper.
  38994. */
  38995. get: function () {
  38996. return this._skyboxTexture;
  38997. },
  38998. enumerable: true,
  38999. configurable: true
  39000. });
  39001. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39002. /**
  39003. * Gets the skybox material created by the helper.
  39004. */
  39005. get: function () {
  39006. return this._skyboxMaterial;
  39007. },
  39008. enumerable: true,
  39009. configurable: true
  39010. });
  39011. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39012. /**
  39013. * Gets the ground mesh created by the helper.
  39014. */
  39015. get: function () {
  39016. return this._ground;
  39017. },
  39018. enumerable: true,
  39019. configurable: true
  39020. });
  39021. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39022. /**
  39023. * Gets the ground texture created by the helper.
  39024. */
  39025. get: function () {
  39026. return this._groundTexture;
  39027. },
  39028. enumerable: true,
  39029. configurable: true
  39030. });
  39031. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39032. /**
  39033. * Gets the ground mirror created by the helper.
  39034. */
  39035. get: function () {
  39036. return this._groundMirror;
  39037. },
  39038. enumerable: true,
  39039. configurable: true
  39040. });
  39041. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39042. /**
  39043. * Gets the ground mirror render list to helps pushing the meshes
  39044. * you wish in the ground reflection.
  39045. */
  39046. get: function () {
  39047. if (this._groundMirror) {
  39048. return this._groundMirror.renderList;
  39049. }
  39050. return null;
  39051. },
  39052. enumerable: true,
  39053. configurable: true
  39054. });
  39055. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39056. /**
  39057. * Gets the ground material created by the helper.
  39058. */
  39059. get: function () {
  39060. return this._groundMaterial;
  39061. },
  39062. enumerable: true,
  39063. configurable: true
  39064. });
  39065. /**
  39066. * Updates the background according to the new options
  39067. * @param options
  39068. */
  39069. EnvironmentHelper.prototype.updateOptions = function (options) {
  39070. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39071. if (this._ground && !newOptions.createGround) {
  39072. this._ground.dispose();
  39073. this._ground = null;
  39074. }
  39075. if (this._groundMaterial && !newOptions.createGround) {
  39076. this._groundMaterial.dispose();
  39077. this._groundMaterial = null;
  39078. }
  39079. if (this._groundTexture) {
  39080. if (this._options.groundTexture != newOptions.groundTexture) {
  39081. this._groundTexture.dispose();
  39082. this._groundTexture = null;
  39083. }
  39084. }
  39085. if (this._skybox && !newOptions.createSkybox) {
  39086. this._skybox.dispose();
  39087. this._skybox = null;
  39088. }
  39089. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39090. this._skyboxMaterial.dispose();
  39091. this._skyboxMaterial = null;
  39092. }
  39093. if (this._skyboxTexture) {
  39094. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39095. this._skyboxTexture.dispose();
  39096. this._skyboxTexture = null;
  39097. }
  39098. }
  39099. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39100. this._groundMirror.dispose();
  39101. this._groundMirror = null;
  39102. }
  39103. if (this._scene.environmentTexture) {
  39104. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39105. this._scene.environmentTexture.dispose();
  39106. }
  39107. }
  39108. this._options = newOptions;
  39109. this._setupBackground();
  39110. this._setupImageProcessing();
  39111. };
  39112. /**
  39113. * Sets the primary color of all the available elements.
  39114. * @param color the main color to affect to the ground and the background
  39115. */
  39116. EnvironmentHelper.prototype.setMainColor = function (color) {
  39117. if (this.groundMaterial) {
  39118. this.groundMaterial.primaryColor = color;
  39119. }
  39120. if (this.skyboxMaterial) {
  39121. this.skyboxMaterial.primaryColor = color;
  39122. }
  39123. if (this.groundMirror) {
  39124. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39125. }
  39126. };
  39127. /**
  39128. * Setup the image processing according to the specified options.
  39129. */
  39130. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39131. if (this._options.setupImageProcessing) {
  39132. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39133. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39134. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39135. this._setupEnvironmentTexture();
  39136. }
  39137. };
  39138. /**
  39139. * Setup the environment texture according to the specified options.
  39140. */
  39141. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39142. if (this._scene.environmentTexture) {
  39143. return;
  39144. }
  39145. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39146. this._scene.environmentTexture = this._options.environmentTexture;
  39147. return;
  39148. }
  39149. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39150. this._scene.environmentTexture = environmentTexture;
  39151. };
  39152. /**
  39153. * Setup the background according to the specified options.
  39154. */
  39155. EnvironmentHelper.prototype._setupBackground = function () {
  39156. if (!this._rootMesh) {
  39157. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39158. }
  39159. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39160. var sceneSize = this._getSceneSize();
  39161. if (this._options.createGround) {
  39162. this._setupGround(sceneSize);
  39163. this._setupGroundMaterial();
  39164. this._setupGroundDiffuseTexture();
  39165. if (this._options.enableGroundMirror) {
  39166. this._setupGroundMirrorTexture(sceneSize);
  39167. }
  39168. this._setupMirrorInGroundMaterial();
  39169. }
  39170. if (this._options.createSkybox) {
  39171. this._setupSkybox(sceneSize);
  39172. this._setupSkyboxMaterial();
  39173. this._setupSkyboxReflectionTexture();
  39174. }
  39175. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39176. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39177. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39178. };
  39179. /**
  39180. * Get the scene sizes according to the setup.
  39181. */
  39182. EnvironmentHelper.prototype._getSceneSize = function () {
  39183. var _this = this;
  39184. var groundSize = this._options.groundSize;
  39185. var skyboxSize = this._options.skyboxSize;
  39186. var rootPosition = this._options.rootPosition;
  39187. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39188. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39189. }
  39190. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39191. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39192. });
  39193. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39194. if (this._options.sizeAuto) {
  39195. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39196. this._scene.activeCamera.upperRadiusLimit) {
  39197. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39198. skyboxSize = groundSize;
  39199. }
  39200. var sceneDiagonalLenght = sceneDiagonal.length();
  39201. if (sceneDiagonalLenght > groundSize) {
  39202. groundSize = sceneDiagonalLenght * 2;
  39203. skyboxSize = groundSize;
  39204. }
  39205. // 10 % bigger.
  39206. groundSize *= 1.1;
  39207. skyboxSize *= 1.5;
  39208. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  39209. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  39210. }
  39211. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39212. };
  39213. /**
  39214. * Setup the ground according to the specified options.
  39215. */
  39216. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  39217. var _this = this;
  39218. if (!this._ground || this._ground.isDisposed()) {
  39219. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  39220. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  39221. this._ground.parent = this._rootMesh;
  39222. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  39223. }
  39224. this._ground.receiveShadows = this._options.enableGroundShadow;
  39225. };
  39226. /**
  39227. * Setup the ground material according to the specified options.
  39228. */
  39229. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  39230. if (!this._groundMaterial) {
  39231. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  39232. }
  39233. this._groundMaterial.alpha = this._options.groundOpacity;
  39234. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  39235. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  39236. this._groundMaterial.primaryColor = this._options.groundColor;
  39237. this._groundMaterial.useRGBColor = false;
  39238. this._groundMaterial.enableNoise = true;
  39239. if (this._ground) {
  39240. this._ground.material = this._groundMaterial;
  39241. }
  39242. };
  39243. /**
  39244. * Setup the ground diffuse texture according to the specified options.
  39245. */
  39246. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  39247. if (!this._groundMaterial) {
  39248. return;
  39249. }
  39250. if (this._groundTexture) {
  39251. return;
  39252. }
  39253. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39254. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  39255. return;
  39256. }
  39257. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39258. diffuseTexture.gammaSpace = false;
  39259. diffuseTexture.hasAlpha = true;
  39260. this._groundMaterial.diffuseTexture = diffuseTexture;
  39261. };
  39262. /**
  39263. * Setup the ground mirror texture according to the specified options.
  39264. */
  39265. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  39266. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  39267. if (!this._groundMirror) {
  39268. 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);
  39269. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  39270. this._groundMirror.anisotropicFilteringLevel = 1;
  39271. this._groundMirror.wrapU = wrapping;
  39272. this._groundMirror.wrapV = wrapping;
  39273. this._groundMirror.gammaSpace = false;
  39274. if (this._groundMirror.renderList) {
  39275. for (var i = 0; i < this._scene.meshes.length; i++) {
  39276. var mesh = this._scene.meshes[i];
  39277. if (mesh !== this._ground &&
  39278. mesh !== this._skybox &&
  39279. mesh !== this._rootMesh) {
  39280. this._groundMirror.renderList.push(mesh);
  39281. }
  39282. }
  39283. }
  39284. }
  39285. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  39286. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  39287. };
  39288. /**
  39289. * Setup the ground to receive the mirror texture.
  39290. */
  39291. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  39292. if (this._groundMaterial) {
  39293. this._groundMaterial.reflectionTexture = this._groundMirror;
  39294. this._groundMaterial.reflectionFresnel = true;
  39295. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  39296. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  39297. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  39298. }
  39299. };
  39300. /**
  39301. * Setup the skybox according to the specified options.
  39302. */
  39303. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  39304. var _this = this;
  39305. if (!this._skybox || this._skybox.isDisposed()) {
  39306. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  39307. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  39308. }
  39309. this._skybox.parent = this._rootMesh;
  39310. };
  39311. /**
  39312. * Setup the skybox material according to the specified options.
  39313. */
  39314. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  39315. if (!this._skybox) {
  39316. return;
  39317. }
  39318. if (!this._skyboxMaterial) {
  39319. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  39320. }
  39321. this._skyboxMaterial.useRGBColor = false;
  39322. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  39323. this._skyboxMaterial.enableNoise = true;
  39324. this._skybox.material = this._skyboxMaterial;
  39325. };
  39326. /**
  39327. * Setup the skybox reflection texture according to the specified options.
  39328. */
  39329. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  39330. if (!this._skyboxMaterial) {
  39331. return;
  39332. }
  39333. if (this._skyboxTexture) {
  39334. return;
  39335. }
  39336. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39337. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  39338. return;
  39339. }
  39340. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39341. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  39342. this._skyboxTexture.gammaSpace = false;
  39343. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  39344. };
  39345. /**
  39346. * Dispose all the elements created by the Helper.
  39347. */
  39348. EnvironmentHelper.prototype.dispose = function () {
  39349. if (this._groundMaterial) {
  39350. this._groundMaterial.dispose(true, true);
  39351. }
  39352. if (this._skyboxMaterial) {
  39353. this._skyboxMaterial.dispose(true, true);
  39354. }
  39355. this._rootMesh.dispose(false);
  39356. };
  39357. /**
  39358. * Default ground texture URL.
  39359. */
  39360. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  39361. /**
  39362. * Default skybox texture URL.
  39363. */
  39364. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  39365. /**
  39366. * Default environment texture URL.
  39367. */
  39368. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  39369. return EnvironmentHelper;
  39370. }());
  39371. /***/ }),
  39372. /***/ "./Helpers/index.ts":
  39373. /*!**************************!*\
  39374. !*** ./Helpers/index.ts ***!
  39375. \**************************/
  39376. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  39377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39378. "use strict";
  39379. __webpack_require__.r(__webpack_exports__);
  39380. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  39382. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  39383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  39384. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  39385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  39386. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  39387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  39388. /***/ }),
  39389. /***/ "./Helpers/photoDome.ts":
  39390. /*!******************************!*\
  39391. !*** ./Helpers/photoDome.ts ***!
  39392. \******************************/
  39393. /*! exports provided: PhotoDome */
  39394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39395. "use strict";
  39396. __webpack_require__.r(__webpack_exports__);
  39397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  39398. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39399. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39400. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39401. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39402. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39403. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39404. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39405. /**
  39406. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  39407. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  39408. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  39409. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39410. */
  39411. var PhotoDome = /** @class */ (function (_super) {
  39412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  39413. /**
  39414. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  39415. * @param name Element's name, child elements will append suffixes for their own names.
  39416. * @param urlsOfPhoto defines the url of the photo to display
  39417. * @param options defines an object containing optional or exposed sub element properties
  39418. * @param onError defines a callback called when an error occured while loading the texture
  39419. */
  39420. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  39421. if (onError === void 0) { onError = null; }
  39422. var _this = _super.call(this, name, scene) || this;
  39423. _this._useDirectMapping = false;
  39424. /**
  39425. * Observable raised when an error occured while loading the 360 image
  39426. */
  39427. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39428. // set defaults and manage values
  39429. name = name || "photoDome";
  39430. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39431. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39432. if (options.useDirectMapping === undefined) {
  39433. _this._useDirectMapping = true;
  39434. }
  39435. else {
  39436. _this._useDirectMapping = options.useDirectMapping;
  39437. }
  39438. _this._setReady(false);
  39439. // create
  39440. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39441. _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);
  39442. // configure material
  39443. material.opacityFresnel = false;
  39444. material.useEquirectangularFOV = true;
  39445. material.fovMultiplier = 1.0;
  39446. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  39447. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  39448. if (onError) {
  39449. onError(message, exception);
  39450. }
  39451. });
  39452. _this.photoTexture.onLoadObservable.addOnce(function () {
  39453. _this._setReady(true);
  39454. });
  39455. // configure mesh
  39456. _this._mesh.material = material;
  39457. _this._mesh.parent = _this;
  39458. return _this;
  39459. }
  39460. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  39461. /**
  39462. * Gets or sets the texture being displayed on the sphere
  39463. */
  39464. get: function () {
  39465. return this._photoTexture;
  39466. },
  39467. set: function (value) {
  39468. if (this._photoTexture === value) {
  39469. return;
  39470. }
  39471. this._photoTexture = value;
  39472. if (this._useDirectMapping) {
  39473. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39474. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39475. this._material.diffuseTexture = this._photoTexture;
  39476. }
  39477. else {
  39478. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39479. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39480. this._material.reflectionTexture = this._photoTexture;
  39481. }
  39482. },
  39483. enumerable: true,
  39484. configurable: true
  39485. });
  39486. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39487. /**
  39488. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39489. * Also see the options.resolution property.
  39490. */
  39491. get: function () {
  39492. return this._material.fovMultiplier;
  39493. },
  39494. set: function (value) {
  39495. this._material.fovMultiplier = value;
  39496. },
  39497. enumerable: true,
  39498. configurable: true
  39499. });
  39500. /**
  39501. * Releases resources associated with this node.
  39502. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39503. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39504. */
  39505. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39506. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39507. this._photoTexture.dispose();
  39508. this._mesh.dispose();
  39509. this._material.dispose();
  39510. this.onLoadErrorObservable.clear();
  39511. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39512. };
  39513. return PhotoDome;
  39514. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39515. /***/ }),
  39516. /***/ "./Helpers/sceneHelpers.ts":
  39517. /*!*********************************!*\
  39518. !*** ./Helpers/sceneHelpers.ts ***!
  39519. \*********************************/
  39520. /*! exports provided: _forceSceneHelpersToBundle */
  39521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39522. "use strict";
  39523. __webpack_require__.r(__webpack_exports__);
  39524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39525. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39526. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39527. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39528. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39529. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39530. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39531. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39532. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39533. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39534. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39535. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39536. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39537. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39538. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39539. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39540. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39541. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39542. /** @hidden */
  39543. var _forceSceneHelpersToBundle = true;
  39544. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39545. if (replace === void 0) { replace = false; }
  39546. // Dispose existing light in replace mode.
  39547. if (replace) {
  39548. if (this.lights) {
  39549. for (var i = 0; i < this.lights.length; i++) {
  39550. this.lights[i].dispose();
  39551. }
  39552. }
  39553. }
  39554. // Light
  39555. if (this.lights.length === 0) {
  39556. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39557. }
  39558. };
  39559. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39560. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39561. if (replace === void 0) { replace = false; }
  39562. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39563. // Dispose existing camera in replace mode.
  39564. if (replace) {
  39565. if (this.activeCamera) {
  39566. this.activeCamera.dispose();
  39567. this.activeCamera = null;
  39568. }
  39569. }
  39570. // Camera
  39571. if (!this.activeCamera) {
  39572. var worldExtends = this.getWorldExtends();
  39573. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39574. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39575. var camera;
  39576. var radius = worldSize.length() * 1.5;
  39577. // empty scene scenario!
  39578. if (!isFinite(radius)) {
  39579. radius = 1;
  39580. worldCenter.copyFromFloats(0, 0, 0);
  39581. }
  39582. if (createArcRotateCamera) {
  39583. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39584. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39585. arcRotateCamera.wheelPrecision = 100 / radius;
  39586. camera = arcRotateCamera;
  39587. }
  39588. else {
  39589. 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);
  39590. freeCamera.setTarget(worldCenter);
  39591. camera = freeCamera;
  39592. }
  39593. camera.minZ = radius * 0.01;
  39594. camera.maxZ = radius * 1000;
  39595. camera.speed = radius * 0.2;
  39596. this.activeCamera = camera;
  39597. var canvas = this.getEngine().getRenderingCanvas();
  39598. if (attachCameraControls && canvas) {
  39599. camera.attachControl(canvas);
  39600. }
  39601. }
  39602. };
  39603. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39604. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39605. if (replace === void 0) { replace = false; }
  39606. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39607. this.createDefaultLight(replace);
  39608. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39609. };
  39610. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39611. if (pbr === void 0) { pbr = false; }
  39612. if (scale === void 0) { scale = 1000; }
  39613. if (blur === void 0) { blur = 0; }
  39614. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39615. if (!environmentTexture) {
  39616. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39617. return null;
  39618. }
  39619. if (setGlobalEnvTexture) {
  39620. if (environmentTexture) {
  39621. this.environmentTexture = environmentTexture;
  39622. }
  39623. }
  39624. // Skybox
  39625. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39626. if (pbr) {
  39627. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39628. hdrSkyboxMaterial.backFaceCulling = false;
  39629. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39630. if (hdrSkyboxMaterial.reflectionTexture) {
  39631. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39632. }
  39633. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39634. hdrSkyboxMaterial.disableLighting = true;
  39635. hdrSkyboxMaterial.twoSidedLighting = true;
  39636. hdrSkybox.infiniteDistance = true;
  39637. hdrSkybox.material = hdrSkyboxMaterial;
  39638. }
  39639. else {
  39640. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39641. skyboxMaterial.backFaceCulling = false;
  39642. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39643. if (skyboxMaterial.reflectionTexture) {
  39644. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39645. }
  39646. skyboxMaterial.disableLighting = true;
  39647. hdrSkybox.infiniteDistance = true;
  39648. hdrSkybox.material = skyboxMaterial;
  39649. }
  39650. hdrSkybox.isPickable = false;
  39651. return hdrSkybox;
  39652. };
  39653. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39654. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39655. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39656. }
  39657. return null;
  39658. };
  39659. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39660. if (webVROptions === void 0) { webVROptions = {}; }
  39661. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39662. };
  39663. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39664. var _this = this;
  39665. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39666. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39667. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39668. .then(function (ui) {
  39669. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39670. return helper;
  39671. });
  39672. });
  39673. };
  39674. /***/ }),
  39675. /***/ "./Helpers/videoDome.ts":
  39676. /*!******************************!*\
  39677. !*** ./Helpers/videoDome.ts ***!
  39678. \******************************/
  39679. /*! exports provided: VideoDome */
  39680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39681. "use strict";
  39682. __webpack_require__.r(__webpack_exports__);
  39683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39685. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39686. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39687. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39688. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39689. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39690. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39691. /**
  39692. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39693. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39694. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39695. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39696. */
  39697. var VideoDome = /** @class */ (function (_super) {
  39698. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39699. /**
  39700. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39701. * @param name Element's name, child elements will append suffixes for their own names.
  39702. * @param urlsOrVideo defines the url(s) or the video element to use
  39703. * @param options An object containing optional or exposed sub element properties
  39704. */
  39705. function VideoDome(name, urlsOrVideo, options, scene) {
  39706. var _this = _super.call(this, name, scene) || this;
  39707. _this._useDirectMapping = false;
  39708. // set defaults and manage values
  39709. name = name || "videoDome";
  39710. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39711. options.clickToPlay = Boolean(options.clickToPlay);
  39712. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  39713. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  39714. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39715. if (options.useDirectMapping === undefined) {
  39716. _this._useDirectMapping = true;
  39717. }
  39718. else {
  39719. _this._useDirectMapping = options.useDirectMapping;
  39720. }
  39721. _this._setReady(false);
  39722. // create
  39723. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  39724. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39725. 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);
  39726. _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);
  39727. texture.onLoadObservable.addOnce(function () {
  39728. _this._setReady(true);
  39729. });
  39730. // configure material
  39731. material.useEquirectangularFOV = true;
  39732. material.fovMultiplier = 1.0;
  39733. material.opacityFresnel = false;
  39734. if (_this._useDirectMapping) {
  39735. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39736. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39737. material.diffuseTexture = texture;
  39738. }
  39739. else {
  39740. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39741. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39742. material.reflectionTexture = texture;
  39743. }
  39744. // configure mesh
  39745. _this._mesh.material = material;
  39746. _this._mesh.parent = _this;
  39747. // optional configuration
  39748. if (options.clickToPlay) {
  39749. scene.onPointerUp = function () {
  39750. _this._videoTexture.video.play();
  39751. };
  39752. }
  39753. return _this;
  39754. }
  39755. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  39756. /**
  39757. * Gets the video texture being displayed on the sphere
  39758. */
  39759. get: function () {
  39760. return this._videoTexture;
  39761. },
  39762. enumerable: true,
  39763. configurable: true
  39764. });
  39765. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  39766. /**
  39767. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39768. * Also see the options.resolution property.
  39769. */
  39770. get: function () {
  39771. return this._material.fovMultiplier;
  39772. },
  39773. set: function (value) {
  39774. this._material.fovMultiplier = value;
  39775. },
  39776. enumerable: true,
  39777. configurable: true
  39778. });
  39779. /**
  39780. * Releases resources associated with this node.
  39781. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39782. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39783. */
  39784. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39785. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39786. this._videoTexture.dispose();
  39787. this._mesh.dispose();
  39788. this._material.dispose();
  39789. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39790. };
  39791. return VideoDome;
  39792. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  39793. /***/ }),
  39794. /***/ "./Instrumentation/engineInstrumentation.ts":
  39795. /*!**************************************************!*\
  39796. !*** ./Instrumentation/engineInstrumentation.ts ***!
  39797. \**************************************************/
  39798. /*! exports provided: EngineInstrumentation */
  39799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39800. "use strict";
  39801. __webpack_require__.r(__webpack_exports__);
  39802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  39803. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39804. /**
  39805. * This class can be used to get instrumentation data from a Babylon engine
  39806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39807. */
  39808. var EngineInstrumentation = /** @class */ (function () {
  39809. /**
  39810. * Instantiates a new engine instrumentation.
  39811. * This class can be used to get instrumentation data from a Babylon engine
  39812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39813. * @param engine Defines the engine to instrument
  39814. */
  39815. function EngineInstrumentation(
  39816. /**
  39817. * Define the instrumented engine.
  39818. */
  39819. engine) {
  39820. this.engine = engine;
  39821. this._captureGPUFrameTime = false;
  39822. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39823. this._captureShaderCompilationTime = false;
  39824. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39825. // Observers
  39826. this._onBeginFrameObserver = null;
  39827. this._onEndFrameObserver = null;
  39828. this._onBeforeShaderCompilationObserver = null;
  39829. this._onAfterShaderCompilationObserver = null;
  39830. }
  39831. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  39832. // Properties
  39833. /**
  39834. * Gets the perf counter used for GPU frame time
  39835. */
  39836. get: function () {
  39837. return this._gpuFrameTime;
  39838. },
  39839. enumerable: true,
  39840. configurable: true
  39841. });
  39842. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  39843. /**
  39844. * Gets the GPU frame time capture status
  39845. */
  39846. get: function () {
  39847. return this._captureGPUFrameTime;
  39848. },
  39849. /**
  39850. * Enable or disable the GPU frame time capture
  39851. */
  39852. set: function (value) {
  39853. var _this = this;
  39854. if (value === this._captureGPUFrameTime) {
  39855. return;
  39856. }
  39857. this._captureGPUFrameTime = value;
  39858. if (value) {
  39859. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  39860. if (!_this._gpuFrameTimeToken) {
  39861. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  39862. }
  39863. });
  39864. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  39865. if (!_this._gpuFrameTimeToken) {
  39866. return;
  39867. }
  39868. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  39869. if (time > -1) {
  39870. _this._gpuFrameTimeToken = null;
  39871. _this._gpuFrameTime.fetchNewFrame();
  39872. _this._gpuFrameTime.addCount(time, true);
  39873. }
  39874. });
  39875. }
  39876. else {
  39877. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39878. this._onBeginFrameObserver = null;
  39879. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39880. this._onEndFrameObserver = null;
  39881. }
  39882. },
  39883. enumerable: true,
  39884. configurable: true
  39885. });
  39886. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  39887. /**
  39888. * Gets the perf counter used for shader compilation time
  39889. */
  39890. get: function () {
  39891. return this._shaderCompilationTime;
  39892. },
  39893. enumerable: true,
  39894. configurable: true
  39895. });
  39896. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  39897. /**
  39898. * Gets the shader compilation time capture status
  39899. */
  39900. get: function () {
  39901. return this._captureShaderCompilationTime;
  39902. },
  39903. /**
  39904. * Enable or disable the shader compilation time capture
  39905. */
  39906. set: function (value) {
  39907. var _this = this;
  39908. if (value === this._captureShaderCompilationTime) {
  39909. return;
  39910. }
  39911. this._captureShaderCompilationTime = value;
  39912. if (value) {
  39913. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  39914. _this._shaderCompilationTime.fetchNewFrame();
  39915. _this._shaderCompilationTime.beginMonitoring();
  39916. });
  39917. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  39918. _this._shaderCompilationTime.endMonitoring();
  39919. });
  39920. }
  39921. else {
  39922. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39923. this._onBeforeShaderCompilationObserver = null;
  39924. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39925. this._onAfterShaderCompilationObserver = null;
  39926. }
  39927. },
  39928. enumerable: true,
  39929. configurable: true
  39930. });
  39931. /**
  39932. * Dispose and release associated resources.
  39933. */
  39934. EngineInstrumentation.prototype.dispose = function () {
  39935. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39936. this._onBeginFrameObserver = null;
  39937. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39938. this._onEndFrameObserver = null;
  39939. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39940. this._onBeforeShaderCompilationObserver = null;
  39941. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39942. this._onAfterShaderCompilationObserver = null;
  39943. this.engine = null;
  39944. };
  39945. return EngineInstrumentation;
  39946. }());
  39947. /***/ }),
  39948. /***/ "./Instrumentation/index.ts":
  39949. /*!**********************************!*\
  39950. !*** ./Instrumentation/index.ts ***!
  39951. \**********************************/
  39952. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  39953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39954. "use strict";
  39955. __webpack_require__.r(__webpack_exports__);
  39956. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  39957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  39958. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  39959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  39960. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  39961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  39962. /***/ }),
  39963. /***/ "./Instrumentation/sceneInstrumentation.ts":
  39964. /*!*************************************************!*\
  39965. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  39966. \*************************************************/
  39967. /*! exports provided: SceneInstrumentation */
  39968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39969. "use strict";
  39970. __webpack_require__.r(__webpack_exports__);
  39971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  39972. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39973. /**
  39974. * This class can be used to get instrumentation data from a Babylon engine
  39975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39976. */
  39977. var SceneInstrumentation = /** @class */ (function () {
  39978. /**
  39979. * Instantiates a new scene instrumentation.
  39980. * This class can be used to get instrumentation data from a Babylon engine
  39981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39982. * @param scene Defines the scene to instrument
  39983. */
  39984. function SceneInstrumentation(
  39985. /**
  39986. * Defines the scene to instrument
  39987. */
  39988. scene) {
  39989. var _this = this;
  39990. this.scene = scene;
  39991. this._captureActiveMeshesEvaluationTime = false;
  39992. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39993. this._captureRenderTargetsRenderTime = false;
  39994. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39995. this._captureFrameTime = false;
  39996. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39997. this._captureRenderTime = false;
  39998. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39999. this._captureInterFrameTime = false;
  40000. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40001. this._captureParticlesRenderTime = false;
  40002. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40003. this._captureSpritesRenderTime = false;
  40004. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40005. this._capturePhysicsTime = false;
  40006. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40007. this._captureAnimationsTime = false;
  40008. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40009. this._captureCameraRenderTime = false;
  40010. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40011. // Observers
  40012. this._onBeforeActiveMeshesEvaluationObserver = null;
  40013. this._onAfterActiveMeshesEvaluationObserver = null;
  40014. this._onBeforeRenderTargetsRenderObserver = null;
  40015. this._onAfterRenderTargetsRenderObserver = null;
  40016. this._onAfterRenderObserver = null;
  40017. this._onBeforeDrawPhaseObserver = null;
  40018. this._onAfterDrawPhaseObserver = null;
  40019. this._onBeforeAnimationsObserver = null;
  40020. this._onBeforeParticlesRenderingObserver = null;
  40021. this._onAfterParticlesRenderingObserver = null;
  40022. this._onBeforeSpritesRenderingObserver = null;
  40023. this._onAfterSpritesRenderingObserver = null;
  40024. this._onBeforePhysicsObserver = null;
  40025. this._onAfterPhysicsObserver = null;
  40026. this._onAfterAnimationsObserver = null;
  40027. this._onBeforeCameraRenderObserver = null;
  40028. this._onAfterCameraRenderObserver = null;
  40029. // Before render
  40030. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40031. if (_this._captureActiveMeshesEvaluationTime) {
  40032. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40033. }
  40034. if (_this._captureRenderTargetsRenderTime) {
  40035. _this._renderTargetsRenderTime.fetchNewFrame();
  40036. }
  40037. if (_this._captureFrameTime) {
  40038. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40039. _this._frameTime.beginMonitoring();
  40040. }
  40041. if (_this._captureInterFrameTime) {
  40042. _this._interFrameTime.endMonitoring();
  40043. }
  40044. if (_this._captureParticlesRenderTime) {
  40045. _this._particlesRenderTime.fetchNewFrame();
  40046. }
  40047. if (_this._captureSpritesRenderTime) {
  40048. _this._spritesRenderTime.fetchNewFrame();
  40049. }
  40050. if (_this._captureAnimationsTime) {
  40051. _this._animationsTime.beginMonitoring();
  40052. }
  40053. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40054. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40055. });
  40056. // After render
  40057. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40058. if (_this._captureFrameTime) {
  40059. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40060. _this._frameTime.endMonitoring();
  40061. }
  40062. if (_this._captureRenderTime) {
  40063. _this._renderTime.endMonitoring(false);
  40064. }
  40065. if (_this._captureInterFrameTime) {
  40066. _this._interFrameTime.beginMonitoring();
  40067. }
  40068. });
  40069. }
  40070. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40071. // Properties
  40072. /**
  40073. * Gets the perf counter used for active meshes evaluation time
  40074. */
  40075. get: function () {
  40076. return this._activeMeshesEvaluationTime;
  40077. },
  40078. enumerable: true,
  40079. configurable: true
  40080. });
  40081. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40082. /**
  40083. * Gets the active meshes evaluation time capture status
  40084. */
  40085. get: function () {
  40086. return this._captureActiveMeshesEvaluationTime;
  40087. },
  40088. /**
  40089. * Enable or disable the active meshes evaluation time capture
  40090. */
  40091. set: function (value) {
  40092. var _this = this;
  40093. if (value === this._captureActiveMeshesEvaluationTime) {
  40094. return;
  40095. }
  40096. this._captureActiveMeshesEvaluationTime = value;
  40097. if (value) {
  40098. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40099. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40100. _this._activeMeshesEvaluationTime.beginMonitoring();
  40101. });
  40102. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40103. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40104. _this._activeMeshesEvaluationTime.endMonitoring();
  40105. });
  40106. }
  40107. else {
  40108. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40109. this._onBeforeActiveMeshesEvaluationObserver = null;
  40110. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40111. this._onAfterActiveMeshesEvaluationObserver = null;
  40112. }
  40113. },
  40114. enumerable: true,
  40115. configurable: true
  40116. });
  40117. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40118. /**
  40119. * Gets the perf counter used for render targets render time
  40120. */
  40121. get: function () {
  40122. return this._renderTargetsRenderTime;
  40123. },
  40124. enumerable: true,
  40125. configurable: true
  40126. });
  40127. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40128. /**
  40129. * Gets the render targets render time capture status
  40130. */
  40131. get: function () {
  40132. return this._captureRenderTargetsRenderTime;
  40133. },
  40134. /**
  40135. * Enable or disable the render targets render time capture
  40136. */
  40137. set: function (value) {
  40138. var _this = this;
  40139. if (value === this._captureRenderTargetsRenderTime) {
  40140. return;
  40141. }
  40142. this._captureRenderTargetsRenderTime = value;
  40143. if (value) {
  40144. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40145. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40146. _this._renderTargetsRenderTime.beginMonitoring();
  40147. });
  40148. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  40149. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  40150. _this._renderTargetsRenderTime.endMonitoring(false);
  40151. });
  40152. }
  40153. else {
  40154. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40155. this._onBeforeRenderTargetsRenderObserver = null;
  40156. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40157. this._onAfterRenderTargetsRenderObserver = null;
  40158. }
  40159. },
  40160. enumerable: true,
  40161. configurable: true
  40162. });
  40163. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  40164. /**
  40165. * Gets the perf counter used for particles render time
  40166. */
  40167. get: function () {
  40168. return this._particlesRenderTime;
  40169. },
  40170. enumerable: true,
  40171. configurable: true
  40172. });
  40173. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  40174. /**
  40175. * Gets the particles render time capture status
  40176. */
  40177. get: function () {
  40178. return this._captureParticlesRenderTime;
  40179. },
  40180. /**
  40181. * Enable or disable the particles render time capture
  40182. */
  40183. set: function (value) {
  40184. var _this = this;
  40185. if (value === this._captureParticlesRenderTime) {
  40186. return;
  40187. }
  40188. this._captureParticlesRenderTime = value;
  40189. if (value) {
  40190. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  40191. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  40192. _this._particlesRenderTime.beginMonitoring();
  40193. });
  40194. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  40195. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  40196. _this._particlesRenderTime.endMonitoring(false);
  40197. });
  40198. }
  40199. else {
  40200. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40201. this._onBeforeParticlesRenderingObserver = null;
  40202. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40203. this._onAfterParticlesRenderingObserver = null;
  40204. }
  40205. },
  40206. enumerable: true,
  40207. configurable: true
  40208. });
  40209. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  40210. /**
  40211. * Gets the perf counter used for sprites render time
  40212. */
  40213. get: function () {
  40214. return this._spritesRenderTime;
  40215. },
  40216. enumerable: true,
  40217. configurable: true
  40218. });
  40219. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  40220. /**
  40221. * Gets the sprites render time capture status
  40222. */
  40223. get: function () {
  40224. return this._captureSpritesRenderTime;
  40225. },
  40226. /**
  40227. * Enable or disable the sprites render time capture
  40228. */
  40229. set: function (value) {
  40230. var _this = this;
  40231. if (value === this._captureSpritesRenderTime) {
  40232. return;
  40233. }
  40234. this._captureSpritesRenderTime = value;
  40235. if (!this.scene.spriteManagers) {
  40236. return;
  40237. }
  40238. if (value) {
  40239. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  40240. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  40241. _this._spritesRenderTime.beginMonitoring();
  40242. });
  40243. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  40244. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  40245. _this._spritesRenderTime.endMonitoring(false);
  40246. });
  40247. }
  40248. else {
  40249. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40250. this._onBeforeSpritesRenderingObserver = null;
  40251. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40252. this._onAfterSpritesRenderingObserver = null;
  40253. }
  40254. },
  40255. enumerable: true,
  40256. configurable: true
  40257. });
  40258. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  40259. /**
  40260. * Gets the perf counter used for physics time
  40261. */
  40262. get: function () {
  40263. return this._physicsTime;
  40264. },
  40265. enumerable: true,
  40266. configurable: true
  40267. });
  40268. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  40269. /**
  40270. * Gets the physics time capture status
  40271. */
  40272. get: function () {
  40273. return this._capturePhysicsTime;
  40274. },
  40275. /**
  40276. * Enable or disable the physics time capture
  40277. */
  40278. set: function (value) {
  40279. var _this = this;
  40280. if (value === this._capturePhysicsTime) {
  40281. return;
  40282. }
  40283. if (!this.scene.onBeforePhysicsObservable) {
  40284. return;
  40285. }
  40286. this._capturePhysicsTime = value;
  40287. if (value) {
  40288. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  40289. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  40290. _this._physicsTime.beginMonitoring();
  40291. });
  40292. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  40293. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  40294. _this._physicsTime.endMonitoring();
  40295. });
  40296. }
  40297. else {
  40298. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40299. this._onBeforePhysicsObserver = null;
  40300. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40301. this._onAfterPhysicsObserver = null;
  40302. }
  40303. },
  40304. enumerable: true,
  40305. configurable: true
  40306. });
  40307. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  40308. /**
  40309. * Gets the perf counter used for animations time
  40310. */
  40311. get: function () {
  40312. return this._animationsTime;
  40313. },
  40314. enumerable: true,
  40315. configurable: true
  40316. });
  40317. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  40318. /**
  40319. * Gets the animations time capture status
  40320. */
  40321. get: function () {
  40322. return this._captureAnimationsTime;
  40323. },
  40324. /**
  40325. * Enable or disable the animations time capture
  40326. */
  40327. set: function (value) {
  40328. var _this = this;
  40329. if (value === this._captureAnimationsTime) {
  40330. return;
  40331. }
  40332. this._captureAnimationsTime = value;
  40333. if (value) {
  40334. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  40335. _this._animationsTime.endMonitoring();
  40336. });
  40337. }
  40338. else {
  40339. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40340. this._onAfterAnimationsObserver = null;
  40341. }
  40342. },
  40343. enumerable: true,
  40344. configurable: true
  40345. });
  40346. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  40347. /**
  40348. * Gets the perf counter used for frame time capture
  40349. */
  40350. get: function () {
  40351. return this._frameTime;
  40352. },
  40353. enumerable: true,
  40354. configurable: true
  40355. });
  40356. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  40357. /**
  40358. * Gets the frame time capture status
  40359. */
  40360. get: function () {
  40361. return this._captureFrameTime;
  40362. },
  40363. /**
  40364. * Enable or disable the frame time capture
  40365. */
  40366. set: function (value) {
  40367. this._captureFrameTime = value;
  40368. },
  40369. enumerable: true,
  40370. configurable: true
  40371. });
  40372. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  40373. /**
  40374. * Gets the perf counter used for inter-frames time capture
  40375. */
  40376. get: function () {
  40377. return this._interFrameTime;
  40378. },
  40379. enumerable: true,
  40380. configurable: true
  40381. });
  40382. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  40383. /**
  40384. * Gets the inter-frames time capture status
  40385. */
  40386. get: function () {
  40387. return this._captureInterFrameTime;
  40388. },
  40389. /**
  40390. * Enable or disable the inter-frames time capture
  40391. */
  40392. set: function (value) {
  40393. this._captureInterFrameTime = value;
  40394. },
  40395. enumerable: true,
  40396. configurable: true
  40397. });
  40398. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  40399. /**
  40400. * Gets the perf counter used for render time capture
  40401. */
  40402. get: function () {
  40403. return this._renderTime;
  40404. },
  40405. enumerable: true,
  40406. configurable: true
  40407. });
  40408. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  40409. /**
  40410. * Gets the render time capture status
  40411. */
  40412. get: function () {
  40413. return this._captureRenderTime;
  40414. },
  40415. /**
  40416. * Enable or disable the render time capture
  40417. */
  40418. set: function (value) {
  40419. var _this = this;
  40420. if (value === this._captureRenderTime) {
  40421. return;
  40422. }
  40423. this._captureRenderTime = value;
  40424. if (value) {
  40425. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  40426. _this._renderTime.beginMonitoring();
  40427. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  40428. });
  40429. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  40430. _this._renderTime.endMonitoring(false);
  40431. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  40432. });
  40433. }
  40434. else {
  40435. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40436. this._onBeforeDrawPhaseObserver = null;
  40437. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40438. this._onAfterDrawPhaseObserver = null;
  40439. }
  40440. },
  40441. enumerable: true,
  40442. configurable: true
  40443. });
  40444. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  40445. /**
  40446. * Gets the perf counter used for camera render time capture
  40447. */
  40448. get: function () {
  40449. return this._cameraRenderTime;
  40450. },
  40451. enumerable: true,
  40452. configurable: true
  40453. });
  40454. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  40455. /**
  40456. * Gets the camera render time capture status
  40457. */
  40458. get: function () {
  40459. return this._captureCameraRenderTime;
  40460. },
  40461. /**
  40462. * Enable or disable the camera render time capture
  40463. */
  40464. set: function (value) {
  40465. var _this = this;
  40466. if (value === this._captureCameraRenderTime) {
  40467. return;
  40468. }
  40469. this._captureCameraRenderTime = value;
  40470. if (value) {
  40471. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40472. _this._cameraRenderTime.beginMonitoring();
  40473. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40474. });
  40475. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40476. _this._cameraRenderTime.endMonitoring(false);
  40477. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40478. });
  40479. }
  40480. else {
  40481. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40482. this._onBeforeCameraRenderObserver = null;
  40483. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40484. this._onAfterCameraRenderObserver = null;
  40485. }
  40486. },
  40487. enumerable: true,
  40488. configurable: true
  40489. });
  40490. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40491. /**
  40492. * Gets the perf counter used for draw calls
  40493. */
  40494. get: function () {
  40495. return this.scene.getEngine()._drawCalls;
  40496. },
  40497. enumerable: true,
  40498. configurable: true
  40499. });
  40500. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40501. /**
  40502. * Gets the perf counter used for texture collisions
  40503. */
  40504. get: function () {
  40505. return this.scene.getEngine()._textureCollisions;
  40506. },
  40507. enumerable: true,
  40508. configurable: true
  40509. });
  40510. /**
  40511. * Dispose and release associated resources.
  40512. */
  40513. SceneInstrumentation.prototype.dispose = function () {
  40514. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40515. this._onAfterRenderObserver = null;
  40516. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40517. this._onBeforeActiveMeshesEvaluationObserver = null;
  40518. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40519. this._onAfterActiveMeshesEvaluationObserver = null;
  40520. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40521. this._onBeforeRenderTargetsRenderObserver = null;
  40522. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40523. this._onAfterRenderTargetsRenderObserver = null;
  40524. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40525. this._onBeforeAnimationsObserver = null;
  40526. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40527. this._onBeforeParticlesRenderingObserver = null;
  40528. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40529. this._onAfterParticlesRenderingObserver = null;
  40530. if (this._onBeforeSpritesRenderingObserver) {
  40531. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40532. this._onBeforeSpritesRenderingObserver = null;
  40533. }
  40534. if (this._onAfterSpritesRenderingObserver) {
  40535. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40536. this._onAfterSpritesRenderingObserver = null;
  40537. }
  40538. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40539. this._onBeforeDrawPhaseObserver = null;
  40540. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40541. this._onAfterDrawPhaseObserver = null;
  40542. if (this._onBeforePhysicsObserver) {
  40543. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40544. this._onBeforePhysicsObserver = null;
  40545. }
  40546. if (this._onAfterPhysicsObserver) {
  40547. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40548. this._onAfterPhysicsObserver = null;
  40549. }
  40550. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40551. this._onAfterAnimationsObserver = null;
  40552. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40553. this._onBeforeCameraRenderObserver = null;
  40554. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40555. this._onAfterCameraRenderObserver = null;
  40556. this.scene = null;
  40557. };
  40558. return SceneInstrumentation;
  40559. }());
  40560. /***/ }),
  40561. /***/ "./Instrumentation/timeToken.ts":
  40562. /*!**************************************!*\
  40563. !*** ./Instrumentation/timeToken.ts ***!
  40564. \**************************************/
  40565. /*! exports provided: _TimeToken */
  40566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40567. "use strict";
  40568. __webpack_require__.r(__webpack_exports__);
  40569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40570. /**
  40571. * @hidden
  40572. **/
  40573. var _TimeToken = /** @class */ (function () {
  40574. function _TimeToken() {
  40575. this._timeElapsedQueryEnded = false;
  40576. }
  40577. return _TimeToken;
  40578. }());
  40579. /***/ }),
  40580. /***/ "./Layers/effectLayer.ts":
  40581. /*!*******************************!*\
  40582. !*** ./Layers/effectLayer.ts ***!
  40583. \*******************************/
  40584. /*! exports provided: EffectLayer */
  40585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40586. "use strict";
  40587. __webpack_require__.r(__webpack_exports__);
  40588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40590. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40591. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40592. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40593. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40594. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40595. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40596. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40597. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40598. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40599. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40600. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40601. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40602. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40603. /**
  40604. * The effect layer Helps adding post process effect blended with the main pass.
  40605. *
  40606. * This can be for instance use to generate glow or higlight effects on the scene.
  40607. *
  40608. * The effect layer class can not be used directly and is intented to inherited from to be
  40609. * customized per effects.
  40610. */
  40611. var EffectLayer = /** @class */ (function () {
  40612. /**
  40613. * Instantiates a new effect Layer and references it in the scene.
  40614. * @param name The name of the layer
  40615. * @param scene The scene to use the layer in
  40616. */
  40617. function EffectLayer(
  40618. /** The Friendly of the effect in the scene */
  40619. name, scene) {
  40620. this._vertexBuffers = {};
  40621. this._maxSize = 0;
  40622. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40623. this._shouldRender = true;
  40624. this._postProcesses = [];
  40625. this._textures = [];
  40626. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40627. /**
  40628. * The clear color of the texture used to generate the glow map.
  40629. */
  40630. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40631. /**
  40632. * Specifies wether the highlight layer is enabled or not.
  40633. */
  40634. this.isEnabled = true;
  40635. /**
  40636. * An event triggered when the effect layer has been disposed.
  40637. */
  40638. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40639. /**
  40640. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40641. */
  40642. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40643. /**
  40644. * An event triggered when the generated texture is being merged in the scene.
  40645. */
  40646. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40647. /**
  40648. * An event triggered when the generated texture has been merged in the scene.
  40649. */
  40650. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40651. /**
  40652. * An event triggered when the efffect layer changes its size.
  40653. */
  40654. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40655. this.name = name;
  40656. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40657. EffectLayer._SceneComponentInitialization(this._scene);
  40658. this._engine = this._scene.getEngine();
  40659. this._maxSize = this._engine.getCaps().maxTextureSize;
  40660. this._scene.effectLayers.push(this);
  40661. // Generate Buffers
  40662. this._generateIndexBuffer();
  40663. this._genrateVertexBuffer();
  40664. }
  40665. Object.defineProperty(EffectLayer.prototype, "camera", {
  40666. /**
  40667. * Gets the camera attached to the layer.
  40668. */
  40669. get: function () {
  40670. return this._effectLayerOptions.camera;
  40671. },
  40672. enumerable: true,
  40673. configurable: true
  40674. });
  40675. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40676. /**
  40677. * Gets the rendering group id the layer should render in.
  40678. */
  40679. get: function () {
  40680. return this._effectLayerOptions.renderingGroupId;
  40681. },
  40682. enumerable: true,
  40683. configurable: true
  40684. });
  40685. /**
  40686. * Initializes the effect layer with the required options.
  40687. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40688. */
  40689. EffectLayer.prototype._init = function (options) {
  40690. // Adapt options
  40691. 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);
  40692. this._setMainTextureSize();
  40693. this._createMainTexture();
  40694. this._createTextureAndPostProcesses();
  40695. this._mergeEffect = this._createMergeEffect();
  40696. };
  40697. /**
  40698. * Generates the index buffer of the full screen quad blending to the main canvas.
  40699. */
  40700. EffectLayer.prototype._generateIndexBuffer = function () {
  40701. // Indices
  40702. var indices = [];
  40703. indices.push(0);
  40704. indices.push(1);
  40705. indices.push(2);
  40706. indices.push(0);
  40707. indices.push(2);
  40708. indices.push(3);
  40709. this._indexBuffer = this._engine.createIndexBuffer(indices);
  40710. };
  40711. /**
  40712. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  40713. */
  40714. EffectLayer.prototype._genrateVertexBuffer = function () {
  40715. // VBO
  40716. var vertices = [];
  40717. vertices.push(1, 1);
  40718. vertices.push(-1, 1);
  40719. vertices.push(-1, -1);
  40720. vertices.push(1, -1);
  40721. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  40722. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  40723. };
  40724. /**
  40725. * Sets the main texture desired size which is the closest power of two
  40726. * of the engine canvas size.
  40727. */
  40728. EffectLayer.prototype._setMainTextureSize = function () {
  40729. if (this._effectLayerOptions.mainTextureFixedSize) {
  40730. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  40731. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  40732. }
  40733. else {
  40734. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  40735. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  40736. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  40737. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  40738. }
  40739. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  40740. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  40741. };
  40742. /**
  40743. * Creates the main texture for the effect layer.
  40744. */
  40745. EffectLayer.prototype._createMainTexture = function () {
  40746. var _this = this;
  40747. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  40748. width: this._mainTextureDesiredSize.width,
  40749. height: this._mainTextureDesiredSize.height
  40750. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  40751. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  40752. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40753. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40754. this._mainTexture.anisotropicFilteringLevel = 1;
  40755. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  40756. this._mainTexture.renderParticles = false;
  40757. this._mainTexture.renderList = null;
  40758. this._mainTexture.ignoreCameraViewport = true;
  40759. // Custom render function
  40760. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  40761. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  40762. var index;
  40763. var engine = _this._scene.getEngine();
  40764. if (depthOnlySubMeshes.length) {
  40765. engine.setColorWrite(false);
  40766. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  40767. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  40768. }
  40769. engine.setColorWrite(true);
  40770. }
  40771. for (index = 0; index < opaqueSubMeshes.length; index++) {
  40772. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  40773. }
  40774. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  40775. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  40776. }
  40777. for (index = 0; index < transparentSubMeshes.length; index++) {
  40778. _this._renderSubMesh(transparentSubMeshes.data[index]);
  40779. }
  40780. };
  40781. this._mainTexture.onClearObservable.add(function (engine) {
  40782. engine.clear(_this.neutralColor, true, true, true);
  40783. });
  40784. };
  40785. /**
  40786. * Adds specific effects defines.
  40787. * @param defines The defines to add specifics to.
  40788. */
  40789. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  40790. // Nothing to add by default.
  40791. };
  40792. /**
  40793. * Checks for the readiness of the element composing the layer.
  40794. * @param subMesh the mesh to check for
  40795. * @param useInstances specify wether or not to use instances to render the mesh
  40796. * @param emissiveTexture the associated emissive texture used to generate the glow
  40797. * @return true if ready otherwise, false
  40798. */
  40799. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  40800. var material = subMesh.getMaterial();
  40801. if (!material) {
  40802. return false;
  40803. }
  40804. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  40805. return false;
  40806. }
  40807. var defines = [];
  40808. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40809. var mesh = subMesh.getMesh();
  40810. var uv1 = false;
  40811. var uv2 = false;
  40812. // Diffuse
  40813. if (material) {
  40814. var needAlphaTest = material.needAlphaTesting();
  40815. var diffuseTexture = material.getAlphaTestTexture();
  40816. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40817. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40818. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40819. defines.push("#define DIFFUSE");
  40820. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40821. diffuseTexture.coordinatesIndex === 1) {
  40822. defines.push("#define DIFFUSEUV2");
  40823. uv2 = true;
  40824. }
  40825. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40826. defines.push("#define DIFFUSEUV1");
  40827. uv1 = true;
  40828. }
  40829. if (needAlphaTest) {
  40830. defines.push("#define ALPHATEST");
  40831. defines.push("#define ALPHATESTVALUE 0.4");
  40832. }
  40833. }
  40834. var opacityTexture = material.opacityTexture;
  40835. if (opacityTexture) {
  40836. defines.push("#define OPACITY");
  40837. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40838. opacityTexture.coordinatesIndex === 1) {
  40839. defines.push("#define OPACITYUV2");
  40840. uv2 = true;
  40841. }
  40842. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40843. defines.push("#define OPACITYUV1");
  40844. uv1 = true;
  40845. }
  40846. }
  40847. }
  40848. // Emissive
  40849. if (emissiveTexture) {
  40850. defines.push("#define EMISSIVE");
  40851. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40852. emissiveTexture.coordinatesIndex === 1) {
  40853. defines.push("#define EMISSIVEUV2");
  40854. uv2 = true;
  40855. }
  40856. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40857. defines.push("#define EMISSIVEUV1");
  40858. uv1 = true;
  40859. }
  40860. }
  40861. // Vertex
  40862. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  40863. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  40864. defines.push("#define VERTEXALPHA");
  40865. }
  40866. if (uv1) {
  40867. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  40868. defines.push("#define UV1");
  40869. }
  40870. if (uv2) {
  40871. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  40872. defines.push("#define UV2");
  40873. }
  40874. // Bones
  40875. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  40876. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  40877. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  40878. if (mesh.numBoneInfluencers > 4) {
  40879. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  40880. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  40881. }
  40882. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  40883. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  40884. }
  40885. else {
  40886. defines.push("#define NUM_BONE_INFLUENCERS 0");
  40887. }
  40888. // Morph targets
  40889. var manager = mesh.morphTargetManager;
  40890. var morphInfluencers = 0;
  40891. if (manager) {
  40892. if (manager.numInfluencers > 0) {
  40893. defines.push("#define MORPHTARGETS");
  40894. morphInfluencers = manager.numInfluencers;
  40895. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  40896. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  40897. }
  40898. }
  40899. // Instances
  40900. if (useInstances) {
  40901. defines.push("#define INSTANCES");
  40902. attribs.push("world0");
  40903. attribs.push("world1");
  40904. attribs.push("world2");
  40905. attribs.push("world3");
  40906. }
  40907. this._addCustomEffectDefines(defines);
  40908. // Get correct effect
  40909. var join = defines.join("\n");
  40910. if (this._cachedDefines !== join) {
  40911. this._cachedDefines = join;
  40912. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  40913. "color", "morphTargetInfluences",
  40914. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  40915. }
  40916. return this._effectLayerMapGenerationEffect.isReady();
  40917. };
  40918. /**
  40919. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  40920. */
  40921. EffectLayer.prototype.render = function () {
  40922. var currentEffect = this._mergeEffect;
  40923. // Check
  40924. if (!currentEffect.isReady()) {
  40925. return;
  40926. }
  40927. for (var i = 0; i < this._postProcesses.length; i++) {
  40928. if (!this._postProcesses[i].isReady()) {
  40929. return;
  40930. }
  40931. }
  40932. var engine = this._scene.getEngine();
  40933. this.onBeforeComposeObservable.notifyObservers(this);
  40934. // Render
  40935. engine.enableEffect(currentEffect);
  40936. engine.setState(false);
  40937. // VBOs
  40938. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  40939. // Cache
  40940. var previousAlphaMode = engine.getAlphaMode();
  40941. // Go Blend.
  40942. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  40943. // Blends the map on the main canvas.
  40944. this._internalRender(currentEffect);
  40945. // Restore Alpha
  40946. engine.setAlphaMode(previousAlphaMode);
  40947. this.onAfterComposeObservable.notifyObservers(this);
  40948. // Handle size changes.
  40949. var size = this._mainTexture.getSize();
  40950. this._setMainTextureSize();
  40951. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  40952. // Recreate RTT and post processes on size change.
  40953. this.onSizeChangedObservable.notifyObservers(this);
  40954. this._disposeTextureAndPostProcesses();
  40955. this._createMainTexture();
  40956. this._createTextureAndPostProcesses();
  40957. }
  40958. };
  40959. /**
  40960. * Determine if a given mesh will be used in the current effect.
  40961. * @param mesh mesh to test
  40962. * @returns true if the mesh will be used
  40963. */
  40964. EffectLayer.prototype.hasMesh = function (mesh) {
  40965. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  40966. return true;
  40967. }
  40968. return false;
  40969. };
  40970. /**
  40971. * Returns true if the layer contains information to display, otherwise false.
  40972. * @returns true if the glow layer should be rendered
  40973. */
  40974. EffectLayer.prototype.shouldRender = function () {
  40975. return this.isEnabled && this._shouldRender;
  40976. };
  40977. /**
  40978. * Returns true if the mesh should render, otherwise false.
  40979. * @param mesh The mesh to render
  40980. * @returns true if it should render otherwise false
  40981. */
  40982. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  40983. return true;
  40984. };
  40985. /**
  40986. * Returns true if the mesh can be rendered, otherwise false.
  40987. * @param mesh The mesh to render
  40988. * @param material The material used on the mesh
  40989. * @returns true if it can be rendered otherwise false
  40990. */
  40991. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  40992. return !material.needAlphaBlendingForMesh(mesh);
  40993. };
  40994. /**
  40995. * Returns true if the mesh should render, otherwise false.
  40996. * @param mesh The mesh to render
  40997. * @returns true if it should render otherwise false
  40998. */
  40999. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41000. return true;
  41001. };
  41002. /**
  41003. * Renders the submesh passed in parameter to the generation map.
  41004. */
  41005. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41006. var _this = this;
  41007. if (!this.shouldRender()) {
  41008. return;
  41009. }
  41010. var material = subMesh.getMaterial();
  41011. var mesh = subMesh.getRenderingMesh();
  41012. var scene = this._scene;
  41013. var engine = scene.getEngine();
  41014. if (!material) {
  41015. return;
  41016. }
  41017. // Do not block in blend mode.
  41018. if (!this._canRenderMesh(mesh, material)) {
  41019. return;
  41020. }
  41021. // Culling
  41022. engine.setState(material.backFaceCulling);
  41023. // Managing instances
  41024. var batch = mesh._getInstancesRenderList(subMesh._id);
  41025. if (batch.mustReturn) {
  41026. return;
  41027. }
  41028. // Early Exit per mesh
  41029. if (!this._shouldRenderMesh(mesh)) {
  41030. return;
  41031. }
  41032. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41033. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41034. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41035. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41036. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41037. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41038. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41039. var needAlphaTest = material.needAlphaTesting();
  41040. var diffuseTexture = material.getAlphaTestTexture();
  41041. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41042. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41043. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41044. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41045. var textureMatrix = diffuseTexture.getTextureMatrix();
  41046. if (textureMatrix) {
  41047. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41048. }
  41049. }
  41050. var opacityTexture = material.opacityTexture;
  41051. if (opacityTexture) {
  41052. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41053. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41054. var textureMatrix = opacityTexture.getTextureMatrix();
  41055. if (textureMatrix) {
  41056. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41057. }
  41058. }
  41059. // Glow emissive only
  41060. if (this._emissiveTextureAndColor.texture) {
  41061. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41062. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41063. }
  41064. // Bones
  41065. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41066. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41067. }
  41068. // Morph targets
  41069. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41070. // Draw
  41071. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41072. }
  41073. else {
  41074. // Need to reset refresh rate of the main map
  41075. this._mainTexture.resetRefreshCounter();
  41076. }
  41077. };
  41078. /**
  41079. * Rebuild the required buffers.
  41080. * @hidden Internal use only.
  41081. */
  41082. EffectLayer.prototype._rebuild = function () {
  41083. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41084. if (vb) {
  41085. vb._rebuild();
  41086. }
  41087. this._generateIndexBuffer();
  41088. };
  41089. /**
  41090. * Dispose only the render target textures and post process.
  41091. */
  41092. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41093. this._mainTexture.dispose();
  41094. for (var i = 0; i < this._postProcesses.length; i++) {
  41095. if (this._postProcesses[i]) {
  41096. this._postProcesses[i].dispose();
  41097. }
  41098. }
  41099. this._postProcesses = [];
  41100. for (var i = 0; i < this._textures.length; i++) {
  41101. if (this._textures[i]) {
  41102. this._textures[i].dispose();
  41103. }
  41104. }
  41105. this._textures = [];
  41106. };
  41107. /**
  41108. * Dispose the highlight layer and free resources.
  41109. */
  41110. EffectLayer.prototype.dispose = function () {
  41111. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41112. if (vertexBuffer) {
  41113. vertexBuffer.dispose();
  41114. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41115. }
  41116. if (this._indexBuffer) {
  41117. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41118. this._indexBuffer = null;
  41119. }
  41120. // Clean textures and post processes
  41121. this._disposeTextureAndPostProcesses();
  41122. // Remove from scene
  41123. var index = this._scene.effectLayers.indexOf(this, 0);
  41124. if (index > -1) {
  41125. this._scene.effectLayers.splice(index, 1);
  41126. }
  41127. // Callback
  41128. this.onDisposeObservable.notifyObservers(this);
  41129. this.onDisposeObservable.clear();
  41130. this.onBeforeRenderMainTextureObservable.clear();
  41131. this.onBeforeComposeObservable.clear();
  41132. this.onAfterComposeObservable.clear();
  41133. this.onSizeChangedObservable.clear();
  41134. };
  41135. /**
  41136. * Gets the class name of the effect layer
  41137. * @returns the string with the class name of the effect layer
  41138. */
  41139. EffectLayer.prototype.getClassName = function () {
  41140. return "EffectLayer";
  41141. };
  41142. /**
  41143. * Creates an effect layer from parsed effect layer data
  41144. * @param parsedEffectLayer defines effect layer data
  41145. * @param scene defines the current scene
  41146. * @param rootUrl defines the root URL containing the effect layer information
  41147. * @returns a parsed effect Layer
  41148. */
  41149. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  41150. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  41151. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  41152. };
  41153. /** @hidden */
  41154. EffectLayer._SceneComponentInitialization = function (_) {
  41155. throw "Import EffectLayerSceneComponent before creating EffectLayer.";
  41156. };
  41157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41159. ], EffectLayer.prototype, "name", void 0);
  41160. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  41162. ], EffectLayer.prototype, "neutralColor", void 0);
  41163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41165. ], EffectLayer.prototype, "isEnabled", void 0);
  41166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  41168. ], EffectLayer.prototype, "camera", null);
  41169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41171. ], EffectLayer.prototype, "renderingGroupId", null);
  41172. return EffectLayer;
  41173. }());
  41174. /***/ }),
  41175. /***/ "./Layers/effectLayerSceneComponent.ts":
  41176. /*!*********************************************!*\
  41177. !*** ./Layers/effectLayerSceneComponent.ts ***!
  41178. \*********************************************/
  41179. /*! exports provided: EffectLayerSceneComponent */
  41180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41181. "use strict";
  41182. __webpack_require__.r(__webpack_exports__);
  41183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  41184. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  41185. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41186. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41187. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41188. // Adds the parser to the scene parsers.
  41189. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  41190. if (parsedData.effectLayers) {
  41191. if (!container.effectLayers) {
  41192. container.effectLayers = new Array();
  41193. }
  41194. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  41195. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  41196. container.effectLayers.push(effectLayer);
  41197. }
  41198. }
  41199. });
  41200. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  41201. var index = this.effectLayers.indexOf(toRemove);
  41202. if (index !== -1) {
  41203. this.effectLayers.splice(index, 1);
  41204. }
  41205. return index;
  41206. };
  41207. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  41208. this.effectLayers.push(newEffectLayer);
  41209. };
  41210. /**
  41211. * Defines the layer scene component responsible to manage any effect layers
  41212. * in a given scene.
  41213. */
  41214. var EffectLayerSceneComponent = /** @class */ (function () {
  41215. /**
  41216. * Creates a new instance of the component for the given scene
  41217. * @param scene Defines the scene to register the component in
  41218. */
  41219. function EffectLayerSceneComponent(scene) {
  41220. /**
  41221. * The component name helpfull to identify the component in the list of scene components.
  41222. */
  41223. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  41224. this._renderEffects = false;
  41225. this._needStencil = false;
  41226. this._previousStencilState = false;
  41227. this.scene = scene;
  41228. this._engine = scene.getEngine();
  41229. scene.effectLayers = new Array();
  41230. }
  41231. /**
  41232. * Registers the component in a given scene
  41233. */
  41234. EffectLayerSceneComponent.prototype.register = function () {
  41235. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  41236. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  41237. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  41238. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  41239. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  41240. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  41241. };
  41242. /**
  41243. * Rebuilds the elements related to this component in case of
  41244. * context lost for instance.
  41245. */
  41246. EffectLayerSceneComponent.prototype.rebuild = function () {
  41247. var layers = this.scene.effectLayers;
  41248. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  41249. var effectLayer = layers_1[_i];
  41250. effectLayer._rebuild();
  41251. }
  41252. };
  41253. /**
  41254. * Serializes the component data to the specified json object
  41255. * @param serializationObject The object to serialize to
  41256. */
  41257. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  41258. // Effect layers
  41259. serializationObject.effectLayers = [];
  41260. var layers = this.scene.effectLayers;
  41261. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  41262. var effectLayer = layers_2[_i];
  41263. if (effectLayer.serialize) {
  41264. serializationObject.effectLayers.push(effectLayer.serialize());
  41265. }
  41266. }
  41267. };
  41268. /**
  41269. * Adds all the element from the container to the scene
  41270. * @param container the container holding the elements
  41271. */
  41272. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  41273. var _this = this;
  41274. if (!container.effectLayers) {
  41275. return;
  41276. }
  41277. container.effectLayers.forEach(function (o) {
  41278. _this.scene.addEffectLayer(o);
  41279. });
  41280. };
  41281. /**
  41282. * Removes all the elements in the container from the scene
  41283. * @param container contains the elements to remove
  41284. */
  41285. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  41286. var _this = this;
  41287. if (!container.effectLayers) {
  41288. return;
  41289. }
  41290. container.effectLayers.forEach(function (o) {
  41291. _this.scene.removeEffectLayer(o);
  41292. });
  41293. };
  41294. /**
  41295. * Disposes the component and the associated ressources.
  41296. */
  41297. EffectLayerSceneComponent.prototype.dispose = function () {
  41298. var layers = this.scene.effectLayers;
  41299. while (layers.length) {
  41300. layers[0].dispose();
  41301. }
  41302. };
  41303. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  41304. var layers = this.scene.effectLayers;
  41305. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  41306. var layer = layers_3[_i];
  41307. if (!layer.hasMesh(mesh)) {
  41308. continue;
  41309. }
  41310. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  41311. var subMesh = _b[_a];
  41312. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  41313. return false;
  41314. }
  41315. }
  41316. }
  41317. return true;
  41318. };
  41319. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  41320. this._renderEffects = false;
  41321. this._needStencil = false;
  41322. var layers = this.scene.effectLayers;
  41323. if (layers && layers.length > 0) {
  41324. this._previousStencilState = this._engine.getStencilBuffer();
  41325. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  41326. var effectLayer = layers_4[_i];
  41327. if (effectLayer.shouldRender() &&
  41328. (!effectLayer.camera ||
  41329. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  41330. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  41331. this._renderEffects = true;
  41332. this._needStencil = this._needStencil || effectLayer.needStencil();
  41333. var renderTarget = effectLayer._mainTexture;
  41334. if (renderTarget._shouldRender()) {
  41335. this.scene.incrementRenderId();
  41336. renderTarget.render(false, false);
  41337. }
  41338. }
  41339. }
  41340. this.scene.incrementRenderId();
  41341. }
  41342. };
  41343. EffectLayerSceneComponent.prototype._setStencil = function () {
  41344. // Activate effect Layer stencil
  41345. if (this._needStencil) {
  41346. this._engine.setStencilBuffer(true);
  41347. }
  41348. };
  41349. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  41350. // Restore effect Layer stencil
  41351. if (this._needStencil) {
  41352. this._engine.setStencilBuffer(this._previousStencilState);
  41353. }
  41354. };
  41355. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  41356. if (this._renderEffects) {
  41357. this._engine.setDepthBuffer(false);
  41358. var layers = this.scene.effectLayers;
  41359. for (var i = 0; i < layers.length; i++) {
  41360. var effectLayer = layers[i];
  41361. if (effectLayer.renderingGroupId === renderingGroupId) {
  41362. if (effectLayer.shouldRender()) {
  41363. effectLayer.render();
  41364. }
  41365. }
  41366. }
  41367. this._engine.setDepthBuffer(true);
  41368. }
  41369. };
  41370. EffectLayerSceneComponent.prototype._drawCamera = function () {
  41371. if (this._renderEffects) {
  41372. this._draw(-1);
  41373. }
  41374. };
  41375. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  41376. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  41377. this._draw(index);
  41378. }
  41379. };
  41380. return EffectLayerSceneComponent;
  41381. }());
  41382. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  41383. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  41384. if (!component) {
  41385. component = new EffectLayerSceneComponent(scene);
  41386. scene._addComponent(component);
  41387. }
  41388. };
  41389. /***/ }),
  41390. /***/ "./Layers/glowLayer.ts":
  41391. /*!*****************************!*\
  41392. !*** ./Layers/glowLayer.ts ***!
  41393. \*****************************/
  41394. /*! exports provided: GlowLayer */
  41395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41396. "use strict";
  41397. __webpack_require__.r(__webpack_exports__);
  41398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  41399. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41400. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41401. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41402. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41403. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41404. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41405. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41406. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41407. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41408. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41409. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41410. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41411. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41412. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41413. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41414. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  41415. for (var index = 0; index < this.effectLayers.length; index++) {
  41416. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  41417. return this.effectLayers[index];
  41418. }
  41419. }
  41420. return null;
  41421. };
  41422. /**
  41423. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  41424. *
  41425. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41426. * glowy meshes to your scene.
  41427. *
  41428. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  41429. */
  41430. var GlowLayer = /** @class */ (function (_super) {
  41431. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  41432. /**
  41433. * Instantiates a new glow Layer and references it to the scene.
  41434. * @param name The name of the layer
  41435. * @param scene The scene to use the layer in
  41436. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  41437. */
  41438. function GlowLayer(name, scene, options) {
  41439. var _this = _super.call(this, name, scene) || this;
  41440. _this._intensity = 1.0;
  41441. _this._includedOnlyMeshes = [];
  41442. _this._excludedMeshes = [];
  41443. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  41444. // Adapt options
  41445. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  41446. // Initialize the layer
  41447. _this._init({
  41448. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  41449. camera: _this._options.camera,
  41450. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41451. mainTextureRatio: _this._options.mainTextureRatio,
  41452. renderingGroupId: _this._options.renderingGroupId
  41453. });
  41454. return _this;
  41455. }
  41456. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  41457. /**
  41458. * Gets the kernel size of the blur.
  41459. */
  41460. get: function () {
  41461. return this._horizontalBlurPostprocess1.kernel;
  41462. },
  41463. /**
  41464. * Sets the kernel size of the blur.
  41465. */
  41466. set: function (value) {
  41467. this._horizontalBlurPostprocess1.kernel = value;
  41468. this._verticalBlurPostprocess1.kernel = value;
  41469. this._horizontalBlurPostprocess2.kernel = value;
  41470. this._verticalBlurPostprocess2.kernel = value;
  41471. },
  41472. enumerable: true,
  41473. configurable: true
  41474. });
  41475. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41476. /**
  41477. * Gets the glow intensity.
  41478. */
  41479. get: function () {
  41480. return this._intensity;
  41481. },
  41482. /**
  41483. * Sets the glow intensity.
  41484. */
  41485. set: function (value) {
  41486. this._intensity = value;
  41487. },
  41488. enumerable: true,
  41489. configurable: true
  41490. });
  41491. /**
  41492. * Get the effect name of the layer.
  41493. * @return The effect name
  41494. */
  41495. GlowLayer.prototype.getEffectName = function () {
  41496. return GlowLayer.EffectName;
  41497. };
  41498. /**
  41499. * Create the merge effect. This is the shader use to blit the information back
  41500. * to the main canvas at the end of the scene rendering.
  41501. */
  41502. GlowLayer.prototype._createMergeEffect = function () {
  41503. // Effect
  41504. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41505. };
  41506. /**
  41507. * Creates the render target textures and post processes used in the glow layer.
  41508. */
  41509. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41510. var _this = this;
  41511. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41512. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41513. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41514. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41515. var textureType = 0;
  41516. if (this._engine.getCaps().textureHalfFloatRender) {
  41517. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41518. }
  41519. else {
  41520. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41521. }
  41522. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41523. width: blurTextureWidth,
  41524. height: blurTextureHeight
  41525. }, this._scene, false, true, textureType);
  41526. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41527. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41528. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41529. this._blurTexture1.renderParticles = false;
  41530. this._blurTexture1.ignoreCameraViewport = true;
  41531. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41532. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41533. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41534. width: blurTextureWidth2,
  41535. height: blurTextureHeight2
  41536. }, this._scene, false, true, textureType);
  41537. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41538. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41539. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41540. this._blurTexture2.renderParticles = false;
  41541. this._blurTexture2.ignoreCameraViewport = true;
  41542. this._textures = [this._blurTexture1, this._blurTexture2];
  41543. 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, {
  41544. width: blurTextureWidth,
  41545. height: blurTextureHeight
  41546. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41547. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41548. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41549. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41550. effect.setTexture("textureSampler", _this._mainTexture);
  41551. });
  41552. 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, {
  41553. width: blurTextureWidth,
  41554. height: blurTextureHeight
  41555. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41556. 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, {
  41557. width: blurTextureWidth2,
  41558. height: blurTextureHeight2
  41559. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41560. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41561. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41562. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41563. effect.setTexture("textureSampler", _this._blurTexture1);
  41564. });
  41565. 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, {
  41566. width: blurTextureWidth2,
  41567. height: blurTextureHeight2
  41568. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41569. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41570. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41571. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41572. this._mainTexture.samples = this._options.mainTextureSamples;
  41573. this._mainTexture.onAfterUnbindObservable.add(function () {
  41574. var internalTexture = _this._blurTexture1.getInternalTexture();
  41575. if (internalTexture) {
  41576. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41577. internalTexture = _this._blurTexture2.getInternalTexture();
  41578. if (internalTexture) {
  41579. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41580. }
  41581. }
  41582. });
  41583. // Prevent autoClear.
  41584. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41585. };
  41586. /**
  41587. * Checks for the readiness of the element composing the layer.
  41588. * @param subMesh the mesh to check for
  41589. * @param useInstances specify wether or not to use instances to render the mesh
  41590. * @param emissiveTexture the associated emissive texture used to generate the glow
  41591. * @return true if ready otherwise, false
  41592. */
  41593. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41594. var material = subMesh.getMaterial();
  41595. var mesh = subMesh.getRenderingMesh();
  41596. if (!material || !mesh) {
  41597. return false;
  41598. }
  41599. var emissiveTexture = material.emissiveTexture;
  41600. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41601. };
  41602. /**
  41603. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41604. */
  41605. GlowLayer.prototype.needStencil = function () {
  41606. return false;
  41607. };
  41608. /**
  41609. * Returns true if the mesh can be rendered, otherwise false.
  41610. * @param mesh The mesh to render
  41611. * @param material The material used on the mesh
  41612. * @returns true if it can be rendered otherwise false
  41613. */
  41614. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41615. return true;
  41616. };
  41617. /**
  41618. * Implementation specific of rendering the generating effect on the main canvas.
  41619. * @param effect The effect used to render through
  41620. */
  41621. GlowLayer.prototype._internalRender = function (effect) {
  41622. // Texture
  41623. effect.setTexture("textureSampler", this._blurTexture1);
  41624. effect.setTexture("textureSampler2", this._blurTexture2);
  41625. effect.setFloat("offset", this._intensity);
  41626. // Cache
  41627. var engine = this._engine;
  41628. var previousStencilBuffer = engine.getStencilBuffer();
  41629. // Draw order
  41630. engine.setStencilBuffer(false);
  41631. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41632. // Draw order
  41633. engine.setStencilBuffer(previousStencilBuffer);
  41634. };
  41635. /**
  41636. * Sets the required values for both the emissive texture and and the main color.
  41637. */
  41638. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41639. var textureLevel = 1.0;
  41640. if (this.customEmissiveTextureSelector) {
  41641. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41642. }
  41643. else {
  41644. if (material) {
  41645. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41646. if (this._emissiveTextureAndColor.texture) {
  41647. textureLevel = this._emissiveTextureAndColor.texture.level;
  41648. }
  41649. }
  41650. else {
  41651. this._emissiveTextureAndColor.texture = null;
  41652. }
  41653. }
  41654. if (this.customEmissiveColorSelector) {
  41655. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41656. }
  41657. else {
  41658. if (material.emissiveColor) {
  41659. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41660. }
  41661. else {
  41662. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41663. }
  41664. }
  41665. };
  41666. /**
  41667. * Returns true if the mesh should render, otherwise false.
  41668. * @param mesh The mesh to render
  41669. * @returns true if it should render otherwise false
  41670. */
  41671. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41672. return this.hasMesh(mesh);
  41673. };
  41674. /**
  41675. * Adds specific effects defines.
  41676. * @param defines The defines to add specifics to.
  41677. */
  41678. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41679. defines.push("#define GLOW");
  41680. };
  41681. /**
  41682. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41683. * @param mesh The mesh to exclude from the glow layer
  41684. */
  41685. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41686. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41687. this._excludedMeshes.push(mesh.uniqueId);
  41688. }
  41689. };
  41690. /**
  41691. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41692. * @param mesh The mesh to remove
  41693. */
  41694. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41695. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41696. if (index !== -1) {
  41697. this._excludedMeshes.splice(index, 1);
  41698. }
  41699. };
  41700. /**
  41701. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41702. * @param mesh The mesh to include in the glow layer
  41703. */
  41704. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41705. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41706. this._includedOnlyMeshes.push(mesh.uniqueId);
  41707. }
  41708. };
  41709. /**
  41710. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  41711. * @param mesh The mesh to remove
  41712. */
  41713. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  41714. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  41715. if (index !== -1) {
  41716. this._includedOnlyMeshes.splice(index, 1);
  41717. }
  41718. };
  41719. /**
  41720. * Determine if a given mesh will be used in the glow layer
  41721. * @param mesh The mesh to test
  41722. * @returns true if the mesh will be highlighted by the current glow layer
  41723. */
  41724. GlowLayer.prototype.hasMesh = function (mesh) {
  41725. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41726. return false;
  41727. }
  41728. // Included Mesh
  41729. if (this._includedOnlyMeshes.length) {
  41730. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  41731. }
  41732. // Excluded Mesh
  41733. if (this._excludedMeshes.length) {
  41734. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  41735. }
  41736. return true;
  41737. };
  41738. /**
  41739. * Free any resources and references associated to a mesh.
  41740. * Internal use
  41741. * @param mesh The mesh to free.
  41742. * @hidden
  41743. */
  41744. GlowLayer.prototype._disposeMesh = function (mesh) {
  41745. this.removeIncludedOnlyMesh(mesh);
  41746. this.removeExcludedMesh(mesh);
  41747. };
  41748. /**
  41749. * Gets the class name of the effect layer
  41750. * @returns the string with the class name of the effect layer
  41751. */
  41752. GlowLayer.prototype.getClassName = function () {
  41753. return "GlowLayer";
  41754. };
  41755. /**
  41756. * Serializes this glow layer
  41757. * @returns a serialized glow layer object
  41758. */
  41759. GlowLayer.prototype.serialize = function () {
  41760. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41761. serializationObject.customType = "BABYLON.GlowLayer";
  41762. var index;
  41763. // Included meshes
  41764. serializationObject.includedMeshes = [];
  41765. if (this._includedOnlyMeshes.length) {
  41766. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  41767. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  41768. if (mesh) {
  41769. serializationObject.includedMeshes.push(mesh.id);
  41770. }
  41771. }
  41772. }
  41773. // Excluded meshes
  41774. serializationObject.excludedMeshes = [];
  41775. if (this._excludedMeshes.length) {
  41776. for (index = 0; index < this._excludedMeshes.length; index++) {
  41777. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  41778. if (mesh) {
  41779. serializationObject.excludedMeshes.push(mesh.id);
  41780. }
  41781. }
  41782. }
  41783. return serializationObject;
  41784. };
  41785. /**
  41786. * Creates a Glow Layer from parsed glow layer data
  41787. * @param parsedGlowLayer defines glow layer data
  41788. * @param scene defines the current scene
  41789. * @param rootUrl defines the root URL containing the glow layer information
  41790. * @returns a parsed Glow Layer
  41791. */
  41792. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  41793. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  41794. var index;
  41795. // Excluded meshes
  41796. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  41797. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  41798. if (mesh) {
  41799. gl.addExcludedMesh(mesh);
  41800. }
  41801. }
  41802. // Included meshes
  41803. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  41804. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  41805. if (mesh) {
  41806. gl.addIncludedOnlyMesh(mesh);
  41807. }
  41808. }
  41809. return gl;
  41810. };
  41811. /**
  41812. * Effect Name of the layer.
  41813. */
  41814. GlowLayer.EffectName = "GlowLayer";
  41815. /**
  41816. * The default blur kernel size used for the glow.
  41817. */
  41818. GlowLayer.DefaultBlurKernelSize = 32;
  41819. /**
  41820. * The default texture size ratio used for the glow.
  41821. */
  41822. GlowLayer.DefaultTextureRatio = 0.5;
  41823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41825. ], GlowLayer.prototype, "blurKernelSize", null);
  41826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41828. ], GlowLayer.prototype, "intensity", null);
  41829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41831. ], GlowLayer.prototype, "_options", void 0);
  41832. return GlowLayer;
  41833. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  41834. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  41835. /***/ }),
  41836. /***/ "./Layers/highlightLayer.ts":
  41837. /*!**********************************!*\
  41838. !*** ./Layers/highlightLayer.ts ***!
  41839. \**********************************/
  41840. /*! exports provided: HighlightLayer */
  41841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41842. "use strict";
  41843. __webpack_require__.r(__webpack_exports__);
  41844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  41845. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41846. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41847. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41848. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41849. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41850. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41851. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41852. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41853. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41854. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  41855. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  41856. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41857. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41858. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41859. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41860. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  41861. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41862. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41863. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41864. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  41865. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  41866. for (var index = 0; index < this.effectLayers.length; index++) {
  41867. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  41868. return this.effectLayers[index];
  41869. }
  41870. }
  41871. return null;
  41872. };
  41873. /**
  41874. * Special Glow Blur post process only blurring the alpha channel
  41875. * It enforces keeping the most luminous color in the color channel.
  41876. */
  41877. var GlowBlurPostProcess = /** @class */ (function (_super) {
  41878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  41879. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  41880. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  41881. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  41882. _this.direction = direction;
  41883. _this.kernel = kernel;
  41884. _this.onApplyObservable.add(function (effect) {
  41885. effect.setFloat2("screenSize", _this.width, _this.height);
  41886. effect.setVector2("direction", _this.direction);
  41887. effect.setFloat("blurWidth", _this.kernel);
  41888. });
  41889. return _this;
  41890. }
  41891. return GlowBlurPostProcess;
  41892. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  41893. /**
  41894. * The highlight layer Helps adding a glow effect around a mesh.
  41895. *
  41896. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41897. * glowy meshes to your scene.
  41898. *
  41899. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  41900. */
  41901. var HighlightLayer = /** @class */ (function (_super) {
  41902. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  41903. /**
  41904. * Instantiates a new highlight Layer and references it to the scene..
  41905. * @param name The name of the layer
  41906. * @param scene The scene to use the layer in
  41907. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  41908. */
  41909. function HighlightLayer(name, scene, options) {
  41910. var _this = _super.call(this, name, scene) || this;
  41911. _this.name = name;
  41912. /**
  41913. * Specifies whether or not the inner glow is ACTIVE in the layer.
  41914. */
  41915. _this.innerGlow = true;
  41916. /**
  41917. * Specifies whether or not the outer glow is ACTIVE in the layer.
  41918. */
  41919. _this.outerGlow = true;
  41920. /**
  41921. * An event triggered when the highlight layer is being blurred.
  41922. */
  41923. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41924. /**
  41925. * An event triggered when the highlight layer has been blurred.
  41926. */
  41927. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41928. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  41929. _this._meshes = {};
  41930. _this._excludedMeshes = {};
  41931. _this.neutralColor = HighlightLayer.NeutralColor;
  41932. // Warn on stencil
  41933. if (!_this._engine.isStencilEnable) {
  41934. _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 }");
  41935. }
  41936. // Adapt options
  41937. _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);
  41938. // Initialize the layer
  41939. _this._init({
  41940. alphaBlendingMode: _this._options.alphaBlendingMode,
  41941. camera: _this._options.camera,
  41942. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41943. mainTextureRatio: _this._options.mainTextureRatio,
  41944. renderingGroupId: _this._options.renderingGroupId
  41945. });
  41946. // Do not render as long as no meshes have been added
  41947. _this._shouldRender = false;
  41948. return _this;
  41949. }
  41950. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  41951. /**
  41952. * Gets the horizontal size of the blur.
  41953. */
  41954. get: function () {
  41955. return this._horizontalBlurPostprocess.kernel;
  41956. },
  41957. /**
  41958. * Specifies the horizontal size of the blur.
  41959. */
  41960. set: function (value) {
  41961. this._horizontalBlurPostprocess.kernel = value;
  41962. },
  41963. enumerable: true,
  41964. configurable: true
  41965. });
  41966. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  41967. /**
  41968. * Gets the vertical size of the blur.
  41969. */
  41970. get: function () {
  41971. return this._verticalBlurPostprocess.kernel;
  41972. },
  41973. /**
  41974. * Specifies the vertical size of the blur.
  41975. */
  41976. set: function (value) {
  41977. this._verticalBlurPostprocess.kernel = value;
  41978. },
  41979. enumerable: true,
  41980. configurable: true
  41981. });
  41982. /**
  41983. * Get the effect name of the layer.
  41984. * @return The effect name
  41985. */
  41986. HighlightLayer.prototype.getEffectName = function () {
  41987. return HighlightLayer.EffectName;
  41988. };
  41989. /**
  41990. * Create the merge effect. This is the shader use to blit the information back
  41991. * to the main canvas at the end of the scene rendering.
  41992. */
  41993. HighlightLayer.prototype._createMergeEffect = function () {
  41994. // Effect
  41995. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  41996. };
  41997. /**
  41998. * Creates the render target textures and post processes used in the highlight layer.
  41999. */
  42000. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42001. var _this = this;
  42002. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42003. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42004. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42005. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42006. var textureType = 0;
  42007. if (this._engine.getCaps().textureHalfFloatRender) {
  42008. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42009. }
  42010. else {
  42011. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42012. }
  42013. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42014. width: blurTextureWidth,
  42015. height: blurTextureHeight
  42016. }, this._scene, false, true, textureType);
  42017. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42018. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42019. this._blurTexture.anisotropicFilteringLevel = 16;
  42020. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42021. this._blurTexture.renderParticles = false;
  42022. this._blurTexture.ignoreCameraViewport = true;
  42023. this._textures = [this._blurTexture];
  42024. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42025. 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());
  42026. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42027. effect.setTexture("textureSampler", _this._mainTexture);
  42028. });
  42029. 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());
  42030. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42031. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42032. });
  42033. 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());
  42034. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42035. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42036. });
  42037. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42038. }
  42039. else {
  42040. 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, {
  42041. width: blurTextureWidth,
  42042. height: blurTextureHeight
  42043. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42044. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42045. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42046. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42047. effect.setTexture("textureSampler", _this._mainTexture);
  42048. });
  42049. 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, {
  42050. width: blurTextureWidth,
  42051. height: blurTextureHeight
  42052. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42053. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42054. }
  42055. this._mainTexture.onAfterUnbindObservable.add(function () {
  42056. _this.onBeforeBlurObservable.notifyObservers(_this);
  42057. var internalTexture = _this._blurTexture.getInternalTexture();
  42058. if (internalTexture) {
  42059. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42060. }
  42061. _this.onAfterBlurObservable.notifyObservers(_this);
  42062. });
  42063. // Prevent autoClear.
  42064. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42065. };
  42066. /**
  42067. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42068. */
  42069. HighlightLayer.prototype.needStencil = function () {
  42070. return true;
  42071. };
  42072. /**
  42073. * Checks for the readiness of the element composing the layer.
  42074. * @param subMesh the mesh to check for
  42075. * @param useInstances specify wether or not to use instances to render the mesh
  42076. * @param emissiveTexture the associated emissive texture used to generate the glow
  42077. * @return true if ready otherwise, false
  42078. */
  42079. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42080. var material = subMesh.getMaterial();
  42081. var mesh = subMesh.getRenderingMesh();
  42082. if (!material || !mesh || !this._meshes) {
  42083. return false;
  42084. }
  42085. var emissiveTexture = null;
  42086. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42087. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42088. emissiveTexture = material.emissiveTexture;
  42089. }
  42090. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42091. };
  42092. /**
  42093. * Implementation specific of rendering the generating effect on the main canvas.
  42094. * @param effect The effect used to render through
  42095. */
  42096. HighlightLayer.prototype._internalRender = function (effect) {
  42097. // Texture
  42098. effect.setTexture("textureSampler", this._blurTexture);
  42099. // Cache
  42100. var engine = this._engine;
  42101. var previousStencilBuffer = engine.getStencilBuffer();
  42102. var previousStencilFunction = engine.getStencilFunction();
  42103. var previousStencilMask = engine.getStencilMask();
  42104. var previousStencilOperationPass = engine.getStencilOperationPass();
  42105. var previousStencilOperationFail = engine.getStencilOperationFail();
  42106. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42107. var previousStencilReference = engine.getStencilFunctionReference();
  42108. // Stencil operations
  42109. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42110. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42111. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42112. // Draw order
  42113. engine.setStencilMask(0x00);
  42114. engine.setStencilBuffer(true);
  42115. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42116. // 2 passes inner outer
  42117. if (this.outerGlow) {
  42118. effect.setFloat("offset", 0);
  42119. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42120. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42121. }
  42122. if (this.innerGlow) {
  42123. effect.setFloat("offset", 1);
  42124. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42125. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42126. }
  42127. // Restore Cache
  42128. engine.setStencilFunction(previousStencilFunction);
  42129. engine.setStencilMask(previousStencilMask);
  42130. engine.setStencilBuffer(previousStencilBuffer);
  42131. engine.setStencilOperationPass(previousStencilOperationPass);
  42132. engine.setStencilOperationFail(previousStencilOperationFail);
  42133. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42134. engine.setStencilFunctionReference(previousStencilReference);
  42135. };
  42136. /**
  42137. * Returns true if the layer contains information to display, otherwise false.
  42138. */
  42139. HighlightLayer.prototype.shouldRender = function () {
  42140. if (_super.prototype.shouldRender.call(this)) {
  42141. return this._meshes ? true : false;
  42142. }
  42143. return false;
  42144. };
  42145. /**
  42146. * Returns true if the mesh should render, otherwise false.
  42147. * @param mesh The mesh to render
  42148. * @returns true if it should render otherwise false
  42149. */
  42150. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  42151. // Excluded Mesh
  42152. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  42153. return false;
  42154. }
  42155. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42156. return false;
  42157. }
  42158. return true;
  42159. };
  42160. /**
  42161. * Sets the required values for both the emissive texture and and the main color.
  42162. */
  42163. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42164. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42165. if (highlightLayerMesh) {
  42166. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  42167. }
  42168. else {
  42169. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42170. }
  42171. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42172. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42173. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  42174. }
  42175. else {
  42176. this._emissiveTextureAndColor.texture = null;
  42177. }
  42178. };
  42179. /**
  42180. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  42181. * @param mesh The mesh to exclude from the highlight layer
  42182. */
  42183. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  42184. if (!this._excludedMeshes) {
  42185. return;
  42186. }
  42187. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42188. if (!meshExcluded) {
  42189. this._excludedMeshes[mesh.uniqueId] = {
  42190. mesh: mesh,
  42191. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  42192. mesh.getEngine().setStencilBuffer(false);
  42193. }),
  42194. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  42195. mesh.getEngine().setStencilBuffer(true);
  42196. }),
  42197. };
  42198. }
  42199. };
  42200. /**
  42201. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  42202. * @param mesh The mesh to highlight
  42203. */
  42204. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  42205. if (!this._excludedMeshes) {
  42206. return;
  42207. }
  42208. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42209. if (meshExcluded) {
  42210. if (meshExcluded.beforeBind) {
  42211. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  42212. }
  42213. if (meshExcluded.afterRender) {
  42214. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  42215. }
  42216. }
  42217. this._excludedMeshes[mesh.uniqueId] = null;
  42218. };
  42219. /**
  42220. * Determine if a given mesh will be highlighted by the current HighlightLayer
  42221. * @param mesh mesh to test
  42222. * @returns true if the mesh will be highlighted by the current HighlightLayer
  42223. */
  42224. HighlightLayer.prototype.hasMesh = function (mesh) {
  42225. if (!this._meshes) {
  42226. return false;
  42227. }
  42228. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42229. return false;
  42230. }
  42231. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  42232. };
  42233. /**
  42234. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  42235. * @param mesh The mesh to highlight
  42236. * @param color The color of the highlight
  42237. * @param glowEmissiveOnly Extract the glow from the emissive texture
  42238. */
  42239. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  42240. var _this = this;
  42241. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  42242. if (!this._meshes) {
  42243. return;
  42244. }
  42245. var meshHighlight = this._meshes[mesh.uniqueId];
  42246. if (meshHighlight) {
  42247. meshHighlight.color = color;
  42248. }
  42249. else {
  42250. this._meshes[mesh.uniqueId] = {
  42251. mesh: mesh,
  42252. color: color,
  42253. // Lambda required for capture due to Observable this context
  42254. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  42255. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  42256. _this._defaultStencilReference(mesh);
  42257. }
  42258. else {
  42259. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  42260. }
  42261. }),
  42262. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  42263. glowEmissiveOnly: glowEmissiveOnly
  42264. };
  42265. mesh.onDisposeObservable.add(function () {
  42266. _this._disposeMesh(mesh);
  42267. });
  42268. }
  42269. this._shouldRender = true;
  42270. };
  42271. /**
  42272. * Remove a mesh from the highlight layer in order to make it stop glowing.
  42273. * @param mesh The mesh to highlight
  42274. */
  42275. HighlightLayer.prototype.removeMesh = function (mesh) {
  42276. if (!this._meshes) {
  42277. return;
  42278. }
  42279. var meshHighlight = this._meshes[mesh.uniqueId];
  42280. if (meshHighlight) {
  42281. if (meshHighlight.observerHighlight) {
  42282. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42283. }
  42284. if (meshHighlight.observerDefault) {
  42285. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42286. }
  42287. delete this._meshes[mesh.uniqueId];
  42288. }
  42289. this._shouldRender = false;
  42290. for (var meshHighlightToCheck in this._meshes) {
  42291. if (this._meshes[meshHighlightToCheck]) {
  42292. this._shouldRender = true;
  42293. break;
  42294. }
  42295. }
  42296. };
  42297. /**
  42298. * Force the stencil to the normal expected value for none glowing parts
  42299. */
  42300. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  42301. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  42302. };
  42303. /**
  42304. * Free any resources and references associated to a mesh.
  42305. * Internal use
  42306. * @param mesh The mesh to free.
  42307. * @hidden
  42308. */
  42309. HighlightLayer.prototype._disposeMesh = function (mesh) {
  42310. this.removeMesh(mesh);
  42311. this.removeExcludedMesh(mesh);
  42312. };
  42313. /**
  42314. * Dispose the highlight layer and free resources.
  42315. */
  42316. HighlightLayer.prototype.dispose = function () {
  42317. if (this._meshes) {
  42318. // Clean mesh references
  42319. for (var id in this._meshes) {
  42320. var meshHighlight = this._meshes[id];
  42321. if (meshHighlight && meshHighlight.mesh) {
  42322. if (meshHighlight.observerHighlight) {
  42323. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42324. }
  42325. if (meshHighlight.observerDefault) {
  42326. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42327. }
  42328. }
  42329. }
  42330. this._meshes = null;
  42331. }
  42332. if (this._excludedMeshes) {
  42333. for (var id in this._excludedMeshes) {
  42334. var meshHighlight = this._excludedMeshes[id];
  42335. if (meshHighlight) {
  42336. if (meshHighlight.beforeBind) {
  42337. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  42338. }
  42339. if (meshHighlight.afterRender) {
  42340. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  42341. }
  42342. }
  42343. }
  42344. this._excludedMeshes = null;
  42345. }
  42346. _super.prototype.dispose.call(this);
  42347. };
  42348. /**
  42349. * Gets the class name of the effect layer
  42350. * @returns the string with the class name of the effect layer
  42351. */
  42352. HighlightLayer.prototype.getClassName = function () {
  42353. return "HighlightLayer";
  42354. };
  42355. /**
  42356. * Serializes this Highlight layer
  42357. * @returns a serialized Highlight layer object
  42358. */
  42359. HighlightLayer.prototype.serialize = function () {
  42360. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42361. serializationObject.customType = "BABYLON.HighlightLayer";
  42362. // Highlighted meshes
  42363. serializationObject.meshes = [];
  42364. if (this._meshes) {
  42365. for (var m in this._meshes) {
  42366. var mesh = this._meshes[m];
  42367. if (mesh) {
  42368. serializationObject.meshes.push({
  42369. glowEmissiveOnly: mesh.glowEmissiveOnly,
  42370. color: mesh.color.asArray(),
  42371. meshId: mesh.mesh.id
  42372. });
  42373. }
  42374. }
  42375. }
  42376. // Excluded meshes
  42377. serializationObject.excludedMeshes = [];
  42378. if (this._excludedMeshes) {
  42379. for (var e in this._excludedMeshes) {
  42380. var excludedMesh = this._excludedMeshes[e];
  42381. if (excludedMesh) {
  42382. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  42383. }
  42384. }
  42385. }
  42386. return serializationObject;
  42387. };
  42388. /**
  42389. * Creates a Highlight layer from parsed Highlight layer data
  42390. * @param parsedHightlightLayer defines the Highlight layer data
  42391. * @param scene defines the current scene
  42392. * @param rootUrl defines the root URL containing the Highlight layer information
  42393. * @returns a parsed Highlight layer
  42394. */
  42395. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  42396. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  42397. var index;
  42398. // Excluded meshes
  42399. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  42400. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  42401. if (mesh) {
  42402. hl.addExcludedMesh(mesh);
  42403. }
  42404. }
  42405. // Included meshes
  42406. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  42407. var highlightedMesh = parsedHightlightLayer.meshes[index];
  42408. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  42409. if (mesh) {
  42410. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  42411. }
  42412. }
  42413. return hl;
  42414. };
  42415. /**
  42416. * Effect Name of the highlight layer.
  42417. */
  42418. HighlightLayer.EffectName = "HighlightLayer";
  42419. /**
  42420. * The neutral color used during the preparation of the glow effect.
  42421. * This is black by default as the blend operation is a blend operation.
  42422. */
  42423. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  42424. /**
  42425. * Stencil value used for glowing meshes.
  42426. */
  42427. HighlightLayer.GlowingMeshStencilReference = 0x02;
  42428. /**
  42429. * Stencil value used for the other meshes in the scene.
  42430. */
  42431. HighlightLayer.NormalMeshStencilReference = 0x01;
  42432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42434. ], HighlightLayer.prototype, "innerGlow", void 0);
  42435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42437. ], HighlightLayer.prototype, "outerGlow", void 0);
  42438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42440. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  42441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42443. ], HighlightLayer.prototype, "blurVerticalSize", null);
  42444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42446. ], HighlightLayer.prototype, "_options", void 0);
  42447. return HighlightLayer;
  42448. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  42449. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  42450. /***/ }),
  42451. /***/ "./Layers/index.ts":
  42452. /*!*************************!*\
  42453. !*** ./Layers/index.ts ***!
  42454. \*************************/
  42455. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  42456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42457. "use strict";
  42458. __webpack_require__.r(__webpack_exports__);
  42459. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42461. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42463. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42465. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42467. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42469. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42471. /***/ }),
  42472. /***/ "./Layers/layer.ts":
  42473. /*!*************************!*\
  42474. !*** ./Layers/layer.ts ***!
  42475. \*************************/
  42476. /*! exports provided: Layer */
  42477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42478. "use strict";
  42479. __webpack_require__.r(__webpack_exports__);
  42480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42481. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42483. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42484. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42485. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42486. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42487. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42488. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42489. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42490. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42491. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42492. /**
  42493. * This represents a full screen 2d layer.
  42494. * This can be useful to display a picture in the background of your scene for instance.
  42495. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42496. */
  42497. var Layer = /** @class */ (function () {
  42498. /**
  42499. * Instantiates a new layer.
  42500. * This represents a full screen 2d layer.
  42501. * This can be useful to display a picture in the background of your scene for instance.
  42502. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42503. * @param name Define the name of the layer in the scene
  42504. * @param imgUrl Define the url of the texture to display in the layer
  42505. * @param scene Define the scene the layer belongs to
  42506. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42507. * @param color Defines a color for the layer
  42508. */
  42509. function Layer(
  42510. /**
  42511. * Define the name of the layer.
  42512. */
  42513. name, imgUrl, scene, isBackground, color) {
  42514. this.name = name;
  42515. /**
  42516. * Define the scale of the layer in order to zoom in out of the texture.
  42517. */
  42518. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42519. /**
  42520. * Define an offset for the layer in order to shift the texture.
  42521. */
  42522. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42523. /**
  42524. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42525. */
  42526. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42527. /**
  42528. * Define a mask to restrict the layer to only some of the scene cameras.
  42529. */
  42530. this.layerMask = 0x0FFFFFFF;
  42531. /**
  42532. * Define the list of render target the layer is visible into.
  42533. */
  42534. this.renderTargetTextures = [];
  42535. /**
  42536. * Define if the layer is only used in renderTarget or if it also
  42537. * renders in the main frame buffer of the canvas.
  42538. */
  42539. this.renderOnlyInRenderTargetTextures = false;
  42540. this._vertexBuffers = {};
  42541. /**
  42542. * An event triggered when the layer is disposed.
  42543. */
  42544. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42545. /**
  42546. * An event triggered before rendering the scene
  42547. */
  42548. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42549. /**
  42550. * An event triggered after rendering the scene
  42551. */
  42552. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42553. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42554. this.isBackground = isBackground === undefined ? true : isBackground;
  42555. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42556. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42557. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42558. if (!layerComponent) {
  42559. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42560. this._scene._addComponent(layerComponent);
  42561. }
  42562. this._scene.layers.push(this);
  42563. var engine = this._scene.getEngine();
  42564. // VBO
  42565. var vertices = [];
  42566. vertices.push(1, 1);
  42567. vertices.push(-1, 1);
  42568. vertices.push(-1, -1);
  42569. vertices.push(1, -1);
  42570. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42571. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42572. this._createIndexBuffer();
  42573. // Effects
  42574. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42575. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42576. }
  42577. Object.defineProperty(Layer.prototype, "onDispose", {
  42578. /**
  42579. * Back compatibility with callback before the onDisposeObservable existed.
  42580. * The set callback will be triggered when the layer has been disposed.
  42581. */
  42582. set: function (callback) {
  42583. if (this._onDisposeObserver) {
  42584. this.onDisposeObservable.remove(this._onDisposeObserver);
  42585. }
  42586. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42587. },
  42588. enumerable: true,
  42589. configurable: true
  42590. });
  42591. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42592. /**
  42593. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42594. * The set callback will be triggered just before rendering the layer.
  42595. */
  42596. set: function (callback) {
  42597. if (this._onBeforeRenderObserver) {
  42598. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42599. }
  42600. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42601. },
  42602. enumerable: true,
  42603. configurable: true
  42604. });
  42605. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42606. /**
  42607. * Back compatibility with callback before the onAfterRenderObservable existed.
  42608. * The set callback will be triggered just after rendering the layer.
  42609. */
  42610. set: function (callback) {
  42611. if (this._onAfterRenderObserver) {
  42612. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42613. }
  42614. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42615. },
  42616. enumerable: true,
  42617. configurable: true
  42618. });
  42619. Layer.prototype._createIndexBuffer = function () {
  42620. var engine = this._scene.getEngine();
  42621. // Indices
  42622. var indices = [];
  42623. indices.push(0);
  42624. indices.push(1);
  42625. indices.push(2);
  42626. indices.push(0);
  42627. indices.push(2);
  42628. indices.push(3);
  42629. this._indexBuffer = engine.createIndexBuffer(indices);
  42630. };
  42631. /** @hidden */
  42632. Layer.prototype._rebuild = function () {
  42633. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42634. if (vb) {
  42635. vb._rebuild();
  42636. }
  42637. this._createIndexBuffer();
  42638. };
  42639. /**
  42640. * Renders the layer in the scene.
  42641. */
  42642. Layer.prototype.render = function () {
  42643. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42644. // Check
  42645. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42646. return;
  42647. }
  42648. var engine = this._scene.getEngine();
  42649. this.onBeforeRenderObservable.notifyObservers(this);
  42650. // Render
  42651. engine.enableEffect(currentEffect);
  42652. engine.setState(false);
  42653. // Texture
  42654. currentEffect.setTexture("textureSampler", this.texture);
  42655. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42656. // Color
  42657. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42658. // Scale / offset
  42659. currentEffect.setVector2("offset", this.offset);
  42660. currentEffect.setVector2("scale", this.scale);
  42661. // VBOs
  42662. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42663. // Draw order
  42664. if (!this.alphaTest) {
  42665. engine.setAlphaMode(this.alphaBlendingMode);
  42666. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42667. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42668. }
  42669. else {
  42670. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42671. }
  42672. this.onAfterRenderObservable.notifyObservers(this);
  42673. };
  42674. /**
  42675. * Disposes and releases the associated ressources.
  42676. */
  42677. Layer.prototype.dispose = function () {
  42678. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42679. if (vertexBuffer) {
  42680. vertexBuffer.dispose();
  42681. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42682. }
  42683. if (this._indexBuffer) {
  42684. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42685. this._indexBuffer = null;
  42686. }
  42687. if (this.texture) {
  42688. this.texture.dispose();
  42689. this.texture = null;
  42690. }
  42691. // Clean RTT list
  42692. this.renderTargetTextures = [];
  42693. // Remove from scene
  42694. var index = this._scene.layers.indexOf(this);
  42695. this._scene.layers.splice(index, 1);
  42696. // Callback
  42697. this.onDisposeObservable.notifyObservers(this);
  42698. this.onDisposeObservable.clear();
  42699. this.onAfterRenderObservable.clear();
  42700. this.onBeforeRenderObservable.clear();
  42701. };
  42702. return Layer;
  42703. }());
  42704. /***/ }),
  42705. /***/ "./Layers/layerSceneComponent.ts":
  42706. /*!***************************************!*\
  42707. !*** ./Layers/layerSceneComponent.ts ***!
  42708. \***************************************/
  42709. /*! exports provided: LayerSceneComponent */
  42710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42711. "use strict";
  42712. __webpack_require__.r(__webpack_exports__);
  42713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  42714. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42715. /**
  42716. * Defines the layer scene component responsible to manage any layers
  42717. * in a given scene.
  42718. */
  42719. var LayerSceneComponent = /** @class */ (function () {
  42720. /**
  42721. * Creates a new instance of the component for the given scene
  42722. * @param scene Defines the scene to register the component in
  42723. */
  42724. function LayerSceneComponent(scene) {
  42725. /**
  42726. * The component name helpfull to identify the component in the list of scene components.
  42727. */
  42728. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  42729. this.scene = scene;
  42730. this._engine = scene.getEngine();
  42731. scene.layers = new Array();
  42732. }
  42733. /**
  42734. * Registers the component in a given scene
  42735. */
  42736. LayerSceneComponent.prototype.register = function () {
  42737. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  42738. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  42739. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  42740. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  42741. };
  42742. /**
  42743. * Rebuilds the elements related to this component in case of
  42744. * context lost for instance.
  42745. */
  42746. LayerSceneComponent.prototype.rebuild = function () {
  42747. var layers = this.scene.layers;
  42748. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42749. var layer = layers_1[_i];
  42750. layer._rebuild();
  42751. }
  42752. };
  42753. /**
  42754. * Disposes the component and the associated ressources.
  42755. */
  42756. LayerSceneComponent.prototype.dispose = function () {
  42757. var layers = this.scene.layers;
  42758. while (layers.length) {
  42759. layers[0].dispose();
  42760. }
  42761. };
  42762. LayerSceneComponent.prototype._draw = function (predicate) {
  42763. var layers = this.scene.layers;
  42764. if (layers.length) {
  42765. this._engine.setDepthBuffer(false);
  42766. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42767. var layer = layers_2[_i];
  42768. if (predicate(layer)) {
  42769. layer.render();
  42770. }
  42771. }
  42772. this._engine.setDepthBuffer(true);
  42773. }
  42774. };
  42775. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  42776. return !layer.renderOnlyInRenderTargetTextures &&
  42777. layer.isBackground === isBackground &&
  42778. ((layer.layerMask & cameraLayerMask) !== 0);
  42779. };
  42780. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  42781. var _this = this;
  42782. this._draw(function (layer) {
  42783. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  42784. });
  42785. };
  42786. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  42787. var _this = this;
  42788. this._draw(function (layer) {
  42789. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  42790. });
  42791. };
  42792. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  42793. return (layer.renderTargetTextures.length > 0) &&
  42794. layer.isBackground === isBackground &&
  42795. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  42796. ((layer.layerMask & cameraLayerMask) !== 0);
  42797. };
  42798. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  42799. var _this = this;
  42800. this._draw(function (layer) {
  42801. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  42802. });
  42803. };
  42804. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  42805. var _this = this;
  42806. this._draw(function (layer) {
  42807. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  42808. });
  42809. };
  42810. return LayerSceneComponent;
  42811. }());
  42812. /***/ }),
  42813. /***/ "./Legacy/legacy.ts":
  42814. /*!**************************!*\
  42815. !*** ./Legacy/legacy.ts ***!
  42816. \**************************/
  42817. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, 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, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, 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, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, 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, 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, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, 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, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, MultiRenderTarget, ProceduralTexture, ProceduralTextureSceneComponent, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, RibbonBuilder, 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, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  42818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42819. "use strict";
  42820. __webpack_require__.r(__webpack_exports__);
  42821. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  42822. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  42823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  42824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  42825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  42826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  42827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  42828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  42829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  42830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  42831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  42832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  42833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  42834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  42835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  42836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  42837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  42838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  42839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  42840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  42841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  42842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  42843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  42844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  42845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  42846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  42847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  42848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  42849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  42850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  42851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  42852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  42853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  42854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  42855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  42856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  42857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  42858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  42859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  42860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  42861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  42862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  42863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  42864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  42865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  42866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  42867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  42868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  42869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  42870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  42871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  42872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  42873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  42874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  42875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  42876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  42877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  42878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  42879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  42880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  42881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  42882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  42883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  42884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  42885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  42886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  42887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  42888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  42889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  42890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  42891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  42892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  42893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  42894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  42895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  42896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  42897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  42898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  42899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  42900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  42901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  42902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  42903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  42904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  42905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  42906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  42907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  42908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  42909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  42910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  42911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  42912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  42913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  42914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  42915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  42916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  42917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  42918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  42919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  42920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  42921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  42922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  42923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  42924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  42925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  42926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  42927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  42928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  42929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  42930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  42931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  42932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  42933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  42934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  42935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  42936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  42937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  42938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  42939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  42940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  42941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  42942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  42943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  42944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  42945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  42946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  42947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  42948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  42949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  42950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  42951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  42952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  42953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  42954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  42955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  42956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  42957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  42958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  42959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  42960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  42961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  42962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  42963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  42964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  42966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  42967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  42968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  42969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  42970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  42972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  42973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  42974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  42975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  42976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  42977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  42978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  42979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  42980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  42981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  42982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  42983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  42984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  42985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  42986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  42987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  42988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  42989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  42990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  42991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  42992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  42993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  42994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  42995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  42996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  42997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  42998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  42999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  43064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  43154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  43155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  43156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  43157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  43158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  43159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  43160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  43161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  43162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  43163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  43164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  43165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  43166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  43167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  43168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  43169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  43170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  43171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  43172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  43173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  43174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  43175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  43176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  43177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  43178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  43179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  43180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  43181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  43182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  43183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  43184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  43185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  43186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  43187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  43188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  43189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  43190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  43191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  43192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  43193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  43194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  43195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  43196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  43197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  43198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  43199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  43200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  43201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  43202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  43203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  43204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  43205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  43206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  43207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  43208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  43209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  43210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  43211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  43212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  43213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  43214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  43215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  43216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  43217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  43218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  43219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  43220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  43221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  43222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  43223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  43224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  43225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  43226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  43227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  43228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  43233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  43236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  43237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  43238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  43239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  43240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  43241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  43242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  43243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  43244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  43245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  43246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  43247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  43248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  43249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  43250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  43251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  43252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  43253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  43254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  43255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  43256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  43257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  43258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  43259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  43260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  43261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  43262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  43263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  43264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  43265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  43266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  43267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  43268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  43269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  43270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  43271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  43272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  43273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  43274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  43275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  43276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  43277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  43278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  43280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  43281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  43282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  43284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  43286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  43287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  43288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  43291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  43292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  43293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  43294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  43295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  43297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  43298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  43300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  43301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  43302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  43303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  43305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  43306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  43307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  43308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  43309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  43310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  43311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  43312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  43314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  43316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  43318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  43320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  43322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  43324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  43325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  43326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  43327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  43328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  43329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  43330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  43331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  43332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  43333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  43335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  43337. /**
  43338. * Legacy support, defining window.BABYLON (global variable).
  43339. *
  43340. * This is the entry point for the UMD module.
  43341. * The entry point for a future ESM package should be index.ts
  43342. */
  43343. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  43344. if (typeof globalObject !== "undefined") {
  43345. globalObject.BABYLON = BABYLON;
  43346. globalObject.BABYLON = globalObject.BABYLON || {};
  43347. var BABYLON = globalObject.BABYLON;
  43348. BABYLON.Debug = BABYLON.Debug || {};
  43349. var keys = [];
  43350. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  43351. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  43352. keys.push(key);
  43353. }
  43354. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  43355. // Prevent Reassignment.
  43356. if (keys.indexOf(key) > -1) {
  43357. continue;
  43358. }
  43359. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  43360. }
  43361. }
  43362. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  43363. /***/ }),
  43364. /***/ "./LensFlares/index.ts":
  43365. /*!*****************************!*\
  43366. !*** ./LensFlares/index.ts ***!
  43367. \*****************************/
  43368. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  43369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43370. "use strict";
  43371. __webpack_require__.r(__webpack_exports__);
  43372. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43374. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  43376. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  43377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  43378. /***/ }),
  43379. /***/ "./LensFlares/lensFlare.ts":
  43380. /*!*********************************!*\
  43381. !*** ./LensFlares/lensFlare.ts ***!
  43382. \*********************************/
  43383. /*! exports provided: LensFlare */
  43384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43385. "use strict";
  43386. __webpack_require__.r(__webpack_exports__);
  43387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  43388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43389. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43390. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43391. /**
  43392. * This represents one of the lens effect in a `lensFlareSystem`.
  43393. * It controls one of the indiviual texture used in the effect.
  43394. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43395. */
  43396. var LensFlare = /** @class */ (function () {
  43397. /**
  43398. * Instantiates a new Lens Flare.
  43399. * This represents one of the lens effect in a `lensFlareSystem`.
  43400. * It controls one of the indiviual texture used in the effect.
  43401. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43402. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43403. * @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.
  43404. * @param color Define the lens color
  43405. * @param imgUrl Define the lens texture url
  43406. * @param system Define the `lensFlareSystem` this flare is part of
  43407. */
  43408. function LensFlare(
  43409. /**
  43410. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43411. */
  43412. size,
  43413. /**
  43414. * 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.
  43415. */
  43416. position, color, imgUrl, system) {
  43417. this.size = size;
  43418. this.position = position;
  43419. /**
  43420. * Define the alpha mode to render this particular lens.
  43421. */
  43422. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  43423. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  43424. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  43425. this._system = system;
  43426. system.lensFlares.push(this);
  43427. }
  43428. /**
  43429. * Creates a new Lens Flare.
  43430. * This represents one of the lens effect in a `lensFlareSystem`.
  43431. * It controls one of the indiviual texture used in the effect.
  43432. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43433. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43434. * @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.
  43435. * @param color Define the lens color
  43436. * @param imgUrl Define the lens texture url
  43437. * @param system Define the `lensFlareSystem` this flare is part of
  43438. * @returns The newly created Lens Flare
  43439. */
  43440. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  43441. return new LensFlare(size, position, color, imgUrl, system);
  43442. };
  43443. /**
  43444. * Dispose and release the lens flare with its associated resources.
  43445. */
  43446. LensFlare.prototype.dispose = function () {
  43447. if (this.texture) {
  43448. this.texture.dispose();
  43449. }
  43450. // Remove from scene
  43451. var index = this._system.lensFlares.indexOf(this);
  43452. this._system.lensFlares.splice(index, 1);
  43453. };
  43454. return LensFlare;
  43455. }());
  43456. /***/ }),
  43457. /***/ "./LensFlares/lensFlareSystem.ts":
  43458. /*!***************************************!*\
  43459. !*** ./LensFlares/lensFlareSystem.ts ***!
  43460. \***************************************/
  43461. /*! exports provided: LensFlareSystem */
  43462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43463. "use strict";
  43464. __webpack_require__.r(__webpack_exports__);
  43465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  43466. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43468. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43469. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43470. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43471. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43472. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43473. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43474. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43475. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43476. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43477. /**
  43478. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43479. * It is usually composed of several `lensFlare`.
  43480. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43481. */
  43482. var LensFlareSystem = /** @class */ (function () {
  43483. /**
  43484. * Instantiates a lens flare system.
  43485. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43486. * It is usually composed of several `lensFlare`.
  43487. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43488. * @param name Define the name of the lens flare system in the scene
  43489. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43490. * @param scene Define the scene the lens flare system belongs to
  43491. */
  43492. function LensFlareSystem(
  43493. /**
  43494. * Define the name of the lens flare system
  43495. */
  43496. name, emitter, scene) {
  43497. this.name = name;
  43498. /**
  43499. * List of lens flares used in this system.
  43500. */
  43501. this.lensFlares = new Array();
  43502. /**
  43503. * Define a limit from the border the lens flare can be visible.
  43504. */
  43505. this.borderLimit = 300;
  43506. /**
  43507. * Define a viewport border we do not want to see the lens flare in.
  43508. */
  43509. this.viewportBorder = 0;
  43510. /**
  43511. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43512. */
  43513. this.layerMask = 0x0FFFFFFF;
  43514. this._vertexBuffers = {};
  43515. this._isEnabled = true;
  43516. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43517. LensFlareSystem._SceneComponentInitialization(this._scene);
  43518. this._emitter = emitter;
  43519. this.id = name;
  43520. scene.lensFlareSystems.push(this);
  43521. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43522. var engine = scene.getEngine();
  43523. // VBO
  43524. var vertices = [];
  43525. vertices.push(1, 1);
  43526. vertices.push(-1, 1);
  43527. vertices.push(-1, -1);
  43528. vertices.push(1, -1);
  43529. 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);
  43530. // Indices
  43531. var indices = [];
  43532. indices.push(0);
  43533. indices.push(1);
  43534. indices.push(2);
  43535. indices.push(0);
  43536. indices.push(2);
  43537. indices.push(3);
  43538. this._indexBuffer = engine.createIndexBuffer(indices);
  43539. // Effects
  43540. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43541. }
  43542. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43543. /**
  43544. * Define if the lens flare system is enabled.
  43545. */
  43546. get: function () {
  43547. return this._isEnabled;
  43548. },
  43549. set: function (value) {
  43550. this._isEnabled = value;
  43551. },
  43552. enumerable: true,
  43553. configurable: true
  43554. });
  43555. /**
  43556. * Get the scene the effects belongs to.
  43557. * @returns the scene holding the lens flare system
  43558. */
  43559. LensFlareSystem.prototype.getScene = function () {
  43560. return this._scene;
  43561. };
  43562. /**
  43563. * Get the emitter of the lens flare system.
  43564. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43565. * @returns the emitter of the lens flare system
  43566. */
  43567. LensFlareSystem.prototype.getEmitter = function () {
  43568. return this._emitter;
  43569. };
  43570. /**
  43571. * Set the emitter of the lens flare system.
  43572. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43573. * @param newEmitter Define the new emitter of the system
  43574. */
  43575. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43576. this._emitter = newEmitter;
  43577. };
  43578. /**
  43579. * Get the lens flare system emitter position.
  43580. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43581. * @returns the position
  43582. */
  43583. LensFlareSystem.prototype.getEmitterPosition = function () {
  43584. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43585. };
  43586. /**
  43587. * @hidden
  43588. */
  43589. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43590. var position = this.getEmitterPosition();
  43591. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43592. this._positionX = position.x;
  43593. this._positionY = position.y;
  43594. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43595. if (this.viewportBorder > 0) {
  43596. globalViewport.x -= this.viewportBorder;
  43597. globalViewport.y -= this.viewportBorder;
  43598. globalViewport.width += this.viewportBorder * 2;
  43599. globalViewport.height += this.viewportBorder * 2;
  43600. position.x += this.viewportBorder;
  43601. position.y += this.viewportBorder;
  43602. this._positionX += this.viewportBorder;
  43603. this._positionY += this.viewportBorder;
  43604. }
  43605. if (position.z > 0) {
  43606. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43607. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43608. return true;
  43609. }
  43610. }
  43611. return true;
  43612. }
  43613. return false;
  43614. };
  43615. /** @hidden */
  43616. LensFlareSystem.prototype._isVisible = function () {
  43617. if (!this._isEnabled || !this._scene.activeCamera) {
  43618. return false;
  43619. }
  43620. var emitterPosition = this.getEmitterPosition();
  43621. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43622. var distance = direction.length();
  43623. direction.normalize();
  43624. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43625. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43626. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43627. };
  43628. /**
  43629. * @hidden
  43630. */
  43631. LensFlareSystem.prototype.render = function () {
  43632. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43633. return false;
  43634. }
  43635. var engine = this._scene.getEngine();
  43636. var viewport = this._scene.activeCamera.viewport;
  43637. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43638. // Position
  43639. if (!this.computeEffectivePosition(globalViewport)) {
  43640. return false;
  43641. }
  43642. // Visibility
  43643. if (!this._isVisible()) {
  43644. return false;
  43645. }
  43646. // Intensity
  43647. var awayX;
  43648. var awayY;
  43649. if (this._positionX < this.borderLimit + globalViewport.x) {
  43650. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43651. }
  43652. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43653. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43654. }
  43655. else {
  43656. awayX = 0;
  43657. }
  43658. if (this._positionY < this.borderLimit + globalViewport.y) {
  43659. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43660. }
  43661. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43662. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43663. }
  43664. else {
  43665. awayY = 0;
  43666. }
  43667. var away = (awayX > awayY) ? awayX : awayY;
  43668. away -= this.viewportBorder;
  43669. if (away > this.borderLimit) {
  43670. away = this.borderLimit;
  43671. }
  43672. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43673. if (intensity < 0) {
  43674. return false;
  43675. }
  43676. if (intensity > 1.0) {
  43677. intensity = 1.0;
  43678. }
  43679. if (this.viewportBorder > 0) {
  43680. globalViewport.x += this.viewportBorder;
  43681. globalViewport.y += this.viewportBorder;
  43682. globalViewport.width -= this.viewportBorder * 2;
  43683. globalViewport.height -= this.viewportBorder * 2;
  43684. this._positionX -= this.viewportBorder;
  43685. this._positionY -= this.viewportBorder;
  43686. }
  43687. // Position
  43688. var centerX = globalViewport.x + globalViewport.width / 2;
  43689. var centerY = globalViewport.y + globalViewport.height / 2;
  43690. var distX = centerX - this._positionX;
  43691. var distY = centerY - this._positionY;
  43692. // Effects
  43693. engine.enableEffect(this._effect);
  43694. engine.setState(false);
  43695. engine.setDepthBuffer(false);
  43696. // VBOs
  43697. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43698. // Flares
  43699. for (var index = 0; index < this.lensFlares.length; index++) {
  43700. var flare = this.lensFlares[index];
  43701. engine.setAlphaMode(flare.alphaMode);
  43702. var x = centerX - (distX * flare.position);
  43703. var y = centerY - (distY * flare.position);
  43704. var cw = flare.size;
  43705. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43706. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  43707. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  43708. 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);
  43709. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  43710. // Texture
  43711. this._effect.setTexture("textureSampler", flare.texture);
  43712. // Color
  43713. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  43714. // Draw order
  43715. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43716. }
  43717. engine.setDepthBuffer(true);
  43718. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43719. return true;
  43720. };
  43721. /**
  43722. * Dispose and release the lens flare with its associated resources.
  43723. */
  43724. LensFlareSystem.prototype.dispose = function () {
  43725. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  43726. if (vertexBuffer) {
  43727. vertexBuffer.dispose();
  43728. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  43729. }
  43730. if (this._indexBuffer) {
  43731. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43732. this._indexBuffer = null;
  43733. }
  43734. while (this.lensFlares.length) {
  43735. this.lensFlares[0].dispose();
  43736. }
  43737. // Remove from scene
  43738. var index = this._scene.lensFlareSystems.indexOf(this);
  43739. this._scene.lensFlareSystems.splice(index, 1);
  43740. };
  43741. /**
  43742. * Parse a lens flare system from a JSON repressentation
  43743. * @param parsedLensFlareSystem Define the JSON to parse
  43744. * @param scene Define the scene the parsed system should be instantiated in
  43745. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43746. * @returns the parsed system
  43747. */
  43748. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  43749. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  43750. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  43751. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  43752. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  43753. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  43754. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  43755. var parsedFlare = parsedLensFlareSystem.flares[index];
  43756. _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);
  43757. }
  43758. return lensFlareSystem;
  43759. };
  43760. /**
  43761. * Serialize the current Lens Flare System into a JSON representation.
  43762. * @returns the serialized JSON
  43763. */
  43764. LensFlareSystem.prototype.serialize = function () {
  43765. var serializationObject = {};
  43766. serializationObject.id = this.id;
  43767. serializationObject.name = this.name;
  43768. serializationObject.emitterId = this.getEmitter().id;
  43769. serializationObject.borderLimit = this.borderLimit;
  43770. serializationObject.flares = [];
  43771. for (var index = 0; index < this.lensFlares.length; index++) {
  43772. var flare = this.lensFlares[index];
  43773. serializationObject.flares.push({
  43774. size: flare.size,
  43775. position: flare.position,
  43776. color: flare.color.asArray(),
  43777. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  43778. });
  43779. }
  43780. return serializationObject;
  43781. };
  43782. /** @hidden */
  43783. LensFlareSystem._SceneComponentInitialization = function (_) {
  43784. throw "Import LensFlareSystemSceneComponent before creating LensFlareSystem.";
  43785. };
  43786. return LensFlareSystem;
  43787. }());
  43788. /***/ }),
  43789. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  43790. /*!*****************************************************!*\
  43791. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  43792. \*****************************************************/
  43793. /*! exports provided: LensFlareSystemSceneComponent */
  43794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43795. "use strict";
  43796. __webpack_require__.r(__webpack_exports__);
  43797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  43798. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43799. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43800. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43801. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43802. // Adds the parser to the scene parsers.
  43803. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  43804. // Lens flares
  43805. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  43806. if (!container.lensFlareSystems) {
  43807. container.lensFlareSystems = new Array();
  43808. }
  43809. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  43810. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  43811. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  43812. container.lensFlareSystems.push(lf);
  43813. }
  43814. }
  43815. });
  43816. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  43817. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43818. if (this.lensFlareSystems[index].name === name) {
  43819. return this.lensFlareSystems[index];
  43820. }
  43821. }
  43822. return null;
  43823. };
  43824. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  43825. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43826. if (this.lensFlareSystems[index].id === id) {
  43827. return this.lensFlareSystems[index];
  43828. }
  43829. }
  43830. return null;
  43831. };
  43832. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  43833. var index = this.lensFlareSystems.indexOf(toRemove);
  43834. if (index !== -1) {
  43835. this.lensFlareSystems.splice(index, 1);
  43836. }
  43837. return index;
  43838. };
  43839. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  43840. this.lensFlareSystems.push(newLensFlareSystem);
  43841. };
  43842. /**
  43843. * Defines the lens flare scene component responsible to manage any lens flares
  43844. * in a given scene.
  43845. */
  43846. var LensFlareSystemSceneComponent = /** @class */ (function () {
  43847. /**
  43848. * Creates a new instance of the component for the given scene
  43849. * @param scene Defines the scene to register the component in
  43850. */
  43851. function LensFlareSystemSceneComponent(scene) {
  43852. /**
  43853. * The component name helpfull to identify the component in the list of scene components.
  43854. */
  43855. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  43856. this.scene = scene;
  43857. scene.lensFlareSystems = new Array();
  43858. }
  43859. /**
  43860. * Registers the component in a given scene
  43861. */
  43862. LensFlareSystemSceneComponent.prototype.register = function () {
  43863. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  43864. };
  43865. /**
  43866. * Rebuilds the elements related to this component in case of
  43867. * context lost for instance.
  43868. */
  43869. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  43870. // Nothing to do for lens flare
  43871. };
  43872. /**
  43873. * Adds all the element from the container to the scene
  43874. * @param container the container holding the elements
  43875. */
  43876. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  43877. var _this = this;
  43878. if (!container.lensFlareSystems) {
  43879. return;
  43880. }
  43881. container.lensFlareSystems.forEach(function (o) {
  43882. _this.scene.addLensFlareSystem(o);
  43883. });
  43884. };
  43885. /**
  43886. * Removes all the elements in the container from the scene
  43887. * @param container contains the elements to remove
  43888. */
  43889. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  43890. var _this = this;
  43891. if (!container.lensFlareSystems) {
  43892. return;
  43893. }
  43894. container.lensFlareSystems.forEach(function (o) {
  43895. _this.scene.removeLensFlareSystem(o);
  43896. });
  43897. };
  43898. /**
  43899. * Serializes the component data to the specified json object
  43900. * @param serializationObject The object to serialize to
  43901. */
  43902. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  43903. // Lens flares
  43904. serializationObject.lensFlareSystems = [];
  43905. var lensFlareSystems = this.scene.lensFlareSystems;
  43906. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  43907. var lensFlareSystem = lensFlareSystems_1[_i];
  43908. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  43909. }
  43910. };
  43911. /**
  43912. * Disposes the component and the associated ressources.
  43913. */
  43914. LensFlareSystemSceneComponent.prototype.dispose = function () {
  43915. var lensFlareSystems = this.scene.lensFlareSystems;
  43916. while (lensFlareSystems.length) {
  43917. lensFlareSystems[0].dispose();
  43918. }
  43919. };
  43920. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  43921. // Lens flares
  43922. if (this.scene.lensFlaresEnabled) {
  43923. var lensFlareSystems = this.scene.lensFlareSystems;
  43924. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43925. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  43926. var lensFlareSystem = lensFlareSystems_2[_i];
  43927. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  43928. lensFlareSystem.render();
  43929. }
  43930. }
  43931. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43932. }
  43933. };
  43934. return LensFlareSystemSceneComponent;
  43935. }());
  43936. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  43937. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  43938. if (!component) {
  43939. component = new LensFlareSystemSceneComponent(scene);
  43940. scene._addComponent(component);
  43941. }
  43942. };
  43943. /***/ }),
  43944. /***/ "./Lights/Shadows/index.ts":
  43945. /*!*********************************!*\
  43946. !*** ./Lights/Shadows/index.ts ***!
  43947. \*********************************/
  43948. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  43949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43950. "use strict";
  43951. __webpack_require__.r(__webpack_exports__);
  43952. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  43953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43954. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  43955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  43956. /***/ }),
  43957. /***/ "./Lights/Shadows/shadowGenerator.ts":
  43958. /*!*******************************************!*\
  43959. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  43960. \*******************************************/
  43961. /*! exports provided: ShadowGenerator */
  43962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43963. "use strict";
  43964. __webpack_require__.r(__webpack_exports__);
  43965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  43966. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  43968. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  43969. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  43970. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  43971. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  43972. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43973. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43974. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43975. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43976. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  43977. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  43978. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  43979. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  43980. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  43981. /**
  43982. * Default implementation IShadowGenerator.
  43983. * This is the main object responsible of generating shadows in the framework.
  43984. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43985. */
  43986. var ShadowGenerator = /** @class */ (function () {
  43987. /**
  43988. * Creates a ShadowGenerator object.
  43989. * A ShadowGenerator is the required tool to use the shadows.
  43990. * Each light casting shadows needs to use its own ShadowGenerator.
  43991. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  43992. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43993. * @param light The light object generating the shadows.
  43994. * @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.
  43995. */
  43996. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  43997. /**
  43998. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  43999. */
  44000. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44001. this._bias = 0.00005;
  44002. this._normalBias = 0;
  44003. this._blurBoxOffset = 1;
  44004. this._blurScale = 2;
  44005. this._blurKernel = 1;
  44006. this._useKernelBlur = false;
  44007. this._filter = ShadowGenerator.FILTER_NONE;
  44008. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44009. this._contactHardeningLightSizeUVRatio = 0.1;
  44010. this._darkness = 0;
  44011. this._transparencyShadow = false;
  44012. /**
  44013. * Controls the extent to which the shadows fade out at the edge of the frustum
  44014. * Used only by directionals and spots
  44015. */
  44016. this.frustumEdgeFalloff = 0;
  44017. /**
  44018. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44019. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44020. * It might on the other hand introduce peter panning.
  44021. */
  44022. this.forceBackFacesOnly = false;
  44023. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44024. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44025. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44026. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44027. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44028. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44029. this._currentFaceIndex = 0;
  44030. this._currentFaceIndexCache = 0;
  44031. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44032. this._mapSize = mapSize;
  44033. this._light = light;
  44034. this._scene = light.getScene();
  44035. light._shadowGenerator = this;
  44036. ShadowGenerator._SceneComponentInitialization(this._scene);
  44037. // Texture type fallback from float to int if not supported.
  44038. var caps = this._scene.getEngine().getCaps();
  44039. if (!usefulFloatFirst) {
  44040. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44041. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44042. }
  44043. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44044. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44045. }
  44046. else {
  44047. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44048. }
  44049. }
  44050. else {
  44051. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44052. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44053. }
  44054. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44055. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44056. }
  44057. else {
  44058. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44059. }
  44060. }
  44061. this._initializeGenerator();
  44062. this._applyFilterValues();
  44063. }
  44064. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44065. /**
  44066. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44067. */
  44068. get: function () {
  44069. return this._bias;
  44070. },
  44071. /**
  44072. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44073. */
  44074. set: function (bias) {
  44075. this._bias = bias;
  44076. },
  44077. enumerable: true,
  44078. configurable: true
  44079. });
  44080. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44081. /**
  44082. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44083. */
  44084. get: function () {
  44085. return this._normalBias;
  44086. },
  44087. /**
  44088. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44089. */
  44090. set: function (normalBias) {
  44091. this._normalBias = normalBias;
  44092. },
  44093. enumerable: true,
  44094. configurable: true
  44095. });
  44096. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44097. /**
  44098. * Gets the blur box offset: offset applied during the blur pass.
  44099. * Only useful if useKernelBlur = false
  44100. */
  44101. get: function () {
  44102. return this._blurBoxOffset;
  44103. },
  44104. /**
  44105. * Sets the blur box offset: offset applied during the blur pass.
  44106. * Only useful if useKernelBlur = false
  44107. */
  44108. set: function (value) {
  44109. if (this._blurBoxOffset === value) {
  44110. return;
  44111. }
  44112. this._blurBoxOffset = value;
  44113. this._disposeBlurPostProcesses();
  44114. },
  44115. enumerable: true,
  44116. configurable: true
  44117. });
  44118. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44119. /**
  44120. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44121. * 2 means half of the size.
  44122. */
  44123. get: function () {
  44124. return this._blurScale;
  44125. },
  44126. /**
  44127. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44128. * 2 means half of the size.
  44129. */
  44130. set: function (value) {
  44131. if (this._blurScale === value) {
  44132. return;
  44133. }
  44134. this._blurScale = value;
  44135. this._disposeBlurPostProcesses();
  44136. },
  44137. enumerable: true,
  44138. configurable: true
  44139. });
  44140. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  44141. /**
  44142. * Gets the blur kernel: kernel size of the blur pass.
  44143. * Only useful if useKernelBlur = true
  44144. */
  44145. get: function () {
  44146. return this._blurKernel;
  44147. },
  44148. /**
  44149. * Sets the blur kernel: kernel size of the blur pass.
  44150. * Only useful if useKernelBlur = true
  44151. */
  44152. set: function (value) {
  44153. if (this._blurKernel === value) {
  44154. return;
  44155. }
  44156. this._blurKernel = value;
  44157. this._disposeBlurPostProcesses();
  44158. },
  44159. enumerable: true,
  44160. configurable: true
  44161. });
  44162. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  44163. /**
  44164. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44165. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44166. */
  44167. get: function () {
  44168. return this._useKernelBlur;
  44169. },
  44170. /**
  44171. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44172. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44173. */
  44174. set: function (value) {
  44175. if (this._useKernelBlur === value) {
  44176. return;
  44177. }
  44178. this._useKernelBlur = value;
  44179. this._disposeBlurPostProcesses();
  44180. },
  44181. enumerable: true,
  44182. configurable: true
  44183. });
  44184. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  44185. /**
  44186. * Gets the depth scale used in ESM mode.
  44187. */
  44188. get: function () {
  44189. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  44190. },
  44191. /**
  44192. * Sets the depth scale used in ESM mode.
  44193. * This can override the scale stored on the light.
  44194. */
  44195. set: function (value) {
  44196. this._depthScale = value;
  44197. },
  44198. enumerable: true,
  44199. configurable: true
  44200. });
  44201. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  44202. /**
  44203. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44204. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44205. */
  44206. get: function () {
  44207. return this._filter;
  44208. },
  44209. /**
  44210. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44211. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44212. */
  44213. set: function (value) {
  44214. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  44215. if (this._light.needCube()) {
  44216. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44217. this.useExponentialShadowMap = true;
  44218. return;
  44219. }
  44220. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44221. this.useCloseExponentialShadowMap = true;
  44222. return;
  44223. }
  44224. // PCF on cubemap would also be expensive
  44225. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44226. this.usePoissonSampling = true;
  44227. return;
  44228. }
  44229. }
  44230. // Weblg1 fallback for PCF.
  44231. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44232. if (this._scene.getEngine().webGLVersion === 1) {
  44233. this.usePoissonSampling = true;
  44234. return;
  44235. }
  44236. }
  44237. if (this._filter === value) {
  44238. return;
  44239. }
  44240. this._filter = value;
  44241. this._disposeBlurPostProcesses();
  44242. this._applyFilterValues();
  44243. this._light._markMeshesAsLightDirty();
  44244. },
  44245. enumerable: true,
  44246. configurable: true
  44247. });
  44248. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  44249. /**
  44250. * Gets if the current filter is set to Poisson Sampling.
  44251. */
  44252. get: function () {
  44253. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  44254. },
  44255. /**
  44256. * Sets the current filter to Poisson Sampling.
  44257. */
  44258. set: function (value) {
  44259. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  44260. return;
  44261. }
  44262. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  44263. },
  44264. enumerable: true,
  44265. configurable: true
  44266. });
  44267. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  44268. /**
  44269. * Gets if the current filter is set to ESM.
  44270. */
  44271. get: function () {
  44272. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  44273. },
  44274. /**
  44275. * Sets the current filter is to ESM.
  44276. */
  44277. set: function (value) {
  44278. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  44279. return;
  44280. }
  44281. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44282. },
  44283. enumerable: true,
  44284. configurable: true
  44285. });
  44286. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  44287. /**
  44288. * Gets if the current filter is set to filtered ESM.
  44289. */
  44290. get: function () {
  44291. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  44292. },
  44293. /**
  44294. * Gets if the current filter is set to filtered ESM.
  44295. */
  44296. set: function (value) {
  44297. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44298. return;
  44299. }
  44300. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44301. },
  44302. enumerable: true,
  44303. configurable: true
  44304. });
  44305. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  44306. /**
  44307. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44308. * exponential to prevent steep falloff artifacts).
  44309. */
  44310. get: function () {
  44311. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  44312. },
  44313. /**
  44314. * Sets the current filter to "close ESM" (using the inverse of the
  44315. * exponential to prevent steep falloff artifacts).
  44316. */
  44317. set: function (value) {
  44318. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  44319. return;
  44320. }
  44321. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44322. },
  44323. enumerable: true,
  44324. configurable: true
  44325. });
  44326. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  44327. /**
  44328. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44329. * exponential to prevent steep falloff artifacts).
  44330. */
  44331. get: function () {
  44332. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  44333. },
  44334. /**
  44335. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44336. * exponential to prevent steep falloff artifacts).
  44337. */
  44338. set: function (value) {
  44339. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44340. return;
  44341. }
  44342. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44343. },
  44344. enumerable: true,
  44345. configurable: true
  44346. });
  44347. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  44348. /**
  44349. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44350. */
  44351. get: function () {
  44352. return this.filter === ShadowGenerator.FILTER_PCF;
  44353. },
  44354. /**
  44355. * Sets the current filter to "PCF" (percentage closer filtering).
  44356. */
  44357. set: function (value) {
  44358. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  44359. return;
  44360. }
  44361. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  44362. },
  44363. enumerable: true,
  44364. configurable: true
  44365. });
  44366. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  44367. /**
  44368. * Gets the PCF or PCSS Quality.
  44369. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44370. */
  44371. get: function () {
  44372. return this._filteringQuality;
  44373. },
  44374. /**
  44375. * Sets the PCF or PCSS Quality.
  44376. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44377. */
  44378. set: function (filteringQuality) {
  44379. this._filteringQuality = filteringQuality;
  44380. },
  44381. enumerable: true,
  44382. configurable: true
  44383. });
  44384. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  44385. /**
  44386. * Gets if the current filter is set to "PCSS" (contact hardening).
  44387. */
  44388. get: function () {
  44389. return this.filter === ShadowGenerator.FILTER_PCSS;
  44390. },
  44391. /**
  44392. * Sets the current filter to "PCSS" (contact hardening).
  44393. */
  44394. set: function (value) {
  44395. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  44396. return;
  44397. }
  44398. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  44399. },
  44400. enumerable: true,
  44401. configurable: true
  44402. });
  44403. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  44404. /**
  44405. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44406. * Using a ratio helps keeping shape stability independently of the map size.
  44407. *
  44408. * It does not account for the light projection as it was having too much
  44409. * instability during the light setup or during light position changes.
  44410. *
  44411. * Only valid if useContactHardeningShadow is true.
  44412. */
  44413. get: function () {
  44414. return this._contactHardeningLightSizeUVRatio;
  44415. },
  44416. /**
  44417. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44418. * Using a ratio helps keeping shape stability independently of the map size.
  44419. *
  44420. * It does not account for the light projection as it was having too much
  44421. * instability during the light setup or during light position changes.
  44422. *
  44423. * Only valid if useContactHardeningShadow is true.
  44424. */
  44425. set: function (contactHardeningLightSizeUVRatio) {
  44426. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  44427. },
  44428. enumerable: true,
  44429. configurable: true
  44430. });
  44431. /**
  44432. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44433. * 0 means strongest and 1 would means no shadow.
  44434. * @returns the darkness.
  44435. */
  44436. ShadowGenerator.prototype.getDarkness = function () {
  44437. return this._darkness;
  44438. };
  44439. /**
  44440. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44441. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44442. * @returns the shadow generator allowing fluent coding.
  44443. */
  44444. ShadowGenerator.prototype.setDarkness = function (darkness) {
  44445. if (darkness >= 1.0) {
  44446. this._darkness = 1.0;
  44447. }
  44448. else if (darkness <= 0.0) {
  44449. this._darkness = 0.0;
  44450. }
  44451. else {
  44452. this._darkness = darkness;
  44453. }
  44454. return this;
  44455. };
  44456. /**
  44457. * Sets the ability to have transparent shadow (boolean).
  44458. * @param transparent True if transparent else False
  44459. * @returns the shadow generator allowing fluent coding
  44460. */
  44461. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  44462. this._transparencyShadow = transparent;
  44463. return this;
  44464. };
  44465. /**
  44466. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44467. * @returns The render target texture if present otherwise, null
  44468. */
  44469. ShadowGenerator.prototype.getShadowMap = function () {
  44470. return this._shadowMap;
  44471. };
  44472. /**
  44473. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44474. * @returns The render target texture if the shadow map is present otherwise, null
  44475. */
  44476. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44477. if (this._shadowMap2) {
  44478. return this._shadowMap2;
  44479. }
  44480. return this._shadowMap;
  44481. };
  44482. /**
  44483. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44484. * @param mesh Mesh to add
  44485. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44486. * @returns the Shadow Generator itself
  44487. */
  44488. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44489. if (includeDescendants === void 0) { includeDescendants = true; }
  44490. var _a;
  44491. if (!this._shadowMap) {
  44492. return this;
  44493. }
  44494. if (!this._shadowMap.renderList) {
  44495. this._shadowMap.renderList = [];
  44496. }
  44497. this._shadowMap.renderList.push(mesh);
  44498. if (includeDescendants) {
  44499. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44500. }
  44501. return this;
  44502. };
  44503. /**
  44504. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44505. * @param mesh Mesh to remove
  44506. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44507. * @returns the Shadow Generator itself
  44508. */
  44509. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44510. if (includeDescendants === void 0) { includeDescendants = true; }
  44511. if (!this._shadowMap || !this._shadowMap.renderList) {
  44512. return this;
  44513. }
  44514. var index = this._shadowMap.renderList.indexOf(mesh);
  44515. if (index !== -1) {
  44516. this._shadowMap.renderList.splice(index, 1);
  44517. }
  44518. if (includeDescendants) {
  44519. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44520. var child = _a[_i];
  44521. this.removeShadowCaster(child);
  44522. }
  44523. }
  44524. return this;
  44525. };
  44526. /**
  44527. * Returns the associated light object.
  44528. * @returns the light generating the shadow
  44529. */
  44530. ShadowGenerator.prototype.getLight = function () {
  44531. return this._light;
  44532. };
  44533. ShadowGenerator.prototype._initializeGenerator = function () {
  44534. this._light._markMeshesAsLightDirty();
  44535. this._initializeShadowMap();
  44536. };
  44537. ShadowGenerator.prototype._initializeShadowMap = function () {
  44538. var _this = this;
  44539. // Render target
  44540. var engine = this._scene.getEngine();
  44541. if (engine.webGLVersion > 1) {
  44542. 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);
  44543. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44544. }
  44545. else {
  44546. 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());
  44547. }
  44548. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44549. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44550. this._shadowMap.anisotropicFilteringLevel = 1;
  44551. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44552. this._shadowMap.renderParticles = false;
  44553. this._shadowMap.ignoreCameraViewport = true;
  44554. // Record Face Index before render.
  44555. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44556. _this._currentFaceIndex = faceIndex;
  44557. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44558. engine.setColorWrite(false);
  44559. }
  44560. });
  44561. // Custom render function.
  44562. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44563. // Blur if required afer render.
  44564. this._shadowMap.onAfterUnbindObservable.add(function () {
  44565. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44566. engine.setColorWrite(true);
  44567. }
  44568. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44569. return;
  44570. }
  44571. var shadowMap = _this.getShadowMapForRendering();
  44572. if (shadowMap) {
  44573. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44574. }
  44575. });
  44576. // Clear according to the chosen filter.
  44577. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44578. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44579. this._shadowMap.onClearObservable.add(function (engine) {
  44580. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44581. engine.clear(clearOne, false, true, false);
  44582. }
  44583. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44584. engine.clear(clearZero, true, true, false);
  44585. }
  44586. else {
  44587. engine.clear(clearOne, true, true, false);
  44588. }
  44589. });
  44590. };
  44591. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44592. var _this = this;
  44593. var engine = this._scene.getEngine();
  44594. var targetSize = this._mapSize / this.blurScale;
  44595. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44596. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44597. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44598. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44599. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44600. }
  44601. if (this.useKernelBlur) {
  44602. 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);
  44603. this._kernelBlurXPostprocess.width = targetSize;
  44604. this._kernelBlurXPostprocess.height = targetSize;
  44605. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44606. effect.setTexture("textureSampler", _this._shadowMap);
  44607. });
  44608. 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);
  44609. this._kernelBlurXPostprocess.autoClear = false;
  44610. this._kernelBlurYPostprocess.autoClear = false;
  44611. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44612. this._kernelBlurXPostprocess.packedFloat = true;
  44613. this._kernelBlurYPostprocess.packedFloat = true;
  44614. }
  44615. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44616. }
  44617. else {
  44618. 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);
  44619. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44620. effect.setFloat2("screenSize", targetSize, targetSize);
  44621. effect.setTexture("textureSampler", _this._shadowMap);
  44622. });
  44623. this._boxBlurPostprocess.autoClear = false;
  44624. this._blurPostProcesses = [this._boxBlurPostprocess];
  44625. }
  44626. };
  44627. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44628. var index;
  44629. var engine = this._scene.getEngine();
  44630. if (depthOnlySubMeshes.length) {
  44631. engine.setColorWrite(false);
  44632. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44633. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44634. }
  44635. engine.setColorWrite(true);
  44636. }
  44637. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44638. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44639. }
  44640. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44641. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44642. }
  44643. if (this._transparencyShadow) {
  44644. for (index = 0; index < transparentSubMeshes.length; index++) {
  44645. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44646. }
  44647. }
  44648. };
  44649. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44650. var _this = this;
  44651. var mesh = subMesh.getRenderingMesh();
  44652. var scene = this._scene;
  44653. var engine = scene.getEngine();
  44654. var material = subMesh.getMaterial();
  44655. if (!material || subMesh.verticesCount === 0) {
  44656. return;
  44657. }
  44658. // Culling
  44659. engine.setState(material.backFaceCulling);
  44660. // Managing instances
  44661. var batch = mesh._getInstancesRenderList(subMesh._id);
  44662. if (batch.mustReturn) {
  44663. return;
  44664. }
  44665. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44666. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44667. engine.enableEffect(this._effect);
  44668. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44669. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44670. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44671. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44672. this._effect.setVector3("lightData", this._cachedDirection);
  44673. }
  44674. else {
  44675. this._effect.setVector3("lightData", this._cachedPosition);
  44676. }
  44677. if (scene.activeCamera) {
  44678. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44679. }
  44680. // Alpha test
  44681. if (material && material.needAlphaTesting()) {
  44682. var alphaTexture = material.getAlphaTestTexture();
  44683. if (alphaTexture) {
  44684. this._effect.setTexture("diffuseSampler", alphaTexture);
  44685. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44686. }
  44687. }
  44688. // Bones
  44689. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44690. var skeleton = mesh.skeleton;
  44691. if (skeleton.isUsingTextureForMatrices) {
  44692. var boneTexture = skeleton.getTransformMatrixTexture();
  44693. if (!boneTexture) {
  44694. return;
  44695. }
  44696. this._effect.setTexture("boneSampler", boneTexture);
  44697. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44698. }
  44699. else {
  44700. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44701. }
  44702. }
  44703. // Morph targets
  44704. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44705. if (this.forceBackFacesOnly) {
  44706. engine.setState(true, 0, false, true);
  44707. }
  44708. // Observable
  44709. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  44710. // Draw
  44711. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  44712. if (this.forceBackFacesOnly) {
  44713. engine.setState(true, 0, false, false);
  44714. }
  44715. }
  44716. else {
  44717. // Need to reset refresh rate of the shadowMap
  44718. if (this._shadowMap) {
  44719. this._shadowMap.resetRefreshCounter();
  44720. }
  44721. }
  44722. };
  44723. ShadowGenerator.prototype._applyFilterValues = function () {
  44724. if (!this._shadowMap) {
  44725. return;
  44726. }
  44727. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  44728. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  44729. }
  44730. else {
  44731. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44732. }
  44733. };
  44734. /**
  44735. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44736. * @param onCompiled Callback triggered at the and of the effects compilation
  44737. * @param options Sets of optional options forcing the compilation with different modes
  44738. */
  44739. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  44740. var _this = this;
  44741. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  44742. var shadowMap = this.getShadowMap();
  44743. if (!shadowMap) {
  44744. if (onCompiled) {
  44745. onCompiled(this);
  44746. }
  44747. return;
  44748. }
  44749. var renderList = shadowMap.renderList;
  44750. if (!renderList) {
  44751. if (onCompiled) {
  44752. onCompiled(this);
  44753. }
  44754. return;
  44755. }
  44756. var subMeshes = new Array();
  44757. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  44758. var mesh = renderList_1[_i];
  44759. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  44760. }
  44761. if (subMeshes.length === 0) {
  44762. if (onCompiled) {
  44763. onCompiled(this);
  44764. }
  44765. return;
  44766. }
  44767. var currentIndex = 0;
  44768. var checkReady = function () {
  44769. if (!_this._scene || !_this._scene.getEngine()) {
  44770. return;
  44771. }
  44772. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  44773. currentIndex++;
  44774. if (currentIndex >= subMeshes.length) {
  44775. if (onCompiled) {
  44776. onCompiled(_this);
  44777. }
  44778. return;
  44779. }
  44780. }
  44781. setTimeout(checkReady, 16);
  44782. };
  44783. checkReady();
  44784. };
  44785. /**
  44786. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44787. * @param options Sets of optional options forcing the compilation with different modes
  44788. * @returns A promise that resolves when the compilation completes
  44789. */
  44790. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  44791. var _this = this;
  44792. return new Promise(function (resolve) {
  44793. _this.forceCompilation(function () {
  44794. resolve();
  44795. }, options);
  44796. });
  44797. };
  44798. /**
  44799. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44800. * @param subMesh The submesh we want to render in the shadow map
  44801. * @param useInstances Defines wether will draw in the map using instances
  44802. * @returns true if ready otherwise, false
  44803. */
  44804. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  44805. var defines = [];
  44806. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44807. defines.push("#define FLOAT");
  44808. }
  44809. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44810. defines.push("#define ESM");
  44811. }
  44812. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  44813. defines.push("#define DEPTHTEXTURE");
  44814. }
  44815. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  44816. var mesh = subMesh.getMesh();
  44817. var material = subMesh.getMaterial();
  44818. // Normal bias.
  44819. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  44820. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  44821. defines.push("#define NORMAL");
  44822. if (mesh.nonUniformScaling) {
  44823. defines.push("#define NONUNIFORMSCALING");
  44824. }
  44825. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44826. defines.push("#define DIRECTIONINLIGHTDATA");
  44827. }
  44828. }
  44829. // Alpha test
  44830. if (material && material.needAlphaTesting()) {
  44831. var alphaTexture = material.getAlphaTestTexture();
  44832. if (alphaTexture) {
  44833. defines.push("#define ALPHATEST");
  44834. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  44835. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  44836. defines.push("#define UV1");
  44837. }
  44838. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  44839. if (alphaTexture.coordinatesIndex === 1) {
  44840. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  44841. defines.push("#define UV2");
  44842. }
  44843. }
  44844. }
  44845. }
  44846. // Bones
  44847. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44848. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  44849. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  44850. if (mesh.numBoneInfluencers > 4) {
  44851. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  44852. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  44853. }
  44854. var skeleton = mesh.skeleton;
  44855. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  44856. if (skeleton.isUsingTextureForMatrices) {
  44857. defines.push("#define BONETEXTURE");
  44858. }
  44859. else {
  44860. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  44861. }
  44862. }
  44863. else {
  44864. defines.push("#define NUM_BONE_INFLUENCERS 0");
  44865. }
  44866. // Morph targets
  44867. var manager = mesh.morphTargetManager;
  44868. var morphInfluencers = 0;
  44869. if (manager) {
  44870. if (manager.numInfluencers > 0) {
  44871. defines.push("#define MORPHTARGETS");
  44872. morphInfluencers = manager.numInfluencers;
  44873. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  44874. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  44875. }
  44876. }
  44877. // Instances
  44878. if (useInstances) {
  44879. defines.push("#define INSTANCES");
  44880. attribs.push("world0");
  44881. attribs.push("world1");
  44882. attribs.push("world2");
  44883. attribs.push("world3");
  44884. }
  44885. if (this.customShaderOptions) {
  44886. if (this.customShaderOptions.defines) {
  44887. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  44888. var define = _a[_i];
  44889. if (defines.indexOf(define) === -1) {
  44890. defines.push(define);
  44891. }
  44892. }
  44893. }
  44894. }
  44895. // Get correct effect
  44896. var join = defines.join("\n");
  44897. if (this._cachedDefines !== join) {
  44898. this._cachedDefines = join;
  44899. var shaderName = "shadowMap";
  44900. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  44901. var samplers = ["diffuseSampler", "boneSampler"];
  44902. // Custom shader?
  44903. if (this.customShaderOptions) {
  44904. shaderName = this.customShaderOptions.shaderName;
  44905. if (this.customShaderOptions.attributes) {
  44906. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  44907. var attrib = _c[_b];
  44908. if (attribs.indexOf(attrib) === -1) {
  44909. attribs.push(attrib);
  44910. }
  44911. }
  44912. }
  44913. if (this.customShaderOptions.uniforms) {
  44914. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  44915. var uniform = _e[_d];
  44916. if (uniforms.indexOf(uniform) === -1) {
  44917. uniforms.push(uniform);
  44918. }
  44919. }
  44920. }
  44921. if (this.customShaderOptions.samplers) {
  44922. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  44923. var sampler = _g[_f];
  44924. if (samplers.indexOf(sampler) === -1) {
  44925. samplers.push(sampler);
  44926. }
  44927. }
  44928. }
  44929. }
  44930. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  44931. }
  44932. if (!this._effect.isReady()) {
  44933. return false;
  44934. }
  44935. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44936. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  44937. this._initializeBlurRTTAndPostProcesses();
  44938. }
  44939. }
  44940. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  44941. return false;
  44942. }
  44943. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  44944. return false;
  44945. }
  44946. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  44947. return false;
  44948. }
  44949. return true;
  44950. };
  44951. /**
  44952. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44953. * @param defines Defines of the material we want to update
  44954. * @param lightIndex Index of the light in the enabled light list of the material
  44955. */
  44956. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  44957. var scene = this._scene;
  44958. var light = this._light;
  44959. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44960. return;
  44961. }
  44962. defines["SHADOW" + lightIndex] = true;
  44963. if (this.useContactHardeningShadow) {
  44964. defines["SHADOWPCSS" + lightIndex] = true;
  44965. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44966. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44967. }
  44968. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44969. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44970. }
  44971. // else default to high.
  44972. }
  44973. if (this.usePercentageCloserFiltering) {
  44974. defines["SHADOWPCF" + lightIndex] = true;
  44975. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44976. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44977. }
  44978. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44979. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44980. }
  44981. // else default to high.
  44982. }
  44983. else if (this.usePoissonSampling) {
  44984. defines["SHADOWPOISSON" + lightIndex] = true;
  44985. }
  44986. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44987. defines["SHADOWESM" + lightIndex] = true;
  44988. }
  44989. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44990. defines["SHADOWCLOSEESM" + lightIndex] = true;
  44991. }
  44992. if (light.needCube()) {
  44993. defines["SHADOWCUBE" + lightIndex] = true;
  44994. }
  44995. };
  44996. /**
  44997. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44998. * defined in the generator but impacting the effect).
  44999. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45000. * @param effect The effect we are binfing the information for
  45001. */
  45002. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45003. var light = this._light;
  45004. var scene = this._scene;
  45005. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45006. return;
  45007. }
  45008. var camera = scene.activeCamera;
  45009. if (!camera) {
  45010. return;
  45011. }
  45012. var shadowMap = this.getShadowMap();
  45013. if (!shadowMap) {
  45014. return;
  45015. }
  45016. if (!light.needCube()) {
  45017. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45018. }
  45019. // Only PCF uses depth stencil texture.
  45020. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45021. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45022. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45023. }
  45024. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45025. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45026. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45027. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45028. }
  45029. else {
  45030. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45031. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45032. }
  45033. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45034. };
  45035. /**
  45036. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45037. * (eq to shadow prjection matrix * light transform matrix)
  45038. * @returns The transform matrix used to create the shadow map
  45039. */
  45040. ShadowGenerator.prototype.getTransformMatrix = function () {
  45041. var scene = this._scene;
  45042. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45043. return this._transformMatrix;
  45044. }
  45045. this._currentRenderID = scene.getRenderId();
  45046. this._currentFaceIndexCache = this._currentFaceIndex;
  45047. var lightPosition = this._light.position;
  45048. if (this._light.computeTransformedInformation()) {
  45049. lightPosition = this._light.transformedPosition;
  45050. }
  45051. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45052. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45053. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45054. }
  45055. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45056. this._cachedPosition.copyFrom(lightPosition);
  45057. this._cachedDirection.copyFrom(this._lightDirection);
  45058. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45059. var shadowMap = this.getShadowMap();
  45060. if (shadowMap) {
  45061. var renderList = shadowMap.renderList;
  45062. if (renderList) {
  45063. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45064. }
  45065. }
  45066. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45067. }
  45068. return this._transformMatrix;
  45069. };
  45070. /**
  45071. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45072. * Cube and 2D textures for instance.
  45073. */
  45074. ShadowGenerator.prototype.recreateShadowMap = function () {
  45075. var shadowMap = this._shadowMap;
  45076. if (!shadowMap) {
  45077. return;
  45078. }
  45079. // Track render list.
  45080. var renderList = shadowMap.renderList;
  45081. // Clean up existing data.
  45082. this._disposeRTTandPostProcesses();
  45083. // Reinitializes.
  45084. this._initializeGenerator();
  45085. // Reaffect the filter to ensure a correct fallback if necessary.
  45086. this.filter = this.filter;
  45087. // Reaffect the filter.
  45088. this._applyFilterValues();
  45089. // Reaffect Render List.
  45090. this._shadowMap.renderList = renderList;
  45091. };
  45092. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45093. if (this._shadowMap2) {
  45094. this._shadowMap2.dispose();
  45095. this._shadowMap2 = null;
  45096. }
  45097. if (this._boxBlurPostprocess) {
  45098. this._boxBlurPostprocess.dispose();
  45099. this._boxBlurPostprocess = null;
  45100. }
  45101. if (this._kernelBlurXPostprocess) {
  45102. this._kernelBlurXPostprocess.dispose();
  45103. this._kernelBlurXPostprocess = null;
  45104. }
  45105. if (this._kernelBlurYPostprocess) {
  45106. this._kernelBlurYPostprocess.dispose();
  45107. this._kernelBlurYPostprocess = null;
  45108. }
  45109. this._blurPostProcesses = [];
  45110. };
  45111. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45112. if (this._shadowMap) {
  45113. this._shadowMap.dispose();
  45114. this._shadowMap = null;
  45115. }
  45116. this._disposeBlurPostProcesses();
  45117. };
  45118. /**
  45119. * Disposes the ShadowGenerator.
  45120. * Returns nothing.
  45121. */
  45122. ShadowGenerator.prototype.dispose = function () {
  45123. this._disposeRTTandPostProcesses();
  45124. if (this._light) {
  45125. this._light._shadowGenerator = null;
  45126. this._light._markMeshesAsLightDirty();
  45127. }
  45128. };
  45129. /**
  45130. * Serializes the shadow generator setup to a json object.
  45131. * @returns The serialized JSON object
  45132. */
  45133. ShadowGenerator.prototype.serialize = function () {
  45134. var serializationObject = {};
  45135. var shadowMap = this.getShadowMap();
  45136. if (!shadowMap) {
  45137. return serializationObject;
  45138. }
  45139. serializationObject.lightId = this._light.id;
  45140. serializationObject.mapSize = shadowMap.getRenderSize();
  45141. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  45142. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  45143. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45144. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45145. serializationObject.usePoissonSampling = this.usePoissonSampling;
  45146. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  45147. serializationObject.depthScale = this.depthScale;
  45148. serializationObject.darkness = this.getDarkness();
  45149. serializationObject.blurBoxOffset = this.blurBoxOffset;
  45150. serializationObject.blurKernel = this.blurKernel;
  45151. serializationObject.blurScale = this.blurScale;
  45152. serializationObject.useKernelBlur = this.useKernelBlur;
  45153. serializationObject.transparencyShadow = this._transparencyShadow;
  45154. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  45155. serializationObject.bias = this.bias;
  45156. serializationObject.normalBias = this.normalBias;
  45157. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  45158. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  45159. serializationObject.filteringQuality = this.filteringQuality;
  45160. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  45161. serializationObject.renderList = [];
  45162. if (shadowMap.renderList) {
  45163. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  45164. var mesh = shadowMap.renderList[meshIndex];
  45165. serializationObject.renderList.push(mesh.id);
  45166. }
  45167. }
  45168. return serializationObject;
  45169. };
  45170. /**
  45171. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  45172. * @param parsedShadowGenerator The JSON object to parse
  45173. * @param scene The scene to create the shadow map for
  45174. * @returns The parsed shadow generator
  45175. */
  45176. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  45177. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  45178. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  45179. var shadowMap = shadowGenerator.getShadowMap();
  45180. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  45181. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  45182. meshes.forEach(function (mesh) {
  45183. if (!shadowMap) {
  45184. return;
  45185. }
  45186. if (!shadowMap.renderList) {
  45187. shadowMap.renderList = [];
  45188. }
  45189. shadowMap.renderList.push(mesh);
  45190. });
  45191. }
  45192. if (parsedShadowGenerator.usePoissonSampling) {
  45193. shadowGenerator.usePoissonSampling = true;
  45194. }
  45195. else if (parsedShadowGenerator.useExponentialShadowMap) {
  45196. shadowGenerator.useExponentialShadowMap = true;
  45197. }
  45198. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  45199. shadowGenerator.useBlurExponentialShadowMap = true;
  45200. }
  45201. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  45202. shadowGenerator.useCloseExponentialShadowMap = true;
  45203. }
  45204. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  45205. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  45206. }
  45207. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  45208. shadowGenerator.usePercentageCloserFiltering = true;
  45209. }
  45210. else if (parsedShadowGenerator.useContactHardeningShadow) {
  45211. shadowGenerator.useContactHardeningShadow = true;
  45212. }
  45213. if (parsedShadowGenerator.filteringQuality) {
  45214. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  45215. }
  45216. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  45217. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  45218. }
  45219. // Backward compat
  45220. else if (parsedShadowGenerator.useVarianceShadowMap) {
  45221. shadowGenerator.useExponentialShadowMap = true;
  45222. }
  45223. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  45224. shadowGenerator.useBlurExponentialShadowMap = true;
  45225. }
  45226. if (parsedShadowGenerator.depthScale) {
  45227. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  45228. }
  45229. if (parsedShadowGenerator.blurScale) {
  45230. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  45231. }
  45232. if (parsedShadowGenerator.blurBoxOffset) {
  45233. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  45234. }
  45235. if (parsedShadowGenerator.useKernelBlur) {
  45236. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  45237. }
  45238. if (parsedShadowGenerator.blurKernel) {
  45239. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  45240. }
  45241. if (parsedShadowGenerator.bias !== undefined) {
  45242. shadowGenerator.bias = parsedShadowGenerator.bias;
  45243. }
  45244. if (parsedShadowGenerator.normalBias !== undefined) {
  45245. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  45246. }
  45247. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  45248. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  45249. }
  45250. if (parsedShadowGenerator.darkness) {
  45251. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  45252. }
  45253. if (parsedShadowGenerator.transparencyShadow) {
  45254. shadowGenerator.setTransparencyShadow(true);
  45255. }
  45256. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  45257. return shadowGenerator;
  45258. };
  45259. /**
  45260. * Shadow generator mode None: no filtering applied.
  45261. */
  45262. ShadowGenerator.FILTER_NONE = 0;
  45263. /**
  45264. * Shadow generator mode ESM: Exponential Shadow Mapping.
  45265. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45266. */
  45267. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  45268. /**
  45269. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  45270. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  45271. */
  45272. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  45273. /**
  45274. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  45275. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45276. */
  45277. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  45278. /**
  45279. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  45280. * edge artifacts on steep falloff.
  45281. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45282. */
  45283. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  45284. /**
  45285. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  45286. * edge artifacts on steep falloff.
  45287. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45288. */
  45289. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  45290. /**
  45291. * Shadow generator mode PCF: Percentage Closer Filtering
  45292. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45293. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  45294. */
  45295. ShadowGenerator.FILTER_PCF = 6;
  45296. /**
  45297. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  45298. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45299. * Contact Hardening
  45300. */
  45301. ShadowGenerator.FILTER_PCSS = 7;
  45302. /**
  45303. * Reserved for PCF and PCSS
  45304. * Highest Quality.
  45305. *
  45306. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  45307. *
  45308. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  45309. */
  45310. ShadowGenerator.QUALITY_HIGH = 0;
  45311. /**
  45312. * Reserved for PCF and PCSS
  45313. * Good tradeoff for quality/perf cross devices
  45314. *
  45315. * Execute PCF on a 3*3 kernel.
  45316. *
  45317. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  45318. */
  45319. ShadowGenerator.QUALITY_MEDIUM = 1;
  45320. /**
  45321. * Reserved for PCF and PCSS
  45322. * The lowest quality but the fastest.
  45323. *
  45324. * Execute PCF on a 1*1 kernel.
  45325. *
  45326. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  45327. */
  45328. ShadowGenerator.QUALITY_LOW = 2;
  45329. /** @hidden */
  45330. ShadowGenerator._SceneComponentInitialization = function (_) {
  45331. throw "Import ShadowGeneratorSceneComponent before creating ShadowGenerator.";
  45332. };
  45333. return ShadowGenerator;
  45334. }());
  45335. /***/ }),
  45336. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  45337. /*!*********************************************************!*\
  45338. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  45339. \*********************************************************/
  45340. /*! exports provided: ShadowGeneratorSceneComponent */
  45341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45342. "use strict";
  45343. __webpack_require__.r(__webpack_exports__);
  45344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  45345. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45346. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  45347. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  45348. // Adds the parser to the scene parsers.
  45349. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  45350. // Shadows
  45351. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  45352. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  45353. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  45354. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  45355. // SG would be available on their associated lights
  45356. }
  45357. }
  45358. });
  45359. /**
  45360. * Defines the shadow generator component responsible to manage any shadow generators
  45361. * in a given scene.
  45362. */
  45363. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  45364. /**
  45365. * Creates a new instance of the component for the given scene
  45366. * @param scene Defines the scene to register the component in
  45367. */
  45368. function ShadowGeneratorSceneComponent(scene) {
  45369. /**
  45370. * The component name helpfull to identify the component in the list of scene components.
  45371. */
  45372. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  45373. this.scene = scene;
  45374. }
  45375. /**
  45376. * Registers the component in a given scene
  45377. */
  45378. ShadowGeneratorSceneComponent.prototype.register = function () {
  45379. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  45380. };
  45381. /**
  45382. * Rebuilds the elements related to this component in case of
  45383. * context lost for instance.
  45384. */
  45385. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  45386. // Nothing To Do Here.
  45387. };
  45388. /**
  45389. * Serializes the component data to the specified json object
  45390. * @param serializationObject The object to serialize to
  45391. */
  45392. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  45393. // Shadows
  45394. serializationObject.shadowGenerators = [];
  45395. var lights = this.scene.lights;
  45396. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  45397. var light = lights_1[_i];
  45398. var shadowGenerator = light.getShadowGenerator();
  45399. if (shadowGenerator) {
  45400. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  45401. }
  45402. }
  45403. };
  45404. /**
  45405. * Adds all the element from the container to the scene
  45406. * @param container the container holding the elements
  45407. */
  45408. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  45409. // Nothing To Do Here. (directly attached to a light)
  45410. };
  45411. /**
  45412. * Removes all the elements in the container from the scene
  45413. * @param container contains the elements to remove
  45414. */
  45415. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  45416. // Nothing To Do Here. (directly attached to a light)
  45417. };
  45418. /**
  45419. * Rebuilds the elements related to this component in case of
  45420. * context lost for instance.
  45421. */
  45422. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  45423. // Nothing To Do Here.
  45424. };
  45425. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  45426. // Shadows
  45427. var scene = this.scene;
  45428. if (this.scene.shadowsEnabled) {
  45429. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  45430. var light = scene.lights[lightIndex];
  45431. var shadowGenerator = light.getShadowGenerator();
  45432. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  45433. var shadowMap = (shadowGenerator.getShadowMap());
  45434. if (scene.textures.indexOf(shadowMap) !== -1) {
  45435. renderTargets.push(shadowMap);
  45436. }
  45437. }
  45438. }
  45439. }
  45440. };
  45441. return ShadowGeneratorSceneComponent;
  45442. }());
  45443. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  45444. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  45445. if (!component) {
  45446. component = new ShadowGeneratorSceneComponent(scene);
  45447. scene._addComponent(component);
  45448. }
  45449. };
  45450. /***/ }),
  45451. /***/ "./Lights/directionalLight.ts":
  45452. /*!************************************!*\
  45453. !*** ./Lights/directionalLight.ts ***!
  45454. \************************************/
  45455. /*! exports provided: DirectionalLight */
  45456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45457. "use strict";
  45458. __webpack_require__.r(__webpack_exports__);
  45459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  45460. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45461. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45463. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45464. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45465. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45466. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45467. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45468. });
  45469. /**
  45470. * A directional light is defined by a direction (what a surprise!).
  45471. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45472. * 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.
  45473. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45474. */
  45475. var DirectionalLight = /** @class */ (function (_super) {
  45476. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45477. /**
  45478. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45479. * The directional light is emitted from everywhere in the given direction.
  45480. * It can cast shadows.
  45481. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45482. * @param name The friendly name of the light
  45483. * @param direction The direction of the light
  45484. * @param scene The scene the light belongs to
  45485. */
  45486. function DirectionalLight(name, direction, scene) {
  45487. var _this = _super.call(this, name, scene) || this;
  45488. _this._shadowFrustumSize = 0;
  45489. _this._shadowOrthoScale = 0.1;
  45490. /**
  45491. * Automatically compute the projection matrix to best fit (including all the casters)
  45492. * on each frame.
  45493. */
  45494. _this.autoUpdateExtends = true;
  45495. // Cache
  45496. _this._orthoLeft = Number.MAX_VALUE;
  45497. _this._orthoRight = Number.MIN_VALUE;
  45498. _this._orthoTop = Number.MIN_VALUE;
  45499. _this._orthoBottom = Number.MAX_VALUE;
  45500. _this.position = direction.scale(-1.0);
  45501. _this.direction = direction;
  45502. return _this;
  45503. }
  45504. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45505. /**
  45506. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45507. */
  45508. get: function () {
  45509. return this._shadowFrustumSize;
  45510. },
  45511. /**
  45512. * Specifies a fix frustum size for the shadow generation.
  45513. */
  45514. set: function (value) {
  45515. this._shadowFrustumSize = value;
  45516. this.forceProjectionMatrixCompute();
  45517. },
  45518. enumerable: true,
  45519. configurable: true
  45520. });
  45521. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45522. /**
  45523. * Gets the shadow projection scale against the optimal computed one.
  45524. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45525. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45526. */
  45527. get: function () {
  45528. return this._shadowOrthoScale;
  45529. },
  45530. /**
  45531. * Sets the shadow projection scale against the optimal computed one.
  45532. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45533. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45534. */
  45535. set: function (value) {
  45536. this._shadowOrthoScale = value;
  45537. this.forceProjectionMatrixCompute();
  45538. },
  45539. enumerable: true,
  45540. configurable: true
  45541. });
  45542. /**
  45543. * Returns the string "DirectionalLight".
  45544. * @return The class name
  45545. */
  45546. DirectionalLight.prototype.getClassName = function () {
  45547. return "DirectionalLight";
  45548. };
  45549. /**
  45550. * Returns the integer 1.
  45551. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45552. */
  45553. DirectionalLight.prototype.getTypeID = function () {
  45554. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45555. };
  45556. /**
  45557. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45558. * Returns the DirectionalLight Shadow projection matrix.
  45559. */
  45560. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45561. if (this.shadowFrustumSize > 0) {
  45562. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45563. }
  45564. else {
  45565. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45566. }
  45567. };
  45568. /**
  45569. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45570. * Returns the DirectionalLight Shadow projection matrix.
  45571. */
  45572. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45573. var activeCamera = this.getScene().activeCamera;
  45574. if (!activeCamera) {
  45575. return;
  45576. }
  45577. _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);
  45578. };
  45579. /**
  45580. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45581. * Returns the DirectionalLight Shadow projection matrix.
  45582. */
  45583. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45584. var activeCamera = this.getScene().activeCamera;
  45585. if (!activeCamera) {
  45586. return;
  45587. }
  45588. // Check extends
  45589. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45590. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45591. this._orthoLeft = Number.MAX_VALUE;
  45592. this._orthoRight = Number.MIN_VALUE;
  45593. this._orthoTop = Number.MIN_VALUE;
  45594. this._orthoBottom = Number.MAX_VALUE;
  45595. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45596. var mesh = renderList[meshIndex];
  45597. if (!mesh) {
  45598. continue;
  45599. }
  45600. var boundingInfo = mesh.getBoundingInfo();
  45601. var boundingBox = boundingInfo.boundingBox;
  45602. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45603. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45604. if (tempVector3.x < this._orthoLeft) {
  45605. this._orthoLeft = tempVector3.x;
  45606. }
  45607. if (tempVector3.y < this._orthoBottom) {
  45608. this._orthoBottom = tempVector3.y;
  45609. }
  45610. if (tempVector3.x > this._orthoRight) {
  45611. this._orthoRight = tempVector3.x;
  45612. }
  45613. if (tempVector3.y > this._orthoTop) {
  45614. this._orthoTop = tempVector3.y;
  45615. }
  45616. }
  45617. }
  45618. }
  45619. var xOffset = this._orthoRight - this._orthoLeft;
  45620. var yOffset = this._orthoTop - this._orthoBottom;
  45621. _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);
  45622. };
  45623. DirectionalLight.prototype._buildUniformLayout = function () {
  45624. this._uniformBuffer.addUniform("vLightData", 4);
  45625. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45626. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45627. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45628. this._uniformBuffer.addUniform("depthValues", 2);
  45629. this._uniformBuffer.create();
  45630. };
  45631. /**
  45632. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45633. * @param effect The effect to update
  45634. * @param lightIndex The index of the light in the effect to update
  45635. * @returns The directional light
  45636. */
  45637. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45638. if (this.computeTransformedInformation()) {
  45639. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45640. return this;
  45641. }
  45642. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45643. return this;
  45644. };
  45645. /**
  45646. * Gets the minZ used for shadow according to both the scene and the light.
  45647. *
  45648. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45649. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45650. * @param activeCamera The camera we are returning the min for
  45651. * @returns the depth min z
  45652. */
  45653. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45654. return 1;
  45655. };
  45656. /**
  45657. * Gets the maxZ used for shadow according to both the scene and the light.
  45658. *
  45659. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45660. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45661. * @param activeCamera The camera we are returning the max for
  45662. * @returns the depth max z
  45663. */
  45664. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45665. return 1;
  45666. };
  45667. /**
  45668. * Prepares the list of defines specific to the light type.
  45669. * @param defines the list of defines
  45670. * @param lightIndex defines the index of the light for the effect
  45671. */
  45672. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45673. defines["DIRLIGHT" + lightIndex] = true;
  45674. };
  45675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45677. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45680. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45683. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45684. return DirectionalLight;
  45685. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45686. /***/ }),
  45687. /***/ "./Lights/hemisphericLight.ts":
  45688. /*!************************************!*\
  45689. !*** ./Lights/hemisphericLight.ts ***!
  45690. \************************************/
  45691. /*! exports provided: HemisphericLight */
  45692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45693. "use strict";
  45694. __webpack_require__.r(__webpack_exports__);
  45695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45696. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45697. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45699. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45700. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45701. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45702. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45703. });
  45704. /**
  45705. * The HemisphericLight simulates the ambient environment light,
  45706. * so the passed direction is the light reflection direction, not the incoming direction.
  45707. */
  45708. var HemisphericLight = /** @class */ (function (_super) {
  45709. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  45710. /**
  45711. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  45712. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  45713. * The HemisphericLight can't cast shadows.
  45714. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45715. * @param name The friendly name of the light
  45716. * @param direction The direction of the light reflection
  45717. * @param scene The scene the light belongs to
  45718. */
  45719. function HemisphericLight(name, direction, scene) {
  45720. var _this = _super.call(this, name, scene) || this;
  45721. /**
  45722. * The groundColor is the light in the opposite direction to the one specified during creation.
  45723. * 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.
  45724. */
  45725. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  45726. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  45727. return _this;
  45728. }
  45729. HemisphericLight.prototype._buildUniformLayout = function () {
  45730. this._uniformBuffer.addUniform("vLightData", 4);
  45731. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45732. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45733. this._uniformBuffer.addUniform("vLightGround", 3);
  45734. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45735. this._uniformBuffer.addUniform("depthValues", 2);
  45736. this._uniformBuffer.create();
  45737. };
  45738. /**
  45739. * Returns the string "HemisphericLight".
  45740. * @return The class name
  45741. */
  45742. HemisphericLight.prototype.getClassName = function () {
  45743. return "HemisphericLight";
  45744. };
  45745. /**
  45746. * Sets the HemisphericLight direction towards the passed target (Vector3).
  45747. * Returns the updated direction.
  45748. * @param target The target the direction should point to
  45749. * @return The computed direction
  45750. */
  45751. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  45752. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  45753. return this.direction;
  45754. };
  45755. /**
  45756. * Returns the shadow generator associated to the light.
  45757. * @returns Always null for hemispheric lights because it does not support shadows.
  45758. */
  45759. HemisphericLight.prototype.getShadowGenerator = function () {
  45760. return null;
  45761. };
  45762. /**
  45763. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  45764. * @param effect The effect to update
  45765. * @param lightIndex The index of the light in the effect to update
  45766. * @returns The hemispheric light
  45767. */
  45768. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  45769. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  45770. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  45771. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  45772. return this;
  45773. };
  45774. /**
  45775. * Computes the world matrix of the node
  45776. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  45777. * @param useWasUpdatedFlag defines a reserved property
  45778. * @returns the world matrix
  45779. */
  45780. HemisphericLight.prototype.computeWorldMatrix = function () {
  45781. if (!this._worldMatrix) {
  45782. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  45783. }
  45784. return this._worldMatrix;
  45785. };
  45786. /**
  45787. * Returns the integer 3.
  45788. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45789. */
  45790. HemisphericLight.prototype.getTypeID = function () {
  45791. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  45792. };
  45793. /**
  45794. * Prepares the list of defines specific to the light type.
  45795. * @param defines the list of defines
  45796. * @param lightIndex defines the index of the light for the effect
  45797. */
  45798. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45799. defines["HEMILIGHT" + lightIndex] = true;
  45800. };
  45801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45803. ], HemisphericLight.prototype, "groundColor", void 0);
  45804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  45806. ], HemisphericLight.prototype, "direction", void 0);
  45807. return HemisphericLight;
  45808. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  45809. /***/ }),
  45810. /***/ "./Lights/index.ts":
  45811. /*!*************************!*\
  45812. !*** ./Lights/index.ts ***!
  45813. \*************************/
  45814. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  45815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45816. "use strict";
  45817. __webpack_require__.r(__webpack_exports__);
  45818. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  45820. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  45822. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  45823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  45824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  45825. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  45826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  45827. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  45828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  45829. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  45830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  45831. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  45832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  45833. /***/ }),
  45834. /***/ "./Lights/light.ts":
  45835. /*!*************************!*\
  45836. !*** ./Lights/light.ts ***!
  45837. \*************************/
  45838. /*! exports provided: Light */
  45839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45840. "use strict";
  45841. __webpack_require__.r(__webpack_exports__);
  45842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  45843. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45844. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45845. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45846. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45847. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  45848. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  45849. /**
  45850. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  45851. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  45852. * 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.
  45853. */
  45854. var Light = /** @class */ (function (_super) {
  45855. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  45856. /**
  45857. * Creates a Light object in the scene.
  45858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45859. * @param name The firendly name of the light
  45860. * @param scene The scene the light belongs too
  45861. */
  45862. function Light(name, scene) {
  45863. var _this = _super.call(this, name, scene) || this;
  45864. /**
  45865. * Diffuse gives the basic color to an object.
  45866. */
  45867. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45868. /**
  45869. * Specular produces a highlight color on an object.
  45870. * Note: This is note affecting PBR materials.
  45871. */
  45872. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45873. /**
  45874. * Defines the falloff type for this light. This lets overrriding how punctual light are
  45875. * falling off base on range or angle.
  45876. * This can be set to any values in Light.FALLOFF_x.
  45877. *
  45878. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  45879. * other types of materials.
  45880. */
  45881. _this.falloffType = Light.FALLOFF_DEFAULT;
  45882. /**
  45883. * Strength of the light.
  45884. * Note: By default it is define in the framework own unit.
  45885. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  45886. */
  45887. _this.intensity = 1.0;
  45888. _this._range = Number.MAX_VALUE;
  45889. _this._inverseSquaredRange = 0;
  45890. /**
  45891. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  45892. * of light.
  45893. */
  45894. _this._photometricScale = 1.0;
  45895. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  45896. _this._radius = 0.00001;
  45897. /**
  45898. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  45899. * exceeding the number allowed of the materials.
  45900. */
  45901. _this.renderPriority = 0;
  45902. _this._shadowEnabled = true;
  45903. _this._excludeWithLayerMask = 0;
  45904. _this._includeOnlyWithLayerMask = 0;
  45905. _this._lightmapMode = 0;
  45906. /**
  45907. * @hidden Internal use only.
  45908. */
  45909. _this._excludedMeshesIds = new Array();
  45910. /**
  45911. * @hidden Internal use only.
  45912. */
  45913. _this._includedOnlyMeshesIds = new Array();
  45914. /** @hidden */
  45915. _this._isLight = true;
  45916. _this.getScene().addLight(_this);
  45917. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  45918. _this._buildUniformLayout();
  45919. _this.includedOnlyMeshes = new Array();
  45920. _this.excludedMeshes = new Array();
  45921. _this._resyncMeshes();
  45922. return _this;
  45923. }
  45924. Object.defineProperty(Light.prototype, "range", {
  45925. /**
  45926. * Defines how far from the source the light is impacting in scene units.
  45927. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45928. */
  45929. get: function () {
  45930. return this._range;
  45931. },
  45932. /**
  45933. * Defines how far from the source the light is impacting in scene units.
  45934. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45935. */
  45936. set: function (value) {
  45937. this._range = value;
  45938. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  45939. },
  45940. enumerable: true,
  45941. configurable: true
  45942. });
  45943. Object.defineProperty(Light.prototype, "intensityMode", {
  45944. /**
  45945. * Gets the photometric scale used to interpret the intensity.
  45946. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45947. */
  45948. get: function () {
  45949. return this._intensityMode;
  45950. },
  45951. /**
  45952. * Sets the photometric scale used to interpret the intensity.
  45953. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45954. */
  45955. set: function (value) {
  45956. this._intensityMode = value;
  45957. this._computePhotometricScale();
  45958. },
  45959. enumerable: true,
  45960. configurable: true
  45961. });
  45962. Object.defineProperty(Light.prototype, "radius", {
  45963. /**
  45964. * Gets the light radius used by PBR Materials to simulate soft area lights.
  45965. */
  45966. get: function () {
  45967. return this._radius;
  45968. },
  45969. /**
  45970. * sets the light radius used by PBR Materials to simulate soft area lights.
  45971. */
  45972. set: function (value) {
  45973. this._radius = value;
  45974. this._computePhotometricScale();
  45975. },
  45976. enumerable: true,
  45977. configurable: true
  45978. });
  45979. Object.defineProperty(Light.prototype, "shadowEnabled", {
  45980. /**
  45981. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45982. * the current shadow generator.
  45983. */
  45984. get: function () {
  45985. return this._shadowEnabled;
  45986. },
  45987. /**
  45988. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45989. * the current shadow generator.
  45990. */
  45991. set: function (value) {
  45992. if (this._shadowEnabled === value) {
  45993. return;
  45994. }
  45995. this._shadowEnabled = value;
  45996. this._markMeshesAsLightDirty();
  45997. },
  45998. enumerable: true,
  45999. configurable: true
  46000. });
  46001. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46002. /**
  46003. * Gets the only meshes impacted by this light.
  46004. */
  46005. get: function () {
  46006. return this._includedOnlyMeshes;
  46007. },
  46008. /**
  46009. * Sets the only meshes impacted by this light.
  46010. */
  46011. set: function (value) {
  46012. this._includedOnlyMeshes = value;
  46013. this._hookArrayForIncludedOnly(value);
  46014. },
  46015. enumerable: true,
  46016. configurable: true
  46017. });
  46018. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46019. /**
  46020. * Gets the meshes not impacted by this light.
  46021. */
  46022. get: function () {
  46023. return this._excludedMeshes;
  46024. },
  46025. /**
  46026. * Sets the meshes not impacted by this light.
  46027. */
  46028. set: function (value) {
  46029. this._excludedMeshes = value;
  46030. this._hookArrayForExcluded(value);
  46031. },
  46032. enumerable: true,
  46033. configurable: true
  46034. });
  46035. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46036. /**
  46037. * Gets the layer id use to find what meshes are not impacted by the light.
  46038. * Inactive if 0
  46039. */
  46040. get: function () {
  46041. return this._excludeWithLayerMask;
  46042. },
  46043. /**
  46044. * Sets the layer id use to find what meshes are not impacted by the light.
  46045. * Inactive if 0
  46046. */
  46047. set: function (value) {
  46048. this._excludeWithLayerMask = value;
  46049. this._resyncMeshes();
  46050. },
  46051. enumerable: true,
  46052. configurable: true
  46053. });
  46054. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46055. /**
  46056. * Gets the layer id use to find what meshes are impacted by the light.
  46057. * Inactive if 0
  46058. */
  46059. get: function () {
  46060. return this._includeOnlyWithLayerMask;
  46061. },
  46062. /**
  46063. * Sets the layer id use to find what meshes are impacted by the light.
  46064. * Inactive if 0
  46065. */
  46066. set: function (value) {
  46067. this._includeOnlyWithLayerMask = value;
  46068. this._resyncMeshes();
  46069. },
  46070. enumerable: true,
  46071. configurable: true
  46072. });
  46073. Object.defineProperty(Light.prototype, "lightmapMode", {
  46074. /**
  46075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46076. */
  46077. get: function () {
  46078. return this._lightmapMode;
  46079. },
  46080. /**
  46081. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46082. */
  46083. set: function (value) {
  46084. if (this._lightmapMode === value) {
  46085. return;
  46086. }
  46087. this._lightmapMode = value;
  46088. this._markMeshesAsLightDirty();
  46089. },
  46090. enumerable: true,
  46091. configurable: true
  46092. });
  46093. /**
  46094. * Returns the string "Light".
  46095. * @returns the class name
  46096. */
  46097. Light.prototype.getClassName = function () {
  46098. return "Light";
  46099. };
  46100. /**
  46101. * Converts the light information to a readable string for debug purpose.
  46102. * @param fullDetails Supports for multiple levels of logging within scene loading
  46103. * @returns the human readable light info
  46104. */
  46105. Light.prototype.toString = function (fullDetails) {
  46106. var ret = "Name: " + this.name;
  46107. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46108. if (this.animations) {
  46109. for (var i = 0; i < this.animations.length; i++) {
  46110. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46111. }
  46112. }
  46113. if (fullDetails) {
  46114. }
  46115. return ret;
  46116. };
  46117. /** @hidden */
  46118. Light.prototype._syncParentEnabledState = function () {
  46119. _super.prototype._syncParentEnabledState.call(this);
  46120. this._resyncMeshes();
  46121. };
  46122. /**
  46123. * Set the enabled state of this node.
  46124. * @param value - the new enabled state
  46125. */
  46126. Light.prototype.setEnabled = function (value) {
  46127. _super.prototype.setEnabled.call(this, value);
  46128. this._resyncMeshes();
  46129. };
  46130. /**
  46131. * Returns the Light associated shadow generator if any.
  46132. * @return the associated shadow generator.
  46133. */
  46134. Light.prototype.getShadowGenerator = function () {
  46135. return this._shadowGenerator;
  46136. };
  46137. /**
  46138. * Returns a Vector3, the absolute light position in the World.
  46139. * @returns the world space position of the light
  46140. */
  46141. Light.prototype.getAbsolutePosition = function () {
  46142. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46143. };
  46144. /**
  46145. * Specifies if the light will affect the passed mesh.
  46146. * @param mesh The mesh to test against the light
  46147. * @return true the mesh is affected otherwise, false.
  46148. */
  46149. Light.prototype.canAffectMesh = function (mesh) {
  46150. if (!mesh) {
  46151. return true;
  46152. }
  46153. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  46154. return false;
  46155. }
  46156. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  46157. return false;
  46158. }
  46159. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  46160. return false;
  46161. }
  46162. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  46163. return false;
  46164. }
  46165. return true;
  46166. };
  46167. /**
  46168. * Sort function to order lights for rendering.
  46169. * @param a First Light object to compare to second.
  46170. * @param b Second Light object to compare first.
  46171. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  46172. */
  46173. Light.CompareLightsPriority = function (a, b) {
  46174. //shadow-casting lights have priority over non-shadow-casting lights
  46175. //the renderPrioirty is a secondary sort criterion
  46176. if (a.shadowEnabled !== b.shadowEnabled) {
  46177. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  46178. }
  46179. return b.renderPriority - a.renderPriority;
  46180. };
  46181. /**
  46182. * Releases resources associated with this node.
  46183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46185. */
  46186. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  46187. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  46188. if (this._shadowGenerator) {
  46189. this._shadowGenerator.dispose();
  46190. this._shadowGenerator = null;
  46191. }
  46192. // Animations
  46193. this.getScene().stopAnimation(this);
  46194. // Remove from meshes
  46195. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46196. var mesh = _a[_i];
  46197. mesh._removeLightSource(this);
  46198. }
  46199. this._uniformBuffer.dispose();
  46200. // Remove from scene
  46201. this.getScene().removeLight(this);
  46202. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  46203. };
  46204. /**
  46205. * Returns the light type ID (integer).
  46206. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46207. */
  46208. Light.prototype.getTypeID = function () {
  46209. return 0;
  46210. };
  46211. /**
  46212. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  46213. * @returns the scaled intensity in intensity mode unit
  46214. */
  46215. Light.prototype.getScaledIntensity = function () {
  46216. return this._photometricScale * this.intensity;
  46217. };
  46218. /**
  46219. * Returns a new Light object, named "name", from the current one.
  46220. * @param name The name of the cloned light
  46221. * @returns the new created light
  46222. */
  46223. Light.prototype.clone = function (name) {
  46224. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  46225. if (!constructor) {
  46226. return null;
  46227. }
  46228. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  46229. };
  46230. /**
  46231. * Serializes the current light into a Serialization object.
  46232. * @returns the serialized object.
  46233. */
  46234. Light.prototype.serialize = function () {
  46235. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46236. // Type
  46237. serializationObject.type = this.getTypeID();
  46238. // Parent
  46239. if (this.parent) {
  46240. serializationObject.parentId = this.parent.id;
  46241. }
  46242. // Inclusion / exclusions
  46243. if (this.excludedMeshes.length > 0) {
  46244. serializationObject.excludedMeshesIds = [];
  46245. this.excludedMeshes.forEach(function (mesh) {
  46246. serializationObject.excludedMeshesIds.push(mesh.id);
  46247. });
  46248. }
  46249. if (this.includedOnlyMeshes.length > 0) {
  46250. serializationObject.includedOnlyMeshesIds = [];
  46251. this.includedOnlyMeshes.forEach(function (mesh) {
  46252. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  46253. });
  46254. }
  46255. // Animations
  46256. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  46257. serializationObject.ranges = this.serializeAnimationRanges();
  46258. return serializationObject;
  46259. };
  46260. /**
  46261. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  46262. * This new light is named "name" and added to the passed scene.
  46263. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  46264. * @param name The friendly name of the light
  46265. * @param scene The scene the new light will belong to
  46266. * @returns the constructor function
  46267. */
  46268. Light.GetConstructorFromName = function (type, name, scene) {
  46269. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  46270. if (constructorFunc) {
  46271. return constructorFunc;
  46272. }
  46273. // Default to no light for none present once.
  46274. return null;
  46275. };
  46276. /**
  46277. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  46278. * @param parsedLight The JSON representation of the light
  46279. * @param scene The scene to create the parsed light in
  46280. * @returns the created light after parsing
  46281. */
  46282. Light.Parse = function (parsedLight, scene) {
  46283. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  46284. if (!constructor) {
  46285. return null;
  46286. }
  46287. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  46288. // Inclusion / exclusions
  46289. if (parsedLight.excludedMeshesIds) {
  46290. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  46291. }
  46292. if (parsedLight.includedOnlyMeshesIds) {
  46293. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  46294. }
  46295. // Parent
  46296. if (parsedLight.parentId) {
  46297. light._waitingParentId = parsedLight.parentId;
  46298. }
  46299. // Animations
  46300. if (parsedLight.animations) {
  46301. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  46302. var parsedAnimation = parsedLight.animations[animationIndex];
  46303. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  46304. if (internalClass) {
  46305. light.animations.push(internalClass.Parse(parsedAnimation));
  46306. }
  46307. }
  46308. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  46309. }
  46310. if (parsedLight.autoAnimate) {
  46311. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  46312. }
  46313. return light;
  46314. };
  46315. Light.prototype._hookArrayForExcluded = function (array) {
  46316. var _this = this;
  46317. var oldPush = array.push;
  46318. array.push = function () {
  46319. var items = [];
  46320. for (var _i = 0; _i < arguments.length; _i++) {
  46321. items[_i] = arguments[_i];
  46322. }
  46323. var result = oldPush.apply(array, items);
  46324. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  46325. var item = items_1[_a];
  46326. item._resyncLighSource(_this);
  46327. }
  46328. return result;
  46329. };
  46330. var oldSplice = array.splice;
  46331. array.splice = function (index, deleteCount) {
  46332. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46333. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  46334. var item = deleted_1[_i];
  46335. item._resyncLighSource(_this);
  46336. }
  46337. return deleted;
  46338. };
  46339. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46340. var item = array_1[_i];
  46341. item._resyncLighSource(this);
  46342. }
  46343. };
  46344. Light.prototype._hookArrayForIncludedOnly = function (array) {
  46345. var _this = this;
  46346. var oldPush = array.push;
  46347. array.push = function () {
  46348. var items = [];
  46349. for (var _i = 0; _i < arguments.length; _i++) {
  46350. items[_i] = arguments[_i];
  46351. }
  46352. var result = oldPush.apply(array, items);
  46353. _this._resyncMeshes();
  46354. return result;
  46355. };
  46356. var oldSplice = array.splice;
  46357. array.splice = function (index, deleteCount) {
  46358. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46359. _this._resyncMeshes();
  46360. return deleted;
  46361. };
  46362. this._resyncMeshes();
  46363. };
  46364. Light.prototype._resyncMeshes = function () {
  46365. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46366. var mesh = _a[_i];
  46367. mesh._resyncLighSource(this);
  46368. }
  46369. };
  46370. /**
  46371. * Forces the meshes to update their light related information in their rendering used effects
  46372. * @hidden Internal Use Only
  46373. */
  46374. Light.prototype._markMeshesAsLightDirty = function () {
  46375. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46376. var mesh = _a[_i];
  46377. if (mesh._lightSources.indexOf(this) !== -1) {
  46378. mesh._markSubMeshesAsLightDirty();
  46379. }
  46380. }
  46381. };
  46382. /**
  46383. * Recomputes the cached photometric scale if needed.
  46384. */
  46385. Light.prototype._computePhotometricScale = function () {
  46386. this._photometricScale = this._getPhotometricScale();
  46387. this.getScene().resetCachedMaterial();
  46388. };
  46389. /**
  46390. * Returns the Photometric Scale according to the light type and intensity mode.
  46391. */
  46392. Light.prototype._getPhotometricScale = function () {
  46393. var photometricScale = 0.0;
  46394. var lightTypeID = this.getTypeID();
  46395. //get photometric mode
  46396. var photometricMode = this.intensityMode;
  46397. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  46398. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  46399. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  46400. }
  46401. else {
  46402. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  46403. }
  46404. }
  46405. //compute photometric scale
  46406. switch (lightTypeID) {
  46407. case Light.LIGHTTYPEID_POINTLIGHT:
  46408. case Light.LIGHTTYPEID_SPOTLIGHT:
  46409. switch (photometricMode) {
  46410. case Light.INTENSITYMODE_LUMINOUSPOWER:
  46411. photometricScale = 1.0 / (4.0 * Math.PI);
  46412. break;
  46413. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  46414. photometricScale = 1.0;
  46415. break;
  46416. case Light.INTENSITYMODE_LUMINANCE:
  46417. photometricScale = this.radius * this.radius;
  46418. break;
  46419. }
  46420. break;
  46421. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  46422. switch (photometricMode) {
  46423. case Light.INTENSITYMODE_ILLUMINANCE:
  46424. photometricScale = 1.0;
  46425. break;
  46426. case Light.INTENSITYMODE_LUMINANCE:
  46427. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  46428. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  46429. var apexAngleRadians = this.radius;
  46430. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  46431. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  46432. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  46433. photometricScale = solidAngle;
  46434. break;
  46435. }
  46436. break;
  46437. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  46438. // No fall off in hemisperic light.
  46439. photometricScale = 1.0;
  46440. break;
  46441. }
  46442. return photometricScale;
  46443. };
  46444. /**
  46445. * Reorder the light in the scene according to their defined priority.
  46446. * @hidden Internal Use Only
  46447. */
  46448. Light.prototype._reorderLightsInScene = function () {
  46449. var scene = this.getScene();
  46450. if (this._renderPriority != 0) {
  46451. scene.requireLightSorting = true;
  46452. }
  46453. this.getScene().sortLightsByPriority();
  46454. };
  46455. /**
  46456. * Falloff Default: light is falling off following the material specification:
  46457. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  46458. */
  46459. Light.FALLOFF_DEFAULT = 0;
  46460. /**
  46461. * Falloff Physical: light is falling off following the inverse squared distance law.
  46462. */
  46463. Light.FALLOFF_PHYSICAL = 1;
  46464. /**
  46465. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  46466. * to enhance interoperability with other engines.
  46467. */
  46468. Light.FALLOFF_GLTF = 2;
  46469. /**
  46470. * Falloff Standard: light is falling off like in the standard material
  46471. * to enhance interoperability with other materials.
  46472. */
  46473. Light.FALLOFF_STANDARD = 3;
  46474. //lightmapMode Consts
  46475. /**
  46476. * If every light affecting the material is in this lightmapMode,
  46477. * material.lightmapTexture adds or multiplies
  46478. * (depends on material.useLightmapAsShadowmap)
  46479. * after every other light calculations.
  46480. */
  46481. Light.LIGHTMAP_DEFAULT = 0;
  46482. /**
  46483. * material.lightmapTexture as only diffuse lighting from this light
  46484. * adds only specular lighting from this light
  46485. * adds dynamic shadows
  46486. */
  46487. Light.LIGHTMAP_SPECULAR = 1;
  46488. /**
  46489. * material.lightmapTexture as only lighting
  46490. * no light calculation from this light
  46491. * only adds dynamic shadows from this light
  46492. */
  46493. Light.LIGHTMAP_SHADOWSONLY = 2;
  46494. // Intensity Mode Consts
  46495. /**
  46496. * Each light type uses the default quantity according to its type:
  46497. * point/spot lights use luminous intensity
  46498. * directional lights use illuminance
  46499. */
  46500. Light.INTENSITYMODE_AUTOMATIC = 0;
  46501. /**
  46502. * lumen (lm)
  46503. */
  46504. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46505. /**
  46506. * candela (lm/sr)
  46507. */
  46508. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46509. /**
  46510. * lux (lm/m^2)
  46511. */
  46512. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46513. /**
  46514. * nit (cd/m^2)
  46515. */
  46516. Light.INTENSITYMODE_LUMINANCE = 4;
  46517. // Light types ids const.
  46518. /**
  46519. * Light type const id of the point light.
  46520. */
  46521. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46522. /**
  46523. * Light type const id of the directional light.
  46524. */
  46525. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46526. /**
  46527. * Light type const id of the spot light.
  46528. */
  46529. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46530. /**
  46531. * Light type const id of the hemispheric light.
  46532. */
  46533. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46536. ], Light.prototype, "diffuse", void 0);
  46537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46539. ], Light.prototype, "specular", void 0);
  46540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46542. ], Light.prototype, "falloffType", void 0);
  46543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46545. ], Light.prototype, "intensity", void 0);
  46546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46548. ], Light.prototype, "range", null);
  46549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46551. ], Light.prototype, "intensityMode", null);
  46552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46554. ], Light.prototype, "radius", null);
  46555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46557. ], Light.prototype, "_renderPriority", void 0);
  46558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46560. ], Light.prototype, "renderPriority", void 0);
  46561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46563. ], Light.prototype, "_shadowEnabled", void 0);
  46564. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46566. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46567. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46568. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46569. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46570. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46572. ], Light.prototype, "_lightmapMode", void 0);
  46573. return Light;
  46574. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46575. /***/ }),
  46576. /***/ "./Lights/pointLight.ts":
  46577. /*!******************************!*\
  46578. !*** ./Lights/pointLight.ts ***!
  46579. \******************************/
  46580. /*! exports provided: PointLight */
  46581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46582. "use strict";
  46583. __webpack_require__.r(__webpack_exports__);
  46584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46585. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46586. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46587. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46588. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46589. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46590. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46591. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46592. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46593. });
  46594. /**
  46595. * A point light is a light defined by an unique point in world space.
  46596. * The light is emitted in every direction from this point.
  46597. * A good example of a point light is a standard light bulb.
  46598. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46599. */
  46600. var PointLight = /** @class */ (function (_super) {
  46601. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46602. /**
  46603. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46604. * A PointLight emits the light in every direction.
  46605. * It can cast shadows.
  46606. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46607. * ```javascript
  46608. * var pointLight = new PointLight("pl", camera.position, scene);
  46609. * ```
  46610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46611. * @param name The light friendly name
  46612. * @param position The position of the point light in the scene
  46613. * @param scene The scene the lights belongs to
  46614. */
  46615. function PointLight(name, position, scene) {
  46616. var _this = _super.call(this, name, scene) || this;
  46617. _this._shadowAngle = Math.PI / 2;
  46618. _this.position = position;
  46619. return _this;
  46620. }
  46621. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46622. /**
  46623. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46624. * This specifies what angle the shadow will use to be created.
  46625. *
  46626. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46627. */
  46628. get: function () {
  46629. return this._shadowAngle;
  46630. },
  46631. /**
  46632. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46633. * This specifies what angle the shadow will use to be created.
  46634. *
  46635. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46636. */
  46637. set: function (value) {
  46638. this._shadowAngle = value;
  46639. this.forceProjectionMatrixCompute();
  46640. },
  46641. enumerable: true,
  46642. configurable: true
  46643. });
  46644. Object.defineProperty(PointLight.prototype, "direction", {
  46645. /**
  46646. * Gets the direction if it has been set.
  46647. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46648. */
  46649. get: function () {
  46650. return this._direction;
  46651. },
  46652. /**
  46653. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46654. */
  46655. set: function (value) {
  46656. var previousNeedCube = this.needCube();
  46657. this._direction = value;
  46658. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46659. this._shadowGenerator.recreateShadowMap();
  46660. }
  46661. },
  46662. enumerable: true,
  46663. configurable: true
  46664. });
  46665. /**
  46666. * Returns the string "PointLight"
  46667. * @returns the class name
  46668. */
  46669. PointLight.prototype.getClassName = function () {
  46670. return "PointLight";
  46671. };
  46672. /**
  46673. * Returns the integer 0.
  46674. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46675. */
  46676. PointLight.prototype.getTypeID = function () {
  46677. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46678. };
  46679. /**
  46680. * Specifies wether or not the shadowmap should be a cube texture.
  46681. * @returns true if the shadowmap needs to be a cube texture.
  46682. */
  46683. PointLight.prototype.needCube = function () {
  46684. return !this.direction;
  46685. };
  46686. /**
  46687. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46688. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46689. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46690. */
  46691. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46692. if (this.direction) {
  46693. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46694. }
  46695. else {
  46696. switch (faceIndex) {
  46697. case 0:
  46698. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46699. case 1:
  46700. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46701. case 2:
  46702. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46703. case 3:
  46704. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46705. case 4:
  46706. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  46707. case 5:
  46708. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  46709. }
  46710. }
  46711. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46712. };
  46713. /**
  46714. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46715. * - fov = PI / 2
  46716. * - aspect ratio : 1.0
  46717. * - z-near and far equal to the active camera minZ and maxZ.
  46718. * Returns the PointLight.
  46719. */
  46720. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46721. var activeCamera = this.getScene().activeCamera;
  46722. if (!activeCamera) {
  46723. return;
  46724. }
  46725. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46726. };
  46727. PointLight.prototype._buildUniformLayout = function () {
  46728. this._uniformBuffer.addUniform("vLightData", 4);
  46729. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46730. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46731. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46732. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46733. this._uniformBuffer.addUniform("depthValues", 2);
  46734. this._uniformBuffer.create();
  46735. };
  46736. /**
  46737. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46738. * @param effect The effect to update
  46739. * @param lightIndex The index of the light in the effect to update
  46740. * @returns The point light
  46741. */
  46742. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  46743. if (this.computeTransformedInformation()) {
  46744. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  46745. }
  46746. else {
  46747. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  46748. }
  46749. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  46750. return this;
  46751. };
  46752. /**
  46753. * Prepares the list of defines specific to the light type.
  46754. * @param defines the list of defines
  46755. * @param lightIndex defines the index of the light for the effect
  46756. */
  46757. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46758. defines["POINTLIGHT" + lightIndex] = true;
  46759. };
  46760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46762. ], PointLight.prototype, "shadowAngle", null);
  46763. return PointLight;
  46764. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46765. /***/ }),
  46766. /***/ "./Lights/shadowLight.ts":
  46767. /*!*******************************!*\
  46768. !*** ./Lights/shadowLight.ts ***!
  46769. \*******************************/
  46770. /*! exports provided: ShadowLight */
  46771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46772. "use strict";
  46773. __webpack_require__.r(__webpack_exports__);
  46774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  46775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46776. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46777. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46778. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46779. /**
  46780. * Base implementation IShadowLight
  46781. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  46782. */
  46783. var ShadowLight = /** @class */ (function (_super) {
  46784. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  46785. function ShadowLight() {
  46786. var _this = _super !== null && _super.apply(this, arguments) || this;
  46787. _this._needProjectionMatrixCompute = true;
  46788. return _this;
  46789. }
  46790. ShadowLight.prototype._setPosition = function (value) {
  46791. this._position = value;
  46792. };
  46793. Object.defineProperty(ShadowLight.prototype, "position", {
  46794. /**
  46795. * Sets the position the shadow will be casted from. Also use as the light position for both
  46796. * point and spot lights.
  46797. */
  46798. get: function () {
  46799. return this._position;
  46800. },
  46801. /**
  46802. * Sets the position the shadow will be casted from. Also use as the light position for both
  46803. * point and spot lights.
  46804. */
  46805. set: function (value) {
  46806. this._setPosition(value);
  46807. },
  46808. enumerable: true,
  46809. configurable: true
  46810. });
  46811. ShadowLight.prototype._setDirection = function (value) {
  46812. this._direction = value;
  46813. };
  46814. Object.defineProperty(ShadowLight.prototype, "direction", {
  46815. /**
  46816. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  46817. * Also use as the light direction on spot and directional lights.
  46818. */
  46819. get: function () {
  46820. return this._direction;
  46821. },
  46822. /**
  46823. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  46824. * Also use as the light direction on spot and directional lights.
  46825. */
  46826. set: function (value) {
  46827. this._setDirection(value);
  46828. },
  46829. enumerable: true,
  46830. configurable: true
  46831. });
  46832. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  46833. /**
  46834. * Gets the shadow projection clipping minimum z value.
  46835. */
  46836. get: function () {
  46837. return this._shadowMinZ;
  46838. },
  46839. /**
  46840. * Sets the shadow projection clipping minimum z value.
  46841. */
  46842. set: function (value) {
  46843. this._shadowMinZ = value;
  46844. this.forceProjectionMatrixCompute();
  46845. },
  46846. enumerable: true,
  46847. configurable: true
  46848. });
  46849. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  46850. /**
  46851. * Sets the shadow projection clipping maximum z value.
  46852. */
  46853. get: function () {
  46854. return this._shadowMaxZ;
  46855. },
  46856. /**
  46857. * Gets the shadow projection clipping maximum z value.
  46858. */
  46859. set: function (value) {
  46860. this._shadowMaxZ = value;
  46861. this.forceProjectionMatrixCompute();
  46862. },
  46863. enumerable: true,
  46864. configurable: true
  46865. });
  46866. /**
  46867. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  46868. * @returns true if the information has been computed, false if it does not need to (no parenting)
  46869. */
  46870. ShadowLight.prototype.computeTransformedInformation = function () {
  46871. if (this.parent && this.parent.getWorldMatrix) {
  46872. if (!this.transformedPosition) {
  46873. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46874. }
  46875. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  46876. // In case the direction is present.
  46877. if (this.direction) {
  46878. if (!this.transformedDirection) {
  46879. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46880. }
  46881. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  46882. }
  46883. return true;
  46884. }
  46885. return false;
  46886. };
  46887. /**
  46888. * Return the depth scale used for the shadow map.
  46889. * @returns the depth scale.
  46890. */
  46891. ShadowLight.prototype.getDepthScale = function () {
  46892. return 50.0;
  46893. };
  46894. /**
  46895. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  46896. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46897. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46898. */
  46899. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  46900. return this.transformedDirection ? this.transformedDirection : this.direction;
  46901. };
  46902. /**
  46903. * Returns the ShadowLight absolute position in the World.
  46904. * @returns the position vector in world space
  46905. */
  46906. ShadowLight.prototype.getAbsolutePosition = function () {
  46907. return this.transformedPosition ? this.transformedPosition : this.position;
  46908. };
  46909. /**
  46910. * Sets the ShadowLight direction toward the passed target.
  46911. * @param target The point tot target in local space
  46912. * @returns the updated ShadowLight direction
  46913. */
  46914. ShadowLight.prototype.setDirectionToTarget = function (target) {
  46915. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  46916. return this.direction;
  46917. };
  46918. /**
  46919. * Returns the light rotation in euler definition.
  46920. * @returns the x y z rotation in local space.
  46921. */
  46922. ShadowLight.prototype.getRotation = function () {
  46923. this.direction.normalize();
  46924. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  46925. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  46926. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  46927. };
  46928. /**
  46929. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  46930. * @returns true if a cube texture needs to be use
  46931. */
  46932. ShadowLight.prototype.needCube = function () {
  46933. return false;
  46934. };
  46935. /**
  46936. * Detects if the projection matrix requires to be recomputed this frame.
  46937. * @returns true if it requires to be recomputed otherwise, false.
  46938. */
  46939. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  46940. return this._needProjectionMatrixCompute;
  46941. };
  46942. /**
  46943. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  46944. */
  46945. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  46946. this._needProjectionMatrixCompute = true;
  46947. };
  46948. /** @hidden */
  46949. ShadowLight.prototype._initCache = function () {
  46950. _super.prototype._initCache.call(this);
  46951. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46952. };
  46953. /** @hidden */
  46954. ShadowLight.prototype._isSynchronized = function () {
  46955. if (!this._cache.position.equals(this.position)) {
  46956. return false;
  46957. }
  46958. return true;
  46959. };
  46960. /**
  46961. * Computes the world matrix of the node
  46962. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46963. * @returns the world matrix
  46964. */
  46965. ShadowLight.prototype.computeWorldMatrix = function (force) {
  46966. if (!force && this.isSynchronized()) {
  46967. this._currentRenderId = this.getScene().getRenderId();
  46968. return this._worldMatrix;
  46969. }
  46970. this._updateCache();
  46971. this._cache.position.copyFrom(this.position);
  46972. if (!this._worldMatrix) {
  46973. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46974. }
  46975. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  46976. if (this.parent && this.parent.getWorldMatrix) {
  46977. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  46978. this._markSyncedWithParent();
  46979. }
  46980. // Cache the determinant
  46981. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  46982. return this._worldMatrix;
  46983. };
  46984. /**
  46985. * Gets the minZ used for shadow according to both the scene and the light.
  46986. * @param activeCamera The camera we are returning the min for
  46987. * @returns the depth min z
  46988. */
  46989. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  46990. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  46991. };
  46992. /**
  46993. * Gets the maxZ used for shadow according to both the scene and the light.
  46994. * @param activeCamera The camera we are returning the max for
  46995. * @returns the depth max z
  46996. */
  46997. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  46998. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  46999. };
  47000. /**
  47001. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47002. * @param matrix The materix to updated with the projection information
  47003. * @param viewMatrix The transform matrix of the light
  47004. * @param renderList The list of mesh to render in the map
  47005. * @returns The current light
  47006. */
  47007. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47008. if (this.customProjectionMatrixBuilder) {
  47009. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47010. }
  47011. else {
  47012. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47013. }
  47014. return this;
  47015. };
  47016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47018. ], ShadowLight.prototype, "position", null);
  47019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47021. ], ShadowLight.prototype, "direction", null);
  47022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47024. ], ShadowLight.prototype, "shadowMinZ", null);
  47025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47027. ], ShadowLight.prototype, "shadowMaxZ", null);
  47028. return ShadowLight;
  47029. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47030. /***/ }),
  47031. /***/ "./Lights/spotLight.ts":
  47032. /*!*****************************!*\
  47033. !*** ./Lights/spotLight.ts ***!
  47034. \*****************************/
  47035. /*! exports provided: SpotLight */
  47036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47037. "use strict";
  47038. __webpack_require__.r(__webpack_exports__);
  47039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47041. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47043. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47044. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47045. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47046. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47047. 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); };
  47048. });
  47049. /**
  47050. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47051. * These values define a cone of light starting from the position, emitting toward the direction.
  47052. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47053. * and the exponent defines the speed of the decay of the light with distance (reach).
  47054. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47055. */
  47056. var SpotLight = /** @class */ (function (_super) {
  47057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47058. /**
  47059. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47060. * It can cast shadows.
  47061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47062. * @param name The light friendly name
  47063. * @param position The position of the spot light in the scene
  47064. * @param direction The direction of the light in the scene
  47065. * @param angle The cone angle of the light in Radians
  47066. * @param exponent The light decay speed with the distance from the emission spot
  47067. * @param scene The scene the lights belongs to
  47068. */
  47069. function SpotLight(name, position, direction, angle, exponent, scene) {
  47070. var _this = _super.call(this, name, scene) || this;
  47071. _this._innerAngle = 0;
  47072. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47073. _this._projectionTextureLightNear = 1e-6;
  47074. _this._projectionTextureLightFar = 1000.0;
  47075. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47076. _this._projectionTextureViewLightDirty = true;
  47077. _this._projectionTextureProjectionLightDirty = true;
  47078. _this._projectionTextureDirty = true;
  47079. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47080. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47081. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47082. _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);
  47083. _this.position = position;
  47084. _this.direction = direction;
  47085. _this.angle = angle;
  47086. _this.exponent = exponent;
  47087. return _this;
  47088. }
  47089. Object.defineProperty(SpotLight.prototype, "angle", {
  47090. /**
  47091. * Gets the cone angle of the spot light in Radians.
  47092. */
  47093. get: function () {
  47094. return this._angle;
  47095. },
  47096. /**
  47097. * Sets the cone angle of the spot light in Radians.
  47098. */
  47099. set: function (value) {
  47100. this._angle = value;
  47101. this._cosHalfAngle = Math.cos(value * 0.5);
  47102. this._projectionTextureProjectionLightDirty = true;
  47103. this.forceProjectionMatrixCompute();
  47104. this._computeAngleValues();
  47105. },
  47106. enumerable: true,
  47107. configurable: true
  47108. });
  47109. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47110. /**
  47111. * Only used in gltf falloff mode, this defines the angle where
  47112. * the directional falloff will start before cutting at angle which could be seen
  47113. * as outer angle.
  47114. */
  47115. get: function () {
  47116. return this._innerAngle;
  47117. },
  47118. /**
  47119. * Only used in gltf falloff mode, this defines the angle where
  47120. * the directional falloff will start before cutting at angle which could be seen
  47121. * as outer angle.
  47122. */
  47123. set: function (value) {
  47124. this._innerAngle = value;
  47125. this._computeAngleValues();
  47126. },
  47127. enumerable: true,
  47128. configurable: true
  47129. });
  47130. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47131. /**
  47132. * Allows scaling the angle of the light for shadow generation only.
  47133. */
  47134. get: function () {
  47135. return this._shadowAngleScale;
  47136. },
  47137. /**
  47138. * Allows scaling the angle of the light for shadow generation only.
  47139. */
  47140. set: function (value) {
  47141. this._shadowAngleScale = value;
  47142. this.forceProjectionMatrixCompute();
  47143. },
  47144. enumerable: true,
  47145. configurable: true
  47146. });
  47147. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  47148. /**
  47149. * Allows reading the projecton texture
  47150. */
  47151. get: function () {
  47152. return this._projectionTextureMatrix;
  47153. },
  47154. enumerable: true,
  47155. configurable: true
  47156. });
  47157. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  47158. /**
  47159. * Gets the near clip of the Spotlight for texture projection.
  47160. */
  47161. get: function () {
  47162. return this._projectionTextureLightNear;
  47163. },
  47164. /**
  47165. * Sets the near clip of the Spotlight for texture projection.
  47166. */
  47167. set: function (value) {
  47168. this._projectionTextureLightNear = value;
  47169. this._projectionTextureProjectionLightDirty = true;
  47170. },
  47171. enumerable: true,
  47172. configurable: true
  47173. });
  47174. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  47175. /**
  47176. * Gets the far clip of the Spotlight for texture projection.
  47177. */
  47178. get: function () {
  47179. return this._projectionTextureLightFar;
  47180. },
  47181. /**
  47182. * Sets the far clip of the Spotlight for texture projection.
  47183. */
  47184. set: function (value) {
  47185. this._projectionTextureLightFar = value;
  47186. this._projectionTextureProjectionLightDirty = true;
  47187. },
  47188. enumerable: true,
  47189. configurable: true
  47190. });
  47191. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  47192. /**
  47193. * Gets the Up vector of the Spotlight for texture projection.
  47194. */
  47195. get: function () {
  47196. return this._projectionTextureUpDirection;
  47197. },
  47198. /**
  47199. * Sets the Up vector of the Spotlight for texture projection.
  47200. */
  47201. set: function (value) {
  47202. this._projectionTextureUpDirection = value;
  47203. this._projectionTextureProjectionLightDirty = true;
  47204. },
  47205. enumerable: true,
  47206. configurable: true
  47207. });
  47208. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  47209. /**
  47210. * Gets the projection texture of the light.
  47211. */
  47212. get: function () {
  47213. return this._projectionTexture;
  47214. },
  47215. /**
  47216. * Sets the projection texture of the light.
  47217. */
  47218. set: function (value) {
  47219. this._projectionTexture = value;
  47220. this._projectionTextureDirty = true;
  47221. },
  47222. enumerable: true,
  47223. configurable: true
  47224. });
  47225. /**
  47226. * Returns the string "SpotLight".
  47227. * @returns the class name
  47228. */
  47229. SpotLight.prototype.getClassName = function () {
  47230. return "SpotLight";
  47231. };
  47232. /**
  47233. * Returns the integer 2.
  47234. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47235. */
  47236. SpotLight.prototype.getTypeID = function () {
  47237. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  47238. };
  47239. /**
  47240. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47241. */
  47242. SpotLight.prototype._setDirection = function (value) {
  47243. _super.prototype._setDirection.call(this, value);
  47244. this._projectionTextureViewLightDirty = true;
  47245. };
  47246. /**
  47247. * Overrides the position setter to recompute the projection texture view light Matrix.
  47248. */
  47249. SpotLight.prototype._setPosition = function (value) {
  47250. _super.prototype._setPosition.call(this, value);
  47251. this._projectionTextureViewLightDirty = true;
  47252. };
  47253. /**
  47254. * 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.
  47255. * Returns the SpotLight.
  47256. */
  47257. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47258. var activeCamera = this.getScene().activeCamera;
  47259. if (!activeCamera) {
  47260. return;
  47261. }
  47262. this._shadowAngleScale = this._shadowAngleScale || 1;
  47263. var angle = this._shadowAngleScale * this._angle;
  47264. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47265. };
  47266. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  47267. this._projectionTextureViewLightDirty = false;
  47268. this._projectionTextureDirty = true;
  47269. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  47270. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  47271. };
  47272. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  47273. this._projectionTextureProjectionLightDirty = false;
  47274. this._projectionTextureDirty = true;
  47275. var light_far = this.projectionTextureLightFar;
  47276. var light_near = this.projectionTextureLightNear;
  47277. var P = light_far / (light_far - light_near);
  47278. var Q = -P * light_near;
  47279. var S = 1.0 / Math.tan(this._angle / 2.0);
  47280. var A = 1.0;
  47281. _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);
  47282. };
  47283. /**
  47284. * Main function for light texture projection matrix computing.
  47285. */
  47286. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  47287. this._projectionTextureDirty = false;
  47288. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  47289. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  47290. };
  47291. SpotLight.prototype._buildUniformLayout = function () {
  47292. this._uniformBuffer.addUniform("vLightData", 4);
  47293. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47294. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47295. this._uniformBuffer.addUniform("vLightDirection", 3);
  47296. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47297. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47298. this._uniformBuffer.addUniform("depthValues", 2);
  47299. this._uniformBuffer.create();
  47300. };
  47301. SpotLight.prototype._computeAngleValues = function () {
  47302. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  47303. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  47304. };
  47305. /**
  47306. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47307. * @param effect The effect to update
  47308. * @param lightIndex The index of the light in the effect to update
  47309. * @returns The spot light
  47310. */
  47311. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  47312. var normalizeDirection;
  47313. if (this.computeTransformedInformation()) {
  47314. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  47315. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  47316. }
  47317. else {
  47318. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  47319. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47320. }
  47321. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  47322. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  47323. if (this.projectionTexture && this.projectionTexture.isReady()) {
  47324. if (this._projectionTextureViewLightDirty) {
  47325. this._computeProjectionTextureViewLightMatrix();
  47326. }
  47327. if (this._projectionTextureProjectionLightDirty) {
  47328. this._computeProjectionTextureProjectionLightMatrix();
  47329. }
  47330. if (this._projectionTextureDirty) {
  47331. this._computeProjectionTextureMatrix();
  47332. }
  47333. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  47334. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  47335. }
  47336. return this;
  47337. };
  47338. /**
  47339. * Disposes the light and the associated resources.
  47340. */
  47341. SpotLight.prototype.dispose = function () {
  47342. _super.prototype.dispose.call(this);
  47343. if (this._projectionTexture) {
  47344. this._projectionTexture.dispose();
  47345. }
  47346. };
  47347. /**
  47348. * Prepares the list of defines specific to the light type.
  47349. * @param defines the list of defines
  47350. * @param lightIndex defines the index of the light for the effect
  47351. */
  47352. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47353. defines["SPOTLIGHT" + lightIndex] = true;
  47354. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  47355. };
  47356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47358. ], SpotLight.prototype, "angle", null);
  47359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47361. ], SpotLight.prototype, "innerAngle", null);
  47362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47364. ], SpotLight.prototype, "shadowAngleScale", null);
  47365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47367. ], SpotLight.prototype, "exponent", void 0);
  47368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47370. ], SpotLight.prototype, "projectionTextureLightNear", null);
  47371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47373. ], SpotLight.prototype, "projectionTextureLightFar", null);
  47374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47376. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  47377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  47379. ], SpotLight.prototype, "_projectionTexture", void 0);
  47380. return SpotLight;
  47381. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47382. /***/ }),
  47383. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  47384. /*!**********************************************!*\
  47385. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  47386. \**********************************************/
  47387. /*! exports provided: _BabylonLoaderRegistered */
  47388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47389. "use strict";
  47390. __webpack_require__.r(__webpack_exports__);
  47391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  47392. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  47393. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  47394. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  47395. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  47396. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  47397. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  47398. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  47399. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  47400. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  47401. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  47402. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  47403. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  47404. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47405. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  47406. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47407. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  47408. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  47409. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  47410. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  47411. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  47412. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  47413. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  47414. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  47415. /** @hidden */
  47416. var _BabylonLoaderRegistered = true;
  47417. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  47418. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47419. var parsedMaterial = parsedData.materials[index];
  47420. if (parsedMaterial.id === id) {
  47421. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47422. }
  47423. }
  47424. return null;
  47425. };
  47426. var isDescendantOf = function (mesh, names, hierarchyIds) {
  47427. for (var i in names) {
  47428. if (mesh.name === names[i]) {
  47429. hierarchyIds.push(mesh.id);
  47430. return true;
  47431. }
  47432. }
  47433. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  47434. hierarchyIds.push(mesh.id);
  47435. return true;
  47436. }
  47437. return false;
  47438. };
  47439. var logOperation = function (operation, producer) {
  47440. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  47441. };
  47442. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  47443. if (addToScene === void 0) { addToScene = false; }
  47444. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  47445. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47446. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47447. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47448. // and avoid problems with multiple concurrent .babylon loads.
  47449. var log = "importScene has failed JSON parse";
  47450. try {
  47451. var parsedData = JSON.parse(data);
  47452. log = "";
  47453. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47454. var index;
  47455. var cache;
  47456. // Lights
  47457. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  47458. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  47459. var parsedLight = parsedData.lights[index];
  47460. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  47461. if (light) {
  47462. container.lights.push(light);
  47463. log += (index === 0 ? "\n\tLights:" : "");
  47464. log += "\n\t\t" + light.toString(fullDetails);
  47465. }
  47466. }
  47467. }
  47468. // Reflection probes
  47469. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47470. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47471. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47472. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47473. if (reflectionProbe) {
  47474. container.reflectionProbes.push(reflectionProbe);
  47475. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47476. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47477. }
  47478. }
  47479. }
  47480. // Animations
  47481. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47482. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47483. var parsedAnimation = parsedData.animations[index];
  47484. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  47485. if (internalClass) {
  47486. var animation = internalClass.Parse(parsedAnimation);
  47487. scene.animations.push(animation);
  47488. container.animations.push(animation);
  47489. log += (index === 0 ? "\n\tAnimations:" : "");
  47490. log += "\n\t\t" + animation.toString(fullDetails);
  47491. }
  47492. }
  47493. }
  47494. // Materials
  47495. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47496. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47497. var parsedMaterial = parsedData.materials[index];
  47498. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47499. container.materials.push(mat);
  47500. log += (index === 0 ? "\n\tMaterials:" : "");
  47501. log += "\n\t\t" + mat.toString(fullDetails);
  47502. }
  47503. }
  47504. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47505. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47506. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47507. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47508. container.multiMaterials.push(mmat);
  47509. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47510. log += "\n\t\t" + mmat.toString(fullDetails);
  47511. }
  47512. }
  47513. // Morph targets
  47514. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47515. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47516. var managerData = _a[_i];
  47517. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  47518. }
  47519. }
  47520. // Skeletons
  47521. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47522. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47523. var parsedSkeleton = parsedData.skeletons[index];
  47524. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47525. container.skeletons.push(skeleton);
  47526. log += (index === 0 ? "\n\tSkeletons:" : "");
  47527. log += "\n\t\t" + skeleton.toString(fullDetails);
  47528. }
  47529. }
  47530. // Geometries
  47531. var geometries = parsedData.geometries;
  47532. if (geometries !== undefined && geometries !== null) {
  47533. var addedGeometry = new Array();
  47534. // VertexData
  47535. var vertexData = geometries.vertexData;
  47536. if (vertexData !== undefined && vertexData !== null) {
  47537. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47538. var parsedVertexData = vertexData[index];
  47539. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47540. }
  47541. }
  47542. addedGeometry.forEach(function (g) {
  47543. if (g) {
  47544. container.geometries.push(g);
  47545. }
  47546. });
  47547. }
  47548. // Transform nodes
  47549. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47550. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47551. var parsedTransformNode = parsedData.transformNodes[index];
  47552. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47553. container.transformNodes.push(node);
  47554. }
  47555. }
  47556. // Meshes
  47557. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47558. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47559. var parsedMesh = parsedData.meshes[index];
  47560. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47561. container.meshes.push(mesh);
  47562. log += (index === 0 ? "\n\tMeshes:" : "");
  47563. log += "\n\t\t" + mesh.toString(fullDetails);
  47564. }
  47565. }
  47566. // Cameras
  47567. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47568. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47569. var parsedCamera = parsedData.cameras[index];
  47570. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47571. container.cameras.push(camera);
  47572. log += (index === 0 ? "\n\tCameras:" : "");
  47573. log += "\n\t\t" + camera.toString(fullDetails);
  47574. }
  47575. }
  47576. // Animation Groups
  47577. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47578. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47579. var parsedAnimationGroup = parsedData.animationGroups[index];
  47580. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47581. container.animationGroups.push(animationGroup);
  47582. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47583. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47584. }
  47585. }
  47586. // Browsing all the graph to connect the dots
  47587. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47588. var camera = scene.cameras[index];
  47589. if (camera._waitingParentId) {
  47590. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47591. camera._waitingParentId = null;
  47592. }
  47593. }
  47594. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47595. var light_1 = scene.lights[index];
  47596. if (light_1 && light_1._waitingParentId) {
  47597. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47598. light_1._waitingParentId = null;
  47599. }
  47600. }
  47601. // Connect parents & children and parse actions
  47602. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47603. var transformNode = scene.transformNodes[index];
  47604. if (transformNode._waitingParentId) {
  47605. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47606. transformNode._waitingParentId = null;
  47607. }
  47608. }
  47609. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47610. var mesh = scene.meshes[index];
  47611. if (mesh._waitingParentId) {
  47612. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47613. mesh._waitingParentId = null;
  47614. }
  47615. }
  47616. // freeze world matrix application
  47617. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47618. var currentMesh = scene.meshes[index];
  47619. if (currentMesh._waitingFreezeWorldMatrix) {
  47620. currentMesh.freezeWorldMatrix();
  47621. currentMesh._waitingFreezeWorldMatrix = null;
  47622. }
  47623. else {
  47624. currentMesh.computeWorldMatrix(true);
  47625. }
  47626. }
  47627. // Lights exclusions / inclusions
  47628. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47629. var light_2 = scene.lights[index];
  47630. // Excluded check
  47631. if (light_2._excludedMeshesIds.length > 0) {
  47632. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47633. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47634. if (excludedMesh) {
  47635. light_2.excludedMeshes.push(excludedMesh);
  47636. }
  47637. }
  47638. light_2._excludedMeshesIds = [];
  47639. }
  47640. // Included check
  47641. if (light_2._includedOnlyMeshesIds.length > 0) {
  47642. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47643. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47644. if (includedOnlyMesh) {
  47645. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47646. }
  47647. }
  47648. light_2._includedOnlyMeshesIds = [];
  47649. }
  47650. }
  47651. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47652. // Actions (scene) Done last as it can access other objects.
  47653. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47654. var mesh = scene.meshes[index];
  47655. if (mesh._waitingActions) {
  47656. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47657. mesh._waitingActions = null;
  47658. }
  47659. }
  47660. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47661. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  47662. }
  47663. if (!addToScene) {
  47664. container.removeAllFromScene();
  47665. }
  47666. }
  47667. catch (err) {
  47668. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47669. if (onError) {
  47670. onError(msg, err);
  47671. }
  47672. else {
  47673. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47674. throw err;
  47675. }
  47676. }
  47677. finally {
  47678. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47679. _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 : ""));
  47680. }
  47681. }
  47682. return container;
  47683. };
  47684. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  47685. name: "babylon.js",
  47686. extensions: ".babylon",
  47687. canDirectLoad: function (data) {
  47688. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47689. return true;
  47690. }
  47691. return false;
  47692. },
  47693. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47694. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47695. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47696. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47697. // and avoid problems with multiple concurrent .babylon loads.
  47698. var log = "importMesh has failed JSON parse";
  47699. try {
  47700. var parsedData = JSON.parse(data);
  47701. log = "";
  47702. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47703. if (!meshesNames) {
  47704. meshesNames = null;
  47705. }
  47706. else if (!Array.isArray(meshesNames)) {
  47707. meshesNames = [meshesNames];
  47708. }
  47709. var hierarchyIds = new Array();
  47710. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47711. var loadedSkeletonsIds = [];
  47712. var loadedMaterialsIds = [];
  47713. var index;
  47714. var cache;
  47715. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47716. var parsedMesh = parsedData.meshes[index];
  47717. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  47718. if (meshesNames !== null) {
  47719. // Remove found mesh name from list.
  47720. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  47721. }
  47722. //Geometry?
  47723. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  47724. //does the file contain geometries?
  47725. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  47726. //find the correct geometry and add it to the scene
  47727. var found = false;
  47728. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  47729. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  47730. return;
  47731. }
  47732. else {
  47733. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  47734. if (parsedGeometryData.id === parsedMesh.geometryId) {
  47735. switch (geometryType) {
  47736. case "vertexData":
  47737. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  47738. break;
  47739. }
  47740. found = true;
  47741. }
  47742. });
  47743. }
  47744. });
  47745. if (found === false) {
  47746. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  47747. }
  47748. }
  47749. }
  47750. // Material ?
  47751. if (parsedMesh.materialId) {
  47752. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  47753. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47754. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  47755. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  47756. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  47757. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  47758. var subMatId = parsedMultiMaterial.materials[matIndex];
  47759. loadedMaterialsIds.push(subMatId);
  47760. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  47761. if (mat) {
  47762. log += "\n\tMaterial " + mat.toString(fullDetails);
  47763. }
  47764. }
  47765. loadedMaterialsIds.push(parsedMultiMaterial.id);
  47766. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47767. if (mmat) {
  47768. materialFound = true;
  47769. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  47770. }
  47771. break;
  47772. }
  47773. }
  47774. }
  47775. if (materialFound === false) {
  47776. loadedMaterialsIds.push(parsedMesh.materialId);
  47777. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  47778. if (!mat) {
  47779. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  47780. }
  47781. else {
  47782. log += "\n\tMaterial " + mat.toString(fullDetails);
  47783. }
  47784. }
  47785. }
  47786. // Skeleton ?
  47787. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47788. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  47789. if (skeletonAlreadyLoaded === false) {
  47790. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  47791. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  47792. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  47793. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47794. skeletons.push(skeleton);
  47795. loadedSkeletonsIds.push(parsedSkeleton.id);
  47796. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  47797. }
  47798. }
  47799. }
  47800. }
  47801. // Morph targets ?
  47802. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47803. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47804. var managerData = _a[_i];
  47805. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  47806. }
  47807. }
  47808. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47809. meshes.push(mesh);
  47810. log += "\n\tMesh " + mesh.toString(fullDetails);
  47811. }
  47812. }
  47813. // Connecting parents
  47814. var currentMesh;
  47815. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47816. currentMesh = scene.meshes[index];
  47817. if (currentMesh._waitingParentId) {
  47818. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  47819. currentMesh._waitingParentId = null;
  47820. }
  47821. }
  47822. // freeze and compute world matrix application
  47823. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47824. currentMesh = scene.meshes[index];
  47825. if (currentMesh._waitingFreezeWorldMatrix) {
  47826. currentMesh.freezeWorldMatrix();
  47827. currentMesh._waitingFreezeWorldMatrix = null;
  47828. }
  47829. else {
  47830. currentMesh.computeWorldMatrix(true);
  47831. }
  47832. }
  47833. }
  47834. // Particles
  47835. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  47836. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  47837. if (parser) {
  47838. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  47839. var parsedParticleSystem = parsedData.particleSystems[index];
  47840. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  47841. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  47842. }
  47843. }
  47844. }
  47845. }
  47846. return true;
  47847. }
  47848. catch (err) {
  47849. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  47850. if (onError) {
  47851. onError(msg, err);
  47852. }
  47853. else {
  47854. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47855. throw err;
  47856. }
  47857. }
  47858. finally {
  47859. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47860. _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 : ""));
  47861. }
  47862. }
  47863. return false;
  47864. },
  47865. load: function (scene, data, rootUrl, onError) {
  47866. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47867. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47868. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47869. // and avoid problems with multiple concurrent .babylon loads.
  47870. var log = "importScene has failed JSON parse";
  47871. try {
  47872. var parsedData = JSON.parse(data);
  47873. log = "";
  47874. // Scene
  47875. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  47876. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  47877. }
  47878. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  47879. scene.autoClear = parsedData.autoClear;
  47880. }
  47881. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  47882. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  47883. }
  47884. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  47885. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  47886. }
  47887. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  47888. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  47889. }
  47890. // Fog
  47891. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  47892. scene.fogMode = parsedData.fogMode;
  47893. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  47894. scene.fogStart = parsedData.fogStart;
  47895. scene.fogEnd = parsedData.fogEnd;
  47896. scene.fogDensity = parsedData.fogDensity;
  47897. log += "\tFog mode for scene: ";
  47898. switch (scene.fogMode) {
  47899. // getters not compiling, so using hardcoded
  47900. case 1:
  47901. log += "exp\n";
  47902. break;
  47903. case 2:
  47904. log += "exp2\n";
  47905. break;
  47906. case 3:
  47907. log += "linear\n";
  47908. break;
  47909. }
  47910. }
  47911. //Physics
  47912. if (parsedData.physicsEnabled) {
  47913. var physicsPlugin;
  47914. if (parsedData.physicsEngine === "cannon") {
  47915. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  47916. }
  47917. else if (parsedData.physicsEngine === "oimo") {
  47918. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  47919. }
  47920. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  47921. //else - default engine, which is currently oimo
  47922. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  47923. scene.enablePhysics(physicsGravity, physicsPlugin);
  47924. }
  47925. // Metadata
  47926. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  47927. scene.metadata = parsedData.metadata;
  47928. }
  47929. //collisions, if defined. otherwise, default is true
  47930. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  47931. scene.collisionsEnabled = parsedData.collisionsEnabled;
  47932. }
  47933. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  47934. if (!container) {
  47935. return false;
  47936. }
  47937. if (parsedData.autoAnimate) {
  47938. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  47939. }
  47940. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  47941. scene.setActiveCameraByID(parsedData.activeCameraID);
  47942. }
  47943. // Environment texture
  47944. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  47945. // PBR needed for both HDR texture (gamma space) & a sky box
  47946. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  47947. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  47948. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  47949. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  47950. if (parsedData.environmentTextureRotationY) {
  47951. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  47952. }
  47953. scene.environmentTexture = hdrTexture;
  47954. }
  47955. else {
  47956. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  47957. if (parsedData.environmentTextureRotationY) {
  47958. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  47959. }
  47960. scene.environmentTexture = cubeTexture;
  47961. }
  47962. if (parsedData.createDefaultSkybox === true) {
  47963. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  47964. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  47965. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  47966. }
  47967. }
  47968. // Finish
  47969. return true;
  47970. }
  47971. catch (err) {
  47972. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  47973. if (onError) {
  47974. onError(msg, err);
  47975. }
  47976. else {
  47977. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47978. throw err;
  47979. }
  47980. }
  47981. finally {
  47982. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47983. _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 : ""));
  47984. }
  47985. }
  47986. return false;
  47987. },
  47988. loadAssetContainer: function (scene, data, rootUrl, onError) {
  47989. var container = loadAssetContainer(scene, data, rootUrl, onError);
  47990. return container;
  47991. }
  47992. });
  47993. /***/ }),
  47994. /***/ "./Loading/Plugins/index.ts":
  47995. /*!**********************************!*\
  47996. !*** ./Loading/Plugins/index.ts ***!
  47997. \**********************************/
  47998. /*! exports provided: _BabylonLoaderRegistered */
  47999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48000. "use strict";
  48001. __webpack_require__.r(__webpack_exports__);
  48002. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48004. /***/ }),
  48005. /***/ "./Loading/index.ts":
  48006. /*!**************************!*\
  48007. !*** ./Loading/index.ts ***!
  48008. \**************************/
  48009. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48011. "use strict";
  48012. __webpack_require__.r(__webpack_exports__);
  48013. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48015. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48017. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48020. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48022. /***/ }),
  48023. /***/ "./Loading/loadingScreen.ts":
  48024. /*!**********************************!*\
  48025. !*** ./Loading/loadingScreen.ts ***!
  48026. \**********************************/
  48027. /*! exports provided: DefaultLoadingScreen */
  48028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48029. "use strict";
  48030. __webpack_require__.r(__webpack_exports__);
  48031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48032. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48033. /**
  48034. * Class used for the default loading screen
  48035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48036. */
  48037. var DefaultLoadingScreen = /** @class */ (function () {
  48038. /**
  48039. * Creates a new default loading screen
  48040. * @param _renderingCanvas defines the canvas used to render the scene
  48041. * @param _loadingText defines the default text to display
  48042. * @param _loadingDivBackgroundColor defines the default background color
  48043. */
  48044. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48045. if (_loadingText === void 0) { _loadingText = ""; }
  48046. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48047. var _this = this;
  48048. this._renderingCanvas = _renderingCanvas;
  48049. this._loadingText = _loadingText;
  48050. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48051. // Resize
  48052. this._resizeLoadingUI = function () {
  48053. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48054. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48055. if (!_this._loadingDiv) {
  48056. return;
  48057. }
  48058. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48059. _this._loadingDiv.style.left = canvasRect.left + "px";
  48060. _this._loadingDiv.style.top = canvasRect.top + "px";
  48061. _this._loadingDiv.style.width = canvasRect.width + "px";
  48062. _this._loadingDiv.style.height = canvasRect.height + "px";
  48063. };
  48064. }
  48065. /**
  48066. * Function called to display the loading screen
  48067. */
  48068. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48069. if (this._loadingDiv) {
  48070. // Do not add a loading screen if there is already one
  48071. return;
  48072. }
  48073. this._loadingDiv = document.createElement("div");
  48074. this._loadingDiv.id = "babylonjsLoadingDiv";
  48075. this._loadingDiv.style.opacity = "0";
  48076. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48077. this._loadingDiv.style.pointerEvents = "none";
  48078. // Loading text
  48079. this._loadingTextDiv = document.createElement("div");
  48080. this._loadingTextDiv.style.position = "absolute";
  48081. this._loadingTextDiv.style.left = "0";
  48082. this._loadingTextDiv.style.top = "50%";
  48083. this._loadingTextDiv.style.marginTop = "80px";
  48084. this._loadingTextDiv.style.width = "100%";
  48085. this._loadingTextDiv.style.height = "20px";
  48086. this._loadingTextDiv.style.fontFamily = "Arial";
  48087. this._loadingTextDiv.style.fontSize = "14px";
  48088. this._loadingTextDiv.style.color = "white";
  48089. this._loadingTextDiv.style.textAlign = "center";
  48090. this._loadingTextDiv.innerHTML = "Loading";
  48091. this._loadingDiv.appendChild(this._loadingTextDiv);
  48092. //set the predefined text
  48093. this._loadingTextDiv.innerHTML = this._loadingText;
  48094. // Generating keyframes
  48095. var style = document.createElement('style');
  48096. style.type = 'text/css';
  48097. 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 }";
  48098. style.innerHTML = keyFrames;
  48099. document.getElementsByTagName('head')[0].appendChild(style);
  48100. // Loading img
  48101. var imgBack = new Image();
  48102. imgBack.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC";
  48103. imgBack.style.position = "absolute";
  48104. imgBack.style.left = "50%";
  48105. imgBack.style.top = "50%";
  48106. imgBack.style.marginLeft = "-60px";
  48107. imgBack.style.marginTop = "-60px";
  48108. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48109. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48110. imgBack.style.transformOrigin = "50% 50%";
  48111. imgBack.style.webkitTransformOrigin = "50% 50%";
  48112. this._loadingDiv.appendChild(imgBack);
  48113. this._resizeLoadingUI();
  48114. window.addEventListener("resize", this._resizeLoadingUI);
  48115. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48116. document.body.appendChild(this._loadingDiv);
  48117. this._loadingDiv.style.opacity = "1";
  48118. };
  48119. /**
  48120. * Function called to hide the loading screen
  48121. */
  48122. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48123. var _this = this;
  48124. if (!this._loadingDiv) {
  48125. return;
  48126. }
  48127. var onTransitionEnd = function () {
  48128. if (!_this._loadingDiv) {
  48129. return;
  48130. }
  48131. if (_this._loadingDiv.parentElement) {
  48132. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48133. }
  48134. window.removeEventListener("resize", _this._resizeLoadingUI);
  48135. _this._loadingDiv = null;
  48136. };
  48137. this._loadingDiv.style.opacity = "0";
  48138. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  48139. };
  48140. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  48141. get: function () {
  48142. return this._loadingText;
  48143. },
  48144. /**
  48145. * Gets or sets the text to display while loading
  48146. */
  48147. set: function (text) {
  48148. this._loadingText = text;
  48149. if (this._loadingTextDiv) {
  48150. this._loadingTextDiv.innerHTML = this._loadingText;
  48151. }
  48152. },
  48153. enumerable: true,
  48154. configurable: true
  48155. });
  48156. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  48157. /**
  48158. * Gets or sets the color to use for the background
  48159. */
  48160. get: function () {
  48161. return this._loadingDivBackgroundColor;
  48162. },
  48163. set: function (color) {
  48164. this._loadingDivBackgroundColor = color;
  48165. if (!this._loadingDiv) {
  48166. return;
  48167. }
  48168. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48169. },
  48170. enumerable: true,
  48171. configurable: true
  48172. });
  48173. return DefaultLoadingScreen;
  48174. }());
  48175. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  48176. /***/ }),
  48177. /***/ "./Loading/sceneLoader.ts":
  48178. /*!********************************!*\
  48179. !*** ./Loading/sceneLoader.ts ***!
  48180. \********************************/
  48181. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  48182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48183. "use strict";
  48184. __webpack_require__.r(__webpack_exports__);
  48185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  48186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  48187. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48188. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  48189. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  48190. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  48191. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48192. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48193. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  48194. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48195. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48196. /**
  48197. * Class used to represent data loading progression
  48198. */
  48199. var SceneLoaderProgressEvent = /** @class */ (function () {
  48200. /**
  48201. * Create a new progress event
  48202. * @param lengthComputable defines if data length to load can be evaluated
  48203. * @param loaded defines the loaded data length
  48204. * @param total defines the data length to load
  48205. */
  48206. function SceneLoaderProgressEvent(
  48207. /** defines if data length to load can be evaluated */
  48208. lengthComputable,
  48209. /** defines the loaded data length */
  48210. loaded,
  48211. /** defines the data length to load */
  48212. total) {
  48213. this.lengthComputable = lengthComputable;
  48214. this.loaded = loaded;
  48215. this.total = total;
  48216. }
  48217. /**
  48218. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48219. * @param event defines the source event
  48220. * @returns a new SceneLoaderProgressEvent
  48221. */
  48222. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  48223. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  48224. };
  48225. return SceneLoaderProgressEvent;
  48226. }());
  48227. /**
  48228. * Class used to load scene from various file formats using registered plugins
  48229. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48230. */
  48231. var SceneLoader = /** @class */ (function () {
  48232. function SceneLoader() {
  48233. }
  48234. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  48235. /**
  48236. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48237. */
  48238. get: function () {
  48239. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  48240. },
  48241. set: function (value) {
  48242. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  48243. },
  48244. enumerable: true,
  48245. configurable: true
  48246. });
  48247. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  48248. /**
  48249. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48250. */
  48251. get: function () {
  48252. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  48253. },
  48254. set: function (value) {
  48255. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  48256. },
  48257. enumerable: true,
  48258. configurable: true
  48259. });
  48260. Object.defineProperty(SceneLoader, "loggingLevel", {
  48261. /**
  48262. * Defines the current logging level (while loading the scene)
  48263. * @ignorenaming
  48264. */
  48265. get: function () {
  48266. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  48267. },
  48268. set: function (value) {
  48269. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  48270. },
  48271. enumerable: true,
  48272. configurable: true
  48273. });
  48274. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  48275. /**
  48276. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48277. */
  48278. get: function () {
  48279. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  48280. },
  48281. set: function (value) {
  48282. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  48283. },
  48284. enumerable: true,
  48285. configurable: true
  48286. });
  48287. SceneLoader._getDefaultPlugin = function () {
  48288. return SceneLoader._registeredPlugins[".babylon"];
  48289. };
  48290. SceneLoader._getPluginForExtension = function (extension) {
  48291. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  48292. if (registeredPlugin) {
  48293. return registeredPlugin;
  48294. }
  48295. _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");
  48296. return SceneLoader._getDefaultPlugin();
  48297. };
  48298. SceneLoader._getPluginForDirectLoad = function (data) {
  48299. for (var extension in SceneLoader._registeredPlugins) {
  48300. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  48301. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  48302. return SceneLoader._registeredPlugins[extension];
  48303. }
  48304. }
  48305. return SceneLoader._getDefaultPlugin();
  48306. };
  48307. SceneLoader._getPluginForFilename = function (sceneFilename) {
  48308. var queryStringPosition = sceneFilename.indexOf("?");
  48309. if (queryStringPosition !== -1) {
  48310. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  48311. }
  48312. var dotPosition = sceneFilename.lastIndexOf(".");
  48313. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  48314. return SceneLoader._getPluginForExtension(extension);
  48315. };
  48316. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  48317. SceneLoader._getDirectLoad = function (sceneFilename) {
  48318. if (sceneFilename.substr(0, 5) === "data:") {
  48319. return sceneFilename.substr(5);
  48320. }
  48321. return null;
  48322. };
  48323. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  48324. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  48325. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  48326. var plugin;
  48327. if (registeredPlugin.plugin.createPlugin) {
  48328. plugin = registeredPlugin.plugin.createPlugin();
  48329. }
  48330. else {
  48331. plugin = registeredPlugin.plugin;
  48332. }
  48333. if (!plugin) {
  48334. 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.";
  48335. }
  48336. var useArrayBuffer = registeredPlugin.isBinary;
  48337. var offlineProvider;
  48338. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  48339. var dataCallback = function (data, responseURL) {
  48340. if (scene.isDisposed) {
  48341. onError("Scene has been disposed");
  48342. return;
  48343. }
  48344. scene.offlineProvider = offlineProvider;
  48345. onSuccess(plugin, data, responseURL);
  48346. };
  48347. var request = null;
  48348. var pluginDisposed = false;
  48349. var onDisposeObservable = plugin.onDisposeObservable;
  48350. if (onDisposeObservable) {
  48351. onDisposeObservable.add(function () {
  48352. pluginDisposed = true;
  48353. if (request) {
  48354. request.abort();
  48355. request = null;
  48356. }
  48357. onDispose();
  48358. });
  48359. }
  48360. var manifestChecked = function () {
  48361. if (pluginDisposed) {
  48362. return;
  48363. }
  48364. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  48365. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  48366. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  48367. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  48368. });
  48369. };
  48370. if (directLoad) {
  48371. dataCallback(directLoad);
  48372. return plugin;
  48373. }
  48374. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  48375. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  48376. var engine = scene.getEngine();
  48377. var canUseOfflineSupport = engine.enableOfflineSupport;
  48378. if (canUseOfflineSupport) {
  48379. // Also check for exceptions
  48380. var exceptionFound = false;
  48381. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  48382. var regex = _a[_i];
  48383. if (regex.test(fileInfo.url)) {
  48384. exceptionFound = true;
  48385. break;
  48386. }
  48387. }
  48388. canUseOfflineSupport = !exceptionFound;
  48389. }
  48390. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  48391. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  48392. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  48393. }
  48394. else {
  48395. manifestChecked();
  48396. }
  48397. }
  48398. // Loading file from disk via input file or drag'n'drop
  48399. else {
  48400. if (file) {
  48401. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48402. }
  48403. else {
  48404. onError("Unable to find file named " + fileInfo.name);
  48405. }
  48406. }
  48407. return plugin;
  48408. };
  48409. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48410. var url;
  48411. var name;
  48412. var file = null;
  48413. if (!sceneFilename) {
  48414. url = rootUrl;
  48415. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48416. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48417. }
  48418. else if (sceneFilename.lastModified) {
  48419. var sceneFile = sceneFilename;
  48420. url = rootUrl + sceneFile.name;
  48421. name = sceneFile.name;
  48422. file = sceneFile;
  48423. }
  48424. else {
  48425. var filename = sceneFilename;
  48426. if (filename.substr(0, 1) === "/") {
  48427. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48428. return null;
  48429. }
  48430. url = rootUrl + filename;
  48431. name = filename;
  48432. }
  48433. return {
  48434. url: url,
  48435. rootUrl: rootUrl,
  48436. name: name,
  48437. file: file
  48438. };
  48439. };
  48440. // Public functions
  48441. /**
  48442. * Gets a plugin that can load the given extension
  48443. * @param extension defines the extension to load
  48444. * @returns a plugin or null if none works
  48445. */
  48446. SceneLoader.GetPluginForExtension = function (extension) {
  48447. return SceneLoader._getPluginForExtension(extension).plugin;
  48448. };
  48449. /**
  48450. * Gets a boolean indicating that the given extension can be loaded
  48451. * @param extension defines the extension to load
  48452. * @returns true if the extension is supported
  48453. */
  48454. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48455. return !!SceneLoader._registeredPlugins[extension];
  48456. };
  48457. /**
  48458. * Adds a new plugin to the list of registered plugins
  48459. * @param plugin defines the plugin to add
  48460. */
  48461. SceneLoader.RegisterPlugin = function (plugin) {
  48462. if (typeof plugin.extensions === "string") {
  48463. var extension = plugin.extensions;
  48464. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48465. plugin: plugin,
  48466. isBinary: false
  48467. };
  48468. }
  48469. else {
  48470. var extensions = plugin.extensions;
  48471. Object.keys(extensions).forEach(function (extension) {
  48472. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48473. plugin: plugin,
  48474. isBinary: extensions[extension].isBinary
  48475. };
  48476. });
  48477. }
  48478. };
  48479. /**
  48480. * Import meshes into a scene
  48481. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48482. * @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)
  48483. * @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)
  48484. * @param scene the instance of BABYLON.Scene to append to
  48485. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48486. * @param onProgress a callback with a progress event for each file being loaded
  48487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48488. * @param pluginExtension the extension used to determine the plugin
  48489. * @returns The loaded plugin
  48490. */
  48491. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48492. if (sceneFilename === void 0) { sceneFilename = ""; }
  48493. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48494. if (onSuccess === void 0) { onSuccess = null; }
  48495. if (onProgress === void 0) { onProgress = null; }
  48496. if (onError === void 0) { onError = null; }
  48497. if (pluginExtension === void 0) { pluginExtension = null; }
  48498. if (!scene) {
  48499. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48500. return null;
  48501. }
  48502. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48503. if (!fileInfo) {
  48504. return null;
  48505. }
  48506. var loadingToken = {};
  48507. scene._addPendingData(loadingToken);
  48508. var disposeHandler = function () {
  48509. scene._removePendingData(loadingToken);
  48510. };
  48511. var errorHandler = function (message, exception) {
  48512. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48513. if (onError) {
  48514. onError(scene, errorMessage, exception);
  48515. }
  48516. else {
  48517. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48518. // should the exception be thrown?
  48519. }
  48520. disposeHandler();
  48521. };
  48522. var progressHandler = onProgress ? function (event) {
  48523. try {
  48524. onProgress(event);
  48525. }
  48526. catch (e) {
  48527. errorHandler("Error in onProgress callback", e);
  48528. }
  48529. } : undefined;
  48530. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48531. scene.importedMeshesFiles.push(fileInfo.url);
  48532. if (onSuccess) {
  48533. try {
  48534. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48535. }
  48536. catch (e) {
  48537. errorHandler("Error in onSuccess callback", e);
  48538. }
  48539. }
  48540. scene._removePendingData(loadingToken);
  48541. };
  48542. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48543. if (plugin.rewriteRootURL) {
  48544. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48545. }
  48546. if (plugin.importMesh) {
  48547. var syncedPlugin = plugin;
  48548. var meshes = new Array();
  48549. var particleSystems = new Array();
  48550. var skeletons = new Array();
  48551. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48552. return;
  48553. }
  48554. scene.loadingPluginName = plugin.name;
  48555. successHandler(meshes, particleSystems, skeletons, []);
  48556. }
  48557. else {
  48558. var asyncedPlugin = plugin;
  48559. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48560. scene.loadingPluginName = plugin.name;
  48561. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48562. }).catch(function (error) {
  48563. errorHandler(error.message, error);
  48564. });
  48565. }
  48566. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48567. };
  48568. /**
  48569. * Import meshes into a scene
  48570. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48571. * @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)
  48572. * @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)
  48573. * @param scene the instance of BABYLON.Scene to append to
  48574. * @param onProgress a callback with a progress event for each file being loaded
  48575. * @param pluginExtension the extension used to determine the plugin
  48576. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48577. */
  48578. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48579. if (sceneFilename === void 0) { sceneFilename = ""; }
  48580. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48581. if (onProgress === void 0) { onProgress = null; }
  48582. if (pluginExtension === void 0) { pluginExtension = null; }
  48583. return new Promise(function (resolve, reject) {
  48584. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48585. resolve({
  48586. meshes: meshes,
  48587. particleSystems: particleSystems,
  48588. skeletons: skeletons,
  48589. animationGroups: animationGroups
  48590. });
  48591. }, onProgress, function (scene, message, exception) {
  48592. reject(exception || new Error(message));
  48593. }, pluginExtension);
  48594. });
  48595. };
  48596. /**
  48597. * Load a scene
  48598. * @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)
  48599. * @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)
  48600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48601. * @param onSuccess a callback with the scene when import succeeds
  48602. * @param onProgress a callback with a progress event for each file being loaded
  48603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48604. * @param pluginExtension the extension used to determine the plugin
  48605. * @returns The loaded plugin
  48606. */
  48607. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48608. if (sceneFilename === void 0) { sceneFilename = ""; }
  48609. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48610. if (onSuccess === void 0) { onSuccess = null; }
  48611. if (onProgress === void 0) { onProgress = null; }
  48612. if (onError === void 0) { onError = null; }
  48613. if (pluginExtension === void 0) { pluginExtension = null; }
  48614. if (!engine) {
  48615. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48616. return null;
  48617. }
  48618. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48619. };
  48620. /**
  48621. * Load a scene
  48622. * @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)
  48623. * @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)
  48624. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48625. * @param onProgress a callback with a progress event for each file being loaded
  48626. * @param pluginExtension the extension used to determine the plugin
  48627. * @returns The loaded scene
  48628. */
  48629. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48630. if (sceneFilename === void 0) { sceneFilename = ""; }
  48631. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48632. if (onProgress === void 0) { onProgress = null; }
  48633. if (pluginExtension === void 0) { pluginExtension = null; }
  48634. return new Promise(function (resolve, reject) {
  48635. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48636. resolve(scene);
  48637. }, onProgress, function (scene, message, exception) {
  48638. reject(exception || new Error(message));
  48639. }, pluginExtension);
  48640. });
  48641. };
  48642. /**
  48643. * Append a scene
  48644. * @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)
  48645. * @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)
  48646. * @param scene is the instance of BABYLON.Scene to append to
  48647. * @param onSuccess a callback with the scene when import succeeds
  48648. * @param onProgress a callback with a progress event for each file being loaded
  48649. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48650. * @param pluginExtension the extension used to determine the plugin
  48651. * @returns The loaded plugin
  48652. */
  48653. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48654. if (sceneFilename === void 0) { sceneFilename = ""; }
  48655. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48656. if (onSuccess === void 0) { onSuccess = null; }
  48657. if (onProgress === void 0) { onProgress = null; }
  48658. if (onError === void 0) { onError = null; }
  48659. if (pluginExtension === void 0) { pluginExtension = null; }
  48660. if (!scene) {
  48661. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48662. return null;
  48663. }
  48664. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48665. if (!fileInfo) {
  48666. return null;
  48667. }
  48668. if (SceneLoader.ShowLoadingScreen) {
  48669. scene.getEngine().displayLoadingUI();
  48670. }
  48671. var loadingToken = {};
  48672. scene._addPendingData(loadingToken);
  48673. var disposeHandler = function () {
  48674. scene._removePendingData(loadingToken);
  48675. scene.getEngine().hideLoadingUI();
  48676. };
  48677. var errorHandler = function (message, exception) {
  48678. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48679. if (onError) {
  48680. onError(scene, errorMessage, exception);
  48681. }
  48682. else {
  48683. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48684. // should the exception be thrown?
  48685. }
  48686. disposeHandler();
  48687. };
  48688. var progressHandler = onProgress ? function (event) {
  48689. try {
  48690. onProgress(event);
  48691. }
  48692. catch (e) {
  48693. errorHandler("Error in onProgress callback", e);
  48694. }
  48695. } : undefined;
  48696. var successHandler = function () {
  48697. if (onSuccess) {
  48698. try {
  48699. onSuccess(scene);
  48700. }
  48701. catch (e) {
  48702. errorHandler("Error in onSuccess callback", e);
  48703. }
  48704. }
  48705. scene._removePendingData(loadingToken);
  48706. };
  48707. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48708. if (plugin.load) {
  48709. var syncedPlugin = plugin;
  48710. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  48711. return;
  48712. }
  48713. scene.loadingPluginName = plugin.name;
  48714. successHandler();
  48715. }
  48716. else {
  48717. var asyncedPlugin = plugin;
  48718. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  48719. scene.loadingPluginName = plugin.name;
  48720. successHandler();
  48721. }).catch(function (error) {
  48722. errorHandler(error.message, error);
  48723. });
  48724. }
  48725. if (SceneLoader.ShowLoadingScreen) {
  48726. scene.executeWhenReady(function () {
  48727. scene.getEngine().hideLoadingUI();
  48728. });
  48729. }
  48730. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48731. };
  48732. /**
  48733. * Append a scene
  48734. * @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)
  48735. * @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)
  48736. * @param scene is the instance of BABYLON.Scene to append to
  48737. * @param onProgress a callback with a progress event for each file being loaded
  48738. * @param pluginExtension the extension used to determine the plugin
  48739. * @returns The given scene
  48740. */
  48741. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48742. if (sceneFilename === void 0) { sceneFilename = ""; }
  48743. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48744. if (onProgress === void 0) { onProgress = null; }
  48745. if (pluginExtension === void 0) { pluginExtension = null; }
  48746. return new Promise(function (resolve, reject) {
  48747. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  48748. resolve(scene);
  48749. }, onProgress, function (scene, message, exception) {
  48750. reject(exception || new Error(message));
  48751. }, pluginExtension);
  48752. });
  48753. };
  48754. /**
  48755. * Load a scene into an asset container
  48756. * @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)
  48757. * @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)
  48758. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48759. * @param onSuccess a callback with the scene when import succeeds
  48760. * @param onProgress a callback with a progress event for each file being loaded
  48761. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48762. * @param pluginExtension the extension used to determine the plugin
  48763. * @returns The loaded plugin
  48764. */
  48765. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48766. if (sceneFilename === void 0) { sceneFilename = ""; }
  48767. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48768. if (onSuccess === void 0) { onSuccess = null; }
  48769. if (onProgress === void 0) { onProgress = null; }
  48770. if (onError === void 0) { onError = null; }
  48771. if (pluginExtension === void 0) { pluginExtension = null; }
  48772. if (!scene) {
  48773. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  48774. return null;
  48775. }
  48776. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48777. if (!fileInfo) {
  48778. return null;
  48779. }
  48780. var loadingToken = {};
  48781. scene._addPendingData(loadingToken);
  48782. var disposeHandler = function () {
  48783. scene._removePendingData(loadingToken);
  48784. };
  48785. var errorHandler = function (message, exception) {
  48786. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  48787. if (onError) {
  48788. onError(scene, errorMessage, exception);
  48789. }
  48790. else {
  48791. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48792. // should the exception be thrown?
  48793. }
  48794. disposeHandler();
  48795. };
  48796. var progressHandler = onProgress ? function (event) {
  48797. try {
  48798. onProgress(event);
  48799. }
  48800. catch (e) {
  48801. errorHandler("Error in onProgress callback", e);
  48802. }
  48803. } : undefined;
  48804. var successHandler = function (assets) {
  48805. if (onSuccess) {
  48806. try {
  48807. onSuccess(assets);
  48808. }
  48809. catch (e) {
  48810. errorHandler("Error in onSuccess callback", e);
  48811. }
  48812. }
  48813. scene._removePendingData(loadingToken);
  48814. };
  48815. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48816. if (plugin.loadAssetContainer) {
  48817. var syncedPlugin = plugin;
  48818. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  48819. if (!assetContainer) {
  48820. return;
  48821. }
  48822. scene.loadingPluginName = plugin.name;
  48823. successHandler(assetContainer);
  48824. }
  48825. else if (plugin.loadAssetContainerAsync) {
  48826. var asyncedPlugin = plugin;
  48827. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  48828. scene.loadingPluginName = plugin.name;
  48829. successHandler(assetContainer);
  48830. }).catch(function (error) {
  48831. errorHandler(error.message, error);
  48832. });
  48833. }
  48834. else {
  48835. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  48836. }
  48837. if (SceneLoader.ShowLoadingScreen) {
  48838. scene.executeWhenReady(function () {
  48839. scene.getEngine().hideLoadingUI();
  48840. });
  48841. }
  48842. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48843. };
  48844. /**
  48845. * Load a scene into an asset container
  48846. * @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)
  48847. * @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)
  48848. * @param scene is the instance of Scene to append to
  48849. * @param onProgress a callback with a progress event for each file being loaded
  48850. * @param pluginExtension the extension used to determine the plugin
  48851. * @returns The loaded asset container
  48852. */
  48853. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48854. if (sceneFilename === void 0) { sceneFilename = ""; }
  48855. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48856. if (onProgress === void 0) { onProgress = null; }
  48857. if (pluginExtension === void 0) { pluginExtension = null; }
  48858. return new Promise(function (resolve, reject) {
  48859. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  48860. resolve(assetContainer);
  48861. }, onProgress, function (scene, message, exception) {
  48862. reject(exception || new Error(message));
  48863. }, pluginExtension);
  48864. });
  48865. };
  48866. /**
  48867. * No logging while loading
  48868. */
  48869. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  48870. /**
  48871. * Minimal logging while loading
  48872. */
  48873. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  48874. /**
  48875. * Summary logging while loading
  48876. */
  48877. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  48878. /**
  48879. * Detailled logging while loading
  48880. */
  48881. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  48882. // Members
  48883. /**
  48884. * Event raised when a plugin is used to load a scene
  48885. */
  48886. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  48887. SceneLoader._registeredPlugins = {};
  48888. return SceneLoader;
  48889. }());
  48890. /***/ }),
  48891. /***/ "./Loading/sceneLoaderFlags.ts":
  48892. /*!*************************************!*\
  48893. !*** ./Loading/sceneLoaderFlags.ts ***!
  48894. \*************************************/
  48895. /*! exports provided: SceneLoaderFlags */
  48896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48897. "use strict";
  48898. __webpack_require__.r(__webpack_exports__);
  48899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  48900. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48901. /**
  48902. * Class used to represent data loading progression
  48903. */
  48904. var SceneLoaderFlags = /** @class */ (function () {
  48905. function SceneLoaderFlags() {
  48906. }
  48907. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  48908. /**
  48909. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48910. */
  48911. get: function () {
  48912. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  48913. },
  48914. set: function (value) {
  48915. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  48916. },
  48917. enumerable: true,
  48918. configurable: true
  48919. });
  48920. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  48921. /**
  48922. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48923. */
  48924. get: function () {
  48925. return SceneLoaderFlags._ShowLoadingScreen;
  48926. },
  48927. set: function (value) {
  48928. SceneLoaderFlags._ShowLoadingScreen = value;
  48929. },
  48930. enumerable: true,
  48931. configurable: true
  48932. });
  48933. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  48934. /**
  48935. * Defines the current logging level (while loading the scene)
  48936. * @ignorenaming
  48937. */
  48938. get: function () {
  48939. return SceneLoaderFlags._loggingLevel;
  48940. },
  48941. set: function (value) {
  48942. SceneLoaderFlags._loggingLevel = value;
  48943. },
  48944. enumerable: true,
  48945. configurable: true
  48946. });
  48947. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  48948. /**
  48949. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48950. */
  48951. get: function () {
  48952. return SceneLoaderFlags._CleanBoneMatrixWeights;
  48953. },
  48954. set: function (value) {
  48955. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  48956. },
  48957. enumerable: true,
  48958. configurable: true
  48959. });
  48960. // Flags
  48961. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  48962. SceneLoaderFlags._ShowLoadingScreen = true;
  48963. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  48964. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  48965. return SceneLoaderFlags;
  48966. }());
  48967. /***/ }),
  48968. /***/ "./Materials/Background/backgroundMaterial.ts":
  48969. /*!****************************************************!*\
  48970. !*** ./Materials/Background/backgroundMaterial.ts ***!
  48971. \****************************************************/
  48972. /*! exports provided: BackgroundMaterial */
  48973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48974. "use strict";
  48975. __webpack_require__.r(__webpack_exports__);
  48976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  48977. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48978. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  48979. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  48980. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48981. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48982. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  48983. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  48984. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  48985. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  48986. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  48987. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  48988. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  48989. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  48990. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48991. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  48992. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  48993. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  48994. /**
  48995. * Background material defines definition.
  48996. * @hidden Mainly internal Use
  48997. */
  48998. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  48999. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49000. /**
  49001. * Constructor of the defines.
  49002. */
  49003. function BackgroundMaterialDefines() {
  49004. var _this = _super.call(this) || this;
  49005. /**
  49006. * True if the diffuse texture is in use.
  49007. */
  49008. _this.DIFFUSE = false;
  49009. /**
  49010. * The direct UV channel to use.
  49011. */
  49012. _this.DIFFUSEDIRECTUV = 0;
  49013. /**
  49014. * True if the diffuse texture is in gamma space.
  49015. */
  49016. _this.GAMMADIFFUSE = false;
  49017. /**
  49018. * True if the diffuse texture has opacity in the alpha channel.
  49019. */
  49020. _this.DIFFUSEHASALPHA = false;
  49021. /**
  49022. * True if you want the material to fade to transparent at grazing angle.
  49023. */
  49024. _this.OPACITYFRESNEL = false;
  49025. /**
  49026. * True if an extra blur needs to be added in the reflection.
  49027. */
  49028. _this.REFLECTIONBLUR = false;
  49029. /**
  49030. * True if you want the material to fade to reflection at grazing angle.
  49031. */
  49032. _this.REFLECTIONFRESNEL = false;
  49033. /**
  49034. * True if you want the material to falloff as far as you move away from the scene center.
  49035. */
  49036. _this.REFLECTIONFALLOFF = false;
  49037. /**
  49038. * False if the current Webgl implementation does not support the texture lod extension.
  49039. */
  49040. _this.TEXTURELODSUPPORT = false;
  49041. /**
  49042. * True to ensure the data are premultiplied.
  49043. */
  49044. _this.PREMULTIPLYALPHA = false;
  49045. /**
  49046. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49047. */
  49048. _this.USERGBCOLOR = false;
  49049. /**
  49050. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49051. * stays aligned with the desired configuration.
  49052. */
  49053. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49054. /**
  49055. * True to add noise in order to reduce the banding effect.
  49056. */
  49057. _this.NOISE = false;
  49058. /**
  49059. * is the reflection texture in BGR color scheme?
  49060. * Mainly used to solve a bug in ios10 video tag
  49061. */
  49062. _this.REFLECTIONBGR = false;
  49063. _this.IMAGEPROCESSING = false;
  49064. _this.VIGNETTE = false;
  49065. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49066. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49067. _this.TONEMAPPING = false;
  49068. _this.TONEMAPPING_ACES = false;
  49069. _this.CONTRAST = false;
  49070. _this.COLORCURVES = false;
  49071. _this.COLORGRADING = false;
  49072. _this.COLORGRADING3D = false;
  49073. _this.SAMPLER3DGREENDEPTH = false;
  49074. _this.SAMPLER3DBGRMAP = false;
  49075. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49076. _this.EXPOSURE = false;
  49077. // Reflection.
  49078. _this.REFLECTION = false;
  49079. _this.REFLECTIONMAP_3D = false;
  49080. _this.REFLECTIONMAP_SPHERICAL = false;
  49081. _this.REFLECTIONMAP_PLANAR = false;
  49082. _this.REFLECTIONMAP_CUBIC = false;
  49083. _this.REFLECTIONMAP_PROJECTION = false;
  49084. _this.REFLECTIONMAP_SKYBOX = false;
  49085. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49086. _this.REFLECTIONMAP_EXPLICIT = false;
  49087. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49088. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49089. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49090. _this.INVERTCUBICMAP = false;
  49091. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49092. _this.LODINREFLECTIONALPHA = false;
  49093. _this.GAMMAREFLECTION = false;
  49094. _this.RGBDREFLECTION = false;
  49095. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49096. // Default BJS.
  49097. _this.MAINUV1 = false;
  49098. _this.MAINUV2 = false;
  49099. _this.UV1 = false;
  49100. _this.UV2 = false;
  49101. _this.CLIPPLANE = false;
  49102. _this.CLIPPLANE2 = false;
  49103. _this.CLIPPLANE3 = false;
  49104. _this.CLIPPLANE4 = false;
  49105. _this.POINTSIZE = false;
  49106. _this.FOG = false;
  49107. _this.NORMAL = false;
  49108. _this.NUM_BONE_INFLUENCERS = 0;
  49109. _this.BonesPerMesh = 0;
  49110. _this.INSTANCES = false;
  49111. _this.SHADOWFLOAT = false;
  49112. _this.rebuild();
  49113. return _this;
  49114. }
  49115. return BackgroundMaterialDefines;
  49116. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49117. /**
  49118. * Background material used to create an efficient environement around your scene.
  49119. */
  49120. var BackgroundMaterial = /** @class */ (function (_super) {
  49121. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49122. /**
  49123. * Instantiates a Background Material in the given scene
  49124. * @param name The friendly name of the material
  49125. * @param scene The scene to add the material to
  49126. */
  49127. function BackgroundMaterial(name, scene) {
  49128. var _this = _super.call(this, name, scene) || this;
  49129. /**
  49130. * Key light Color (multiply against the environement texture)
  49131. */
  49132. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49133. _this._primaryColorShadowLevel = 0;
  49134. _this._primaryColorHighlightLevel = 0;
  49135. /**
  49136. * Reflection Texture used in the material.
  49137. * Should be author in a specific way for the best result (refer to the documentation).
  49138. */
  49139. _this.reflectionTexture = null;
  49140. /**
  49141. * Reflection Texture level of blur.
  49142. *
  49143. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49144. * texture twice.
  49145. */
  49146. _this.reflectionBlur = 0;
  49147. /**
  49148. * Diffuse Texture used in the material.
  49149. * Should be author in a specific way for the best result (refer to the documentation).
  49150. */
  49151. _this.diffuseTexture = null;
  49152. _this._shadowLights = null;
  49153. /**
  49154. * Specify the list of lights casting shadow on the material.
  49155. * All scene shadow lights will be included if null.
  49156. */
  49157. _this.shadowLights = null;
  49158. /**
  49159. * Helps adjusting the shadow to a softer level if required.
  49160. * 0 means black shadows and 1 means no shadows.
  49161. */
  49162. _this.shadowLevel = 0;
  49163. /**
  49164. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49165. * It is usually zero but might be interesting to modify according to your setup.
  49166. */
  49167. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  49168. /**
  49169. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49170. * This helps ensuring a nice transition when the camera goes under the ground.
  49171. */
  49172. _this.opacityFresnel = true;
  49173. /**
  49174. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49175. * This helps adding a mirror texture on the ground.
  49176. */
  49177. _this.reflectionFresnel = false;
  49178. /**
  49179. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49180. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49181. */
  49182. _this.reflectionFalloffDistance = 0.0;
  49183. /**
  49184. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49185. */
  49186. _this.reflectionAmount = 1.0;
  49187. /**
  49188. * This specifies the weight of the reflection at grazing angle.
  49189. */
  49190. _this.reflectionReflectance0 = 0.05;
  49191. /**
  49192. * This specifies the weight of the reflection at a perpendicular point of view.
  49193. */
  49194. _this.reflectionReflectance90 = 0.5;
  49195. /**
  49196. * Helps to directly use the maps channels instead of their level.
  49197. */
  49198. _this.useRGBColor = true;
  49199. /**
  49200. * This helps reducing the banding effect that could occur on the background.
  49201. */
  49202. _this.enableNoise = false;
  49203. _this._fovMultiplier = 1.0;
  49204. /**
  49205. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49206. */
  49207. _this.useEquirectangularFOV = false;
  49208. _this._maxSimultaneousLights = 4;
  49209. /**
  49210. * Number of Simultaneous lights allowed on the material.
  49211. */
  49212. _this.maxSimultaneousLights = 4;
  49213. /**
  49214. * Keep track of the image processing observer to allow dispose and replace.
  49215. */
  49216. _this._imageProcessingObserver = null;
  49217. /**
  49218. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49219. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49220. */
  49221. _this.switchToBGR = false;
  49222. // Temp values kept as cache in the material.
  49223. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  49224. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  49225. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49226. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49227. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49228. // Setup the default processing configuration to the scene.
  49229. _this._attachImageProcessingConfiguration(null);
  49230. _this.getRenderTargetTextures = function () {
  49231. _this._renderTargets.reset();
  49232. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  49233. _this._renderTargets.push(_this._diffuseTexture);
  49234. }
  49235. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49236. _this._renderTargets.push(_this._reflectionTexture);
  49237. }
  49238. return _this._renderTargets;
  49239. };
  49240. return _this;
  49241. }
  49242. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  49243. /**
  49244. * Experimental Internal Use Only.
  49245. *
  49246. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49247. * This acts as a helper to set the primary color to a more "human friendly" value.
  49248. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49249. * output color as close as possible from the chosen value.
  49250. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49251. * part of lighting setup.)
  49252. */
  49253. get: function () {
  49254. return this.__perceptualColor;
  49255. },
  49256. set: function (value) {
  49257. this.__perceptualColor = value;
  49258. this._computePrimaryColorFromPerceptualColor();
  49259. this._markAllSubMeshesAsLightsDirty();
  49260. },
  49261. enumerable: true,
  49262. configurable: true
  49263. });
  49264. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  49265. /**
  49266. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49267. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49268. */
  49269. get: function () {
  49270. return this._primaryColorShadowLevel;
  49271. },
  49272. set: function (value) {
  49273. this._primaryColorShadowLevel = value;
  49274. this._computePrimaryColors();
  49275. this._markAllSubMeshesAsLightsDirty();
  49276. },
  49277. enumerable: true,
  49278. configurable: true
  49279. });
  49280. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  49281. /**
  49282. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49283. * The primary color is used at the level chosen to define what the white area would look.
  49284. */
  49285. get: function () {
  49286. return this._primaryColorHighlightLevel;
  49287. },
  49288. set: function (value) {
  49289. this._primaryColorHighlightLevel = value;
  49290. this._computePrimaryColors();
  49291. this._markAllSubMeshesAsLightsDirty();
  49292. },
  49293. enumerable: true,
  49294. configurable: true
  49295. });
  49296. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  49297. /**
  49298. * Sets the reflection reflectance fresnel values according to the default standard
  49299. * empirically know to work well :-)
  49300. */
  49301. set: function (value) {
  49302. var reflectionWeight = value;
  49303. if (reflectionWeight < 0.5) {
  49304. reflectionWeight = reflectionWeight * 2.0;
  49305. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  49306. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  49307. }
  49308. else {
  49309. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  49310. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  49311. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  49312. }
  49313. },
  49314. enumerable: true,
  49315. configurable: true
  49316. });
  49317. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  49318. /**
  49319. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49320. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49321. * Recommended to be keep at 1.0 except for special cases.
  49322. */
  49323. get: function () {
  49324. return this._fovMultiplier;
  49325. },
  49326. set: function (value) {
  49327. if (isNaN(value)) {
  49328. value = 1.0;
  49329. }
  49330. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  49331. },
  49332. enumerable: true,
  49333. configurable: true
  49334. });
  49335. /**
  49336. * Attaches a new image processing configuration to the PBR Material.
  49337. * @param configuration (if null the scene configuration will be use)
  49338. */
  49339. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49340. var _this = this;
  49341. if (configuration === this._imageProcessingConfiguration) {
  49342. return;
  49343. }
  49344. // Detaches observer.
  49345. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49346. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49347. }
  49348. // Pick the scene configuration if needed.
  49349. if (!configuration) {
  49350. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49351. }
  49352. else {
  49353. this._imageProcessingConfiguration = configuration;
  49354. }
  49355. // Attaches observer.
  49356. if (this._imageProcessingConfiguration) {
  49357. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49358. _this._computePrimaryColorFromPerceptualColor();
  49359. _this._markAllSubMeshesAsImageProcessingDirty();
  49360. });
  49361. }
  49362. };
  49363. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  49364. /**
  49365. * Gets the image processing configuration used either in this material.
  49366. */
  49367. get: function () {
  49368. return this._imageProcessingConfiguration;
  49369. },
  49370. /**
  49371. * Sets the Default image processing configuration used either in the this material.
  49372. *
  49373. * If sets to null, the scene one is in use.
  49374. */
  49375. set: function (value) {
  49376. this._attachImageProcessingConfiguration(value);
  49377. // Ensure the effect will be rebuilt.
  49378. this._markAllSubMeshesAsTexturesDirty();
  49379. },
  49380. enumerable: true,
  49381. configurable: true
  49382. });
  49383. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  49384. /**
  49385. * Gets wether the color curves effect is enabled.
  49386. */
  49387. get: function () {
  49388. return this.imageProcessingConfiguration.colorCurvesEnabled;
  49389. },
  49390. /**
  49391. * Sets wether the color curves effect is enabled.
  49392. */
  49393. set: function (value) {
  49394. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  49395. },
  49396. enumerable: true,
  49397. configurable: true
  49398. });
  49399. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49400. /**
  49401. * Gets wether the color grading effect is enabled.
  49402. */
  49403. get: function () {
  49404. return this.imageProcessingConfiguration.colorGradingEnabled;
  49405. },
  49406. /**
  49407. * Gets wether the color grading effect is enabled.
  49408. */
  49409. set: function (value) {
  49410. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49411. },
  49412. enumerable: true,
  49413. configurable: true
  49414. });
  49415. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49416. /**
  49417. * Gets wether tonemapping is enabled or not.
  49418. */
  49419. get: function () {
  49420. return this._imageProcessingConfiguration.toneMappingEnabled;
  49421. },
  49422. /**
  49423. * Sets wether tonemapping is enabled or not
  49424. */
  49425. set: function (value) {
  49426. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49427. },
  49428. enumerable: true,
  49429. configurable: true
  49430. });
  49431. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49432. /**
  49433. * The camera exposure used on this material.
  49434. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49435. * This corresponds to a photographic exposure.
  49436. */
  49437. get: function () {
  49438. return this._imageProcessingConfiguration.exposure;
  49439. },
  49440. /**
  49441. * The camera exposure used on this material.
  49442. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49443. * This corresponds to a photographic exposure.
  49444. */
  49445. set: function (value) {
  49446. this._imageProcessingConfiguration.exposure = value;
  49447. },
  49448. enumerable: true,
  49449. configurable: true
  49450. });
  49451. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49452. /**
  49453. * Gets The camera contrast used on this material.
  49454. */
  49455. get: function () {
  49456. return this._imageProcessingConfiguration.contrast;
  49457. },
  49458. /**
  49459. * Sets The camera contrast used on this material.
  49460. */
  49461. set: function (value) {
  49462. this._imageProcessingConfiguration.contrast = value;
  49463. },
  49464. enumerable: true,
  49465. configurable: true
  49466. });
  49467. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49468. /**
  49469. * Gets the Color Grading 2D Lookup Texture.
  49470. */
  49471. get: function () {
  49472. return this._imageProcessingConfiguration.colorGradingTexture;
  49473. },
  49474. /**
  49475. * Sets the Color Grading 2D Lookup Texture.
  49476. */
  49477. set: function (value) {
  49478. this.imageProcessingConfiguration.colorGradingTexture = value;
  49479. },
  49480. enumerable: true,
  49481. configurable: true
  49482. });
  49483. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49484. /**
  49485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49487. * 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;
  49488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49489. */
  49490. get: function () {
  49491. return this.imageProcessingConfiguration.colorCurves;
  49492. },
  49493. /**
  49494. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49495. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49496. * 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;
  49497. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49498. */
  49499. set: function (value) {
  49500. this.imageProcessingConfiguration.colorCurves = value;
  49501. },
  49502. enumerable: true,
  49503. configurable: true
  49504. });
  49505. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49506. /**
  49507. * Gets a boolean indicating that current material needs to register RTT
  49508. */
  49509. get: function () {
  49510. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49511. return true;
  49512. }
  49513. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49514. return true;
  49515. }
  49516. return false;
  49517. },
  49518. enumerable: true,
  49519. configurable: true
  49520. });
  49521. /**
  49522. * The entire material has been created in order to prevent overdraw.
  49523. * @returns false
  49524. */
  49525. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49526. return true;
  49527. };
  49528. /**
  49529. * The entire material has been created in order to prevent overdraw.
  49530. * @returns true if blending is enable
  49531. */
  49532. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49533. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49534. };
  49535. /**
  49536. * Checks wether the material is ready to be rendered for a given mesh.
  49537. * @param mesh The mesh to render
  49538. * @param subMesh The submesh to check against
  49539. * @param useInstances Specify wether or not the material is used with instances
  49540. * @returns true if all the dependencies are ready (Textures, Effects...)
  49541. */
  49542. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49543. var _this = this;
  49544. if (useInstances === void 0) { useInstances = false; }
  49545. if (subMesh.effect && this.isFrozen) {
  49546. if (this._wasPreviouslyReady) {
  49547. return true;
  49548. }
  49549. }
  49550. if (!subMesh._materialDefines) {
  49551. subMesh._materialDefines = new BackgroundMaterialDefines();
  49552. }
  49553. var scene = this.getScene();
  49554. var defines = subMesh._materialDefines;
  49555. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49556. if (defines._renderId === scene.getRenderId()) {
  49557. return true;
  49558. }
  49559. }
  49560. var engine = scene.getEngine();
  49561. // Lights
  49562. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49563. defines._needNormals = true;
  49564. // Textures
  49565. if (defines._areTexturesDirty) {
  49566. defines._needUVs = false;
  49567. if (scene.texturesEnabled) {
  49568. if (scene.getEngine().getCaps().textureLOD) {
  49569. defines.TEXTURELODSUPPORT = true;
  49570. }
  49571. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49572. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49573. return false;
  49574. }
  49575. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49576. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49577. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49578. defines.OPACITYFRESNEL = this._opacityFresnel;
  49579. }
  49580. else {
  49581. defines.DIFFUSE = false;
  49582. defines.DIFFUSEHASALPHA = false;
  49583. defines.GAMMADIFFUSE = false;
  49584. defines.OPACITYFRESNEL = false;
  49585. }
  49586. var reflectionTexture = this._reflectionTexture;
  49587. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49588. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49589. return false;
  49590. }
  49591. defines.REFLECTION = true;
  49592. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49593. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49594. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49595. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49596. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49597. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49598. defines.REFLECTIONBGR = this.switchToBGR;
  49599. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49600. defines.INVERTCUBICMAP = true;
  49601. }
  49602. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49603. switch (reflectionTexture.coordinatesMode) {
  49604. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49605. defines.REFLECTIONMAP_EXPLICIT = true;
  49606. break;
  49607. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49608. defines.REFLECTIONMAP_PLANAR = true;
  49609. break;
  49610. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49611. defines.REFLECTIONMAP_PROJECTION = true;
  49612. break;
  49613. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49614. defines.REFLECTIONMAP_SKYBOX = true;
  49615. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49616. break;
  49617. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49618. defines.REFLECTIONMAP_SPHERICAL = true;
  49619. break;
  49620. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49621. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49622. break;
  49623. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49624. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49625. break;
  49626. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49627. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49628. break;
  49629. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49630. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49631. default:
  49632. defines.REFLECTIONMAP_CUBIC = true;
  49633. break;
  49634. }
  49635. if (this.reflectionFresnel) {
  49636. defines.REFLECTIONFRESNEL = true;
  49637. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49638. this._reflectionControls.x = this.reflectionAmount;
  49639. this._reflectionControls.y = this.reflectionReflectance0;
  49640. this._reflectionControls.z = this.reflectionReflectance90;
  49641. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49642. }
  49643. else {
  49644. defines.REFLECTIONFRESNEL = false;
  49645. defines.REFLECTIONFALLOFF = false;
  49646. }
  49647. }
  49648. else {
  49649. defines.REFLECTION = false;
  49650. defines.REFLECTIONFRESNEL = false;
  49651. defines.REFLECTIONFALLOFF = false;
  49652. defines.REFLECTIONBLUR = false;
  49653. defines.REFLECTIONMAP_3D = false;
  49654. defines.REFLECTIONMAP_SPHERICAL = false;
  49655. defines.REFLECTIONMAP_PLANAR = false;
  49656. defines.REFLECTIONMAP_CUBIC = false;
  49657. defines.REFLECTIONMAP_PROJECTION = false;
  49658. defines.REFLECTIONMAP_SKYBOX = false;
  49659. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49660. defines.REFLECTIONMAP_EXPLICIT = false;
  49661. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49662. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49663. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49664. defines.INVERTCUBICMAP = false;
  49665. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49666. defines.LODINREFLECTIONALPHA = false;
  49667. defines.GAMMAREFLECTION = false;
  49668. defines.RGBDREFLECTION = false;
  49669. }
  49670. }
  49671. 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);
  49672. defines.USERGBCOLOR = this._useRGBColor;
  49673. defines.NOISE = this._enableNoise;
  49674. }
  49675. if (defines._areLightsDirty) {
  49676. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49677. }
  49678. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49679. if (!this._imageProcessingConfiguration.isReady()) {
  49680. return false;
  49681. }
  49682. this._imageProcessingConfiguration.prepareDefines(defines);
  49683. }
  49684. // Misc.
  49685. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49686. // Values that need to be evaluated on every frame
  49687. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49688. // Attribs
  49689. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49690. if (mesh) {
  49691. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49692. mesh.createNormals(true);
  49693. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49694. }
  49695. }
  49696. }
  49697. // Get correct effect
  49698. if (defines.isDirty) {
  49699. defines.markAsProcessed();
  49700. scene.resetCachedMaterial();
  49701. // Fallbacks
  49702. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49703. if (defines.FOG) {
  49704. fallbacks.addFallback(0, "FOG");
  49705. }
  49706. if (defines.POINTSIZE) {
  49707. fallbacks.addFallback(1, "POINTSIZE");
  49708. }
  49709. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  49710. if (defines.NUM_BONE_INFLUENCERS > 0) {
  49711. fallbacks.addCPUSkinningFallback(0, mesh);
  49712. }
  49713. //Attributes
  49714. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  49715. if (defines.NORMAL) {
  49716. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  49717. }
  49718. if (defines.UV1) {
  49719. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  49720. }
  49721. if (defines.UV2) {
  49722. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  49723. }
  49724. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  49725. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  49726. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  49727. "vFogInfos", "vFogColor", "pointSize",
  49728. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  49729. "vPrimaryColor", "vPrimaryColorShadow",
  49730. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  49731. "shadowLevel", "alpha",
  49732. "vBackgroundCenter", "vReflectionControl",
  49733. "vDiffuseInfos", "diffuseMatrix",
  49734. ];
  49735. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  49736. var uniformBuffers = ["Material", "Scene"];
  49737. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  49738. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  49739. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  49740. }
  49741. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  49742. uniformsNames: uniforms,
  49743. uniformBuffersNames: uniformBuffers,
  49744. samplers: samplers,
  49745. defines: defines,
  49746. maxSimultaneousLights: this._maxSimultaneousLights
  49747. });
  49748. var onCompiled = function (effect) {
  49749. if (_this.onCompiled) {
  49750. _this.onCompiled(effect);
  49751. }
  49752. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  49753. };
  49754. var join = defines.toString();
  49755. subMesh.setEffect(scene.getEngine().createEffect("background", {
  49756. attributes: attribs,
  49757. uniformsNames: uniforms,
  49758. uniformBuffersNames: uniformBuffers,
  49759. samplers: samplers,
  49760. defines: join,
  49761. fallbacks: fallbacks,
  49762. onCompiled: onCompiled,
  49763. onError: this.onError,
  49764. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  49765. }, engine), defines);
  49766. this.buildUniformLayout();
  49767. }
  49768. if (!subMesh.effect || !subMesh.effect.isReady()) {
  49769. return false;
  49770. }
  49771. defines._renderId = scene.getRenderId();
  49772. this._wasPreviouslyReady = true;
  49773. return true;
  49774. };
  49775. /**
  49776. * Compute the primary color according to the chosen perceptual color.
  49777. */
  49778. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  49779. if (!this.__perceptualColor) {
  49780. return;
  49781. }
  49782. this._primaryColor.copyFrom(this.__perceptualColor);
  49783. // Revert gamma space.
  49784. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  49785. // Revert image processing configuration.
  49786. if (this._imageProcessingConfiguration) {
  49787. // Revert Exposure.
  49788. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  49789. }
  49790. this._computePrimaryColors();
  49791. };
  49792. /**
  49793. * Compute the highlights and shadow colors according to their chosen levels.
  49794. */
  49795. BackgroundMaterial.prototype._computePrimaryColors = function () {
  49796. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  49797. return;
  49798. }
  49799. // Find the highlight color based on the configuration.
  49800. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  49801. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  49802. // Find the shadow color based on the configuration.
  49803. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  49804. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  49805. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  49806. };
  49807. /**
  49808. * Build the uniform buffer used in the material.
  49809. */
  49810. BackgroundMaterial.prototype.buildUniformLayout = function () {
  49811. // Order is important !
  49812. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  49813. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  49814. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  49815. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  49816. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  49817. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  49818. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  49819. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  49820. this._uniformBuffer.addUniform("pointSize", 1);
  49821. this._uniformBuffer.addUniform("shadowLevel", 1);
  49822. this._uniformBuffer.addUniform("alpha", 1);
  49823. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  49824. this._uniformBuffer.addUniform("vReflectionControl", 4);
  49825. this._uniformBuffer.create();
  49826. };
  49827. /**
  49828. * Unbind the material.
  49829. */
  49830. BackgroundMaterial.prototype.unbind = function () {
  49831. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49832. this._uniformBuffer.setTexture("diffuseSampler", null);
  49833. }
  49834. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49835. this._uniformBuffer.setTexture("reflectionSampler", null);
  49836. }
  49837. _super.prototype.unbind.call(this);
  49838. };
  49839. /**
  49840. * Bind only the world matrix to the material.
  49841. * @param world The world matrix to bind.
  49842. */
  49843. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  49844. this._activeEffect.setMatrix("world", world);
  49845. };
  49846. /**
  49847. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49848. * @param world The world matrix to bind.
  49849. * @param subMesh The submesh to bind for.
  49850. */
  49851. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  49852. var scene = this.getScene();
  49853. var defines = subMesh._materialDefines;
  49854. if (!defines) {
  49855. return;
  49856. }
  49857. var effect = subMesh.effect;
  49858. if (!effect) {
  49859. return;
  49860. }
  49861. this._activeEffect = effect;
  49862. // Matrices
  49863. this.bindOnlyWorldMatrix(world);
  49864. // Bones
  49865. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  49866. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  49867. if (mustRebind) {
  49868. this._uniformBuffer.bindToEffect(effect, "Material");
  49869. this.bindViewProjection(effect);
  49870. var reflectionTexture = this._reflectionTexture;
  49871. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  49872. // Texture uniforms
  49873. if (scene.texturesEnabled) {
  49874. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49875. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  49876. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  49877. }
  49878. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49879. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  49880. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  49881. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  49882. }
  49883. }
  49884. if (this.shadowLevel > 0) {
  49885. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  49886. }
  49887. this._uniformBuffer.updateFloat("alpha", this.alpha);
  49888. // Point size
  49889. if (this.pointsCloud) {
  49890. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  49891. }
  49892. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  49893. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  49894. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  49895. }
  49896. else {
  49897. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  49898. }
  49899. }
  49900. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  49901. // Textures
  49902. if (scene.texturesEnabled) {
  49903. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49904. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  49905. }
  49906. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49907. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  49908. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49909. }
  49910. else if (!defines.REFLECTIONBLUR) {
  49911. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49912. }
  49913. else {
  49914. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  49915. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  49916. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  49917. }
  49918. if (defines.REFLECTIONFRESNEL) {
  49919. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  49920. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  49921. }
  49922. }
  49923. }
  49924. // Clip plane
  49925. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  49926. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  49927. }
  49928. if (mustRebind || !this.isFrozen) {
  49929. if (scene.lightsEnabled) {
  49930. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  49931. }
  49932. // View
  49933. this.bindView(effect);
  49934. // Fog
  49935. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  49936. // image processing
  49937. if (this._imageProcessingConfiguration) {
  49938. this._imageProcessingConfiguration.bind(this._activeEffect);
  49939. }
  49940. }
  49941. this._uniformBuffer.update();
  49942. this._afterBind(mesh, this._activeEffect);
  49943. };
  49944. /**
  49945. * Dispose the material.
  49946. * @param forceDisposeEffect Force disposal of the associated effect.
  49947. * @param forceDisposeTextures Force disposal of the associated textures.
  49948. */
  49949. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  49950. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  49951. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  49952. if (forceDisposeTextures) {
  49953. if (this.diffuseTexture) {
  49954. this.diffuseTexture.dispose();
  49955. }
  49956. if (this.reflectionTexture) {
  49957. this.reflectionTexture.dispose();
  49958. }
  49959. }
  49960. this._renderTargets.dispose();
  49961. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49962. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49963. }
  49964. _super.prototype.dispose.call(this, forceDisposeEffect);
  49965. };
  49966. /**
  49967. * Clones the material.
  49968. * @param name The cloned name.
  49969. * @returns The cloned material.
  49970. */
  49971. BackgroundMaterial.prototype.clone = function (name) {
  49972. var _this = this;
  49973. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  49974. };
  49975. /**
  49976. * Serializes the current material to its JSON representation.
  49977. * @returns The JSON representation.
  49978. */
  49979. BackgroundMaterial.prototype.serialize = function () {
  49980. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  49981. serializationObject.customType = "BABYLON.BackgroundMaterial";
  49982. return serializationObject;
  49983. };
  49984. /**
  49985. * Gets the class name of the material
  49986. * @returns "BackgroundMaterial"
  49987. */
  49988. BackgroundMaterial.prototype.getClassName = function () {
  49989. return "BackgroundMaterial";
  49990. };
  49991. /**
  49992. * Parse a JSON input to create back a background material.
  49993. * @param source The JSON data to parse
  49994. * @param scene The scene to create the parsed material in
  49995. * @param rootUrl The root url of the assets the material depends upon
  49996. * @returns the instantiated BackgroundMaterial.
  49997. */
  49998. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  49999. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50000. };
  50001. /**
  50002. * Standard reflectance value at parallel view angle.
  50003. */
  50004. BackgroundMaterial.StandardReflectance0 = 0.05;
  50005. /**
  50006. * Standard reflectance value at grazing angle.
  50007. */
  50008. BackgroundMaterial.StandardReflectance90 = 0.5;
  50009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50011. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50014. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50017. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50020. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50023. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50026. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50029. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50032. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50035. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50038. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50041. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50044. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50047. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50050. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50053. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50056. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50059. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50062. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50065. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50068. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50071. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50074. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50077. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50080. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50083. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50086. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50089. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50092. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50095. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50098. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50101. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50104. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50107. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50110. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50113. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50116. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50117. return BackgroundMaterial;
  50118. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50119. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50120. /***/ }),
  50121. /***/ "./Materials/Background/index.ts":
  50122. /*!***************************************!*\
  50123. !*** ./Materials/Background/index.ts ***!
  50124. \***************************************/
  50125. /*! exports provided: BackgroundMaterial */
  50126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50127. "use strict";
  50128. __webpack_require__.r(__webpack_exports__);
  50129. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50131. /***/ }),
  50132. /***/ "./Materials/PBR/index.ts":
  50133. /*!********************************!*\
  50134. !*** ./Materials/PBR/index.ts ***!
  50135. \********************************/
  50136. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  50137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50138. "use strict";
  50139. __webpack_require__.r(__webpack_exports__);
  50140. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  50141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  50142. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  50143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  50144. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  50145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  50146. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  50147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  50148. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  50149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  50150. /***/ }),
  50151. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  50152. /*!******************************************!*\
  50153. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  50154. \******************************************/
  50155. /*! exports provided: PBRBaseMaterial */
  50156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50157. "use strict";
  50158. __webpack_require__.r(__webpack_exports__);
  50159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  50160. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50161. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50162. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50163. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50164. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  50165. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  50166. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50167. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50168. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50169. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50170. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50171. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50172. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50173. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50174. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50175. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50176. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  50177. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  50178. /**
  50179. * Manages the defines for the PBR Material.
  50180. * @hiddenChildren
  50181. */
  50182. var PBRMaterialDefines = /** @class */ (function (_super) {
  50183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  50184. /**
  50185. * Initializes the PBR Material defines.
  50186. */
  50187. function PBRMaterialDefines() {
  50188. var _this = _super.call(this) || this;
  50189. _this.PBR = true;
  50190. _this.MAINUV1 = false;
  50191. _this.MAINUV2 = false;
  50192. _this.UV1 = false;
  50193. _this.UV2 = false;
  50194. _this.ALBEDO = false;
  50195. _this.ALBEDODIRECTUV = 0;
  50196. _this.VERTEXCOLOR = false;
  50197. _this.AMBIENT = false;
  50198. _this.AMBIENTDIRECTUV = 0;
  50199. _this.AMBIENTINGRAYSCALE = false;
  50200. _this.OPACITY = false;
  50201. _this.VERTEXALPHA = false;
  50202. _this.OPACITYDIRECTUV = 0;
  50203. _this.OPACITYRGB = false;
  50204. _this.ALPHATEST = false;
  50205. _this.DEPTHPREPASS = false;
  50206. _this.ALPHABLEND = false;
  50207. _this.ALPHAFROMALBEDO = false;
  50208. _this.ALPHATESTVALUE = "0.5";
  50209. _this.SPECULAROVERALPHA = false;
  50210. _this.RADIANCEOVERALPHA = false;
  50211. _this.ALPHAFRESNEL = false;
  50212. _this.LINEARALPHAFRESNEL = false;
  50213. _this.PREMULTIPLYALPHA = false;
  50214. _this.EMISSIVE = false;
  50215. _this.EMISSIVEDIRECTUV = 0;
  50216. _this.REFLECTIVITY = false;
  50217. _this.REFLECTIVITYDIRECTUV = 0;
  50218. _this.SPECULARTERM = false;
  50219. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  50220. _this.MICROSURFACEAUTOMATIC = false;
  50221. _this.LODBASEDMICROSFURACE = false;
  50222. _this.MICROSURFACEMAP = false;
  50223. _this.MICROSURFACEMAPDIRECTUV = 0;
  50224. _this.METALLICWORKFLOW = false;
  50225. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  50226. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  50227. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  50228. _this.AOSTOREINMETALMAPRED = false;
  50229. _this.ENVIRONMENTBRDF = false;
  50230. _this.NORMAL = false;
  50231. _this.TANGENT = false;
  50232. _this.BUMP = false;
  50233. _this.BUMPDIRECTUV = 0;
  50234. _this.OBJECTSPACE_NORMALMAP = false;
  50235. _this.PARALLAX = false;
  50236. _this.PARALLAXOCCLUSION = false;
  50237. _this.NORMALXYSCALE = true;
  50238. _this.LIGHTMAP = false;
  50239. _this.LIGHTMAPDIRECTUV = 0;
  50240. _this.USELIGHTMAPASSHADOWMAP = false;
  50241. _this.GAMMALIGHTMAP = false;
  50242. _this.REFLECTION = false;
  50243. _this.REFLECTIONMAP_3D = false;
  50244. _this.REFLECTIONMAP_SPHERICAL = false;
  50245. _this.REFLECTIONMAP_PLANAR = false;
  50246. _this.REFLECTIONMAP_CUBIC = false;
  50247. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50248. _this.REFLECTIONMAP_PROJECTION = false;
  50249. _this.REFLECTIONMAP_SKYBOX = false;
  50250. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50251. _this.REFLECTIONMAP_EXPLICIT = false;
  50252. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50253. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50254. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50255. _this.INVERTCUBICMAP = false;
  50256. _this.USESPHERICALFROMREFLECTIONMAP = false;
  50257. _this.USESPHERICALINVERTEX = false;
  50258. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50259. _this.LODINREFLECTIONALPHA = false;
  50260. _this.GAMMAREFLECTION = false;
  50261. _this.RGBDREFLECTION = false;
  50262. _this.RADIANCEOCCLUSION = false;
  50263. _this.HORIZONOCCLUSION = false;
  50264. _this.REFRACTION = false;
  50265. _this.REFRACTIONMAP_3D = false;
  50266. _this.REFRACTIONMAP_OPPOSITEZ = false;
  50267. _this.LODINREFRACTIONALPHA = false;
  50268. _this.GAMMAREFRACTION = false;
  50269. _this.RGBDREFRACTION = false;
  50270. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  50271. _this.INSTANCES = false;
  50272. _this.NUM_BONE_INFLUENCERS = 0;
  50273. _this.BonesPerMesh = 0;
  50274. _this.BONETEXTURE = false;
  50275. _this.NONUNIFORMSCALING = false;
  50276. _this.MORPHTARGETS = false;
  50277. _this.MORPHTARGETS_NORMAL = false;
  50278. _this.MORPHTARGETS_TANGENT = false;
  50279. _this.NUM_MORPH_INFLUENCERS = 0;
  50280. _this.IMAGEPROCESSING = false;
  50281. _this.VIGNETTE = false;
  50282. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50283. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50284. _this.TONEMAPPING = false;
  50285. _this.TONEMAPPING_ACES = false;
  50286. _this.CONTRAST = false;
  50287. _this.COLORCURVES = false;
  50288. _this.COLORGRADING = false;
  50289. _this.COLORGRADING3D = false;
  50290. _this.SAMPLER3DGREENDEPTH = false;
  50291. _this.SAMPLER3DBGRMAP = false;
  50292. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50293. _this.EXPOSURE = false;
  50294. _this.USEPHYSICALLIGHTFALLOFF = false;
  50295. _this.USEGLTFLIGHTFALLOFF = false;
  50296. _this.TWOSIDEDLIGHTING = false;
  50297. _this.SHADOWFLOAT = false;
  50298. _this.CLIPPLANE = false;
  50299. _this.CLIPPLANE2 = false;
  50300. _this.CLIPPLANE3 = false;
  50301. _this.CLIPPLANE4 = false;
  50302. _this.POINTSIZE = false;
  50303. _this.FOG = false;
  50304. _this.LOGARITHMICDEPTH = false;
  50305. _this.FORCENORMALFORWARD = false;
  50306. _this.SPECULARAA = false;
  50307. _this.UNLIT = false;
  50308. _this.rebuild();
  50309. return _this;
  50310. }
  50311. /**
  50312. * Resets the PBR Material defines.
  50313. */
  50314. PBRMaterialDefines.prototype.reset = function () {
  50315. _super.prototype.reset.call(this);
  50316. this.ALPHATESTVALUE = "0.5";
  50317. this.PBR = true;
  50318. };
  50319. return PBRMaterialDefines;
  50320. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  50321. /**
  50322. * The Physically based material base class of BJS.
  50323. *
  50324. * This offers the main features of a standard PBR material.
  50325. * For more information, please refer to the documentation :
  50326. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  50327. */
  50328. var PBRBaseMaterial = /** @class */ (function (_super) {
  50329. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  50330. /**
  50331. * Instantiates a new PBRMaterial instance.
  50332. *
  50333. * @param name The material name
  50334. * @param scene The scene the material will be use in.
  50335. */
  50336. function PBRBaseMaterial(name, scene) {
  50337. var _this = _super.call(this, name, scene) || this;
  50338. /**
  50339. * Intensity of the direct lights e.g. the four lights available in your scene.
  50340. * This impacts both the direct diffuse and specular highlights.
  50341. */
  50342. _this._directIntensity = 1.0;
  50343. /**
  50344. * Intensity of the emissive part of the material.
  50345. * This helps controlling the emissive effect without modifying the emissive color.
  50346. */
  50347. _this._emissiveIntensity = 1.0;
  50348. /**
  50349. * Intensity of the environment e.g. how much the environment will light the object
  50350. * either through harmonics for rough material or through the refelction for shiny ones.
  50351. */
  50352. _this._environmentIntensity = 1.0;
  50353. /**
  50354. * This is a special control allowing the reduction of the specular highlights coming from the
  50355. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50356. */
  50357. _this._specularIntensity = 1.0;
  50358. /**
  50359. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50360. */
  50361. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  50362. /**
  50363. * Debug Control allowing disabling the bump map on this material.
  50364. */
  50365. _this._disableBumpMap = false;
  50366. /**
  50367. * AKA Occlusion Texture Intensity in other nomenclature.
  50368. */
  50369. _this._ambientTextureStrength = 1.0;
  50370. /**
  50371. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50372. * 1 means it completely occludes it
  50373. * 0 mean it has no impact
  50374. */
  50375. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  50376. /**
  50377. * The color of a material in ambient lighting.
  50378. */
  50379. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50380. /**
  50381. * AKA Diffuse Color in other nomenclature.
  50382. */
  50383. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50384. /**
  50385. * AKA Specular Color in other nomenclature.
  50386. */
  50387. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50388. /**
  50389. * The color applied when light is reflected from a material.
  50390. */
  50391. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50392. /**
  50393. * The color applied when light is emitted from a material.
  50394. */
  50395. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50396. /**
  50397. * AKA Glossiness in other nomenclature.
  50398. */
  50399. _this._microSurface = 0.9;
  50400. /**
  50401. * source material index of refraction (IOR)' / 'destination material IOR.
  50402. */
  50403. _this._indexOfRefraction = 0.66;
  50404. /**
  50405. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50406. */
  50407. _this._invertRefractionY = false;
  50408. /**
  50409. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50410. * Materials half opaque for instance using refraction could benefit from this control.
  50411. */
  50412. _this._linkRefractionWithTransparency = false;
  50413. /**
  50414. * Specifies that the material will use the light map as a show map.
  50415. */
  50416. _this._useLightmapAsShadowmap = false;
  50417. /**
  50418. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50419. * makes the reflect vector face the model (under horizon).
  50420. */
  50421. _this._useHorizonOcclusion = true;
  50422. /**
  50423. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50424. * too much the area relying on ambient texture to define their ambient occlusion.
  50425. */
  50426. _this._useRadianceOcclusion = true;
  50427. /**
  50428. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50429. */
  50430. _this._useAlphaFromAlbedoTexture = false;
  50431. /**
  50432. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50433. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50434. */
  50435. _this._useSpecularOverAlpha = true;
  50436. /**
  50437. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50438. */
  50439. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50440. /**
  50441. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50442. */
  50443. _this._useRoughnessFromMetallicTextureAlpha = true;
  50444. /**
  50445. * Specifies if the metallic texture contains the roughness information in its green channel.
  50446. */
  50447. _this._useRoughnessFromMetallicTextureGreen = false;
  50448. /**
  50449. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50450. */
  50451. _this._useMetallnessFromMetallicTextureBlue = false;
  50452. /**
  50453. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50454. */
  50455. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50456. /**
  50457. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50458. */
  50459. _this._useAmbientInGrayScale = false;
  50460. /**
  50461. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50462. * The material will try to infer what glossiness each pixel should be.
  50463. */
  50464. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50465. /**
  50466. * Defines the falloff type used in this material.
  50467. * It by default is Physical.
  50468. */
  50469. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50470. /**
  50471. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50472. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50473. */
  50474. _this._useRadianceOverAlpha = true;
  50475. /**
  50476. * Allows using an object space normal map (instead of tangent space).
  50477. */
  50478. _this._useObjectSpaceNormalMap = false;
  50479. /**
  50480. * Allows using the bump map in parallax mode.
  50481. */
  50482. _this._useParallax = false;
  50483. /**
  50484. * Allows using the bump map in parallax occlusion mode.
  50485. */
  50486. _this._useParallaxOcclusion = false;
  50487. /**
  50488. * Controls the scale bias of the parallax mode.
  50489. */
  50490. _this._parallaxScaleBias = 0.05;
  50491. /**
  50492. * If sets to true, disables all the lights affecting the material.
  50493. */
  50494. _this._disableLighting = false;
  50495. /**
  50496. * Number of Simultaneous lights allowed on the material.
  50497. */
  50498. _this._maxSimultaneousLights = 4;
  50499. /**
  50500. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50501. */
  50502. _this._invertNormalMapX = false;
  50503. /**
  50504. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50505. */
  50506. _this._invertNormalMapY = false;
  50507. /**
  50508. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50509. */
  50510. _this._twoSidedLighting = false;
  50511. /**
  50512. * Defines the alpha limits in alpha test mode.
  50513. */
  50514. _this._alphaCutOff = 0.4;
  50515. /**
  50516. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50517. */
  50518. _this._forceAlphaTest = false;
  50519. /**
  50520. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50521. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50522. */
  50523. _this._useAlphaFresnel = false;
  50524. /**
  50525. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50526. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50527. */
  50528. _this._useLinearAlphaFresnel = false;
  50529. /**
  50530. * The transparency mode of the material.
  50531. */
  50532. _this._transparencyMode = null;
  50533. /**
  50534. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50535. * from cos thetav and roughness:
  50536. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50537. */
  50538. _this._environmentBRDFTexture = null;
  50539. /**
  50540. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50541. */
  50542. _this._forceIrradianceInFragment = false;
  50543. /**
  50544. * Force normal to face away from face.
  50545. */
  50546. _this._forceNormalForward = false;
  50547. /**
  50548. * Enables specular anti aliasing in the PBR shader.
  50549. * It will both interacts on the Geometry for analytical and IBL lighting.
  50550. * It also prefilter the roughness map based on the bump values.
  50551. */
  50552. _this._enableSpecularAntiAliasing = false;
  50553. /**
  50554. * Stores the available render targets.
  50555. */
  50556. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50557. /**
  50558. * Sets the global ambient color for the material used in lighting calculations.
  50559. */
  50560. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50561. /**
  50562. * If set to true, no lighting calculations will be applied.
  50563. */
  50564. _this._unlit = false;
  50565. // Setup the default processing configuration to the scene.
  50566. _this._attachImageProcessingConfiguration(null);
  50567. _this.getRenderTargetTextures = function () {
  50568. _this._renderTargets.reset();
  50569. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50570. _this._renderTargets.push(_this._reflectionTexture);
  50571. }
  50572. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50573. _this._renderTargets.push(_this._refractionTexture);
  50574. }
  50575. return _this._renderTargets;
  50576. };
  50577. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50578. return _this;
  50579. }
  50580. /**
  50581. * Attaches a new image processing configuration to the PBR Material.
  50582. * @param configuration
  50583. */
  50584. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50585. var _this = this;
  50586. if (configuration === this._imageProcessingConfiguration) {
  50587. return;
  50588. }
  50589. // Detaches observer.
  50590. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50591. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50592. }
  50593. // Pick the scene configuration if needed.
  50594. if (!configuration) {
  50595. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50596. }
  50597. else {
  50598. this._imageProcessingConfiguration = configuration;
  50599. }
  50600. // Attaches observer.
  50601. if (this._imageProcessingConfiguration) {
  50602. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50603. _this._markAllSubMeshesAsImageProcessingDirty();
  50604. });
  50605. }
  50606. };
  50607. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50608. /**
  50609. * Gets a boolean indicating that current material needs to register RTT
  50610. */
  50611. get: function () {
  50612. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50613. return true;
  50614. }
  50615. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50616. return true;
  50617. }
  50618. return false;
  50619. },
  50620. enumerable: true,
  50621. configurable: true
  50622. });
  50623. /**
  50624. * Gets the name of the material class.
  50625. */
  50626. PBRBaseMaterial.prototype.getClassName = function () {
  50627. return "PBRBaseMaterial";
  50628. };
  50629. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50630. /**
  50631. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50632. */
  50633. get: function () {
  50634. return this._useLogarithmicDepth;
  50635. },
  50636. /**
  50637. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50638. */
  50639. set: function (value) {
  50640. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50641. },
  50642. enumerable: true,
  50643. configurable: true
  50644. });
  50645. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50646. /**
  50647. * Gets the current transparency mode.
  50648. */
  50649. get: function () {
  50650. return this._transparencyMode;
  50651. },
  50652. /**
  50653. * Sets the transparency mode of the material.
  50654. *
  50655. * | Value | Type | Description |
  50656. * | ----- | ----------------------------------- | ----------- |
  50657. * | 0 | OPAQUE | |
  50658. * | 1 | ALPHATEST | |
  50659. * | 2 | ALPHABLEND | |
  50660. * | 3 | ALPHATESTANDBLEND | |
  50661. *
  50662. */
  50663. set: function (value) {
  50664. if (this._transparencyMode === value) {
  50665. return;
  50666. }
  50667. this._transparencyMode = value;
  50668. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50669. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50670. },
  50671. enumerable: true,
  50672. configurable: true
  50673. });
  50674. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50675. /**
  50676. * Returns true if alpha blending should be disabled.
  50677. */
  50678. get: function () {
  50679. return (this._linkRefractionWithTransparency ||
  50680. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50681. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50682. },
  50683. enumerable: true,
  50684. configurable: true
  50685. });
  50686. /**
  50687. * Specifies whether or not this material should be rendered in alpha blend mode.
  50688. */
  50689. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50690. if (this._disableAlphaBlending) {
  50691. return false;
  50692. }
  50693. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50694. };
  50695. /**
  50696. * Specifies if the mesh will require alpha blending.
  50697. * @param mesh - BJS mesh.
  50698. */
  50699. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50700. if (this._disableAlphaBlending) {
  50701. return false;
  50702. }
  50703. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50704. };
  50705. /**
  50706. * Specifies whether or not this material should be rendered in alpha test mode.
  50707. */
  50708. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50709. if (this._forceAlphaTest) {
  50710. return true;
  50711. }
  50712. if (this._linkRefractionWithTransparency) {
  50713. return false;
  50714. }
  50715. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50716. };
  50717. /**
  50718. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50719. */
  50720. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  50721. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  50722. };
  50723. /**
  50724. * Gets the texture used for the alpha test.
  50725. */
  50726. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  50727. return this._albedoTexture;
  50728. };
  50729. /**
  50730. * Specifies that the submesh is ready to be used.
  50731. * @param mesh - BJS mesh.
  50732. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50733. * @param useInstances - Specifies that instances should be used.
  50734. * @returns - boolean indicating that the submesh is ready or not.
  50735. */
  50736. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50737. if (subMesh.effect && this.isFrozen) {
  50738. if (this._wasPreviouslyReady) {
  50739. return true;
  50740. }
  50741. }
  50742. if (!subMesh._materialDefines) {
  50743. subMesh._materialDefines = new PBRMaterialDefines();
  50744. }
  50745. var defines = subMesh._materialDefines;
  50746. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50747. if (defines._renderId === this.getScene().getRenderId()) {
  50748. return true;
  50749. }
  50750. }
  50751. var scene = this.getScene();
  50752. var engine = scene.getEngine();
  50753. if (defines._areTexturesDirty) {
  50754. if (scene.texturesEnabled) {
  50755. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50756. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  50757. return false;
  50758. }
  50759. }
  50760. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50761. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  50762. return false;
  50763. }
  50764. }
  50765. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50766. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  50767. return false;
  50768. }
  50769. }
  50770. var reflectionTexture = this._getReflectionTexture();
  50771. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50772. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50773. return false;
  50774. }
  50775. }
  50776. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50777. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  50778. return false;
  50779. }
  50780. }
  50781. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50782. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  50783. return false;
  50784. }
  50785. }
  50786. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50787. if (this._metallicTexture) {
  50788. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  50789. return false;
  50790. }
  50791. }
  50792. else if (this._reflectivityTexture) {
  50793. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  50794. return false;
  50795. }
  50796. }
  50797. if (this._microSurfaceTexture) {
  50798. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  50799. return false;
  50800. }
  50801. }
  50802. }
  50803. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50804. // Bump texture cannot be not blocking.
  50805. if (!this._bumpTexture.isReady()) {
  50806. return false;
  50807. }
  50808. }
  50809. var refractionTexture = this._getRefractionTexture();
  50810. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50811. if (!refractionTexture.isReadyOrNotBlocking()) {
  50812. return false;
  50813. }
  50814. }
  50815. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50816. // This is blocking.
  50817. if (!this._environmentBRDFTexture.isReady()) {
  50818. return false;
  50819. }
  50820. }
  50821. }
  50822. }
  50823. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50824. if (!this._imageProcessingConfiguration.isReady()) {
  50825. return false;
  50826. }
  50827. }
  50828. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  50829. mesh.createNormals(true);
  50830. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  50831. }
  50832. var previousEffect = subMesh.effect;
  50833. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  50834. if (effect) {
  50835. // Use previous effect while new one is compiling
  50836. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  50837. effect = previousEffect;
  50838. defines.markAsUnprocessed();
  50839. }
  50840. else {
  50841. scene.resetCachedMaterial();
  50842. subMesh.setEffect(effect, defines);
  50843. this.buildUniformLayout();
  50844. }
  50845. }
  50846. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50847. return false;
  50848. }
  50849. defines._renderId = scene.getRenderId();
  50850. this._wasPreviouslyReady = true;
  50851. return true;
  50852. };
  50853. /**
  50854. * Specifies if the material uses metallic roughness workflow.
  50855. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50856. */
  50857. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  50858. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  50859. return true;
  50860. }
  50861. return false;
  50862. };
  50863. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  50864. if (onCompiled === void 0) { onCompiled = null; }
  50865. if (onError === void 0) { onError = null; }
  50866. if (useInstances === void 0) { useInstances = null; }
  50867. if (useClipPlane === void 0) { useClipPlane = null; }
  50868. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  50869. if (!defines.isDirty) {
  50870. return null;
  50871. }
  50872. defines.markAsProcessed();
  50873. var scene = this.getScene();
  50874. var engine = scene.getEngine();
  50875. // Fallbacks
  50876. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  50877. var fallbackRank = 0;
  50878. if (defines.USESPHERICALINVERTEX) {
  50879. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  50880. }
  50881. if (defines.FOG) {
  50882. fallbacks.addFallback(fallbackRank, "FOG");
  50883. }
  50884. if (defines.SPECULARAA) {
  50885. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  50886. }
  50887. if (defines.POINTSIZE) {
  50888. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  50889. }
  50890. if (defines.LOGARITHMICDEPTH) {
  50891. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  50892. }
  50893. if (defines.PARALLAX) {
  50894. fallbacks.addFallback(fallbackRank, "PARALLAX");
  50895. }
  50896. if (defines.PARALLAXOCCLUSION) {
  50897. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  50898. }
  50899. if (defines.ENVIRONMENTBRDF) {
  50900. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  50901. }
  50902. if (defines.TANGENT) {
  50903. fallbacks.addFallback(fallbackRank++, "TANGENT");
  50904. }
  50905. if (defines.BUMP) {
  50906. fallbacks.addFallback(fallbackRank++, "BUMP");
  50907. }
  50908. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  50909. if (defines.SPECULARTERM) {
  50910. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  50911. }
  50912. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  50913. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  50914. }
  50915. if (defines.LIGHTMAP) {
  50916. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  50917. }
  50918. if (defines.NORMAL) {
  50919. fallbacks.addFallback(fallbackRank++, "NORMAL");
  50920. }
  50921. if (defines.AMBIENT) {
  50922. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  50923. }
  50924. if (defines.EMISSIVE) {
  50925. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  50926. }
  50927. if (defines.VERTEXCOLOR) {
  50928. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  50929. }
  50930. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50931. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  50932. }
  50933. if (defines.MORPHTARGETS) {
  50934. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  50935. }
  50936. //Attributes
  50937. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  50938. if (defines.NORMAL) {
  50939. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  50940. }
  50941. if (defines.TANGENT) {
  50942. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  50943. }
  50944. if (defines.UV1) {
  50945. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  50946. }
  50947. if (defines.UV2) {
  50948. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  50949. }
  50950. if (defines.VERTEXCOLOR) {
  50951. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  50952. }
  50953. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50954. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50955. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  50956. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  50957. "vFogInfos", "vFogColor", "pointSize",
  50958. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  50959. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  50960. "mBones",
  50961. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  50962. "vLightingIntensity",
  50963. "logarithmicDepthConstant",
  50964. "vSphericalX", "vSphericalY", "vSphericalZ",
  50965. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  50966. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  50967. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  50968. "vTangentSpaceParams", "boneTextureWidth"
  50969. ];
  50970. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  50971. "bumpSampler", "lightmapSampler", "opacitySampler",
  50972. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  50973. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  50974. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  50975. var uniformBuffers = ["Material", "Scene"];
  50976. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  50977. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50978. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50979. }
  50980. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50981. uniformsNames: uniforms,
  50982. uniformBuffersNames: uniformBuffers,
  50983. samplers: samplers,
  50984. defines: defines,
  50985. maxSimultaneousLights: this._maxSimultaneousLights
  50986. });
  50987. var join = defines.toString();
  50988. return engine.createEffect("pbr", {
  50989. attributes: attribs,
  50990. uniformsNames: uniforms,
  50991. uniformBuffersNames: uniformBuffers,
  50992. samplers: samplers,
  50993. defines: join,
  50994. fallbacks: fallbacks,
  50995. onCompiled: onCompiled,
  50996. onError: onError,
  50997. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  50998. }, engine);
  50999. };
  51000. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  51001. if (useInstances === void 0) { useInstances = null; }
  51002. if (useClipPlane === void 0) { useClipPlane = null; }
  51003. var scene = this.getScene();
  51004. var engine = scene.getEngine();
  51005. // Lights
  51006. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  51007. defines._needNormals = true;
  51008. // Textures
  51009. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  51010. if (defines._areTexturesDirty) {
  51011. defines._needUVs = false;
  51012. if (scene.texturesEnabled) {
  51013. if (scene.getEngine().getCaps().textureLOD) {
  51014. defines.LODBASEDMICROSFURACE = true;
  51015. }
  51016. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51017. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  51018. }
  51019. else {
  51020. defines.ALBEDO = false;
  51021. }
  51022. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51023. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  51024. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  51025. }
  51026. else {
  51027. defines.AMBIENT = false;
  51028. }
  51029. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51030. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  51031. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  51032. }
  51033. else {
  51034. defines.OPACITY = false;
  51035. }
  51036. var reflectionTexture = this._getReflectionTexture();
  51037. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51038. defines.REFLECTION = true;
  51039. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51040. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51041. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51042. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51043. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  51044. defines.INVERTCUBICMAP = true;
  51045. }
  51046. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51047. defines.REFLECTIONMAP_CUBIC = false;
  51048. defines.REFLECTIONMAP_EXPLICIT = false;
  51049. defines.REFLECTIONMAP_PLANAR = false;
  51050. defines.REFLECTIONMAP_PROJECTION = false;
  51051. defines.REFLECTIONMAP_SKYBOX = false;
  51052. defines.REFLECTIONMAP_SPHERICAL = false;
  51053. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51054. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51055. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51056. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51057. switch (reflectionTexture.coordinatesMode) {
  51058. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  51059. defines.REFLECTIONMAP_EXPLICIT = true;
  51060. break;
  51061. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  51062. defines.REFLECTIONMAP_PLANAR = true;
  51063. break;
  51064. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  51065. defines.REFLECTIONMAP_PROJECTION = true;
  51066. break;
  51067. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  51068. defines.REFLECTIONMAP_SKYBOX = true;
  51069. break;
  51070. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  51071. defines.REFLECTIONMAP_SPHERICAL = true;
  51072. break;
  51073. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  51074. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51075. break;
  51076. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51077. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51078. break;
  51079. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51080. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51081. break;
  51082. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  51083. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  51084. default:
  51085. defines.REFLECTIONMAP_CUBIC = true;
  51086. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  51087. break;
  51088. }
  51089. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  51090. if (reflectionTexture.sphericalPolynomial) {
  51091. defines.USESPHERICALFROMREFLECTIONMAP = true;
  51092. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  51093. defines.USESPHERICALINVERTEX = false;
  51094. }
  51095. else {
  51096. defines.USESPHERICALINVERTEX = true;
  51097. }
  51098. }
  51099. }
  51100. else {
  51101. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51102. }
  51103. }
  51104. else {
  51105. defines.REFLECTION = false;
  51106. defines.REFLECTIONMAP_3D = false;
  51107. defines.REFLECTIONMAP_SPHERICAL = false;
  51108. defines.REFLECTIONMAP_PLANAR = false;
  51109. defines.REFLECTIONMAP_CUBIC = false;
  51110. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51111. defines.REFLECTIONMAP_PROJECTION = false;
  51112. defines.REFLECTIONMAP_SKYBOX = false;
  51113. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51114. defines.REFLECTIONMAP_EXPLICIT = false;
  51115. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51116. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51117. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51118. defines.INVERTCUBICMAP = false;
  51119. defines.USESPHERICALFROMREFLECTIONMAP = false;
  51120. defines.USESPHERICALINVERTEX = false;
  51121. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51122. defines.LODINREFLECTIONALPHA = false;
  51123. defines.GAMMAREFLECTION = false;
  51124. defines.RGBDREFLECTION = false;
  51125. }
  51126. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51127. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  51128. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  51129. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  51130. }
  51131. else {
  51132. defines.LIGHTMAP = false;
  51133. }
  51134. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51135. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  51136. }
  51137. else {
  51138. defines.EMISSIVE = false;
  51139. }
  51140. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51141. if (this._metallicTexture) {
  51142. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  51143. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  51144. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  51145. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  51146. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  51147. }
  51148. else if (this._reflectivityTexture) {
  51149. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  51150. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  51151. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  51152. }
  51153. else {
  51154. defines.REFLECTIVITY = false;
  51155. }
  51156. if (this._microSurfaceTexture) {
  51157. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  51158. }
  51159. else {
  51160. defines.MICROSURFACEMAP = false;
  51161. }
  51162. }
  51163. else {
  51164. defines.REFLECTIVITY = false;
  51165. defines.MICROSURFACEMAP = false;
  51166. }
  51167. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51168. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  51169. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51170. defines.PARALLAX = true;
  51171. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  51172. }
  51173. else {
  51174. defines.PARALLAX = false;
  51175. }
  51176. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  51177. }
  51178. else {
  51179. defines.BUMP = false;
  51180. }
  51181. var refractionTexture = this._getRefractionTexture();
  51182. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51183. defines.REFRACTION = true;
  51184. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  51185. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  51186. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  51187. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  51188. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  51189. if (this._linkRefractionWithTransparency) {
  51190. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  51191. }
  51192. }
  51193. else {
  51194. defines.REFRACTION = false;
  51195. }
  51196. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51197. defines.ENVIRONMENTBRDF = true;
  51198. }
  51199. else {
  51200. defines.ENVIRONMENTBRDF = false;
  51201. }
  51202. if (this._shouldUseAlphaFromAlbedoTexture()) {
  51203. defines.ALPHAFROMALBEDO = true;
  51204. }
  51205. else {
  51206. defines.ALPHAFROMALBEDO = false;
  51207. }
  51208. }
  51209. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  51210. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  51211. defines.USEPHYSICALLIGHTFALLOFF = false;
  51212. defines.USEGLTFLIGHTFALLOFF = false;
  51213. }
  51214. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  51215. defines.USEPHYSICALLIGHTFALLOFF = false;
  51216. defines.USEGLTFLIGHTFALLOFF = true;
  51217. }
  51218. else {
  51219. defines.USEPHYSICALLIGHTFALLOFF = true;
  51220. defines.USEGLTFLIGHTFALLOFF = false;
  51221. }
  51222. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  51223. if (!this.backFaceCulling && this._twoSidedLighting) {
  51224. defines.TWOSIDEDLIGHTING = true;
  51225. }
  51226. else {
  51227. defines.TWOSIDEDLIGHTING = false;
  51228. }
  51229. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  51230. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  51231. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  51232. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  51233. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  51234. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  51235. }
  51236. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51237. this._imageProcessingConfiguration.prepareDefines(defines);
  51238. }
  51239. defines.FORCENORMALFORWARD = this._forceNormalForward;
  51240. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  51241. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  51242. // Misc.
  51243. if (defines._areMiscDirty) {
  51244. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  51245. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  51246. }
  51247. // Values that need to be evaluated on every frame
  51248. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  51249. // Attribs
  51250. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  51251. };
  51252. /**
  51253. * Force shader compilation
  51254. */
  51255. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  51256. var _this = this;
  51257. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  51258. var defines = new PBRMaterialDefines();
  51259. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  51260. if (effect.isReady()) {
  51261. if (onCompiled) {
  51262. onCompiled(this);
  51263. }
  51264. }
  51265. else {
  51266. effect.onCompileObservable.add(function () {
  51267. if (onCompiled) {
  51268. onCompiled(_this);
  51269. }
  51270. });
  51271. }
  51272. };
  51273. /**
  51274. * Initializes the uniform buffer layout for the shader.
  51275. */
  51276. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  51277. // Order is important !
  51278. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  51279. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  51280. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  51281. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  51282. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  51283. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  51284. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  51285. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  51286. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51287. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  51288. this._uniformBuffer.addUniform("vReflectionSize", 3);
  51289. this._uniformBuffer.addUniform("vBumpInfos", 3);
  51290. this._uniformBuffer.addUniform("albedoMatrix", 16);
  51291. this._uniformBuffer.addUniform("ambientMatrix", 16);
  51292. this._uniformBuffer.addUniform("opacityMatrix", 16);
  51293. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  51294. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  51295. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  51296. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  51297. this._uniformBuffer.addUniform("bumpMatrix", 16);
  51298. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  51299. this._uniformBuffer.addUniform("refractionMatrix", 16);
  51300. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51301. this._uniformBuffer.addUniform("vReflectionColor", 3);
  51302. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  51303. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  51304. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  51305. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51306. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  51307. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  51308. this._uniformBuffer.addUniform("pointSize", 1);
  51309. this._uniformBuffer.create();
  51310. };
  51311. /**
  51312. * Unbinds the textures.
  51313. */
  51314. PBRBaseMaterial.prototype.unbind = function () {
  51315. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51316. this._uniformBuffer.setTexture("reflectionSampler", null);
  51317. }
  51318. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51319. this._uniformBuffer.setTexture("refractionSampler", null);
  51320. }
  51321. _super.prototype.unbind.call(this);
  51322. };
  51323. /**
  51324. * Binds the submesh data.
  51325. * @param world - The world matrix.
  51326. * @param mesh - The BJS mesh.
  51327. * @param subMesh - A submesh of the BJS mesh.
  51328. */
  51329. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51330. var scene = this.getScene();
  51331. var defines = subMesh._materialDefines;
  51332. if (!defines) {
  51333. return;
  51334. }
  51335. var effect = subMesh.effect;
  51336. if (!effect) {
  51337. return;
  51338. }
  51339. this._activeEffect = effect;
  51340. // Matrices
  51341. this.bindOnlyWorldMatrix(world);
  51342. // Normal Matrix
  51343. if (defines.OBJECTSPACE_NORMALMAP) {
  51344. world.toNormalMatrix(this._normalMatrix);
  51345. this.bindOnlyNormalMatrix(this._normalMatrix);
  51346. }
  51347. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51348. // Bones
  51349. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51350. var reflectionTexture = null;
  51351. if (mustRebind) {
  51352. this._uniformBuffer.bindToEffect(effect, "Material");
  51353. this.bindViewProjection(effect);
  51354. reflectionTexture = this._getReflectionTexture();
  51355. var refractionTexture = this._getRefractionTexture();
  51356. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51357. // Texture uniforms
  51358. if (scene.texturesEnabled) {
  51359. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51360. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  51361. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  51362. }
  51363. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51364. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  51365. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  51366. }
  51367. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51368. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  51369. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  51370. }
  51371. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51372. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51373. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  51374. if (reflectionTexture.boundingBoxSize) {
  51375. var cubeTexture = reflectionTexture;
  51376. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  51377. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  51378. }
  51379. var polynomials = reflectionTexture.sphericalPolynomial;
  51380. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  51381. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  51382. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  51383. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  51384. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  51385. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  51386. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  51387. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  51388. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  51389. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  51390. }
  51391. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51392. }
  51393. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51394. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  51395. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  51396. }
  51397. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51398. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51399. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51400. }
  51401. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51402. if (this._metallicTexture) {
  51403. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51404. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51405. }
  51406. else if (this._reflectivityTexture) {
  51407. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51408. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51409. }
  51410. if (this._microSurfaceTexture) {
  51411. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51412. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51413. }
  51414. }
  51415. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51416. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51417. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51418. if (scene._mirroredCameraPosition) {
  51419. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51420. }
  51421. else {
  51422. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51423. }
  51424. }
  51425. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51426. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51427. var depth = 1.0;
  51428. if (!refractionTexture.isCube) {
  51429. if (refractionTexture.depth) {
  51430. depth = refractionTexture.depth;
  51431. }
  51432. }
  51433. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51434. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51435. }
  51436. }
  51437. // Point size
  51438. if (this.pointsCloud) {
  51439. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51440. }
  51441. // Colors
  51442. if (defines.METALLICWORKFLOW) {
  51443. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51444. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51445. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51446. }
  51447. else {
  51448. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51449. }
  51450. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51451. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51452. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51453. // Misc
  51454. this._lightingInfos.x = this._directIntensity;
  51455. this._lightingInfos.y = this._emissiveIntensity;
  51456. this._lightingInfos.z = this._environmentIntensity;
  51457. this._lightingInfos.w = this._specularIntensity;
  51458. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51459. }
  51460. // Textures
  51461. if (scene.texturesEnabled) {
  51462. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51463. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51464. }
  51465. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51466. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51467. }
  51468. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51469. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51470. }
  51471. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51472. if (defines.LODBASEDMICROSFURACE) {
  51473. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51474. }
  51475. else {
  51476. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51477. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51478. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51479. }
  51480. }
  51481. if (defines.ENVIRONMENTBRDF) {
  51482. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51483. }
  51484. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51485. if (defines.LODBASEDMICROSFURACE) {
  51486. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51487. }
  51488. else {
  51489. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51490. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51491. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51492. }
  51493. }
  51494. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51495. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51496. }
  51497. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51498. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51499. }
  51500. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51501. if (this._metallicTexture) {
  51502. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51503. }
  51504. else if (this._reflectivityTexture) {
  51505. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51506. }
  51507. if (this._microSurfaceTexture) {
  51508. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51509. }
  51510. }
  51511. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51512. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51513. }
  51514. }
  51515. // Clip plane
  51516. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51517. // Colors
  51518. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  51519. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  51520. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  51521. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  51522. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  51523. }
  51524. if (mustRebind || !this.isFrozen) {
  51525. // Lights
  51526. if (scene.lightsEnabled && !this._disableLighting) {
  51527. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  51528. }
  51529. // View
  51530. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  51531. this.bindView(effect);
  51532. }
  51533. // Fog
  51534. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51535. // Morph targets
  51536. if (defines.NUM_MORPH_INFLUENCERS) {
  51537. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  51538. }
  51539. // image processing
  51540. this._imageProcessingConfiguration.bind(this._activeEffect);
  51541. // Log. depth
  51542. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  51543. }
  51544. this._uniformBuffer.update();
  51545. this._afterBind(mesh, this._activeEffect);
  51546. };
  51547. /**
  51548. * Returns the animatable textures.
  51549. * @returns - Array of animatable textures.
  51550. */
  51551. PBRBaseMaterial.prototype.getAnimatables = function () {
  51552. var results = [];
  51553. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51554. results.push(this._albedoTexture);
  51555. }
  51556. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51557. results.push(this._ambientTexture);
  51558. }
  51559. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51560. results.push(this._opacityTexture);
  51561. }
  51562. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51563. results.push(this._reflectionTexture);
  51564. }
  51565. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51566. results.push(this._emissiveTexture);
  51567. }
  51568. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51569. results.push(this._metallicTexture);
  51570. }
  51571. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51572. results.push(this._reflectivityTexture);
  51573. }
  51574. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51575. results.push(this._bumpTexture);
  51576. }
  51577. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51578. results.push(this._lightmapTexture);
  51579. }
  51580. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51581. results.push(this._refractionTexture);
  51582. }
  51583. return results;
  51584. };
  51585. /**
  51586. * Returns the texture used for reflections.
  51587. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51588. */
  51589. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51590. if (this._reflectionTexture) {
  51591. return this._reflectionTexture;
  51592. }
  51593. return this.getScene().environmentTexture;
  51594. };
  51595. /**
  51596. * Returns the texture used for refraction or null if none is used.
  51597. * @returns - Refection texture if present. If no refraction texture and refraction
  51598. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51599. */
  51600. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51601. if (this._refractionTexture) {
  51602. return this._refractionTexture;
  51603. }
  51604. if (this._linkRefractionWithTransparency) {
  51605. return this.getScene().environmentTexture;
  51606. }
  51607. return null;
  51608. };
  51609. /**
  51610. * Disposes the resources of the material.
  51611. * @param forceDisposeEffect - Forces the disposal of effects.
  51612. * @param forceDisposeTextures - Forces the disposal of all textures.
  51613. */
  51614. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51615. if (forceDisposeTextures) {
  51616. if (this._albedoTexture) {
  51617. this._albedoTexture.dispose();
  51618. }
  51619. if (this._ambientTexture) {
  51620. this._ambientTexture.dispose();
  51621. }
  51622. if (this._opacityTexture) {
  51623. this._opacityTexture.dispose();
  51624. }
  51625. if (this._reflectionTexture) {
  51626. this._reflectionTexture.dispose();
  51627. }
  51628. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51629. this._environmentBRDFTexture.dispose();
  51630. }
  51631. if (this._emissiveTexture) {
  51632. this._emissiveTexture.dispose();
  51633. }
  51634. if (this._metallicTexture) {
  51635. this._metallicTexture.dispose();
  51636. }
  51637. if (this._reflectivityTexture) {
  51638. this._reflectivityTexture.dispose();
  51639. }
  51640. if (this._bumpTexture) {
  51641. this._bumpTexture.dispose();
  51642. }
  51643. if (this._lightmapTexture) {
  51644. this._lightmapTexture.dispose();
  51645. }
  51646. if (this._refractionTexture) {
  51647. this._refractionTexture.dispose();
  51648. }
  51649. }
  51650. this._renderTargets.dispose();
  51651. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51652. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51653. }
  51654. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51655. };
  51656. /**
  51657. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51658. */
  51659. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51660. /**
  51661. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51662. */
  51663. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51664. /**
  51665. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51666. */
  51667. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51668. /**
  51669. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51670. * They are also discarded below the alpha cutoff threshold to improve performances.
  51671. */
  51672. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51673. /**
  51674. * Defines the default value of how much AO map is occluding the analytical lights
  51675. * (point spot...).
  51676. */
  51677. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51678. /**
  51679. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51680. */
  51681. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51682. /**
  51683. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51684. * to enhance interoperability with other engines.
  51685. */
  51686. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51687. /**
  51688. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51689. * to enhance interoperability with other materials.
  51690. */
  51691. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51694. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51697. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51700. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51701. return PBRBaseMaterial;
  51702. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51703. /***/ }),
  51704. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51705. /*!************************************************!*\
  51706. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51707. \************************************************/
  51708. /*! exports provided: PBRBaseSimpleMaterial */
  51709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51710. "use strict";
  51711. __webpack_require__.r(__webpack_exports__);
  51712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  51713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51714. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51715. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51716. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51717. /**
  51718. * The Physically based simple base material of BJS.
  51719. *
  51720. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51721. * It is used as the base class for both the specGloss and metalRough conventions.
  51722. */
  51723. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  51724. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  51725. /**
  51726. * Instantiates a new PBRMaterial instance.
  51727. *
  51728. * @param name The material name
  51729. * @param scene The scene the material will be use in.
  51730. */
  51731. function PBRBaseSimpleMaterial(name, scene) {
  51732. var _this = _super.call(this, name, scene) || this;
  51733. /**
  51734. * Number of Simultaneous lights allowed on the material.
  51735. */
  51736. _this.maxSimultaneousLights = 4;
  51737. /**
  51738. * If sets to true, disables all the lights affecting the material.
  51739. */
  51740. _this.disableLighting = false;
  51741. /**
  51742. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51743. */
  51744. _this.invertNormalMapX = false;
  51745. /**
  51746. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51747. */
  51748. _this.invertNormalMapY = false;
  51749. /**
  51750. * Emissivie color used to self-illuminate the model.
  51751. */
  51752. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  51753. /**
  51754. * Occlusion Channel Strenght.
  51755. */
  51756. _this.occlusionStrength = 1.0;
  51757. /**
  51758. * If true, the light map contains occlusion information instead of lighting info.
  51759. */
  51760. _this.useLightmapAsShadowmap = false;
  51761. _this._useAlphaFromAlbedoTexture = true;
  51762. _this._useAmbientInGrayScale = true;
  51763. return _this;
  51764. }
  51765. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  51766. /**
  51767. * Gets the current double sided mode.
  51768. */
  51769. get: function () {
  51770. return this._twoSidedLighting;
  51771. },
  51772. /**
  51773. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51774. */
  51775. set: function (value) {
  51776. if (this._twoSidedLighting === value) {
  51777. return;
  51778. }
  51779. this._twoSidedLighting = value;
  51780. this.backFaceCulling = !value;
  51781. this._markAllSubMeshesAsTexturesDirty();
  51782. },
  51783. enumerable: true,
  51784. configurable: true
  51785. });
  51786. /**
  51787. * Return the active textures of the material.
  51788. */
  51789. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  51790. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51791. if (this.environmentTexture) {
  51792. activeTextures.push(this.environmentTexture);
  51793. }
  51794. if (this.normalTexture) {
  51795. activeTextures.push(this.normalTexture);
  51796. }
  51797. if (this.emissiveTexture) {
  51798. activeTextures.push(this.emissiveTexture);
  51799. }
  51800. if (this.occlusionTexture) {
  51801. activeTextures.push(this.occlusionTexture);
  51802. }
  51803. if (this.lightmapTexture) {
  51804. activeTextures.push(this.lightmapTexture);
  51805. }
  51806. return activeTextures;
  51807. };
  51808. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  51809. if (_super.prototype.hasTexture.call(this, texture)) {
  51810. return true;
  51811. }
  51812. if (this.lightmapTexture === texture) {
  51813. return true;
  51814. }
  51815. return false;
  51816. };
  51817. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  51818. return "PBRBaseSimpleMaterial";
  51819. };
  51820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51823. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  51824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51827. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  51828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  51831. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  51832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51835. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  51836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51839. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  51840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  51843. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  51844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  51846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51847. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  51848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51851. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  51852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  51855. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  51856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  51859. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  51860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  51863. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  51864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51866. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  51867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  51870. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  51871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51874. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  51875. return PBRBaseSimpleMaterial;
  51876. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  51877. /***/ }),
  51878. /***/ "./Materials/PBR/pbrMaterial.ts":
  51879. /*!**************************************!*\
  51880. !*** ./Materials/PBR/pbrMaterial.ts ***!
  51881. \**************************************/
  51882. /*! exports provided: PBRMaterial */
  51883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51884. "use strict";
  51885. __webpack_require__.r(__webpack_exports__);
  51886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  51887. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51888. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51889. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51890. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51891. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51892. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  51893. /**
  51894. * The Physically based material of BJS.
  51895. *
  51896. * This offers the main features of a standard PBR material.
  51897. * For more information, please refer to the documentation :
  51898. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51899. */
  51900. var PBRMaterial = /** @class */ (function (_super) {
  51901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  51902. /**
  51903. * Instantiates a new PBRMaterial instance.
  51904. *
  51905. * @param name The material name
  51906. * @param scene The scene the material will be use in.
  51907. */
  51908. function PBRMaterial(name, scene) {
  51909. var _this = _super.call(this, name, scene) || this;
  51910. /**
  51911. * Intensity of the direct lights e.g. the four lights available in your scene.
  51912. * This impacts both the direct diffuse and specular highlights.
  51913. */
  51914. _this.directIntensity = 1.0;
  51915. /**
  51916. * Intensity of the emissive part of the material.
  51917. * This helps controlling the emissive effect without modifying the emissive color.
  51918. */
  51919. _this.emissiveIntensity = 1.0;
  51920. /**
  51921. * Intensity of the environment e.g. how much the environment will light the object
  51922. * either through harmonics for rough material or through the refelction for shiny ones.
  51923. */
  51924. _this.environmentIntensity = 1.0;
  51925. /**
  51926. * This is a special control allowing the reduction of the specular highlights coming from the
  51927. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51928. */
  51929. _this.specularIntensity = 1.0;
  51930. /**
  51931. * Debug Control allowing disabling the bump map on this material.
  51932. */
  51933. _this.disableBumpMap = false;
  51934. /**
  51935. * AKA Occlusion Texture Intensity in other nomenclature.
  51936. */
  51937. _this.ambientTextureStrength = 1.0;
  51938. /**
  51939. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51940. * 1 means it completely occludes it
  51941. * 0 mean it has no impact
  51942. */
  51943. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51944. /**
  51945. * The color of a material in ambient lighting.
  51946. */
  51947. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51948. /**
  51949. * AKA Diffuse Color in other nomenclature.
  51950. */
  51951. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51952. /**
  51953. * AKA Specular Color in other nomenclature.
  51954. */
  51955. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51956. /**
  51957. * The color reflected from the material.
  51958. */
  51959. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  51960. /**
  51961. * The color emitted from the material.
  51962. */
  51963. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51964. /**
  51965. * AKA Glossiness in other nomenclature.
  51966. */
  51967. _this.microSurface = 1.0;
  51968. /**
  51969. * source material index of refraction (IOR)' / 'destination material IOR.
  51970. */
  51971. _this.indexOfRefraction = 0.66;
  51972. /**
  51973. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51974. */
  51975. _this.invertRefractionY = false;
  51976. /**
  51977. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51978. * Materials half opaque for instance using refraction could benefit from this control.
  51979. */
  51980. _this.linkRefractionWithTransparency = false;
  51981. /**
  51982. * If true, the light map contains occlusion information instead of lighting info.
  51983. */
  51984. _this.useLightmapAsShadowmap = false;
  51985. /**
  51986. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51987. */
  51988. _this.useAlphaFromAlbedoTexture = false;
  51989. /**
  51990. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51991. */
  51992. _this.forceAlphaTest = false;
  51993. /**
  51994. * Defines the alpha limits in alpha test mode.
  51995. */
  51996. _this.alphaCutOff = 0.4;
  51997. /**
  51998. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51999. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52000. */
  52001. _this.useSpecularOverAlpha = true;
  52002. /**
  52003. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52004. */
  52005. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  52006. /**
  52007. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52008. */
  52009. _this.useRoughnessFromMetallicTextureAlpha = true;
  52010. /**
  52011. * Specifies if the metallic texture contains the roughness information in its green channel.
  52012. */
  52013. _this.useRoughnessFromMetallicTextureGreen = false;
  52014. /**
  52015. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52016. */
  52017. _this.useMetallnessFromMetallicTextureBlue = false;
  52018. /**
  52019. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52020. */
  52021. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  52022. /**
  52023. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52024. */
  52025. _this.useAmbientInGrayScale = false;
  52026. /**
  52027. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52028. * The material will try to infer what glossiness each pixel should be.
  52029. */
  52030. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  52031. /**
  52032. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52033. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52034. */
  52035. _this.useRadianceOverAlpha = true;
  52036. /**
  52037. * Allows using an object space normal map (instead of tangent space).
  52038. */
  52039. _this.useObjectSpaceNormalMap = false;
  52040. /**
  52041. * Allows using the bump map in parallax mode.
  52042. */
  52043. _this.useParallax = false;
  52044. /**
  52045. * Allows using the bump map in parallax occlusion mode.
  52046. */
  52047. _this.useParallaxOcclusion = false;
  52048. /**
  52049. * Controls the scale bias of the parallax mode.
  52050. */
  52051. _this.parallaxScaleBias = 0.05;
  52052. /**
  52053. * If sets to true, disables all the lights affecting the material.
  52054. */
  52055. _this.disableLighting = false;
  52056. /**
  52057. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52058. */
  52059. _this.forceIrradianceInFragment = false;
  52060. /**
  52061. * Number of Simultaneous lights allowed on the material.
  52062. */
  52063. _this.maxSimultaneousLights = 4;
  52064. /**
  52065. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52066. */
  52067. _this.invertNormalMapX = false;
  52068. /**
  52069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52070. */
  52071. _this.invertNormalMapY = false;
  52072. /**
  52073. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52074. */
  52075. _this.twoSidedLighting = false;
  52076. /**
  52077. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52078. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52079. */
  52080. _this.useAlphaFresnel = false;
  52081. /**
  52082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52083. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52084. */
  52085. _this.useLinearAlphaFresnel = false;
  52086. /**
  52087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52088. * And/Or occlude the blended part.
  52089. */
  52090. _this.environmentBRDFTexture = null;
  52091. /**
  52092. * Force normal to face away from face.
  52093. */
  52094. _this.forceNormalForward = false;
  52095. /**
  52096. * Enables specular anti aliasing in the PBR shader.
  52097. * It will both interacts on the Geometry for analytical and IBL lighting.
  52098. * It also prefilter the roughness map based on the bump values.
  52099. */
  52100. _this.enableSpecularAntiAliasing = false;
  52101. /**
  52102. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52103. * makes the reflect vector face the model (under horizon).
  52104. */
  52105. _this.useHorizonOcclusion = true;
  52106. /**
  52107. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52108. * too much the area relying on ambient texture to define their ambient occlusion.
  52109. */
  52110. _this.useRadianceOcclusion = true;
  52111. /**
  52112. * If set to true, no lighting calculations will be applied.
  52113. */
  52114. _this.unlit = false;
  52115. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  52116. return _this;
  52117. }
  52118. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  52119. /**
  52120. * BJS is using an harcoded light falloff based on a manually sets up range.
  52121. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52122. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52123. */
  52124. get: function () {
  52125. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52126. },
  52127. /**
  52128. * BJS is using an harcoded light falloff based on a manually sets up range.
  52129. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52130. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52131. */
  52132. set: function (value) {
  52133. if (value !== this.usePhysicalLightFalloff) {
  52134. // Ensure the effect will be rebuilt.
  52135. this._markAllSubMeshesAsTexturesDirty();
  52136. if (value) {
  52137. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52138. }
  52139. else {
  52140. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52141. }
  52142. }
  52143. },
  52144. enumerable: true,
  52145. configurable: true
  52146. });
  52147. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  52148. /**
  52149. * In order to support the falloff compatibility with gltf, a special mode has been added
  52150. * to reproduce the gltf light falloff.
  52151. */
  52152. get: function () {
  52153. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52154. },
  52155. /**
  52156. * In order to support the falloff compatibility with gltf, a special mode has been added
  52157. * to reproduce the gltf light falloff.
  52158. */
  52159. set: function (value) {
  52160. if (value !== this.useGLTFLightFalloff) {
  52161. // Ensure the effect will be rebuilt.
  52162. this._markAllSubMeshesAsTexturesDirty();
  52163. if (value) {
  52164. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52165. }
  52166. else {
  52167. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52168. }
  52169. }
  52170. },
  52171. enumerable: true,
  52172. configurable: true
  52173. });
  52174. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  52175. /**
  52176. * Gets the image processing configuration used either in this material.
  52177. */
  52178. get: function () {
  52179. return this._imageProcessingConfiguration;
  52180. },
  52181. /**
  52182. * Sets the Default image processing configuration used either in the this material.
  52183. *
  52184. * If sets to null, the scene one is in use.
  52185. */
  52186. set: function (value) {
  52187. this._attachImageProcessingConfiguration(value);
  52188. // Ensure the effect will be rebuilt.
  52189. this._markAllSubMeshesAsTexturesDirty();
  52190. },
  52191. enumerable: true,
  52192. configurable: true
  52193. });
  52194. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  52195. /**
  52196. * Gets wether the color curves effect is enabled.
  52197. */
  52198. get: function () {
  52199. return this.imageProcessingConfiguration.colorCurvesEnabled;
  52200. },
  52201. /**
  52202. * Sets wether the color curves effect is enabled.
  52203. */
  52204. set: function (value) {
  52205. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  52206. },
  52207. enumerable: true,
  52208. configurable: true
  52209. });
  52210. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  52211. /**
  52212. * Gets wether the color grading effect is enabled.
  52213. */
  52214. get: function () {
  52215. return this.imageProcessingConfiguration.colorGradingEnabled;
  52216. },
  52217. /**
  52218. * Gets wether the color grading effect is enabled.
  52219. */
  52220. set: function (value) {
  52221. this.imageProcessingConfiguration.colorGradingEnabled = value;
  52222. },
  52223. enumerable: true,
  52224. configurable: true
  52225. });
  52226. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  52227. /**
  52228. * Gets wether tonemapping is enabled or not.
  52229. */
  52230. get: function () {
  52231. return this._imageProcessingConfiguration.toneMappingEnabled;
  52232. },
  52233. /**
  52234. * Sets wether tonemapping is enabled or not
  52235. */
  52236. set: function (value) {
  52237. this._imageProcessingConfiguration.toneMappingEnabled = value;
  52238. },
  52239. enumerable: true,
  52240. configurable: true
  52241. });
  52242. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  52243. /**
  52244. * The camera exposure used on this material.
  52245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52246. * This corresponds to a photographic exposure.
  52247. */
  52248. get: function () {
  52249. return this._imageProcessingConfiguration.exposure;
  52250. },
  52251. /**
  52252. * The camera exposure used on this material.
  52253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52254. * This corresponds to a photographic exposure.
  52255. */
  52256. set: function (value) {
  52257. this._imageProcessingConfiguration.exposure = value;
  52258. },
  52259. enumerable: true,
  52260. configurable: true
  52261. });
  52262. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  52263. /**
  52264. * Gets The camera contrast used on this material.
  52265. */
  52266. get: function () {
  52267. return this._imageProcessingConfiguration.contrast;
  52268. },
  52269. /**
  52270. * Sets The camera contrast used on this material.
  52271. */
  52272. set: function (value) {
  52273. this._imageProcessingConfiguration.contrast = value;
  52274. },
  52275. enumerable: true,
  52276. configurable: true
  52277. });
  52278. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  52279. /**
  52280. * Gets the Color Grading 2D Lookup Texture.
  52281. */
  52282. get: function () {
  52283. return this._imageProcessingConfiguration.colorGradingTexture;
  52284. },
  52285. /**
  52286. * Sets the Color Grading 2D Lookup Texture.
  52287. */
  52288. set: function (value) {
  52289. this._imageProcessingConfiguration.colorGradingTexture = value;
  52290. },
  52291. enumerable: true,
  52292. configurable: true
  52293. });
  52294. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  52295. /**
  52296. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52297. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52298. * 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;
  52299. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52300. */
  52301. get: function () {
  52302. return this._imageProcessingConfiguration.colorCurves;
  52303. },
  52304. /**
  52305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52307. * 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;
  52308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52309. */
  52310. set: function (value) {
  52311. this._imageProcessingConfiguration.colorCurves = value;
  52312. },
  52313. enumerable: true,
  52314. configurable: true
  52315. });
  52316. /**
  52317. * Returns the name of this material class.
  52318. */
  52319. PBRMaterial.prototype.getClassName = function () {
  52320. return "PBRMaterial";
  52321. };
  52322. /**
  52323. * Returns an array of the actively used textures.
  52324. * @returns - Array of BaseTextures
  52325. */
  52326. PBRMaterial.prototype.getActiveTextures = function () {
  52327. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52328. if (this._albedoTexture) {
  52329. activeTextures.push(this._albedoTexture);
  52330. }
  52331. if (this._ambientTexture) {
  52332. activeTextures.push(this._ambientTexture);
  52333. }
  52334. if (this._opacityTexture) {
  52335. activeTextures.push(this._opacityTexture);
  52336. }
  52337. if (this._reflectionTexture) {
  52338. activeTextures.push(this._reflectionTexture);
  52339. }
  52340. if (this._emissiveTexture) {
  52341. activeTextures.push(this._emissiveTexture);
  52342. }
  52343. if (this._reflectivityTexture) {
  52344. activeTextures.push(this._reflectivityTexture);
  52345. }
  52346. if (this._metallicTexture) {
  52347. activeTextures.push(this._metallicTexture);
  52348. }
  52349. if (this._microSurfaceTexture) {
  52350. activeTextures.push(this._microSurfaceTexture);
  52351. }
  52352. if (this._bumpTexture) {
  52353. activeTextures.push(this._bumpTexture);
  52354. }
  52355. if (this._lightmapTexture) {
  52356. activeTextures.push(this._lightmapTexture);
  52357. }
  52358. if (this._refractionTexture) {
  52359. activeTextures.push(this._refractionTexture);
  52360. }
  52361. return activeTextures;
  52362. };
  52363. /**
  52364. * Checks to see if a texture is used in the material.
  52365. * @param texture - Base texture to use.
  52366. * @returns - Boolean specifying if a texture is used in the material.
  52367. */
  52368. PBRMaterial.prototype.hasTexture = function (texture) {
  52369. if (_super.prototype.hasTexture.call(this, texture)) {
  52370. return true;
  52371. }
  52372. if (this._albedoTexture === texture) {
  52373. return true;
  52374. }
  52375. if (this._ambientTexture === texture) {
  52376. return true;
  52377. }
  52378. if (this._opacityTexture === texture) {
  52379. return true;
  52380. }
  52381. if (this._reflectionTexture === texture) {
  52382. return true;
  52383. }
  52384. if (this._reflectivityTexture === texture) {
  52385. return true;
  52386. }
  52387. if (this._metallicTexture === texture) {
  52388. return true;
  52389. }
  52390. if (this._microSurfaceTexture === texture) {
  52391. return true;
  52392. }
  52393. if (this._bumpTexture === texture) {
  52394. return true;
  52395. }
  52396. if (this._lightmapTexture === texture) {
  52397. return true;
  52398. }
  52399. if (this._refractionTexture === texture) {
  52400. return true;
  52401. }
  52402. return false;
  52403. };
  52404. /**
  52405. * Makes a duplicate of the current material.
  52406. * @param name - name to use for the new material.
  52407. */
  52408. PBRMaterial.prototype.clone = function (name) {
  52409. var _this = this;
  52410. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  52411. clone.id = name;
  52412. clone.name = name;
  52413. return clone;
  52414. };
  52415. /**
  52416. * Serializes this PBR Material.
  52417. * @returns - An object with the serialized material.
  52418. */
  52419. PBRMaterial.prototype.serialize = function () {
  52420. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52421. serializationObject.customType = "BABYLON.PBRMaterial";
  52422. return serializationObject;
  52423. };
  52424. // Statics
  52425. /**
  52426. * Parses a PBR Material from a serialized object.
  52427. * @param source - Serialized object.
  52428. * @param scene - BJS scene instance.
  52429. * @param rootUrl - url for the scene object
  52430. * @returns - PBRMaterial
  52431. */
  52432. PBRMaterial.Parse = function (source, scene, rootUrl) {
  52433. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  52434. };
  52435. /**
  52436. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52437. */
  52438. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  52439. /**
  52440. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52441. */
  52442. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  52443. /**
  52444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52445. */
  52446. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  52447. /**
  52448. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52449. * They are also discarded below the alpha cutoff threshold to improve performances.
  52450. */
  52451. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  52452. /**
  52453. * Defines the default value of how much AO map is occluding the analytical lights
  52454. * (point spot...).
  52455. */
  52456. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52460. ], PBRMaterial.prototype, "directIntensity", void 0);
  52461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52464. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  52465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52468. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  52469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52472. ], PBRMaterial.prototype, "specularIntensity", void 0);
  52473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52476. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  52477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52480. ], PBRMaterial.prototype, "albedoTexture", void 0);
  52481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52484. ], PBRMaterial.prototype, "ambientTexture", void 0);
  52485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52488. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  52489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52491. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52492. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  52493. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52494. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52496. ], PBRMaterial.prototype, "opacityTexture", void 0);
  52497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52500. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  52501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52503. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52504. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  52505. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52506. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52508. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  52509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52512. ], PBRMaterial.prototype, "metallicTexture", void 0);
  52513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52515. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52516. ], PBRMaterial.prototype, "metallic", void 0);
  52517. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52518. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52520. ], PBRMaterial.prototype, "roughness", void 0);
  52521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52524. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  52525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52527. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52528. ], PBRMaterial.prototype, "bumpTexture", void 0);
  52529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52532. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  52533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52536. ], PBRMaterial.prototype, "refractionTexture", void 0);
  52537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  52539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52540. ], PBRMaterial.prototype, "ambientColor", void 0);
  52541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  52543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52544. ], PBRMaterial.prototype, "albedoColor", void 0);
  52545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  52547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52548. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  52549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52552. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52556. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52560. ], PBRMaterial.prototype, "microSurface", void 0);
  52561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52564. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  52565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52568. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  52569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52572. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  52573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52576. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52580. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  52581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52583. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52584. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  52585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52586. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52588. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  52589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52592. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  52593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52596. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  52597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52600. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  52601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52604. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  52605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52608. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  52609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52612. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  52613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52616. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  52617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52620. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52623. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52626. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52630. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  52631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52634. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  52635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52638. ], PBRMaterial.prototype, "useParallax", void 0);
  52639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52642. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  52643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52646. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  52647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52650. ], PBRMaterial.prototype, "disableLighting", void 0);
  52651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52654. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  52655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52658. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  52659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52662. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  52663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52666. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  52667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52670. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  52671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52674. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  52675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52678. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  52679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52682. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52686. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  52687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52690. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  52691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52694. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  52695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52698. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  52699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52702. ], PBRMaterial.prototype, "unlit", void 0);
  52703. return PBRMaterial;
  52704. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52705. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52706. /***/ }),
  52707. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52708. /*!*******************************************************!*\
  52709. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  52710. \*******************************************************/
  52711. /*! exports provided: PBRMetallicRoughnessMaterial */
  52712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52713. "use strict";
  52714. __webpack_require__.r(__webpack_exports__);
  52715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  52716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52717. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52718. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52719. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52720. /**
  52721. * The PBR material of BJS following the metal roughness convention.
  52722. *
  52723. * This fits to the PBR convention in the GLTF definition:
  52724. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52725. */
  52726. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  52727. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  52728. /**
  52729. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52730. *
  52731. * @param name The material name
  52732. * @param scene The scene the material will be use in.
  52733. */
  52734. function PBRMetallicRoughnessMaterial(name, scene) {
  52735. var _this = _super.call(this, name, scene) || this;
  52736. _this._useRoughnessFromMetallicTextureAlpha = false;
  52737. _this._useRoughnessFromMetallicTextureGreen = true;
  52738. _this._useMetallnessFromMetallicTextureBlue = true;
  52739. _this.metallic = 1.0;
  52740. _this.roughness = 1.0;
  52741. return _this;
  52742. }
  52743. /**
  52744. * Return the currrent class name of the material.
  52745. */
  52746. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  52747. return "PBRMetallicRoughnessMaterial";
  52748. };
  52749. /**
  52750. * Return the active textures of the material.
  52751. */
  52752. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  52753. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52754. if (this.baseTexture) {
  52755. activeTextures.push(this.baseTexture);
  52756. }
  52757. if (this.metallicRoughnessTexture) {
  52758. activeTextures.push(this.metallicRoughnessTexture);
  52759. }
  52760. return activeTextures;
  52761. };
  52762. /**
  52763. * Checks to see if a texture is used in the material.
  52764. * @param texture - Base texture to use.
  52765. * @returns - Boolean specifying if a texture is used in the material.
  52766. */
  52767. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  52768. if (_super.prototype.hasTexture.call(this, texture)) {
  52769. return true;
  52770. }
  52771. if (this.baseTexture === texture) {
  52772. return true;
  52773. }
  52774. if (this.metallicRoughnessTexture === texture) {
  52775. return true;
  52776. }
  52777. return false;
  52778. };
  52779. /**
  52780. * Makes a duplicate of the current material.
  52781. * @param name - name to use for the new material.
  52782. */
  52783. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  52784. var _this = this;
  52785. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  52786. clone.id = name;
  52787. clone.name = name;
  52788. return clone;
  52789. };
  52790. /**
  52791. * Serialize the material to a parsable JSON object.
  52792. */
  52793. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  52794. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52795. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  52796. return serializationObject;
  52797. };
  52798. /**
  52799. * Parses a JSON object correponding to the serialize function.
  52800. */
  52801. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  52802. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  52803. };
  52804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  52806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52807. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  52808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52811. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  52812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52815. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  52816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52819. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  52820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  52823. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  52824. return PBRMetallicRoughnessMaterial;
  52825. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52826. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  52827. /***/ }),
  52828. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  52829. /*!********************************************************!*\
  52830. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  52831. \********************************************************/
  52832. /*! exports provided: PBRSpecularGlossinessMaterial */
  52833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52834. "use strict";
  52835. __webpack_require__.r(__webpack_exports__);
  52836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  52837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52838. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52839. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52840. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52841. /**
  52842. * The PBR material of BJS following the specular glossiness convention.
  52843. *
  52844. * This fits to the PBR convention in the GLTF definition:
  52845. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52846. */
  52847. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  52848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  52849. /**
  52850. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52851. *
  52852. * @param name The material name
  52853. * @param scene The scene the material will be use in.
  52854. */
  52855. function PBRSpecularGlossinessMaterial(name, scene) {
  52856. var _this = _super.call(this, name, scene) || this;
  52857. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  52858. return _this;
  52859. }
  52860. /**
  52861. * Return the currrent class name of the material.
  52862. */
  52863. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  52864. return "PBRSpecularGlossinessMaterial";
  52865. };
  52866. /**
  52867. * Return the active textures of the material.
  52868. */
  52869. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  52870. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52871. if (this.diffuseTexture) {
  52872. activeTextures.push(this.diffuseTexture);
  52873. }
  52874. if (this.specularGlossinessTexture) {
  52875. activeTextures.push(this.specularGlossinessTexture);
  52876. }
  52877. return activeTextures;
  52878. };
  52879. /**
  52880. * Checks to see if a texture is used in the material.
  52881. * @param texture - Base texture to use.
  52882. * @returns - Boolean specifying if a texture is used in the material.
  52883. */
  52884. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  52885. if (_super.prototype.hasTexture.call(this, texture)) {
  52886. return true;
  52887. }
  52888. if (this.diffuseTexture === texture) {
  52889. return true;
  52890. }
  52891. if (this.specularGlossinessTexture === texture) {
  52892. return true;
  52893. }
  52894. return false;
  52895. };
  52896. /**
  52897. * Makes a duplicate of the current material.
  52898. * @param name - name to use for the new material.
  52899. */
  52900. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  52901. var _this = this;
  52902. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  52903. clone.id = name;
  52904. clone.name = name;
  52905. return clone;
  52906. };
  52907. /**
  52908. * Serialize the material to a parsable JSON object.
  52909. */
  52910. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  52911. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52912. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  52913. return serializationObject;
  52914. };
  52915. /**
  52916. * Parses a JSON object correponding to the serialize function.
  52917. */
  52918. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  52919. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  52920. };
  52921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  52923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52924. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  52925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52928. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  52929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  52931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  52932. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  52933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  52936. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  52937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  52940. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  52941. return PBRSpecularGlossinessMaterial;
  52942. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52943. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  52944. /***/ }),
  52945. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  52946. /*!********************************************************!*\
  52947. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  52948. \********************************************************/
  52949. /*! exports provided: _DDSTextureLoader */
  52950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52951. "use strict";
  52952. __webpack_require__.r(__webpack_exports__);
  52953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  52954. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  52955. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52956. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  52957. /**
  52958. * Implementation of the DDS Texture Loader.
  52959. * @hidden
  52960. */
  52961. var _DDSTextureLoader = /** @class */ (function () {
  52962. function _DDSTextureLoader() {
  52963. /**
  52964. * Defines wether the loader supports cascade loading the different faces.
  52965. */
  52966. this.supportCascades = true;
  52967. }
  52968. /**
  52969. * This returns if the loader support the current file information.
  52970. * @param extension defines the file extension of the file being loaded
  52971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52972. * @param fallback defines the fallback internal texture if any
  52973. * @param isBase64 defines whether the texture is encoded as a base64
  52974. * @param isBuffer defines whether the texture data are stored as a buffer
  52975. * @returns true if the loader can load the specified file
  52976. */
  52977. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52978. return extension.indexOf(".dds") === 0;
  52979. };
  52980. /**
  52981. * Transform the url before loading if required.
  52982. * @param rootUrl the url of the texture
  52983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52984. * @returns the transformed texture
  52985. */
  52986. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52987. return rootUrl;
  52988. };
  52989. /**
  52990. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52991. * @param rootUrl the url of the texture
  52992. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52993. * @returns the fallback texture
  52994. */
  52995. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52996. return null;
  52997. };
  52998. /**
  52999. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53000. * @param data contains the texture data
  53001. * @param texture defines the BabylonJS internal texture
  53002. * @param createPolynomials will be true if polynomials have been requested
  53003. * @param onLoad defines the callback to trigger once the texture is ready
  53004. * @param onError defines the callback to trigger in case of error
  53005. */
  53006. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  53007. var engine = texture.getEngine();
  53008. var info;
  53009. var loadMipmap = false;
  53010. if (Array.isArray(imgs)) {
  53011. for (var index = 0; index < imgs.length; index++) {
  53012. var data_1 = imgs[index];
  53013. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  53014. texture.width = info.width;
  53015. texture.height = info.height;
  53016. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53017. engine._unpackFlipY(info.isCompressed);
  53018. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  53019. if (!info.isFourCC && info.mipmapCount === 1) {
  53020. engine.generateMipMapsForCubemap(texture);
  53021. }
  53022. }
  53023. }
  53024. else {
  53025. var data = imgs;
  53026. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53027. texture.width = info.width;
  53028. texture.height = info.height;
  53029. if (createPolynomials) {
  53030. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  53031. }
  53032. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53033. engine._unpackFlipY(info.isCompressed);
  53034. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  53035. if (!info.isFourCC && info.mipmapCount === 1) {
  53036. engine.generateMipMapsForCubemap(texture);
  53037. }
  53038. }
  53039. engine._setCubeMapTextureParams(loadMipmap);
  53040. texture.isReady = true;
  53041. if (onLoad) {
  53042. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  53043. }
  53044. };
  53045. /**
  53046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53047. * @param data contains the texture data
  53048. * @param texture defines the BabylonJS internal texture
  53049. * @param callback defines the method to call once ready to upload
  53050. */
  53051. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  53052. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53053. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  53054. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  53055. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  53056. });
  53057. };
  53058. return _DDSTextureLoader;
  53059. }());
  53060. // Register the loader.
  53061. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  53062. /***/ }),
  53063. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  53064. /*!********************************************************!*\
  53065. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  53066. \********************************************************/
  53067. /*! exports provided: _ENVTextureLoader */
  53068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53069. "use strict";
  53070. __webpack_require__.r(__webpack_exports__);
  53071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  53072. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  53073. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53074. /**
  53075. * Implementation of the ENV Texture Loader.
  53076. * @hidden
  53077. */
  53078. var _ENVTextureLoader = /** @class */ (function () {
  53079. function _ENVTextureLoader() {
  53080. /**
  53081. * Defines wether the loader supports cascade loading the different faces.
  53082. */
  53083. this.supportCascades = false;
  53084. }
  53085. /**
  53086. * This returns if the loader support the current file information.
  53087. * @param extension defines the file extension of the file being loaded
  53088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53089. * @param fallback defines the fallback internal texture if any
  53090. * @param isBase64 defines whether the texture is encoded as a base64
  53091. * @param isBuffer defines whether the texture data are stored as a buffer
  53092. * @returns true if the loader can load the specified file
  53093. */
  53094. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53095. return extension.indexOf(".env") === 0;
  53096. };
  53097. /**
  53098. * Transform the url before loading if required.
  53099. * @param rootUrl the url of the texture
  53100. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53101. * @returns the transformed texture
  53102. */
  53103. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53104. return rootUrl;
  53105. };
  53106. /**
  53107. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53108. * @param rootUrl the url of the texture
  53109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53110. * @returns the fallback texture
  53111. */
  53112. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53113. return null;
  53114. };
  53115. /**
  53116. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53117. * @param data contains the texture data
  53118. * @param texture defines the BabylonJS internal texture
  53119. * @param createPolynomials will be true if polynomials have been requested
  53120. * @param onLoad defines the callback to trigger once the texture is ready
  53121. * @param onError defines the callback to trigger in case of error
  53122. */
  53123. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53124. if (Array.isArray(data)) {
  53125. return;
  53126. }
  53127. data = data;
  53128. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  53129. if (info) {
  53130. texture.width = info.width;
  53131. texture.height = info.width;
  53132. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  53133. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  53134. texture.isReady = true;
  53135. if (onLoad) {
  53136. onLoad();
  53137. }
  53138. });
  53139. }
  53140. else if (onError) {
  53141. onError("Can not parse the environment file", null);
  53142. }
  53143. };
  53144. /**
  53145. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53146. * @param data contains the texture data
  53147. * @param texture defines the BabylonJS internal texture
  53148. * @param callback defines the method to call once ready to upload
  53149. */
  53150. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  53151. throw ".env not supported in 2d.";
  53152. };
  53153. return _ENVTextureLoader;
  53154. }());
  53155. // Register the loader.
  53156. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  53157. /***/ }),
  53158. /***/ "./Materials/Textures/Loaders/index.ts":
  53159. /*!*********************************************!*\
  53160. !*** ./Materials/Textures/Loaders/index.ts ***!
  53161. \*********************************************/
  53162. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  53163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53164. "use strict";
  53165. __webpack_require__.r(__webpack_exports__);
  53166. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  53167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  53168. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  53169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  53170. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  53171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  53172. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  53173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  53174. /***/ }),
  53175. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  53176. /*!********************************************************!*\
  53177. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  53178. \********************************************************/
  53179. /*! exports provided: _KTXTextureLoader */
  53180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53181. "use strict";
  53182. __webpack_require__.r(__webpack_exports__);
  53183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  53184. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  53185. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53186. /**
  53187. * Implementation of the KTX Texture Loader.
  53188. * @hidden
  53189. */
  53190. var _KTXTextureLoader = /** @class */ (function () {
  53191. function _KTXTextureLoader() {
  53192. /**
  53193. * Defines wether the loader supports cascade loading the different faces.
  53194. */
  53195. this.supportCascades = false;
  53196. }
  53197. /**
  53198. * This returns if the loader support the current file information.
  53199. * @param extension defines the file extension of the file being loaded
  53200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53201. * @param fallback defines the fallback internal texture if any
  53202. * @param isBase64 defines whether the texture is encoded as a base64
  53203. * @param isBuffer defines whether the texture data are stored as a buffer
  53204. * @returns true if the loader can load the specified file
  53205. */
  53206. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53207. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  53208. return true;
  53209. }
  53210. return false;
  53211. };
  53212. /**
  53213. * Transform the url before loading if required.
  53214. * @param rootUrl the url of the texture
  53215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53216. * @returns the transformed texture
  53217. */
  53218. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53219. var lastDot = rootUrl.lastIndexOf('.');
  53220. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  53221. // Already transformed
  53222. return rootUrl;
  53223. }
  53224. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  53225. };
  53226. /**
  53227. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53228. * @param rootUrl the url of the texture
  53229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53230. * @returns the fallback texture
  53231. */
  53232. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53233. // remove the format appended to the rootUrl in the original createCubeTexture call.
  53234. var exp = new RegExp("" + textureFormatInUse + "$");
  53235. return rootUrl.replace(exp, "");
  53236. };
  53237. /**
  53238. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53239. * @param data contains the texture data
  53240. * @param texture defines the BabylonJS internal texture
  53241. * @param createPolynomials will be true if polynomials have been requested
  53242. * @param onLoad defines the callback to trigger once the texture is ready
  53243. * @param onError defines the callback to trigger in case of error
  53244. */
  53245. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53246. if (Array.isArray(data)) {
  53247. return;
  53248. }
  53249. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53250. texture._invertVScale = !texture.invertY;
  53251. var engine = texture.getEngine();
  53252. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  53253. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  53254. engine._unpackFlipY(true);
  53255. ktx.uploadLevels(texture, texture.generateMipMaps);
  53256. texture.width = ktx.pixelWidth;
  53257. texture.height = ktx.pixelHeight;
  53258. engine._setCubeMapTextureParams(loadMipmap);
  53259. texture.isReady = true;
  53260. };
  53261. /**
  53262. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53263. * @param data contains the texture data
  53264. * @param texture defines the BabylonJS internal texture
  53265. * @param callback defines the method to call once ready to upload
  53266. */
  53267. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  53268. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53269. texture._invertVScale = !texture.invertY;
  53270. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  53271. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  53272. ktx.uploadLevels(texture, texture.generateMipMaps);
  53273. }, ktx.isInvalid);
  53274. };
  53275. return _KTXTextureLoader;
  53276. }());
  53277. // Register the loader.
  53278. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  53279. /***/ }),
  53280. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  53281. /*!********************************************************!*\
  53282. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  53283. \********************************************************/
  53284. /*! exports provided: _TGATextureLoader */
  53285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53286. "use strict";
  53287. __webpack_require__.r(__webpack_exports__);
  53288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  53289. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  53290. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53291. /**
  53292. * Implementation of the TGA Texture Loader.
  53293. * @hidden
  53294. */
  53295. var _TGATextureLoader = /** @class */ (function () {
  53296. function _TGATextureLoader() {
  53297. /**
  53298. * Defines wether the loader supports cascade loading the different faces.
  53299. */
  53300. this.supportCascades = false;
  53301. }
  53302. /**
  53303. * This returns if the loader support the current file information.
  53304. * @param extension defines the file extension of the file being loaded
  53305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53306. * @param fallback defines the fallback internal texture if any
  53307. * @param isBase64 defines whether the texture is encoded as a base64
  53308. * @param isBuffer defines whether the texture data are stored as a buffer
  53309. * @returns true if the loader can load the specified file
  53310. */
  53311. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53312. return extension.indexOf(".tga") === 0;
  53313. };
  53314. /**
  53315. * Transform the url before loading if required.
  53316. * @param rootUrl the url of the texture
  53317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53318. * @returns the transformed texture
  53319. */
  53320. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53321. return rootUrl;
  53322. };
  53323. /**
  53324. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53325. * @param rootUrl the url of the texture
  53326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53327. * @returns the fallback texture
  53328. */
  53329. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53330. return null;
  53331. };
  53332. /**
  53333. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53334. * @param data contains the texture data
  53335. * @param texture defines the BabylonJS internal texture
  53336. * @param createPolynomials will be true if polynomials have been requested
  53337. * @param onLoad defines the callback to trigger once the texture is ready
  53338. * @param onError defines the callback to trigger in case of error
  53339. */
  53340. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53341. throw ".env not supported in Cube.";
  53342. };
  53343. /**
  53344. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53345. * @param data contains the texture data
  53346. * @param texture defines the BabylonJS internal texture
  53347. * @param callback defines the method to call once ready to upload
  53348. */
  53349. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  53350. var uintData = new Uint8Array(data);
  53351. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  53352. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  53353. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  53354. });
  53355. };
  53356. return _TGATextureLoader;
  53357. }());
  53358. // Register the loader.
  53359. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  53360. /***/ }),
  53361. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  53362. /*!*******************************************************************!*\
  53363. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  53364. \*******************************************************************/
  53365. /*! exports provided: CustomProceduralTexture */
  53366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53367. "use strict";
  53368. __webpack_require__.r(__webpack_exports__);
  53369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  53370. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53371. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53372. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  53373. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  53374. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53375. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53376. /**
  53377. * 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.
  53378. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53379. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53380. */
  53381. var CustomProceduralTexture = /** @class */ (function (_super) {
  53382. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  53383. /**
  53384. * Instantiates a new Custom Procedural Texture.
  53385. * 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.
  53386. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53387. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53388. * @param name Define the name of the texture
  53389. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53390. * @param size Define the size of the texture to create
  53391. * @param scene Define the scene the texture belongs to
  53392. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53393. * @param generateMipMaps Define if the texture should creates mip maps or not
  53394. */
  53395. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  53396. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  53397. _this._animate = true;
  53398. _this._time = 0;
  53399. _this._texturePath = texturePath;
  53400. //Try to load json
  53401. _this._loadJson(texturePath);
  53402. _this.refreshRate = 1;
  53403. return _this;
  53404. }
  53405. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  53406. var _this = this;
  53407. var noConfigFile = function () {
  53408. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  53409. try {
  53410. _this.setFragment(_this._texturePath);
  53411. }
  53412. catch (ex) {
  53413. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  53414. }
  53415. };
  53416. var configFileUrl = jsonUrl + "/config.json";
  53417. var xhr = new XMLHttpRequest();
  53418. xhr.open("GET", configFileUrl, true);
  53419. xhr.addEventListener("load", function () {
  53420. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  53421. try {
  53422. _this._config = JSON.parse(xhr.response);
  53423. _this.updateShaderUniforms();
  53424. _this.updateTextures();
  53425. _this.setFragment(_this._texturePath + "/custom");
  53426. _this._animate = _this._config.animate;
  53427. _this.refreshRate = _this._config.refreshrate;
  53428. }
  53429. catch (ex) {
  53430. noConfigFile();
  53431. }
  53432. }
  53433. else {
  53434. noConfigFile();
  53435. }
  53436. }, false);
  53437. xhr.addEventListener("error", function () {
  53438. noConfigFile();
  53439. }, false);
  53440. try {
  53441. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  53442. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  53443. }
  53444. xhr.send();
  53445. }
  53446. catch (ex) {
  53447. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  53448. }
  53449. };
  53450. /**
  53451. * Is the texture ready to be used ? (rendered at least once)
  53452. * @returns true if ready, otherwise, false.
  53453. */
  53454. CustomProceduralTexture.prototype.isReady = function () {
  53455. if (!_super.prototype.isReady.call(this)) {
  53456. return false;
  53457. }
  53458. for (var name in this._textures) {
  53459. var texture = this._textures[name];
  53460. if (!texture.isReady()) {
  53461. return false;
  53462. }
  53463. }
  53464. return true;
  53465. };
  53466. /**
  53467. * Render the texture to its associated render target.
  53468. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53469. */
  53470. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53471. var scene = this.getScene();
  53472. if (this._animate && scene) {
  53473. this._time += scene.getAnimationRatio() * 0.03;
  53474. this.updateShaderUniforms();
  53475. }
  53476. _super.prototype.render.call(this, useCameraPostProcess);
  53477. };
  53478. /**
  53479. * Update the list of dependant textures samplers in the shader.
  53480. */
  53481. CustomProceduralTexture.prototype.updateTextures = function () {
  53482. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  53483. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  53484. }
  53485. };
  53486. /**
  53487. * Update the uniform values of the procedural texture in the shader.
  53488. */
  53489. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  53490. if (this._config) {
  53491. for (var j = 0; j < this._config.uniforms.length; j++) {
  53492. var uniform = this._config.uniforms[j];
  53493. switch (uniform.type) {
  53494. case "float":
  53495. this.setFloat(uniform.name, uniform.value);
  53496. break;
  53497. case "color3":
  53498. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  53499. break;
  53500. case "color4":
  53501. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  53502. break;
  53503. case "vector2":
  53504. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  53505. break;
  53506. case "vector3":
  53507. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  53508. break;
  53509. }
  53510. }
  53511. }
  53512. this.setFloat("time", this._time);
  53513. };
  53514. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  53515. /**
  53516. * Define if the texture animates or not.
  53517. */
  53518. get: function () {
  53519. return this._animate;
  53520. },
  53521. set: function (value) {
  53522. this._animate = value;
  53523. },
  53524. enumerable: true,
  53525. configurable: true
  53526. });
  53527. return CustomProceduralTexture;
  53528. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  53529. /***/ }),
  53530. /***/ "./Materials/Textures/Procedurals/index.ts":
  53531. /*!*************************************************!*\
  53532. !*** ./Materials/Textures/Procedurals/index.ts ***!
  53533. \*************************************************/
  53534. /*! exports provided: ProceduralTexture, ProceduralTextureSceneComponent, CustomProceduralTexture, NoiseProceduralTexture */
  53535. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53536. "use strict";
  53537. __webpack_require__.r(__webpack_exports__);
  53538. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  53539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  53540. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  53541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  53542. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  53544. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  53546. /***/ }),
  53547. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  53548. /*!******************************************************************!*\
  53549. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  53550. \******************************************************************/
  53551. /*! exports provided: NoiseProceduralTexture */
  53552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53553. "use strict";
  53554. __webpack_require__.r(__webpack_exports__);
  53555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53556. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53557. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53558. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53559. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53560. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53561. /**
  53562. * Class used to generate noise procedural textures
  53563. */
  53564. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53565. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53566. /**
  53567. * Creates a new NoiseProceduralTexture
  53568. * @param name defines the name fo the texture
  53569. * @param size defines the size of the texture (default is 256)
  53570. * @param scene defines the hosting scene
  53571. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53572. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53573. */
  53574. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53575. if (size === void 0) { size = 256; }
  53576. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53577. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53578. _this._time = 0;
  53579. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53580. _this.brightness = 0.2;
  53581. /** Defines the number of octaves to process */
  53582. _this.octaves = 3;
  53583. /** Defines the level of persistence (0.8 by default) */
  53584. _this.persistence = 0.8;
  53585. /** Gets or sets animation speed factor (default is 1) */
  53586. _this.animationSpeedFactor = 1;
  53587. _this.autoClear = false;
  53588. _this._updateShaderUniforms();
  53589. return _this;
  53590. }
  53591. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53592. var scene = this.getScene();
  53593. if (!scene) {
  53594. return;
  53595. }
  53596. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53597. this.setFloat("brightness", this.brightness);
  53598. this.setFloat("persistence", this.persistence);
  53599. this.setFloat("timeScale", this._time);
  53600. };
  53601. NoiseProceduralTexture.prototype._getDefines = function () {
  53602. return "#define OCTAVES " + (this.octaves | 0);
  53603. };
  53604. /** Generate the current state of the procedural texture */
  53605. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53606. this._updateShaderUniforms();
  53607. _super.prototype.render.call(this, useCameraPostProcess);
  53608. };
  53609. /**
  53610. * Serializes this noise procedural texture
  53611. * @returns a serialized noise procedural texture object
  53612. */
  53613. NoiseProceduralTexture.prototype.serialize = function () {
  53614. var serializationObject = {};
  53615. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53616. serializationObject.brightness = this.brightness;
  53617. serializationObject.octaves = this.octaves;
  53618. serializationObject.persistence = this.persistence;
  53619. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53620. serializationObject.size = this.getSize().width;
  53621. serializationObject.generateMipMaps = this._generateMipMaps;
  53622. return serializationObject;
  53623. };
  53624. /**
  53625. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53626. * @param parsedTexture defines parsed texture data
  53627. * @param scene defines the current scene
  53628. * @param rootUrl defines the root URL containing noise procedural texture information
  53629. * @returns a parsed NoiseProceduralTexture
  53630. */
  53631. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53632. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53633. texture.brightness = parsedTexture.brightness;
  53634. texture.octaves = parsedTexture.octaves;
  53635. texture.persistence = parsedTexture.persistence;
  53636. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53637. return texture;
  53638. };
  53639. return NoiseProceduralTexture;
  53640. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53641. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53642. /***/ }),
  53643. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53644. /*!*************************************************************!*\
  53645. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53646. \*************************************************************/
  53647. /*! exports provided: ProceduralTexture */
  53648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53649. "use strict";
  53650. __webpack_require__.r(__webpack_exports__);
  53651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53652. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53653. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53654. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53655. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53656. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53657. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53658. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53659. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53660. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53661. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53662. /**
  53663. * 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.
  53664. * This is the base class of any Procedural texture and contains most of the shareable code.
  53665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53666. */
  53667. var ProceduralTexture = /** @class */ (function (_super) {
  53668. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53669. /**
  53670. * Instantiates a new procedural texture.
  53671. * 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.
  53672. * This is the base class of any Procedural texture and contains most of the shareable code.
  53673. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53674. * @param name Define the name of the texture
  53675. * @param size Define the size of the texture to create
  53676. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53677. * @param scene Define the scene the texture belongs to
  53678. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53679. * @param generateMipMaps Define if the texture should creates mip maps or not
  53680. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53681. */
  53682. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53683. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53684. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53685. if (isCube === void 0) { isCube = false; }
  53686. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53687. _this.isCube = isCube;
  53688. /**
  53689. * Define if the texture is enabled or not (disabled texture will not render)
  53690. */
  53691. _this.isEnabled = true;
  53692. /**
  53693. * Define if the texture must be cleared before rendering (default is true)
  53694. */
  53695. _this.autoClear = true;
  53696. /**
  53697. * Event raised when the texture is generated
  53698. */
  53699. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53700. /** @hidden */
  53701. _this._textures = {};
  53702. _this._currentRefreshId = -1;
  53703. _this._refreshRate = 1;
  53704. _this._vertexBuffers = {};
  53705. _this._uniforms = new Array();
  53706. _this._samplers = new Array();
  53707. _this._floats = {};
  53708. _this._ints = {};
  53709. _this._floatsArrays = {};
  53710. _this._colors3 = {};
  53711. _this._colors4 = {};
  53712. _this._vectors2 = {};
  53713. _this._vectors3 = {};
  53714. _this._matrices = {};
  53715. _this._fallbackTextureUsed = false;
  53716. _this._cachedDefines = "";
  53717. _this._contentUpdateId = -1;
  53718. scene = _this.getScene();
  53719. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  53720. if (!component) {
  53721. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  53722. scene._addComponent(component);
  53723. }
  53724. scene.proceduralTextures.push(_this);
  53725. _this._engine = scene.getEngine();
  53726. _this.name = name;
  53727. _this.isRenderTarget = true;
  53728. _this._size = size;
  53729. _this._generateMipMaps = generateMipMaps;
  53730. _this.setFragment(fragment);
  53731. _this._fallbackTexture = fallbackTexture;
  53732. if (isCube) {
  53733. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53734. _this.setFloat("face", 0);
  53735. }
  53736. else {
  53737. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53738. }
  53739. // VBO
  53740. var vertices = [];
  53741. vertices.push(1, 1);
  53742. vertices.push(-1, 1);
  53743. vertices.push(-1, -1);
  53744. vertices.push(1, -1);
  53745. _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);
  53746. _this._createIndexBuffer();
  53747. return _this;
  53748. }
  53749. /**
  53750. * The effect that is created when initializing the post process.
  53751. * @returns The created effect corrisponding the the postprocess.
  53752. */
  53753. ProceduralTexture.prototype.getEffect = function () {
  53754. return this._effect;
  53755. };
  53756. /**
  53757. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  53758. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  53759. */
  53760. ProceduralTexture.prototype.getContent = function () {
  53761. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  53762. return this._contentData;
  53763. }
  53764. this._contentData = this.readPixels(0, 0, this._contentData);
  53765. this._contentUpdateId = this._currentRefreshId;
  53766. return this._contentData;
  53767. };
  53768. ProceduralTexture.prototype._createIndexBuffer = function () {
  53769. var engine = this._engine;
  53770. // Indices
  53771. var indices = [];
  53772. indices.push(0);
  53773. indices.push(1);
  53774. indices.push(2);
  53775. indices.push(0);
  53776. indices.push(2);
  53777. indices.push(3);
  53778. this._indexBuffer = engine.createIndexBuffer(indices);
  53779. };
  53780. /** @hidden */
  53781. ProceduralTexture.prototype._rebuild = function () {
  53782. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53783. if (vb) {
  53784. vb._rebuild();
  53785. }
  53786. this._createIndexBuffer();
  53787. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  53788. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  53789. }
  53790. };
  53791. /**
  53792. * Resets the texture in order to recreate its associated resources.
  53793. * This can be called in case of context loss
  53794. */
  53795. ProceduralTexture.prototype.reset = function () {
  53796. if (this._effect === undefined) {
  53797. return;
  53798. }
  53799. var engine = this._engine;
  53800. engine._releaseEffect(this._effect);
  53801. };
  53802. ProceduralTexture.prototype._getDefines = function () {
  53803. return "";
  53804. };
  53805. /**
  53806. * Is the texture ready to be used ? (rendered at least once)
  53807. * @returns true if ready, otherwise, false.
  53808. */
  53809. ProceduralTexture.prototype.isReady = function () {
  53810. var _this = this;
  53811. var engine = this._engine;
  53812. var shaders;
  53813. if (!this._fragment) {
  53814. return false;
  53815. }
  53816. if (this._fallbackTextureUsed) {
  53817. return true;
  53818. }
  53819. var defines = this._getDefines();
  53820. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  53821. return true;
  53822. }
  53823. if (this._fragment.fragmentElement !== undefined) {
  53824. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  53825. }
  53826. else {
  53827. shaders = { vertex: "procedural", fragment: this._fragment };
  53828. }
  53829. this._cachedDefines = defines;
  53830. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  53831. _this.releaseInternalTexture();
  53832. if (_this._fallbackTexture) {
  53833. _this._texture = _this._fallbackTexture._texture;
  53834. if (_this._texture) {
  53835. _this._texture.incrementReferences();
  53836. }
  53837. }
  53838. _this._fallbackTextureUsed = true;
  53839. });
  53840. return this._effect.isReady();
  53841. };
  53842. /**
  53843. * Resets the refresh counter of the texture and start bak from scratch.
  53844. * Could be useful to regenerate the texture if it is setup to render only once.
  53845. */
  53846. ProceduralTexture.prototype.resetRefreshCounter = function () {
  53847. this._currentRefreshId = -1;
  53848. };
  53849. /**
  53850. * Set the fragment shader to use in order to render the texture.
  53851. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  53852. */
  53853. ProceduralTexture.prototype.setFragment = function (fragment) {
  53854. this._fragment = fragment;
  53855. };
  53856. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  53857. /**
  53858. * Define the refresh rate of the texture or the rendering frequency.
  53859. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  53860. */
  53861. get: function () {
  53862. return this._refreshRate;
  53863. },
  53864. set: function (value) {
  53865. this._refreshRate = value;
  53866. this.resetRefreshCounter();
  53867. },
  53868. enumerable: true,
  53869. configurable: true
  53870. });
  53871. /** @hidden */
  53872. ProceduralTexture.prototype._shouldRender = function () {
  53873. if (!this.isEnabled || !this.isReady() || !this._texture) {
  53874. if (this._texture) {
  53875. this._texture.isReady = false;
  53876. }
  53877. return false;
  53878. }
  53879. if (this._fallbackTextureUsed) {
  53880. return false;
  53881. }
  53882. if (this._currentRefreshId === -1) { // At least render once
  53883. this._currentRefreshId = 1;
  53884. return true;
  53885. }
  53886. if (this.refreshRate === this._currentRefreshId) {
  53887. this._currentRefreshId = 1;
  53888. return true;
  53889. }
  53890. this._currentRefreshId++;
  53891. return false;
  53892. };
  53893. /**
  53894. * Get the size the texture is rendering at.
  53895. * @returns the size (texture is always squared)
  53896. */
  53897. ProceduralTexture.prototype.getRenderSize = function () {
  53898. return this._size;
  53899. };
  53900. /**
  53901. * Resize the texture to new value.
  53902. * @param size Define the new size the texture should have
  53903. * @param generateMipMaps Define whether the new texture should create mip maps
  53904. */
  53905. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  53906. if (this._fallbackTextureUsed) {
  53907. return;
  53908. }
  53909. this.releaseInternalTexture();
  53910. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  53911. // Update properties
  53912. this._size = size;
  53913. this._generateMipMaps = generateMipMaps;
  53914. };
  53915. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  53916. if (this._uniforms.indexOf(uniformName) === -1) {
  53917. this._uniforms.push(uniformName);
  53918. }
  53919. };
  53920. /**
  53921. * Set a texture in the shader program used to render.
  53922. * @param name Define the name of the uniform samplers as defined in the shader
  53923. * @param texture Define the texture to bind to this sampler
  53924. * @return the texture itself allowing "fluent" like uniform updates
  53925. */
  53926. ProceduralTexture.prototype.setTexture = function (name, texture) {
  53927. if (this._samplers.indexOf(name) === -1) {
  53928. this._samplers.push(name);
  53929. }
  53930. this._textures[name] = texture;
  53931. return this;
  53932. };
  53933. /**
  53934. * Set a float in the shader.
  53935. * @param name Define the name of the uniform as defined in the shader
  53936. * @param value Define the value to give to the uniform
  53937. * @return the texture itself allowing "fluent" like uniform updates
  53938. */
  53939. ProceduralTexture.prototype.setFloat = function (name, value) {
  53940. this._checkUniform(name);
  53941. this._floats[name] = value;
  53942. return this;
  53943. };
  53944. /**
  53945. * Set a int in the shader.
  53946. * @param name Define the name of the uniform as defined in the shader
  53947. * @param value Define the value to give to the uniform
  53948. * @return the texture itself allowing "fluent" like uniform updates
  53949. */
  53950. ProceduralTexture.prototype.setInt = function (name, value) {
  53951. this._checkUniform(name);
  53952. this._ints[name] = value;
  53953. return this;
  53954. };
  53955. /**
  53956. * Set an array of floats in the shader.
  53957. * @param name Define the name of the uniform as defined in the shader
  53958. * @param value Define the value to give to the uniform
  53959. * @return the texture itself allowing "fluent" like uniform updates
  53960. */
  53961. ProceduralTexture.prototype.setFloats = function (name, value) {
  53962. this._checkUniform(name);
  53963. this._floatsArrays[name] = value;
  53964. return this;
  53965. };
  53966. /**
  53967. * Set a vec3 in the shader from a Color3.
  53968. * @param name Define the name of the uniform as defined in the shader
  53969. * @param value Define the value to give to the uniform
  53970. * @return the texture itself allowing "fluent" like uniform updates
  53971. */
  53972. ProceduralTexture.prototype.setColor3 = function (name, value) {
  53973. this._checkUniform(name);
  53974. this._colors3[name] = value;
  53975. return this;
  53976. };
  53977. /**
  53978. * Set a vec4 in the shader from a Color4.
  53979. * @param name Define the name of the uniform as defined in the shader
  53980. * @param value Define the value to give to the uniform
  53981. * @return the texture itself allowing "fluent" like uniform updates
  53982. */
  53983. ProceduralTexture.prototype.setColor4 = function (name, value) {
  53984. this._checkUniform(name);
  53985. this._colors4[name] = value;
  53986. return this;
  53987. };
  53988. /**
  53989. * Set a vec2 in the shader from a Vector2.
  53990. * @param name Define the name of the uniform as defined in the shader
  53991. * @param value Define the value to give to the uniform
  53992. * @return the texture itself allowing "fluent" like uniform updates
  53993. */
  53994. ProceduralTexture.prototype.setVector2 = function (name, value) {
  53995. this._checkUniform(name);
  53996. this._vectors2[name] = value;
  53997. return this;
  53998. };
  53999. /**
  54000. * Set a vec3 in the shader from a Vector3.
  54001. * @param name Define the name of the uniform as defined in the shader
  54002. * @param value Define the value to give to the uniform
  54003. * @return the texture itself allowing "fluent" like uniform updates
  54004. */
  54005. ProceduralTexture.prototype.setVector3 = function (name, value) {
  54006. this._checkUniform(name);
  54007. this._vectors3[name] = value;
  54008. return this;
  54009. };
  54010. /**
  54011. * Set a mat4 in the shader from a MAtrix.
  54012. * @param name Define the name of the uniform as defined in the shader
  54013. * @param value Define the value to give to the uniform
  54014. * @return the texture itself allowing "fluent" like uniform updates
  54015. */
  54016. ProceduralTexture.prototype.setMatrix = function (name, value) {
  54017. this._checkUniform(name);
  54018. this._matrices[name] = value;
  54019. return this;
  54020. };
  54021. /**
  54022. * Render the texture to its associated render target.
  54023. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54024. */
  54025. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54026. var scene = this.getScene();
  54027. if (!scene) {
  54028. return;
  54029. }
  54030. var engine = this._engine;
  54031. // Render
  54032. engine.enableEffect(this._effect);
  54033. engine.setState(false);
  54034. // Texture
  54035. for (var name in this._textures) {
  54036. this._effect.setTexture(name, this._textures[name]);
  54037. }
  54038. // Float
  54039. for (name in this._ints) {
  54040. this._effect.setInt(name, this._ints[name]);
  54041. }
  54042. // Float
  54043. for (name in this._floats) {
  54044. this._effect.setFloat(name, this._floats[name]);
  54045. }
  54046. // Floats
  54047. for (name in this._floatsArrays) {
  54048. this._effect.setArray(name, this._floatsArrays[name]);
  54049. }
  54050. // Color3
  54051. for (name in this._colors3) {
  54052. this._effect.setColor3(name, this._colors3[name]);
  54053. }
  54054. // Color4
  54055. for (name in this._colors4) {
  54056. var color = this._colors4[name];
  54057. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  54058. }
  54059. // Vector2
  54060. for (name in this._vectors2) {
  54061. this._effect.setVector2(name, this._vectors2[name]);
  54062. }
  54063. // Vector3
  54064. for (name in this._vectors3) {
  54065. this._effect.setVector3(name, this._vectors3[name]);
  54066. }
  54067. // Matrix
  54068. for (name in this._matrices) {
  54069. this._effect.setMatrix(name, this._matrices[name]);
  54070. }
  54071. if (!this._texture) {
  54072. return;
  54073. }
  54074. if (this.isCube) {
  54075. for (var face = 0; face < 6; face++) {
  54076. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  54077. // VBOs
  54078. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54079. this._effect.setFloat("face", face);
  54080. // Clear
  54081. if (this.autoClear) {
  54082. engine.clear(scene.clearColor, true, false, false);
  54083. }
  54084. // Draw order
  54085. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54086. // Mipmaps
  54087. if (face === 5) {
  54088. engine.generateMipMapsForCubemap(this._texture);
  54089. }
  54090. }
  54091. }
  54092. else {
  54093. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  54094. // VBOs
  54095. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54096. // Clear
  54097. if (this.autoClear) {
  54098. engine.clear(scene.clearColor, true, false, false);
  54099. }
  54100. // Draw order
  54101. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54102. }
  54103. // Unbind
  54104. engine.unBindFramebuffer(this._texture, this.isCube);
  54105. if (this.onGenerated) {
  54106. this.onGenerated();
  54107. }
  54108. this.onGeneratedObservable.notifyObservers(this);
  54109. };
  54110. /**
  54111. * Clone the texture.
  54112. * @returns the cloned texture
  54113. */
  54114. ProceduralTexture.prototype.clone = function () {
  54115. var textureSize = this.getSize();
  54116. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  54117. // Base texture
  54118. newTexture.hasAlpha = this.hasAlpha;
  54119. newTexture.level = this.level;
  54120. // RenderTarget Texture
  54121. newTexture.coordinatesMode = this.coordinatesMode;
  54122. return newTexture;
  54123. };
  54124. /**
  54125. * Dispose the texture and release its asoociated resources.
  54126. */
  54127. ProceduralTexture.prototype.dispose = function () {
  54128. var scene = this.getScene();
  54129. if (!scene) {
  54130. return;
  54131. }
  54132. var index = scene.proceduralTextures.indexOf(this);
  54133. if (index >= 0) {
  54134. scene.proceduralTextures.splice(index, 1);
  54135. }
  54136. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54137. if (vertexBuffer) {
  54138. vertexBuffer.dispose();
  54139. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  54140. }
  54141. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  54142. this._indexBuffer = null;
  54143. }
  54144. _super.prototype.dispose.call(this);
  54145. };
  54146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54148. ], ProceduralTexture.prototype, "isEnabled", void 0);
  54149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54151. ], ProceduralTexture.prototype, "autoClear", void 0);
  54152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54154. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  54155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54157. ], ProceduralTexture.prototype, "_size", void 0);
  54158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54160. ], ProceduralTexture.prototype, "refreshRate", null);
  54161. return ProceduralTexture;
  54162. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  54163. /***/ }),
  54164. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  54165. /*!***************************************************************************!*\
  54166. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  54167. \***************************************************************************/
  54168. /*! exports provided: ProceduralTextureSceneComponent */
  54169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54170. "use strict";
  54171. __webpack_require__.r(__webpack_exports__);
  54172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  54173. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54174. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54175. /**
  54176. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  54177. * in a given scene.
  54178. */
  54179. var ProceduralTextureSceneComponent = /** @class */ (function () {
  54180. /**
  54181. * Creates a new instance of the component for the given scene
  54182. * @param scene Defines the scene to register the component in
  54183. */
  54184. function ProceduralTextureSceneComponent(scene) {
  54185. /**
  54186. * The component name helpfull to identify the component in the list of scene components.
  54187. */
  54188. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  54189. this.scene = scene;
  54190. this.scene.proceduralTextures = new Array();
  54191. scene.layers = new Array();
  54192. }
  54193. /**
  54194. * Registers the component in a given scene
  54195. */
  54196. ProceduralTextureSceneComponent.prototype.register = function () {
  54197. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  54198. };
  54199. /**
  54200. * Rebuilds the elements related to this component in case of
  54201. * context lost for instance.
  54202. */
  54203. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  54204. // Nothing to do here.
  54205. };
  54206. /**
  54207. * Disposes the component and the associated ressources.
  54208. */
  54209. ProceduralTextureSceneComponent.prototype.dispose = function () {
  54210. // Nothing to do here.
  54211. };
  54212. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  54213. if (this.scene.proceduralTexturesEnabled) {
  54214. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54215. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  54216. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  54217. if (proceduralTexture._shouldRender()) {
  54218. proceduralTexture.render();
  54219. }
  54220. }
  54221. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54222. }
  54223. };
  54224. return ProceduralTextureSceneComponent;
  54225. }());
  54226. /***/ }),
  54227. /***/ "./Materials/Textures/baseTexture.ts":
  54228. /*!*******************************************!*\
  54229. !*** ./Materials/Textures/baseTexture.ts ***!
  54230. \*******************************************/
  54231. /*! exports provided: BaseTexture */
  54232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54233. "use strict";
  54234. __webpack_require__.r(__webpack_exports__);
  54235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  54236. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54237. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54238. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  54239. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54240. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  54241. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54242. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  54243. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54244. /**
  54245. * Base class of all the textures in babylon.
  54246. * It groups all the common properties the materials, post process, lights... might need
  54247. * in order to make a correct use of the texture.
  54248. */
  54249. var BaseTexture = /** @class */ (function () {
  54250. /**
  54251. * Instantiates a new BaseTexture.
  54252. * Base class of all the textures in babylon.
  54253. * It groups all the common properties the materials, post process, lights... might need
  54254. * in order to make a correct use of the texture.
  54255. * @param scene Define the scene the texture blongs to
  54256. */
  54257. function BaseTexture(scene) {
  54258. /**
  54259. * Gets or sets an object used to store user defined information.
  54260. */
  54261. this.metadata = null;
  54262. /**
  54263. * For internal use only. Please do not use.
  54264. */
  54265. this.reservedDataStore = null;
  54266. this._hasAlpha = false;
  54267. /**
  54268. * Defines if the alpha value should be determined via the rgb values.
  54269. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  54270. */
  54271. this.getAlphaFromRGB = false;
  54272. /**
  54273. * Intensity or strength of the texture.
  54274. * It is commonly used by materials to fine tune the intensity of the texture
  54275. */
  54276. this.level = 1;
  54277. /**
  54278. * Define the UV chanel to use starting from 0 and defaulting to 0.
  54279. * This is part of the texture as textures usually maps to one uv set.
  54280. */
  54281. this.coordinatesIndex = 0;
  54282. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  54283. /**
  54284. * | Value | Type | Description |
  54285. * | ----- | ------------------ | ----------- |
  54286. * | 0 | CLAMP_ADDRESSMODE | |
  54287. * | 1 | WRAP_ADDRESSMODE | |
  54288. * | 2 | MIRROR_ADDRESSMODE | |
  54289. */
  54290. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54291. /**
  54292. * | Value | Type | Description |
  54293. * | ----- | ------------------ | ----------- |
  54294. * | 0 | CLAMP_ADDRESSMODE | |
  54295. * | 1 | WRAP_ADDRESSMODE | |
  54296. * | 2 | MIRROR_ADDRESSMODE | |
  54297. */
  54298. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54299. /**
  54300. * | Value | Type | Description |
  54301. * | ----- | ------------------ | ----------- |
  54302. * | 0 | CLAMP_ADDRESSMODE | |
  54303. * | 1 | WRAP_ADDRESSMODE | |
  54304. * | 2 | MIRROR_ADDRESSMODE | |
  54305. */
  54306. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54307. /**
  54308. * With compliant hardware and browser (supporting anisotropic filtering)
  54309. * this defines the level of anisotropic filtering in the texture.
  54310. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  54311. */
  54312. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  54313. /**
  54314. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  54315. * HDR texture are usually stored in linear space.
  54316. * This only impacts the PBR and Background materials
  54317. */
  54318. this.gammaSpace = true;
  54319. /**
  54320. * Is Z inverted in the texture (useful in a cube texture).
  54321. */
  54322. this.invertZ = false;
  54323. /**
  54324. * @hidden
  54325. */
  54326. this.lodLevelInAlpha = false;
  54327. /**
  54328. * Define if the texture is a render target.
  54329. */
  54330. this.isRenderTarget = false;
  54331. /**
  54332. * Define the list of animation attached to the texture.
  54333. */
  54334. this.animations = new Array();
  54335. /**
  54336. * An event triggered when the texture is disposed.
  54337. */
  54338. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  54339. /**
  54340. * Define the current state of the loading sequence when in delayed load mode.
  54341. */
  54342. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  54343. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54344. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  54345. if (this._scene) {
  54346. this.uniqueId = this._scene.getUniqueId();
  54347. this._scene.addTexture(this);
  54348. }
  54349. this._uid = null;
  54350. }
  54351. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  54352. get: function () {
  54353. return this._hasAlpha;
  54354. },
  54355. /**
  54356. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  54357. */
  54358. set: function (value) {
  54359. if (this._hasAlpha === value) {
  54360. return;
  54361. }
  54362. this._hasAlpha = value;
  54363. if (this._scene) {
  54364. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  54365. }
  54366. },
  54367. enumerable: true,
  54368. configurable: true
  54369. });
  54370. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  54371. get: function () {
  54372. return this._coordinatesMode;
  54373. },
  54374. /**
  54375. * How a texture is mapped.
  54376. *
  54377. * | Value | Type | Description |
  54378. * | ----- | ----------------------------------- | ----------- |
  54379. * | 0 | EXPLICIT_MODE | |
  54380. * | 1 | SPHERICAL_MODE | |
  54381. * | 2 | PLANAR_MODE | |
  54382. * | 3 | CUBIC_MODE | |
  54383. * | 4 | PROJECTION_MODE | |
  54384. * | 5 | SKYBOX_MODE | |
  54385. * | 6 | INVCUBIC_MODE | |
  54386. * | 7 | EQUIRECTANGULAR_MODE | |
  54387. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  54388. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  54389. */
  54390. set: function (value) {
  54391. if (this._coordinatesMode === value) {
  54392. return;
  54393. }
  54394. this._coordinatesMode = value;
  54395. if (this._scene) {
  54396. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54397. }
  54398. },
  54399. enumerable: true,
  54400. configurable: true
  54401. });
  54402. Object.defineProperty(BaseTexture.prototype, "isCube", {
  54403. /**
  54404. * Define if the texture is a cube texture or if false a 2d texture.
  54405. */
  54406. get: function () {
  54407. if (!this._texture) {
  54408. return false;
  54409. }
  54410. return this._texture.isCube;
  54411. },
  54412. set: function (value) {
  54413. if (!this._texture) {
  54414. return;
  54415. }
  54416. this._texture.isCube = value;
  54417. },
  54418. enumerable: true,
  54419. configurable: true
  54420. });
  54421. Object.defineProperty(BaseTexture.prototype, "is3D", {
  54422. /**
  54423. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  54424. */
  54425. get: function () {
  54426. if (!this._texture) {
  54427. return false;
  54428. }
  54429. return this._texture.is3D;
  54430. },
  54431. set: function (value) {
  54432. if (!this._texture) {
  54433. return;
  54434. }
  54435. this._texture.is3D = value;
  54436. },
  54437. enumerable: true,
  54438. configurable: true
  54439. });
  54440. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  54441. /**
  54442. * Gets whether or not the texture contains RGBD data.
  54443. */
  54444. get: function () {
  54445. return this._texture != null && this._texture._isRGBD;
  54446. },
  54447. enumerable: true,
  54448. configurable: true
  54449. });
  54450. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  54451. /**
  54452. * Are mip maps generated for this texture or not.
  54453. */
  54454. get: function () {
  54455. return false;
  54456. },
  54457. enumerable: true,
  54458. configurable: true
  54459. });
  54460. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  54461. /**
  54462. * With prefiltered texture, defined the offset used during the prefiltering steps.
  54463. */
  54464. get: function () {
  54465. if (this._texture) {
  54466. return this._texture._lodGenerationOffset;
  54467. }
  54468. return 0.0;
  54469. },
  54470. set: function (value) {
  54471. if (this._texture) {
  54472. this._texture._lodGenerationOffset = value;
  54473. }
  54474. },
  54475. enumerable: true,
  54476. configurable: true
  54477. });
  54478. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  54479. /**
  54480. * With prefiltered texture, defined the scale used during the prefiltering steps.
  54481. */
  54482. get: function () {
  54483. if (this._texture) {
  54484. return this._texture._lodGenerationScale;
  54485. }
  54486. return 0.0;
  54487. },
  54488. set: function (value) {
  54489. if (this._texture) {
  54490. this._texture._lodGenerationScale = value;
  54491. }
  54492. },
  54493. enumerable: true,
  54494. configurable: true
  54495. });
  54496. Object.defineProperty(BaseTexture.prototype, "uid", {
  54497. /**
  54498. * Define the unique id of the texture in the scene.
  54499. */
  54500. get: function () {
  54501. if (!this._uid) {
  54502. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  54503. }
  54504. return this._uid;
  54505. },
  54506. enumerable: true,
  54507. configurable: true
  54508. });
  54509. /**
  54510. * Return a string representation of the texture.
  54511. * @returns the texture as a string
  54512. */
  54513. BaseTexture.prototype.toString = function () {
  54514. return this.name;
  54515. };
  54516. /**
  54517. * Get the class name of the texture.
  54518. * @returns "BaseTexture"
  54519. */
  54520. BaseTexture.prototype.getClassName = function () {
  54521. return "BaseTexture";
  54522. };
  54523. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  54524. /**
  54525. * Callback triggered when the texture has been disposed.
  54526. * Kept for back compatibility, you can use the onDisposeObservable instead.
  54527. */
  54528. set: function (callback) {
  54529. if (this._onDisposeObserver) {
  54530. this.onDisposeObservable.remove(this._onDisposeObserver);
  54531. }
  54532. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  54533. },
  54534. enumerable: true,
  54535. configurable: true
  54536. });
  54537. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  54538. /**
  54539. * Define if the texture is preventinga material to render or not.
  54540. * If not and the texture is not ready, the engine will use a default black texture instead.
  54541. */
  54542. get: function () {
  54543. return true;
  54544. },
  54545. enumerable: true,
  54546. configurable: true
  54547. });
  54548. /**
  54549. * Get the scene the texture belongs to.
  54550. * @returns the scene or null if undefined
  54551. */
  54552. BaseTexture.prototype.getScene = function () {
  54553. return this._scene;
  54554. };
  54555. /**
  54556. * Get the texture transform matrix used to offset tile the texture for istance.
  54557. * @returns the transformation matrix
  54558. */
  54559. BaseTexture.prototype.getTextureMatrix = function () {
  54560. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54561. };
  54562. /**
  54563. * Get the texture reflection matrix used to rotate/transform the reflection.
  54564. * @returns the reflection matrix
  54565. */
  54566. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54567. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54568. };
  54569. /**
  54570. * Get the underlying lower level texture from Babylon.
  54571. * @returns the insternal texture
  54572. */
  54573. BaseTexture.prototype.getInternalTexture = function () {
  54574. return this._texture;
  54575. };
  54576. /**
  54577. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54578. * @returns true if ready or not blocking
  54579. */
  54580. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54581. return !this.isBlocking || this.isReady();
  54582. };
  54583. /**
  54584. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54585. * @returns true if fully ready
  54586. */
  54587. BaseTexture.prototype.isReady = function () {
  54588. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54589. this.delayLoad();
  54590. return false;
  54591. }
  54592. if (this._texture) {
  54593. return this._texture.isReady;
  54594. }
  54595. return false;
  54596. };
  54597. /**
  54598. * Get the size of the texture.
  54599. * @returns the texture size.
  54600. */
  54601. BaseTexture.prototype.getSize = function () {
  54602. if (this._texture) {
  54603. if (this._texture.width) {
  54604. this._cachedSize.width = this._texture.width;
  54605. this._cachedSize.height = this._texture.height;
  54606. return this._cachedSize;
  54607. }
  54608. if (this._texture._size) {
  54609. this._cachedSize.width = this._texture._size;
  54610. this._cachedSize.height = this._texture._size;
  54611. return this._cachedSize;
  54612. }
  54613. }
  54614. return this._cachedSize;
  54615. };
  54616. /**
  54617. * Get the base size of the texture.
  54618. * It can be different from the size if the texture has been resized for POT for instance
  54619. * @returns the base size
  54620. */
  54621. BaseTexture.prototype.getBaseSize = function () {
  54622. if (!this.isReady() || !this._texture) {
  54623. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54624. }
  54625. if (this._texture._size) {
  54626. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54627. }
  54628. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54629. };
  54630. /**
  54631. * Update the sampling mode of the texture.
  54632. * Default is Trilinear mode.
  54633. *
  54634. * | Value | Type | Description |
  54635. * | ----- | ------------------ | ----------- |
  54636. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54637. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54638. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54639. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54640. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54641. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54642. * | 7 | NEAREST_LINEAR | |
  54643. * | 8 | NEAREST_NEAREST | |
  54644. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54645. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54646. * | 11 | LINEAR_LINEAR | |
  54647. * | 12 | LINEAR_NEAREST | |
  54648. *
  54649. * > _mag_: magnification filter (close to the viewer)
  54650. * > _min_: minification filter (far from the viewer)
  54651. * > _mip_: filter used between mip map levels
  54652. *@param samplingMode Define the new sampling mode of the texture
  54653. */
  54654. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54655. if (!this._texture) {
  54656. return;
  54657. }
  54658. var scene = this.getScene();
  54659. if (!scene) {
  54660. return;
  54661. }
  54662. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54663. };
  54664. /**
  54665. * Scales the texture if is `canRescale()`
  54666. * @param ratio the resize factor we want to use to rescale
  54667. */
  54668. BaseTexture.prototype.scale = function (ratio) {
  54669. };
  54670. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54671. /**
  54672. * Get if the texture can rescale.
  54673. */
  54674. get: function () {
  54675. return false;
  54676. },
  54677. enumerable: true,
  54678. configurable: true
  54679. });
  54680. /** @hidden */
  54681. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54682. if (!this._scene) {
  54683. return null;
  54684. }
  54685. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54686. for (var index = 0; index < texturesCache.length; index++) {
  54687. var texturesCacheEntry = texturesCache[index];
  54688. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54689. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54690. texturesCacheEntry.incrementReferences();
  54691. return texturesCacheEntry;
  54692. }
  54693. }
  54694. }
  54695. return null;
  54696. };
  54697. /** @hidden */
  54698. BaseTexture.prototype._rebuild = function () {
  54699. };
  54700. /**
  54701. * Triggers the load sequence in delayed load mode.
  54702. */
  54703. BaseTexture.prototype.delayLoad = function () {
  54704. };
  54705. /**
  54706. * Clones the texture.
  54707. * @returns the cloned texture
  54708. */
  54709. BaseTexture.prototype.clone = function () {
  54710. return null;
  54711. };
  54712. Object.defineProperty(BaseTexture.prototype, "textureType", {
  54713. /**
  54714. * Get the texture underlying type (INT, FLOAT...)
  54715. */
  54716. get: function () {
  54717. if (!this._texture) {
  54718. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54719. }
  54720. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54721. },
  54722. enumerable: true,
  54723. configurable: true
  54724. });
  54725. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  54726. /**
  54727. * Get the texture underlying format (RGB, RGBA...)
  54728. */
  54729. get: function () {
  54730. if (!this._texture) {
  54731. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54732. }
  54733. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54734. },
  54735. enumerable: true,
  54736. configurable: true
  54737. });
  54738. /**
  54739. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  54740. * This will returns an RGBA array buffer containing either in values (0-255) or
  54741. * float values (0-1) depending of the underlying buffer type.
  54742. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  54743. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  54744. * @param buffer defines a user defined buffer to fill with data (can be null)
  54745. * @returns The Array buffer containing the pixels data.
  54746. */
  54747. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  54748. if (faceIndex === void 0) { faceIndex = 0; }
  54749. if (level === void 0) { level = 0; }
  54750. if (buffer === void 0) { buffer = null; }
  54751. if (!this._texture) {
  54752. return null;
  54753. }
  54754. var size = this.getSize();
  54755. var width = size.width;
  54756. var height = size.height;
  54757. var scene = this.getScene();
  54758. if (!scene) {
  54759. return null;
  54760. }
  54761. var engine = scene.getEngine();
  54762. if (level != 0) {
  54763. width = width / Math.pow(2, level);
  54764. height = height / Math.pow(2, level);
  54765. width = Math.round(width);
  54766. height = Math.round(height);
  54767. }
  54768. if (this._texture.isCube) {
  54769. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  54770. }
  54771. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  54772. };
  54773. /**
  54774. * Release and destroy the underlying lower level texture aka internalTexture.
  54775. */
  54776. BaseTexture.prototype.releaseInternalTexture = function () {
  54777. if (this._texture) {
  54778. this._texture.dispose();
  54779. this._texture = null;
  54780. }
  54781. };
  54782. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  54783. /**
  54784. * Get the polynomial representation of the texture data.
  54785. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54786. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54787. */
  54788. get: function () {
  54789. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  54790. return null;
  54791. }
  54792. if (!this._texture._sphericalPolynomial) {
  54793. this._texture._sphericalPolynomial =
  54794. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  54795. }
  54796. return this._texture._sphericalPolynomial;
  54797. },
  54798. set: function (value) {
  54799. if (this._texture) {
  54800. this._texture._sphericalPolynomial = value;
  54801. }
  54802. },
  54803. enumerable: true,
  54804. configurable: true
  54805. });
  54806. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  54807. /** @hidden */
  54808. get: function () {
  54809. if (this._texture) {
  54810. return this._texture._lodTextureHigh;
  54811. }
  54812. return null;
  54813. },
  54814. enumerable: true,
  54815. configurable: true
  54816. });
  54817. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  54818. /** @hidden */
  54819. get: function () {
  54820. if (this._texture) {
  54821. return this._texture._lodTextureMid;
  54822. }
  54823. return null;
  54824. },
  54825. enumerable: true,
  54826. configurable: true
  54827. });
  54828. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  54829. /** @hidden */
  54830. get: function () {
  54831. if (this._texture) {
  54832. return this._texture._lodTextureLow;
  54833. }
  54834. return null;
  54835. },
  54836. enumerable: true,
  54837. configurable: true
  54838. });
  54839. /**
  54840. * Dispose the texture and release its associated resources.
  54841. */
  54842. BaseTexture.prototype.dispose = function () {
  54843. if (!this._scene) {
  54844. return;
  54845. }
  54846. // Animations
  54847. this._scene.stopAnimation(this);
  54848. // Remove from scene
  54849. this._scene._removePendingData(this);
  54850. var index = this._scene.textures.indexOf(this);
  54851. if (index >= 0) {
  54852. this._scene.textures.splice(index, 1);
  54853. }
  54854. this._scene.onTextureRemovedObservable.notifyObservers(this);
  54855. if (this._texture === undefined) {
  54856. return;
  54857. }
  54858. // Release
  54859. this.releaseInternalTexture();
  54860. // Callback
  54861. this.onDisposeObservable.notifyObservers(this);
  54862. this.onDisposeObservable.clear();
  54863. };
  54864. /**
  54865. * Serialize the texture into a JSON representation that can be parsed later on.
  54866. * @returns the JSON representation of the texture
  54867. */
  54868. BaseTexture.prototype.serialize = function () {
  54869. if (!this.name) {
  54870. return null;
  54871. }
  54872. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54873. // Animations
  54874. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  54875. return serializationObject;
  54876. };
  54877. /**
  54878. * Helper function to be called back once a list of texture contains only ready textures.
  54879. * @param textures Define the list of textures to wait for
  54880. * @param callback Define the callback triggered once the entire list will be ready
  54881. */
  54882. BaseTexture.WhenAllReady = function (textures, callback) {
  54883. var numRemaining = textures.length;
  54884. if (numRemaining === 0) {
  54885. callback();
  54886. return;
  54887. }
  54888. var _loop_1 = function () {
  54889. texture = textures[i];
  54890. if (texture.isReady()) {
  54891. if (--numRemaining === 0) {
  54892. callback();
  54893. }
  54894. }
  54895. else {
  54896. onLoadObservable = texture.onLoadObservable;
  54897. var onLoadCallback_1 = function () {
  54898. onLoadObservable.removeCallback(onLoadCallback_1);
  54899. if (--numRemaining === 0) {
  54900. callback();
  54901. }
  54902. };
  54903. onLoadObservable.add(onLoadCallback_1);
  54904. }
  54905. };
  54906. var texture, onLoadObservable;
  54907. for (var i = 0; i < textures.length; i++) {
  54908. _loop_1();
  54909. }
  54910. };
  54911. /**
  54912. * Default anisotropic filtering level for the application.
  54913. * It is set to 4 as a good tradeoff between perf and quality.
  54914. */
  54915. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  54916. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54918. ], BaseTexture.prototype, "uniqueId", void 0);
  54919. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54921. ], BaseTexture.prototype, "name", void 0);
  54922. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54924. ], BaseTexture.prototype, "metadata", void 0);
  54925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  54927. ], BaseTexture.prototype, "_hasAlpha", void 0);
  54928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54930. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  54931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54933. ], BaseTexture.prototype, "level", void 0);
  54934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54936. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  54937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  54939. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  54940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54942. ], BaseTexture.prototype, "wrapU", void 0);
  54943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54945. ], BaseTexture.prototype, "wrapV", void 0);
  54946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54948. ], BaseTexture.prototype, "wrapR", void 0);
  54949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54951. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  54952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54954. ], BaseTexture.prototype, "isCube", null);
  54955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54957. ], BaseTexture.prototype, "is3D", null);
  54958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54960. ], BaseTexture.prototype, "gammaSpace", void 0);
  54961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54963. ], BaseTexture.prototype, "invertZ", void 0);
  54964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54966. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  54967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54969. ], BaseTexture.prototype, "lodGenerationOffset", null);
  54970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54972. ], BaseTexture.prototype, "lodGenerationScale", null);
  54973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54975. ], BaseTexture.prototype, "isRenderTarget", void 0);
  54976. return BaseTexture;
  54977. }());
  54978. /***/ }),
  54979. /***/ "./Materials/Textures/colorGradingTexture.ts":
  54980. /*!***************************************************!*\
  54981. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  54982. \***************************************************/
  54983. /*! exports provided: ColorGradingTexture */
  54984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54985. "use strict";
  54986. __webpack_require__.r(__webpack_exports__);
  54987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  54988. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54989. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54990. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54991. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54992. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54993. /**
  54994. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54995. * It can help converting any input color in a desired output one. This can then be used to create effects
  54996. * from sepia, black and white to sixties or futuristic rendering...
  54997. *
  54998. * The only supported format is currently 3dl.
  54999. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55000. */
  55001. var ColorGradingTexture = /** @class */ (function (_super) {
  55002. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  55003. /**
  55004. * Instantiates a ColorGradingTexture from the following parameters.
  55005. *
  55006. * @param url The location of the color gradind data (currently only supporting 3dl)
  55007. * @param scene The scene the texture will be used in
  55008. */
  55009. function ColorGradingTexture(url, scene) {
  55010. var _this = _super.call(this, scene) || this;
  55011. if (!url) {
  55012. return _this;
  55013. }
  55014. _this._engine = scene.getEngine();
  55015. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55016. _this.name = url;
  55017. _this.url = url;
  55018. _this.hasAlpha = false;
  55019. _this.isCube = false;
  55020. _this.is3D = _this._engine.webGLVersion > 1;
  55021. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55022. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55023. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55024. _this.anisotropicFilteringLevel = 1;
  55025. _this._texture = _this._getFromCache(url, true);
  55026. if (!_this._texture) {
  55027. if (!scene.useDelayedTextureLoading) {
  55028. _this.loadTexture();
  55029. }
  55030. else {
  55031. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55032. }
  55033. }
  55034. return _this;
  55035. }
  55036. /**
  55037. * Returns the texture matrix used in most of the material.
  55038. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55039. */
  55040. ColorGradingTexture.prototype.getTextureMatrix = function () {
  55041. return this._textureMatrix;
  55042. };
  55043. /**
  55044. * Occurs when the file being loaded is a .3dl LUT file.
  55045. */
  55046. ColorGradingTexture.prototype.load3dlTexture = function () {
  55047. var engine = this._engine;
  55048. var texture;
  55049. if (engine.webGLVersion === 1) {
  55050. 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);
  55051. }
  55052. else {
  55053. 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);
  55054. }
  55055. this._texture = texture;
  55056. var callback = function (text) {
  55057. if (typeof text !== "string") {
  55058. return;
  55059. }
  55060. var data = null;
  55061. var tempData = null;
  55062. var line;
  55063. var lines = text.split('\n');
  55064. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  55065. var maxColor = 0;
  55066. for (var i = 0; i < lines.length; i++) {
  55067. line = lines[i];
  55068. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  55069. continue;
  55070. }
  55071. if (line.indexOf('#') === 0) {
  55072. continue;
  55073. }
  55074. var words = line.split(" ");
  55075. if (size === 0) {
  55076. // Number of space + one
  55077. size = words.length;
  55078. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  55079. tempData = new Float32Array(size * size * size * 4);
  55080. continue;
  55081. }
  55082. if (size != 0) {
  55083. var r = Math.max(parseInt(words[0]), 0);
  55084. var g = Math.max(parseInt(words[1]), 0);
  55085. var b = Math.max(parseInt(words[2]), 0);
  55086. maxColor = Math.max(r, maxColor);
  55087. maxColor = Math.max(g, maxColor);
  55088. maxColor = Math.max(b, maxColor);
  55089. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  55090. if (tempData) {
  55091. tempData[pixelStorageIndex + 0] = r;
  55092. tempData[pixelStorageIndex + 1] = g;
  55093. tempData[pixelStorageIndex + 2] = b;
  55094. }
  55095. // Keep for reference in case of back compat problems.
  55096. // pixelIndexSlice++;
  55097. // if (pixelIndexSlice % size == 0) {
  55098. // pixelIndexH++;
  55099. // pixelIndexSlice = 0;
  55100. // if (pixelIndexH % size == 0) {
  55101. // pixelIndexW++;
  55102. // pixelIndexH = 0;
  55103. // }
  55104. // }
  55105. pixelIndexH++;
  55106. if (pixelIndexH % size == 0) {
  55107. pixelIndexSlice++;
  55108. pixelIndexH = 0;
  55109. if (pixelIndexSlice % size == 0) {
  55110. pixelIndexW++;
  55111. pixelIndexSlice = 0;
  55112. }
  55113. }
  55114. }
  55115. }
  55116. if (tempData && data) {
  55117. for (var i = 0; i < tempData.length; i++) {
  55118. if (i > 0 && (i + 1) % 4 === 0) {
  55119. data[i] = 255;
  55120. }
  55121. else {
  55122. var value = tempData[i];
  55123. data[i] = (value / maxColor * 255);
  55124. }
  55125. }
  55126. }
  55127. if (texture.is3D) {
  55128. texture.updateSize(size, size, size);
  55129. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55130. }
  55131. else {
  55132. texture.updateSize(size * size, size);
  55133. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55134. }
  55135. };
  55136. var scene = this.getScene();
  55137. if (scene) {
  55138. scene._loadFile(this.url, callback);
  55139. }
  55140. else {
  55141. this._engine._loadFile(this.url, callback);
  55142. }
  55143. return this._texture;
  55144. };
  55145. /**
  55146. * Starts the loading process of the texture.
  55147. */
  55148. ColorGradingTexture.prototype.loadTexture = function () {
  55149. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  55150. this.load3dlTexture();
  55151. }
  55152. };
  55153. /**
  55154. * Clones the color gradind texture.
  55155. */
  55156. ColorGradingTexture.prototype.clone = function () {
  55157. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  55158. // Base texture
  55159. newTexture.level = this.level;
  55160. return newTexture;
  55161. };
  55162. /**
  55163. * Called during delayed load for textures.
  55164. */
  55165. ColorGradingTexture.prototype.delayLoad = function () {
  55166. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55167. return;
  55168. }
  55169. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  55170. this._texture = this._getFromCache(this.url, true);
  55171. if (!this._texture) {
  55172. this.loadTexture();
  55173. }
  55174. };
  55175. /**
  55176. * Parses a color grading texture serialized by Babylon.
  55177. * @param parsedTexture The texture information being parsedTexture
  55178. * @param scene The scene to load the texture in
  55179. * @param rootUrl The root url of the data assets to load
  55180. * @return A color gradind texture
  55181. */
  55182. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  55183. var texture = null;
  55184. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55185. texture = new ColorGradingTexture(parsedTexture.name, scene);
  55186. texture.name = parsedTexture.name;
  55187. texture.level = parsedTexture.level;
  55188. }
  55189. return texture;
  55190. };
  55191. /**
  55192. * Serializes the LUT texture to json format.
  55193. */
  55194. ColorGradingTexture.prototype.serialize = function () {
  55195. if (!this.name) {
  55196. return null;
  55197. }
  55198. var serializationObject = {};
  55199. serializationObject.name = this.name;
  55200. serializationObject.level = this.level;
  55201. serializationObject.customType = "BABYLON.ColorGradingTexture";
  55202. return serializationObject;
  55203. };
  55204. /**
  55205. * Empty line regex stored for GC.
  55206. */
  55207. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  55208. return ColorGradingTexture;
  55209. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  55210. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  55211. /***/ }),
  55212. /***/ "./Materials/Textures/cubeTexture.ts":
  55213. /*!*******************************************!*\
  55214. !*** ./Materials/Textures/cubeTexture.ts ***!
  55215. \*******************************************/
  55216. /*! exports provided: CubeTexture */
  55217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55218. "use strict";
  55219. __webpack_require__.r(__webpack_exports__);
  55220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  55221. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55222. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55223. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55224. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55225. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55226. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55227. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55228. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55229. /**
  55230. * Class for creating a cube texture
  55231. */
  55232. var CubeTexture = /** @class */ (function (_super) {
  55233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  55234. /**
  55235. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  55236. * as prefiltered data.
  55237. * @param rootUrl defines the url of the texture or the root name of the six images
  55238. * @param scene defines the scene the texture is attached to
  55239. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  55240. * @param noMipmap defines if mipmaps should be created or not
  55241. * @param files defines the six files to load for the different faces
  55242. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  55243. * @param onError defines a callback triggered in case of error during load
  55244. * @param format defines the internal format to use for the texture once loaded
  55245. * @param prefiltered defines whether or not the texture is created from prefiltered data
  55246. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  55247. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55248. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55249. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55250. * @return the cube texture
  55251. */
  55252. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  55253. if (extensions === void 0) { extensions = null; }
  55254. if (noMipmap === void 0) { noMipmap = false; }
  55255. if (files === void 0) { files = null; }
  55256. if (onLoad === void 0) { onLoad = null; }
  55257. if (onError === void 0) { onError = null; }
  55258. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  55259. if (prefiltered === void 0) { prefiltered = false; }
  55260. if (forcedExtension === void 0) { forcedExtension = null; }
  55261. if (createPolynomials === void 0) { createPolynomials = false; }
  55262. if (lodScale === void 0) { lodScale = 0.8; }
  55263. if (lodOffset === void 0) { lodOffset = 0; }
  55264. var _this = _super.call(this, scene) || this;
  55265. /**
  55266. * Gets or sets the center of the bounding box associated with the cube texture.
  55267. * It must define where the camera used to render the texture was set
  55268. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55269. */
  55270. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  55271. _this._rotationY = 0;
  55272. /** @hidden */
  55273. _this._prefiltered = false;
  55274. _this.name = rootUrl;
  55275. _this.url = rootUrl;
  55276. _this._noMipmap = noMipmap;
  55277. _this.hasAlpha = false;
  55278. _this._format = format;
  55279. _this.isCube = true;
  55280. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  55281. _this._createPolynomials = createPolynomials;
  55282. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  55283. if (!rootUrl && !files) {
  55284. return _this;
  55285. }
  55286. var lastDot = rootUrl.lastIndexOf(".");
  55287. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  55288. var isDDS = (extension === ".dds");
  55289. var isEnv = (extension === ".env");
  55290. if (isEnv) {
  55291. _this.gammaSpace = false;
  55292. _this._prefiltered = false;
  55293. }
  55294. else {
  55295. _this._prefiltered = prefiltered;
  55296. if (prefiltered) {
  55297. _this.gammaSpace = false;
  55298. }
  55299. }
  55300. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  55301. if (!files) {
  55302. if (!isEnv && !isDDS && !extensions) {
  55303. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  55304. }
  55305. files = [];
  55306. if (extensions) {
  55307. for (var index = 0; index < extensions.length; index++) {
  55308. files.push(rootUrl + extensions[index]);
  55309. }
  55310. }
  55311. }
  55312. _this._files = files;
  55313. if (!_this._texture) {
  55314. if (!scene.useDelayedTextureLoading) {
  55315. if (prefiltered) {
  55316. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  55317. }
  55318. else {
  55319. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  55320. }
  55321. }
  55322. else {
  55323. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55324. }
  55325. }
  55326. else if (onLoad) {
  55327. if (_this._texture.isReady) {
  55328. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  55329. }
  55330. else {
  55331. _this._texture.onLoadedObservable.add(onLoad);
  55332. }
  55333. }
  55334. return _this;
  55335. }
  55336. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  55337. /**
  55338. * Returns the bounding box size
  55339. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55340. */
  55341. get: function () {
  55342. return this._boundingBoxSize;
  55343. },
  55344. /**
  55345. * Gets or sets the size of the bounding box associated with the cube texture
  55346. * When defined, the cubemap will switch to local mode
  55347. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55348. * @example https://www.babylonjs-playground.com/#RNASML
  55349. */
  55350. set: function (value) {
  55351. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55352. return;
  55353. }
  55354. this._boundingBoxSize = value;
  55355. var scene = this.getScene();
  55356. if (scene) {
  55357. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55358. }
  55359. },
  55360. enumerable: true,
  55361. configurable: true
  55362. });
  55363. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  55364. /**
  55365. * Gets texture matrix rotation angle around Y axis radians.
  55366. */
  55367. get: function () {
  55368. return this._rotationY;
  55369. },
  55370. /**
  55371. * Sets texture matrix rotation angle around Y axis in radians.
  55372. */
  55373. set: function (value) {
  55374. this._rotationY = value;
  55375. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  55376. },
  55377. enumerable: true,
  55378. configurable: true
  55379. });
  55380. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  55381. /**
  55382. * Are mip maps generated for this texture or not.
  55383. */
  55384. get: function () {
  55385. return this._noMipmap;
  55386. },
  55387. enumerable: true,
  55388. configurable: true
  55389. });
  55390. /**
  55391. * Creates a cube texture from an array of image urls
  55392. * @param files defines an array of image urls
  55393. * @param scene defines the hosting scene
  55394. * @param noMipmap specifies if mip maps are not used
  55395. * @returns a cube texture
  55396. */
  55397. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  55398. var rootUrlKey = "";
  55399. files.forEach(function (url) { return rootUrlKey += url; });
  55400. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  55401. };
  55402. /**
  55403. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  55404. * @param url defines the url of the prefiltered texture
  55405. * @param scene defines the scene the texture is attached to
  55406. * @param forcedExtension defines the extension of the file if different from the url
  55407. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55408. * @return the prefiltered texture
  55409. */
  55410. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  55411. if (forcedExtension === void 0) { forcedExtension = null; }
  55412. if (createPolynomials === void 0) { createPolynomials = true; }
  55413. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  55414. };
  55415. /**
  55416. * Get the current class name of the texture useful for serialization or dynamic coding.
  55417. * @returns "CubeTexture"
  55418. */
  55419. CubeTexture.prototype.getClassName = function () {
  55420. return "CubeTexture";
  55421. };
  55422. /**
  55423. * Update the url (and optional buffer) of this texture if url was null during construction.
  55424. * @param url the url of the texture
  55425. * @param forcedExtension defines the extension to use
  55426. * @param onLoad callback called when the texture is loaded (defaults to null)
  55427. */
  55428. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  55429. if (this.url) {
  55430. this.releaseInternalTexture();
  55431. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55432. }
  55433. this.url = url;
  55434. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55435. this._prefiltered = false;
  55436. if (onLoad) {
  55437. this._delayedOnLoad = onLoad;
  55438. }
  55439. this.delayLoad(forcedExtension);
  55440. };
  55441. /**
  55442. * Delays loading of the cube texture
  55443. * @param forcedExtension defines the extension to use
  55444. */
  55445. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  55446. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55447. return;
  55448. }
  55449. var scene = this.getScene();
  55450. if (!scene) {
  55451. return;
  55452. }
  55453. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  55454. this._texture = this._getFromCache(this.url, this._noMipmap);
  55455. if (!this._texture) {
  55456. if (this._prefiltered) {
  55457. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  55458. }
  55459. else {
  55460. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  55461. }
  55462. }
  55463. };
  55464. /**
  55465. * Returns the reflection texture matrix
  55466. * @returns the reflection texture matrix
  55467. */
  55468. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  55469. return this._textureMatrix;
  55470. };
  55471. /**
  55472. * Sets the reflection texture matrix
  55473. * @param value Reflection texture matrix
  55474. */
  55475. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55476. var _this = this;
  55477. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55478. return;
  55479. }
  55480. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55481. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55482. }
  55483. this._textureMatrix = value;
  55484. };
  55485. /**
  55486. * Parses text to create a cube texture
  55487. * @param parsedTexture define the serialized text to read from
  55488. * @param scene defines the hosting scene
  55489. * @param rootUrl defines the root url of the cube texture
  55490. * @returns a cube texture
  55491. */
  55492. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55493. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  55494. var prefiltered = false;
  55495. if (parsedTexture.prefiltered) {
  55496. prefiltered = parsedTexture.prefiltered;
  55497. }
  55498. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  55499. }, parsedTexture, scene);
  55500. // Local Cubemaps
  55501. if (parsedTexture.boundingBoxPosition) {
  55502. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55503. }
  55504. if (parsedTexture.boundingBoxSize) {
  55505. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55506. }
  55507. // Animations
  55508. if (parsedTexture.animations) {
  55509. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  55510. var parsedAnimation = parsedTexture.animations[animationIndex];
  55511. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  55512. if (internalClass) {
  55513. texture.animations.push(internalClass.Parse(parsedAnimation));
  55514. }
  55515. }
  55516. }
  55517. return texture;
  55518. };
  55519. /**
  55520. * Makes a clone, or deep copy, of the cube texture
  55521. * @returns a new cube texture
  55522. */
  55523. CubeTexture.prototype.clone = function () {
  55524. var _this = this;
  55525. var scene = this.getScene();
  55526. var uniqueId = 0;
  55527. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  55528. if (!scene) {
  55529. return _this;
  55530. }
  55531. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  55532. uniqueId = cubeTexture.uniqueId;
  55533. return cubeTexture;
  55534. }, this);
  55535. newCubeTexture.uniqueId = uniqueId;
  55536. return newCubeTexture;
  55537. };
  55538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  55540. ], CubeTexture.prototype, "rotationY", null);
  55541. return CubeTexture;
  55542. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  55543. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  55544. /***/ }),
  55545. /***/ "./Materials/Textures/dynamicTexture.ts":
  55546. /*!**********************************************!*\
  55547. !*** ./Materials/Textures/dynamicTexture.ts ***!
  55548. \**********************************************/
  55549. /*! exports provided: DynamicTexture */
  55550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55551. "use strict";
  55552. __webpack_require__.r(__webpack_exports__);
  55553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55555. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55556. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55557. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55558. /**
  55559. * A class extending Texture allowing drawing on a texture
  55560. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55561. */
  55562. var DynamicTexture = /** @class */ (function (_super) {
  55563. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55564. /**
  55565. * Creates a DynamicTexture
  55566. * @param name defines the name of the texture
  55567. * @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
  55568. * @param scene defines the scene where you want the texture
  55569. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55570. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55571. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55572. */
  55573. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55574. if (scene === void 0) { scene = null; }
  55575. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55576. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55577. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55578. _this.name = name;
  55579. _this._engine = _this.getScene().getEngine();
  55580. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55581. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55582. _this._generateMipMaps = generateMipMaps;
  55583. if (options.getContext) {
  55584. _this._canvas = options;
  55585. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55586. }
  55587. else {
  55588. _this._canvas = document.createElement("canvas");
  55589. if (options.width || options.width === 0) {
  55590. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55591. }
  55592. else {
  55593. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55594. }
  55595. }
  55596. var textureSize = _this.getSize();
  55597. _this._canvas.width = textureSize.width;
  55598. _this._canvas.height = textureSize.height;
  55599. _this._context = _this._canvas.getContext("2d");
  55600. return _this;
  55601. }
  55602. /**
  55603. * Get the current class name of the texture useful for serialization or dynamic coding.
  55604. * @returns "DynamicTexture"
  55605. */
  55606. DynamicTexture.prototype.getClassName = function () {
  55607. return "DynamicTexture";
  55608. };
  55609. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55610. /**
  55611. * Gets the current state of canRescale
  55612. */
  55613. get: function () {
  55614. return true;
  55615. },
  55616. enumerable: true,
  55617. configurable: true
  55618. });
  55619. DynamicTexture.prototype._recreate = function (textureSize) {
  55620. this._canvas.width = textureSize.width;
  55621. this._canvas.height = textureSize.height;
  55622. this.releaseInternalTexture();
  55623. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55624. };
  55625. /**
  55626. * Scales the texture
  55627. * @param ratio the scale factor to apply to both width and height
  55628. */
  55629. DynamicTexture.prototype.scale = function (ratio) {
  55630. var textureSize = this.getSize();
  55631. textureSize.width *= ratio;
  55632. textureSize.height *= ratio;
  55633. this._recreate(textureSize);
  55634. };
  55635. /**
  55636. * Resizes the texture
  55637. * @param width the new width
  55638. * @param height the new height
  55639. */
  55640. DynamicTexture.prototype.scaleTo = function (width, height) {
  55641. var textureSize = this.getSize();
  55642. textureSize.width = width;
  55643. textureSize.height = height;
  55644. this._recreate(textureSize);
  55645. };
  55646. /**
  55647. * Gets the context of the canvas used by the texture
  55648. * @returns the canvas context of the dynamic texture
  55649. */
  55650. DynamicTexture.prototype.getContext = function () {
  55651. return this._context;
  55652. };
  55653. /**
  55654. * Clears the texture
  55655. */
  55656. DynamicTexture.prototype.clear = function () {
  55657. var size = this.getSize();
  55658. this._context.fillRect(0, 0, size.width, size.height);
  55659. };
  55660. /**
  55661. * Updates the texture
  55662. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55663. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55664. */
  55665. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55666. if (premulAlpha === void 0) { premulAlpha = false; }
  55667. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55668. };
  55669. /**
  55670. * Draws text onto the texture
  55671. * @param text defines the text to be drawn
  55672. * @param x defines the placement of the text from the left
  55673. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55674. * @param font defines the font to be used with font-style, font-size, font-name
  55675. * @param color defines the color used for the text
  55676. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55677. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55678. * @param update defines whether texture is immediately update (default is true)
  55679. */
  55680. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55681. if (update === void 0) { update = true; }
  55682. var size = this.getSize();
  55683. if (clearColor) {
  55684. this._context.fillStyle = clearColor;
  55685. this._context.fillRect(0, 0, size.width, size.height);
  55686. }
  55687. this._context.font = font;
  55688. if (x === null || x === undefined) {
  55689. var textSize = this._context.measureText(text);
  55690. x = (size.width - textSize.width) / 2;
  55691. }
  55692. if (y === null || y === undefined) {
  55693. var fontSize = parseInt((font.replace(/\D/g, '')));
  55694. y = (size.height / 2) + (fontSize / 3.65);
  55695. }
  55696. this._context.fillStyle = color;
  55697. this._context.fillText(text, x, y);
  55698. if (update) {
  55699. this.update(invertY);
  55700. }
  55701. };
  55702. /**
  55703. * Clones the texture
  55704. * @returns the clone of the texture.
  55705. */
  55706. DynamicTexture.prototype.clone = function () {
  55707. var scene = this.getScene();
  55708. if (!scene) {
  55709. return this;
  55710. }
  55711. var textureSize = this.getSize();
  55712. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  55713. // Base texture
  55714. newTexture.hasAlpha = this.hasAlpha;
  55715. newTexture.level = this.level;
  55716. // Dynamic Texture
  55717. newTexture.wrapU = this.wrapU;
  55718. newTexture.wrapV = this.wrapV;
  55719. return newTexture;
  55720. };
  55721. /**
  55722. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55723. * @returns a serialized dynamic texture object
  55724. */
  55725. DynamicTexture.prototype.serialize = function () {
  55726. var scene = this.getScene();
  55727. if (scene && !scene.isReady()) {
  55728. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  55729. }
  55730. var serializationObject = _super.prototype.serialize.call(this);
  55731. serializationObject.base64String = this._canvas.toDataURL();
  55732. serializationObject.invertY = this._invertY;
  55733. serializationObject.samplingMode = this.samplingMode;
  55734. return serializationObject;
  55735. };
  55736. /** @hidden */
  55737. DynamicTexture.prototype._rebuild = function () {
  55738. this.update();
  55739. };
  55740. return DynamicTexture;
  55741. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  55742. /***/ }),
  55743. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  55744. /*!**********************************************!*\
  55745. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  55746. \**********************************************/
  55747. /*! exports provided: HDRCubeTexture */
  55748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55749. "use strict";
  55750. __webpack_require__.r(__webpack_exports__);
  55751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  55752. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55753. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55754. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  55755. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55756. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55757. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55758. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  55759. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  55760. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55761. /**
  55762. * This represents a texture coming from an HDR input.
  55763. *
  55764. * The only supported format is currently panorama picture stored in RGBE format.
  55765. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55766. */
  55767. var HDRCubeTexture = /** @class */ (function (_super) {
  55768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  55769. /**
  55770. * Instantiates an HDRTexture from the following parameters.
  55771. *
  55772. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55773. * @param scene The scene the texture will be used in
  55774. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55775. * @param noMipmap Forces to not generate the mipmap if true
  55776. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55777. * @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)
  55778. * @param reserved Reserved flag for internal use.
  55779. */
  55780. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  55781. if (noMipmap === void 0) { noMipmap = false; }
  55782. if (generateHarmonics === void 0) { generateHarmonics = true; }
  55783. if (gammaSpace === void 0) { gammaSpace = false; }
  55784. if (reserved === void 0) { reserved = false; }
  55785. if (onLoad === void 0) { onLoad = null; }
  55786. if (onError === void 0) { onError = null; }
  55787. var _this = _super.call(this, scene) || this;
  55788. _this._generateHarmonics = true;
  55789. _this._onLoad = null;
  55790. _this._onError = null;
  55791. /**
  55792. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55793. */
  55794. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  55795. _this._isBlocking = true;
  55796. _this._rotationY = 0;
  55797. /**
  55798. * Gets or sets the center of the bounding box associated with the cube texture
  55799. * It must define where the camera used to render the texture was set
  55800. */
  55801. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  55802. if (!url) {
  55803. return _this;
  55804. }
  55805. _this.name = url;
  55806. _this.url = url;
  55807. _this.hasAlpha = false;
  55808. _this.isCube = true;
  55809. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55810. _this._onLoad = onLoad;
  55811. _this._onError = onError;
  55812. _this.gammaSpace = gammaSpace;
  55813. _this._noMipmap = noMipmap;
  55814. _this._size = size;
  55815. _this._texture = _this._getFromCache(url, _this._noMipmap);
  55816. if (!_this._texture) {
  55817. if (!scene.useDelayedTextureLoading) {
  55818. _this.loadTexture();
  55819. }
  55820. else {
  55821. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  55822. }
  55823. }
  55824. return _this;
  55825. }
  55826. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  55827. /**
  55828. * Gets wether or not the texture is blocking during loading.
  55829. */
  55830. get: function () {
  55831. return this._isBlocking;
  55832. },
  55833. /**
  55834. * Sets wether or not the texture is blocking during loading.
  55835. */
  55836. set: function (value) {
  55837. this._isBlocking = value;
  55838. },
  55839. enumerable: true,
  55840. configurable: true
  55841. });
  55842. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  55843. /**
  55844. * Gets texture matrix rotation angle around Y axis radians.
  55845. */
  55846. get: function () {
  55847. return this._rotationY;
  55848. },
  55849. /**
  55850. * Sets texture matrix rotation angle around Y axis in radians.
  55851. */
  55852. set: function (value) {
  55853. this._rotationY = value;
  55854. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  55855. },
  55856. enumerable: true,
  55857. configurable: true
  55858. });
  55859. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  55860. get: function () {
  55861. return this._boundingBoxSize;
  55862. },
  55863. /**
  55864. * Gets or sets the size of the bounding box associated with the cube texture
  55865. * When defined, the cubemap will switch to local mode
  55866. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55867. * @example https://www.babylonjs-playground.com/#RNASML
  55868. */
  55869. set: function (value) {
  55870. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55871. return;
  55872. }
  55873. this._boundingBoxSize = value;
  55874. var scene = this.getScene();
  55875. if (scene) {
  55876. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  55877. }
  55878. },
  55879. enumerable: true,
  55880. configurable: true
  55881. });
  55882. /**
  55883. * Get the current class name of the texture useful for serialization or dynamic coding.
  55884. * @returns "HDRCubeTexture"
  55885. */
  55886. HDRCubeTexture.prototype.getClassName = function () {
  55887. return "HDRCubeTexture";
  55888. };
  55889. /**
  55890. * Occurs when the file is raw .hdr file.
  55891. */
  55892. HDRCubeTexture.prototype.loadTexture = function () {
  55893. var _this = this;
  55894. var callback = function (buffer) {
  55895. _this.lodGenerationOffset = 0.0;
  55896. _this.lodGenerationScale = 0.8;
  55897. var scene = _this.getScene();
  55898. if (!scene) {
  55899. return null;
  55900. }
  55901. // Extract the raw linear data.
  55902. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  55903. // Generate harmonics if needed.
  55904. if (_this._generateHarmonics) {
  55905. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  55906. _this.sphericalPolynomial = sphericalPolynomial;
  55907. }
  55908. var results = [];
  55909. var byteArray = null;
  55910. // Push each faces.
  55911. for (var j = 0; j < 6; j++) {
  55912. // Create uintarray fallback.
  55913. if (!scene.getEngine().getCaps().textureFloat) {
  55914. // 3 channels of 1 bytes per pixel in bytes.
  55915. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  55916. byteArray = new Uint8Array(byteBuffer);
  55917. }
  55918. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  55919. // If special cases.
  55920. if (_this.gammaSpace || byteArray) {
  55921. for (var i = 0; i < _this._size * _this._size; i++) {
  55922. // Put in gamma space if requested.
  55923. if (_this.gammaSpace) {
  55924. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55925. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55926. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55927. }
  55928. // Convert to int texture for fallback.
  55929. if (byteArray) {
  55930. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  55931. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  55932. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  55933. // May use luminance instead if the result is not accurate.
  55934. var max = Math.max(Math.max(r, g), b);
  55935. if (max > 255) {
  55936. var scale = 255 / max;
  55937. r *= scale;
  55938. g *= scale;
  55939. b *= scale;
  55940. }
  55941. byteArray[(i * 3) + 0] = r;
  55942. byteArray[(i * 3) + 1] = g;
  55943. byteArray[(i * 3) + 2] = b;
  55944. }
  55945. }
  55946. }
  55947. if (byteArray) {
  55948. results.push(byteArray);
  55949. }
  55950. else {
  55951. results.push(dataFace);
  55952. }
  55953. }
  55954. return results;
  55955. };
  55956. var scene = this.getScene();
  55957. if (scene) {
  55958. 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);
  55959. }
  55960. };
  55961. HDRCubeTexture.prototype.clone = function () {
  55962. var scene = this.getScene();
  55963. if (!scene) {
  55964. return this;
  55965. }
  55966. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  55967. // Base texture
  55968. newTexture.level = this.level;
  55969. newTexture.wrapU = this.wrapU;
  55970. newTexture.wrapV = this.wrapV;
  55971. newTexture.coordinatesIndex = this.coordinatesIndex;
  55972. newTexture.coordinatesMode = this.coordinatesMode;
  55973. return newTexture;
  55974. };
  55975. // Methods
  55976. HDRCubeTexture.prototype.delayLoad = function () {
  55977. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  55978. return;
  55979. }
  55980. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  55981. this._texture = this._getFromCache(this.url, this._noMipmap);
  55982. if (!this._texture) {
  55983. this.loadTexture();
  55984. }
  55985. };
  55986. /**
  55987. * Get the texture reflection matrix used to rotate/transform the reflection.
  55988. * @returns the reflection matrix
  55989. */
  55990. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  55991. return this._textureMatrix;
  55992. };
  55993. /**
  55994. * Set the texture reflection matrix used to rotate/transform the reflection.
  55995. * @param value Define the reflection matrix to set
  55996. */
  55997. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55998. var _this = this;
  55999. this._textureMatrix = value;
  56000. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56001. return;
  56002. }
  56003. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56004. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56005. }
  56006. };
  56007. /**
  56008. * Parses a JSON representation of an HDR Texture in order to create the texture
  56009. * @param parsedTexture Define the JSON representation
  56010. * @param scene Define the scene the texture should be created in
  56011. * @param rootUrl Define the root url in case we need to load relative dependencies
  56012. * @returns the newly created texture after parsing
  56013. */
  56014. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56015. var texture = null;
  56016. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56017. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  56018. texture.name = parsedTexture.name;
  56019. texture.hasAlpha = parsedTexture.hasAlpha;
  56020. texture.level = parsedTexture.level;
  56021. texture.coordinatesMode = parsedTexture.coordinatesMode;
  56022. texture.isBlocking = parsedTexture.isBlocking;
  56023. }
  56024. if (texture) {
  56025. if (parsedTexture.boundingBoxPosition) {
  56026. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56027. }
  56028. if (parsedTexture.boundingBoxSize) {
  56029. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56030. }
  56031. if (parsedTexture.rotationY) {
  56032. texture.rotationY = parsedTexture.rotationY;
  56033. }
  56034. }
  56035. return texture;
  56036. };
  56037. HDRCubeTexture.prototype.serialize = function () {
  56038. if (!this.name) {
  56039. return null;
  56040. }
  56041. var serializationObject = {};
  56042. serializationObject.name = this.name;
  56043. serializationObject.hasAlpha = this.hasAlpha;
  56044. serializationObject.isCube = true;
  56045. serializationObject.level = this.level;
  56046. serializationObject.size = this._size;
  56047. serializationObject.coordinatesMode = this.coordinatesMode;
  56048. serializationObject.useInGammaSpace = this.gammaSpace;
  56049. serializationObject.generateHarmonics = this._generateHarmonics;
  56050. serializationObject.customType = "BABYLON.HDRCubeTexture";
  56051. serializationObject.noMipmap = this._noMipmap;
  56052. serializationObject.isBlocking = this._isBlocking;
  56053. serializationObject.rotationY = this._rotationY;
  56054. return serializationObject;
  56055. };
  56056. HDRCubeTexture._facesMapping = [
  56057. "right",
  56058. "left",
  56059. "up",
  56060. "down",
  56061. "front",
  56062. "back"
  56063. ];
  56064. return HDRCubeTexture;
  56065. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  56066. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  56067. /***/ }),
  56068. /***/ "./Materials/Textures/index.ts":
  56069. /*!*************************************!*\
  56070. !*** ./Materials/Textures/index.ts ***!
  56071. \*************************************/
  56072. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, MultiRenderTarget, ProceduralTexture, ProceduralTextureSceneComponent, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture */
  56073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56074. "use strict";
  56075. __webpack_require__.r(__webpack_exports__);
  56076. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  56077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  56078. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  56079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  56080. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  56082. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  56083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  56084. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  56085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  56086. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  56087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  56088. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  56089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  56090. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  56091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  56092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  56093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  56094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  56095. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  56096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  56097. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  56098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  56099. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  56100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  56101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  56102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  56103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  56104. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  56105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  56106. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  56107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  56108. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  56109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  56110. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  56111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  56112. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  56114. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  56115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  56116. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  56117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  56118. /***/ }),
  56119. /***/ "./Materials/Textures/internalTexture.ts":
  56120. /*!***********************************************!*\
  56121. !*** ./Materials/Textures/internalTexture.ts ***!
  56122. \***********************************************/
  56123. /*! exports provided: InternalTexture */
  56124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56125. "use strict";
  56126. __webpack_require__.r(__webpack_exports__);
  56127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  56128. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56129. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  56130. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56131. /**
  56132. * Class used to store data associated with WebGL texture data for the engine
  56133. * This class should not be used directly
  56134. */
  56135. var InternalTexture = /** @class */ (function () {
  56136. /**
  56137. * Creates a new InternalTexture
  56138. * @param engine defines the engine to use
  56139. * @param dataSource defines the type of data that will be used
  56140. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56141. */
  56142. function InternalTexture(engine, dataSource, delayAllocation) {
  56143. if (delayAllocation === void 0) { delayAllocation = false; }
  56144. /**
  56145. * Observable called when the texture is loaded
  56146. */
  56147. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  56148. /**
  56149. * Gets or set the previous tracker in the list
  56150. */
  56151. this.previous = null;
  56152. /**
  56153. * Gets or set the next tracker in the list
  56154. */
  56155. this.next = null;
  56156. // Private
  56157. /** @hidden */
  56158. this._invertVScale = false;
  56159. /** @hidden */
  56160. this._initialSlot = -1;
  56161. /** @hidden */
  56162. this._designatedSlot = -1;
  56163. /** @hidden */
  56164. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  56165. /** @hidden */
  56166. this._comparisonFunction = 0;
  56167. /** @hidden */
  56168. this._sphericalPolynomial = null;
  56169. /** @hidden */
  56170. this._lodGenerationScale = 0;
  56171. /** @hidden */
  56172. this._lodGenerationOffset = 0;
  56173. /** @hidden */
  56174. this._isRGBD = false;
  56175. /** @hidden */
  56176. this._references = 1;
  56177. this._engine = engine;
  56178. this._dataSource = dataSource;
  56179. if (!delayAllocation) {
  56180. this._webGLTexture = engine._createTexture();
  56181. }
  56182. }
  56183. /**
  56184. * Gets the Engine the texture belongs to.
  56185. * @returns The babylon engine
  56186. */
  56187. InternalTexture.prototype.getEngine = function () {
  56188. return this._engine;
  56189. };
  56190. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  56191. /**
  56192. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  56193. */
  56194. get: function () {
  56195. return this._dataSource;
  56196. },
  56197. enumerable: true,
  56198. configurable: true
  56199. });
  56200. /**
  56201. * Increments the number of references (ie. the number of Texture that point to it)
  56202. */
  56203. InternalTexture.prototype.incrementReferences = function () {
  56204. this._references++;
  56205. };
  56206. /**
  56207. * Change the size of the texture (not the size of the content)
  56208. * @param width defines the new width
  56209. * @param height defines the new height
  56210. * @param depth defines the new depth (1 by default)
  56211. */
  56212. InternalTexture.prototype.updateSize = function (width, height, depth) {
  56213. if (depth === void 0) { depth = 1; }
  56214. this.width = width;
  56215. this.height = height;
  56216. this.depth = depth;
  56217. this.baseWidth = width;
  56218. this.baseHeight = height;
  56219. this.baseDepth = depth;
  56220. this._size = width * height * depth;
  56221. };
  56222. /** @hidden */
  56223. InternalTexture.prototype._rebuild = function () {
  56224. var _this = this;
  56225. var proxy;
  56226. this.isReady = false;
  56227. this._cachedCoordinatesMode = null;
  56228. this._cachedWrapU = null;
  56229. this._cachedWrapV = null;
  56230. this._cachedAnisotropicFilteringLevel = null;
  56231. switch (this._dataSource) {
  56232. case InternalTexture.DATASOURCE_TEMP:
  56233. return;
  56234. case InternalTexture.DATASOURCE_URL:
  56235. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  56236. proxy._swapAndDie(_this);
  56237. _this.isReady = true;
  56238. }, null, this._buffer, undefined, this.format);
  56239. return;
  56240. case InternalTexture.DATASOURCE_RAW:
  56241. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56242. proxy._swapAndDie(this);
  56243. this.isReady = true;
  56244. return;
  56245. case InternalTexture.DATASOURCE_RAW3D:
  56246. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56247. proxy._swapAndDie(this);
  56248. this.isReady = true;
  56249. return;
  56250. case InternalTexture.DATASOURCE_DYNAMIC:
  56251. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  56252. proxy._swapAndDie(this);
  56253. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  56254. // The engine will make sure to update content so no need to flag it as isReady = true
  56255. return;
  56256. case InternalTexture.DATASOURCE_RENDERTARGET:
  56257. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  56258. options.generateDepthBuffer = this._generateDepthBuffer;
  56259. options.generateMipMaps = this.generateMipMaps;
  56260. options.generateStencilBuffer = this._generateStencilBuffer;
  56261. options.samplingMode = this.samplingMode;
  56262. options.type = this.type;
  56263. if (this.isCube) {
  56264. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  56265. }
  56266. else {
  56267. var size = {
  56268. width: this.width,
  56269. height: this.height
  56270. };
  56271. proxy = this._engine.createRenderTargetTexture(size, options);
  56272. }
  56273. proxy._swapAndDie(this);
  56274. this.isReady = true;
  56275. return;
  56276. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  56277. var depthTextureOptions = {
  56278. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  56279. comparisonFunction: this._comparisonFunction,
  56280. generateStencil: this._generateStencilBuffer,
  56281. isCube: this.isCube
  56282. };
  56283. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  56284. proxy._swapAndDie(this);
  56285. this.isReady = true;
  56286. return;
  56287. case InternalTexture.DATASOURCE_CUBE:
  56288. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  56289. proxy._swapAndDie(_this);
  56290. _this.isReady = true;
  56291. }, null, this.format, this._extension);
  56292. return;
  56293. case InternalTexture.DATASOURCE_CUBERAW:
  56294. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56295. proxy._swapAndDie(this);
  56296. this.isReady = true;
  56297. return;
  56298. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  56299. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56300. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  56301. proxy._swapAndDie(_this);
  56302. _this.isReady = true;
  56303. });
  56304. return;
  56305. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  56306. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  56307. if (proxy) {
  56308. proxy._swapAndDie(_this);
  56309. }
  56310. _this.isReady = true;
  56311. }, null, this.format, this._extension);
  56312. proxy._sphericalPolynomial = this._sphericalPolynomial;
  56313. return;
  56314. }
  56315. };
  56316. /** @hidden */
  56317. InternalTexture.prototype._swapAndDie = function (target) {
  56318. target._webGLTexture = this._webGLTexture;
  56319. if (this._framebuffer) {
  56320. target._framebuffer = this._framebuffer;
  56321. }
  56322. if (this._depthStencilBuffer) {
  56323. target._depthStencilBuffer = this._depthStencilBuffer;
  56324. }
  56325. if (this._lodTextureHigh) {
  56326. if (target._lodTextureHigh) {
  56327. target._lodTextureHigh.dispose();
  56328. }
  56329. target._lodTextureHigh = this._lodTextureHigh;
  56330. }
  56331. if (this._lodTextureMid) {
  56332. if (target._lodTextureMid) {
  56333. target._lodTextureMid.dispose();
  56334. }
  56335. target._lodTextureMid = this._lodTextureMid;
  56336. }
  56337. if (this._lodTextureLow) {
  56338. if (target._lodTextureLow) {
  56339. target._lodTextureLow.dispose();
  56340. }
  56341. target._lodTextureLow = this._lodTextureLow;
  56342. }
  56343. var cache = this._engine.getLoadedTexturesCache();
  56344. var index = cache.indexOf(this);
  56345. if (index !== -1) {
  56346. cache.splice(index, 1);
  56347. }
  56348. };
  56349. /**
  56350. * Dispose the current allocated resources
  56351. */
  56352. InternalTexture.prototype.dispose = function () {
  56353. if (!this._webGLTexture) {
  56354. return;
  56355. }
  56356. this._references--;
  56357. if (this._references === 0) {
  56358. this._engine._releaseTexture(this);
  56359. this._webGLTexture = null;
  56360. this.previous = null;
  56361. this.next = null;
  56362. }
  56363. };
  56364. /** hidden */
  56365. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56366. throw "environmentTextureTools needs to be imported before rebuilding RGBD textures.";
  56367. };
  56368. /**
  56369. * The source of the texture data is unknown
  56370. */
  56371. InternalTexture.DATASOURCE_UNKNOWN = 0;
  56372. /**
  56373. * Texture data comes from an URL
  56374. */
  56375. InternalTexture.DATASOURCE_URL = 1;
  56376. /**
  56377. * Texture data is only used for temporary storage
  56378. */
  56379. InternalTexture.DATASOURCE_TEMP = 2;
  56380. /**
  56381. * Texture data comes from raw data (ArrayBuffer)
  56382. */
  56383. InternalTexture.DATASOURCE_RAW = 3;
  56384. /**
  56385. * Texture content is dynamic (video or dynamic texture)
  56386. */
  56387. InternalTexture.DATASOURCE_DYNAMIC = 4;
  56388. /**
  56389. * Texture content is generated by rendering to it
  56390. */
  56391. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  56392. /**
  56393. * Texture content is part of a multi render target process
  56394. */
  56395. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  56396. /**
  56397. * Texture data comes from a cube data file
  56398. */
  56399. InternalTexture.DATASOURCE_CUBE = 7;
  56400. /**
  56401. * Texture data comes from a raw cube data
  56402. */
  56403. InternalTexture.DATASOURCE_CUBERAW = 8;
  56404. /**
  56405. * Texture data come from a prefiltered cube data file
  56406. */
  56407. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  56408. /**
  56409. * Texture content is raw 3D data
  56410. */
  56411. InternalTexture.DATASOURCE_RAW3D = 10;
  56412. /**
  56413. * Texture content is a depth texture
  56414. */
  56415. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  56416. /**
  56417. * Texture data comes from a raw cube data encoded with RGBD
  56418. */
  56419. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  56420. return InternalTexture;
  56421. }());
  56422. /***/ }),
  56423. /***/ "./Materials/Textures/internalTextureTracker.ts":
  56424. /*!******************************************************!*\
  56425. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  56426. \******************************************************/
  56427. /*! exports provided: DummyInternalTextureTracker */
  56428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56429. "use strict";
  56430. __webpack_require__.r(__webpack_exports__);
  56431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  56432. /**
  56433. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  56434. */
  56435. var DummyInternalTextureTracker = /** @class */ (function () {
  56436. function DummyInternalTextureTracker() {
  56437. /**
  56438. * Gets or set the previous tracker in the list
  56439. */
  56440. this.previous = null;
  56441. /**
  56442. * Gets or set the next tracker in the list
  56443. */
  56444. this.next = null;
  56445. }
  56446. return DummyInternalTextureTracker;
  56447. }());
  56448. /***/ }),
  56449. /***/ "./Materials/Textures/mirrorTexture.ts":
  56450. /*!*********************************************!*\
  56451. !*** ./Materials/Textures/mirrorTexture.ts ***!
  56452. \*********************************************/
  56453. /*! exports provided: MirrorTexture */
  56454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56455. "use strict";
  56456. __webpack_require__.r(__webpack_exports__);
  56457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  56458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56459. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56460. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56461. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56462. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  56463. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56464. /**
  56465. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56466. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56467. * You can then easily use it as a reflectionTexture on a flat surface.
  56468. * In case the surface is not a plane, please consider relying on reflection probes.
  56469. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56470. */
  56471. var MirrorTexture = /** @class */ (function (_super) {
  56472. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  56473. /**
  56474. * Instantiates a Mirror Texture.
  56475. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56476. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56477. * You can then easily use it as a reflectionTexture on a flat surface.
  56478. * In case the surface is not a plane, please consider relying on reflection probes.
  56479. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56480. * @param name
  56481. * @param size
  56482. * @param scene
  56483. * @param generateMipMaps
  56484. * @param type
  56485. * @param samplingMode
  56486. * @param generateDepthBuffer
  56487. */
  56488. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  56489. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56490. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  56491. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56492. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  56493. _this.scene = scene;
  56494. /**
  56495. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  56496. * 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.
  56497. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56498. */
  56499. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56500. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56501. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56502. _this._adaptiveBlurKernel = 0;
  56503. _this._blurKernelX = 0;
  56504. _this._blurKernelY = 0;
  56505. _this._blurRatio = 1.0;
  56506. _this.ignoreCameraViewport = true;
  56507. _this._updateGammaSpace();
  56508. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  56509. _this._updateGammaSpace;
  56510. });
  56511. _this.onBeforeRenderObservable.add(function () {
  56512. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  56513. _this._savedViewMatrix = scene.getViewMatrix();
  56514. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  56515. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  56516. scene.clipPlane = _this.mirrorPlane;
  56517. scene.getEngine().cullBackFaces = false;
  56518. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  56519. });
  56520. _this.onAfterRenderObservable.add(function () {
  56521. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  56522. scene.getEngine().cullBackFaces = true;
  56523. scene._mirroredCameraPosition = null;
  56524. delete scene.clipPlane;
  56525. });
  56526. return _this;
  56527. }
  56528. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  56529. get: function () {
  56530. return this._blurRatio;
  56531. },
  56532. /**
  56533. * Define the blur ratio used to blur the reflection if needed.
  56534. */
  56535. set: function (value) {
  56536. if (this._blurRatio === value) {
  56537. return;
  56538. }
  56539. this._blurRatio = value;
  56540. this._preparePostProcesses();
  56541. },
  56542. enumerable: true,
  56543. configurable: true
  56544. });
  56545. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  56546. /**
  56547. * Define the adaptive blur kernel used to blur the reflection if needed.
  56548. * This will autocompute the closest best match for the `blurKernel`
  56549. */
  56550. set: function (value) {
  56551. this._adaptiveBlurKernel = value;
  56552. this._autoComputeBlurKernel();
  56553. },
  56554. enumerable: true,
  56555. configurable: true
  56556. });
  56557. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56558. /**
  56559. * Define the blur kernel used to blur the reflection if needed.
  56560. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56561. */
  56562. set: function (value) {
  56563. this.blurKernelX = value;
  56564. this.blurKernelY = value;
  56565. },
  56566. enumerable: true,
  56567. configurable: true
  56568. });
  56569. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56570. get: function () {
  56571. return this._blurKernelX;
  56572. },
  56573. /**
  56574. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56575. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56576. */
  56577. set: function (value) {
  56578. if (this._blurKernelX === value) {
  56579. return;
  56580. }
  56581. this._blurKernelX = value;
  56582. this._preparePostProcesses();
  56583. },
  56584. enumerable: true,
  56585. configurable: true
  56586. });
  56587. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56588. get: function () {
  56589. return this._blurKernelY;
  56590. },
  56591. /**
  56592. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56594. */
  56595. set: function (value) {
  56596. if (this._blurKernelY === value) {
  56597. return;
  56598. }
  56599. this._blurKernelY = value;
  56600. this._preparePostProcesses();
  56601. },
  56602. enumerable: true,
  56603. configurable: true
  56604. });
  56605. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56606. var engine = this.getScene().getEngine();
  56607. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56608. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56609. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56610. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56611. };
  56612. MirrorTexture.prototype._onRatioRescale = function () {
  56613. if (this._sizeRatio) {
  56614. this.resize(this._initialSizeParameter);
  56615. if (!this._adaptiveBlurKernel) {
  56616. this._preparePostProcesses();
  56617. }
  56618. }
  56619. if (this._adaptiveBlurKernel) {
  56620. this._autoComputeBlurKernel();
  56621. }
  56622. };
  56623. MirrorTexture.prototype._updateGammaSpace = function () {
  56624. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56625. };
  56626. MirrorTexture.prototype._preparePostProcesses = function () {
  56627. this.clearPostProcesses(true);
  56628. if (this._blurKernelX && this._blurKernelY) {
  56629. var engine = this.getScene().getEngine();
  56630. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56631. 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);
  56632. this._blurX.autoClear = false;
  56633. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56634. this._blurX.inputTexture = this._texture;
  56635. }
  56636. else {
  56637. this._blurX.alwaysForcePOT = true;
  56638. }
  56639. 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);
  56640. this._blurY.autoClear = false;
  56641. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56642. this.addPostProcess(this._blurX);
  56643. this.addPostProcess(this._blurY);
  56644. }
  56645. else {
  56646. if (this._blurY) {
  56647. this.removePostProcess(this._blurY);
  56648. this._blurY.dispose();
  56649. this._blurY = null;
  56650. }
  56651. if (this._blurX) {
  56652. this.removePostProcess(this._blurX);
  56653. this._blurX.dispose();
  56654. this._blurX = null;
  56655. }
  56656. }
  56657. };
  56658. /**
  56659. * Clone the mirror texture.
  56660. * @returns the cloned texture
  56661. */
  56662. MirrorTexture.prototype.clone = function () {
  56663. var scene = this.getScene();
  56664. if (!scene) {
  56665. return this;
  56666. }
  56667. var textureSize = this.getSize();
  56668. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56669. // Base texture
  56670. newTexture.hasAlpha = this.hasAlpha;
  56671. newTexture.level = this.level;
  56672. // Mirror Texture
  56673. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56674. if (this.renderList) {
  56675. newTexture.renderList = this.renderList.slice(0);
  56676. }
  56677. return newTexture;
  56678. };
  56679. /**
  56680. * Serialize the texture to a JSON representation you could use in Parse later on
  56681. * @returns the serialized JSON representation
  56682. */
  56683. MirrorTexture.prototype.serialize = function () {
  56684. if (!this.name) {
  56685. return null;
  56686. }
  56687. var serializationObject = _super.prototype.serialize.call(this);
  56688. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56689. return serializationObject;
  56690. };
  56691. /**
  56692. * Dispose the texture and release its associated resources.
  56693. */
  56694. MirrorTexture.prototype.dispose = function () {
  56695. _super.prototype.dispose.call(this);
  56696. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56697. };
  56698. return MirrorTexture;
  56699. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56700. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56701. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56702. };
  56703. /***/ }),
  56704. /***/ "./Materials/Textures/multiRenderTarget.ts":
  56705. /*!*************************************************!*\
  56706. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  56707. \*************************************************/
  56708. /*! exports provided: MultiRenderTarget */
  56709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56710. "use strict";
  56711. __webpack_require__.r(__webpack_exports__);
  56712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  56713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56714. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56715. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56716. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56717. /**
  56718. * A multi render target, like a render target provides the ability to render to a texture.
  56719. * Unlike the render target, it can render to several draw buffers in one draw.
  56720. * This is specially interesting in deferred rendering or for any effects requiring more than
  56721. * just one color from a single pass.
  56722. */
  56723. var MultiRenderTarget = /** @class */ (function (_super) {
  56724. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  56725. /**
  56726. * Instantiate a new multi render target texture.
  56727. * A multi render target, like a render target provides the ability to render to a texture.
  56728. * Unlike the render target, it can render to several draw buffers in one draw.
  56729. * This is specially interesting in deferred rendering or for any effects requiring more than
  56730. * just one color from a single pass.
  56731. * @param name Define the name of the texture
  56732. * @param size Define the size of the buffers to render to
  56733. * @param count Define the number of target we are rendering into
  56734. * @param scene Define the scene the texture belongs to
  56735. * @param options Define the options used to create the multi render target
  56736. */
  56737. function MultiRenderTarget(name, size, count, scene, options) {
  56738. var _this = this;
  56739. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  56740. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  56741. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  56742. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  56743. _this._engine = scene.getEngine();
  56744. if (!_this.isSupported) {
  56745. _this.dispose();
  56746. return;
  56747. }
  56748. var types = [];
  56749. var samplingModes = [];
  56750. for (var i = 0; i < count; i++) {
  56751. if (options && options.types && options.types[i] !== undefined) {
  56752. types.push(options.types[i]);
  56753. }
  56754. else {
  56755. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  56756. }
  56757. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  56758. samplingModes.push(options.samplingModes[i]);
  56759. }
  56760. else {
  56761. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  56762. }
  56763. }
  56764. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  56765. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  56766. _this._size = size;
  56767. _this._multiRenderTargetOptions = {
  56768. samplingModes: samplingModes,
  56769. generateMipMaps: generateMipMaps,
  56770. generateDepthBuffer: generateDepthBuffer,
  56771. generateStencilBuffer: generateStencilBuffer,
  56772. generateDepthTexture: generateDepthTexture,
  56773. types: types,
  56774. textureCount: count
  56775. };
  56776. _this._createInternalTextures();
  56777. _this._createTextures();
  56778. return _this;
  56779. }
  56780. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  56781. /**
  56782. * Get if draw buffers are currently supported by the used hardware and browser.
  56783. */
  56784. get: function () {
  56785. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  56786. },
  56787. enumerable: true,
  56788. configurable: true
  56789. });
  56790. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  56791. /**
  56792. * Get the list of textures generated by the multi render target.
  56793. */
  56794. get: function () {
  56795. return this._textures;
  56796. },
  56797. enumerable: true,
  56798. configurable: true
  56799. });
  56800. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  56801. /**
  56802. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  56803. */
  56804. get: function () {
  56805. return this._textures[this._textures.length - 1];
  56806. },
  56807. enumerable: true,
  56808. configurable: true
  56809. });
  56810. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  56811. /**
  56812. * Set the wrapping mode on U of all the textures we are rendering to.
  56813. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56814. */
  56815. set: function (wrap) {
  56816. if (this._textures) {
  56817. for (var i = 0; i < this._textures.length; i++) {
  56818. this._textures[i].wrapU = wrap;
  56819. }
  56820. }
  56821. },
  56822. enumerable: true,
  56823. configurable: true
  56824. });
  56825. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  56826. /**
  56827. * Set the wrapping mode on V of all the textures we are rendering to.
  56828. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56829. */
  56830. set: function (wrap) {
  56831. if (this._textures) {
  56832. for (var i = 0; i < this._textures.length; i++) {
  56833. this._textures[i].wrapV = wrap;
  56834. }
  56835. }
  56836. },
  56837. enumerable: true,
  56838. configurable: true
  56839. });
  56840. /** @hidden */
  56841. MultiRenderTarget.prototype._rebuild = function () {
  56842. this.releaseInternalTextures();
  56843. this._createInternalTextures();
  56844. for (var i = 0; i < this._internalTextures.length; i++) {
  56845. var texture = this._textures[i];
  56846. texture._texture = this._internalTextures[i];
  56847. }
  56848. // Keeps references to frame buffer and stencil/depth buffer
  56849. this._texture = this._internalTextures[0];
  56850. };
  56851. MultiRenderTarget.prototype._createInternalTextures = function () {
  56852. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  56853. };
  56854. MultiRenderTarget.prototype._createTextures = function () {
  56855. this._textures = [];
  56856. for (var i = 0; i < this._internalTextures.length; i++) {
  56857. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  56858. texture._texture = this._internalTextures[i];
  56859. this._textures.push(texture);
  56860. }
  56861. // Keeps references to frame buffer and stencil/depth buffer
  56862. this._texture = this._internalTextures[0];
  56863. };
  56864. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  56865. /**
  56866. * Define the number of samples used if MSAA is enabled.
  56867. */
  56868. get: function () {
  56869. return this._samples;
  56870. },
  56871. set: function (value) {
  56872. if (this._samples === value) {
  56873. return;
  56874. }
  56875. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  56876. },
  56877. enumerable: true,
  56878. configurable: true
  56879. });
  56880. /**
  56881. * Resize all the textures in the multi render target.
  56882. * Be carrefull as it will recreate all the data in the new texture.
  56883. * @param size Define the new size
  56884. */
  56885. MultiRenderTarget.prototype.resize = function (size) {
  56886. this.releaseInternalTextures();
  56887. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  56888. this._createInternalTextures();
  56889. };
  56890. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  56891. var _this = this;
  56892. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  56893. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  56894. });
  56895. };
  56896. /**
  56897. * Dispose the render targets and their associated resources
  56898. */
  56899. MultiRenderTarget.prototype.dispose = function () {
  56900. this.releaseInternalTextures();
  56901. _super.prototype.dispose.call(this);
  56902. };
  56903. /**
  56904. * Release all the underlying texture used as draw buffers.
  56905. */
  56906. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  56907. if (!this._internalTextures) {
  56908. return;
  56909. }
  56910. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  56911. if (this._internalTextures[i] !== undefined) {
  56912. this._internalTextures[i].dispose();
  56913. this._internalTextures.splice(i, 1);
  56914. }
  56915. }
  56916. };
  56917. return MultiRenderTarget;
  56918. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56919. /***/ }),
  56920. /***/ "./Materials/Textures/rawCubeTexture.ts":
  56921. /*!**********************************************!*\
  56922. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  56923. \**********************************************/
  56924. /*! exports provided: RawCubeTexture */
  56925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56926. "use strict";
  56927. __webpack_require__.r(__webpack_exports__);
  56928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  56929. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56930. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56931. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56932. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56933. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56934. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56935. /**
  56936. * Raw cube texture where the raw buffers are passed in
  56937. */
  56938. var RawCubeTexture = /** @class */ (function (_super) {
  56939. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  56940. /**
  56941. * Creates a cube texture where the raw buffers are passed in.
  56942. * @param scene defines the scene the texture is attached to
  56943. * @param data defines the array of data to use to create each face
  56944. * @param size defines the size of the textures
  56945. * @param format defines the format of the data
  56946. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56947. * @param generateMipMaps defines if the engine should generate the mip levels
  56948. * @param invertY defines if data must be stored with Y axis inverted
  56949. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56950. * @param compression defines the compression used (null by default)
  56951. */
  56952. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  56953. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  56954. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56955. if (generateMipMaps === void 0) { generateMipMaps = false; }
  56956. if (invertY === void 0) { invertY = false; }
  56957. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56958. if (compression === void 0) { compression = null; }
  56959. var _this = _super.call(this, "", scene) || this;
  56960. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  56961. return _this;
  56962. }
  56963. /**
  56964. * Updates the raw cube texture.
  56965. * @param data defines the data to store
  56966. * @param format defines the data format
  56967. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56968. * @param invertY defines if data must be stored with Y axis inverted
  56969. * @param compression defines the compression used (null by default)
  56970. * @param level defines which level of the texture to update
  56971. */
  56972. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  56973. if (compression === void 0) { compression = null; }
  56974. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  56975. };
  56976. /**
  56977. * Updates a raw cube texture with RGBD encoded data.
  56978. * @param data defines the array of data [mipmap][face] to use to create each face
  56979. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56980. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56981. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56982. * @returns a promsie that resolves when the operation is complete
  56983. */
  56984. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  56985. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  56986. if (lodScale === void 0) { lodScale = 0.8; }
  56987. if (lodOffset === void 0) { lodOffset = 0; }
  56988. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  56989. };
  56990. /**
  56991. * Clones the raw cube texture.
  56992. * @return a new cube texture
  56993. */
  56994. RawCubeTexture.prototype.clone = function () {
  56995. var _this = this;
  56996. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  56997. var scene = _this.getScene();
  56998. var internalTexture = _this._texture;
  56999. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  57000. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  57001. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  57002. }
  57003. return texture;
  57004. }, this);
  57005. };
  57006. /** @hidden */
  57007. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57008. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  57009. internalTexture._bufferViewArrayArray = data;
  57010. internalTexture._lodGenerationScale = lodScale;
  57011. internalTexture._lodGenerationOffset = lodOffset;
  57012. internalTexture._sphericalPolynomial = sphericalPolynomial;
  57013. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  57014. internalTexture.isReady = true;
  57015. });
  57016. };
  57017. return RawCubeTexture;
  57018. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  57019. /***/ }),
  57020. /***/ "./Materials/Textures/rawTexture.ts":
  57021. /*!******************************************!*\
  57022. !*** ./Materials/Textures/rawTexture.ts ***!
  57023. \******************************************/
  57024. /*! exports provided: RawTexture */
  57025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57026. "use strict";
  57027. __webpack_require__.r(__webpack_exports__);
  57028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  57029. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57030. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57031. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57032. /**
  57033. * Raw texture can help creating a texture directly from an array of data.
  57034. * This can be super useful if you either get the data from an uncompressed source or
  57035. * if you wish to create your texture pixel by pixel.
  57036. */
  57037. var RawTexture = /** @class */ (function (_super) {
  57038. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  57039. /**
  57040. * Instantiates a new RawTexture.
  57041. * Raw texture can help creating a texture directly from an array of data.
  57042. * This can be super useful if you either get the data from an uncompressed source or
  57043. * if you wish to create your texture pixel by pixel.
  57044. * @param data define the array of data to use to create the texture
  57045. * @param width define the width of the texture
  57046. * @param height define the height of the texture
  57047. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57048. * @param scene define the scene the texture belongs to
  57049. * @param generateMipMaps define whether mip maps should be generated or not
  57050. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57051. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57052. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57053. */
  57054. function RawTexture(data, width, height,
  57055. /**
  57056. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57057. */
  57058. format, scene, generateMipMaps, invertY, samplingMode, type) {
  57059. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57060. if (invertY === void 0) { invertY = false; }
  57061. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57062. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57063. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57064. _this.format = format;
  57065. _this._engine = scene.getEngine();
  57066. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  57067. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57068. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57069. return _this;
  57070. }
  57071. /**
  57072. * Updates the texture underlying data.
  57073. * @param data Define the new data of the texture
  57074. */
  57075. RawTexture.prototype.update = function (data) {
  57076. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57077. };
  57078. /**
  57079. * Creates a luminance texture from some data.
  57080. * @param data Define the texture data
  57081. * @param width Define the width of the texture
  57082. * @param height Define the height of the texture
  57083. * @param scene Define the scene the texture belongs to
  57084. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57085. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57086. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57087. * @returns the luminance texture
  57088. */
  57089. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57090. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57091. if (invertY === void 0) { invertY = false; }
  57092. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57093. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  57094. };
  57095. /**
  57096. * Creates a luminance alpha texture from some data.
  57097. * @param data Define the texture data
  57098. * @param width Define the width of the texture
  57099. * @param height Define the height of the texture
  57100. * @param scene Define the scene the texture belongs to
  57101. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57102. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57103. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57104. * @returns the luminance alpha texture
  57105. */
  57106. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57107. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57108. if (invertY === void 0) { invertY = false; }
  57109. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57110. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57111. };
  57112. /**
  57113. * Creates an alpha texture from some data.
  57114. * @param data Define the texture data
  57115. * @param width Define the width of the texture
  57116. * @param height Define the height of the texture
  57117. * @param scene Define the scene the texture belongs to
  57118. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57119. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57120. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57121. * @returns the alpha texture
  57122. */
  57123. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57124. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57125. if (invertY === void 0) { invertY = false; }
  57126. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57127. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57128. };
  57129. /**
  57130. * Creates a RGB texture from some data.
  57131. * @param data Define the texture data
  57132. * @param width Define the width of the texture
  57133. * @param height Define the height of the texture
  57134. * @param scene Define the scene the texture belongs to
  57135. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57136. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57137. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57138. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57139. * @returns the RGB alpha texture
  57140. */
  57141. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57142. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57143. if (invertY === void 0) { invertY = false; }
  57144. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57145. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57146. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  57147. };
  57148. /**
  57149. * Creates a RGBA texture from some data.
  57150. * @param data Define the texture data
  57151. * @param width Define the width of the texture
  57152. * @param height Define the height of the texture
  57153. * @param scene Define the scene the texture belongs to
  57154. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57155. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57156. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57157. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57158. * @returns the RGBA texture
  57159. */
  57160. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57161. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57162. if (invertY === void 0) { invertY = false; }
  57163. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57164. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57165. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  57166. };
  57167. /**
  57168. * Creates a R texture from some data.
  57169. * @param data Define the texture data
  57170. * @param width Define the width of the texture
  57171. * @param height Define the height of the texture
  57172. * @param scene Define the scene the texture belongs to
  57173. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57174. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57175. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57176. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57177. * @returns the R texture
  57178. */
  57179. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57180. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57181. if (invertY === void 0) { invertY = false; }
  57182. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57183. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  57184. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  57185. };
  57186. return RawTexture;
  57187. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57188. /***/ }),
  57189. /***/ "./Materials/Textures/rawTexture3D.ts":
  57190. /*!********************************************!*\
  57191. !*** ./Materials/Textures/rawTexture3D.ts ***!
  57192. \********************************************/
  57193. /*! exports provided: RawTexture3D */
  57194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57195. "use strict";
  57196. __webpack_require__.r(__webpack_exports__);
  57197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  57198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57199. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57200. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57201. /**
  57202. * Class used to store 3D textures containing user data
  57203. */
  57204. var RawTexture3D = /** @class */ (function (_super) {
  57205. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  57206. /**
  57207. * Create a new RawTexture3D
  57208. * @param data defines the data of the texture
  57209. * @param width defines the width of the texture
  57210. * @param height defines the height of the texture
  57211. * @param depth defines the depth of the texture
  57212. * @param format defines the texture format to use
  57213. * @param scene defines the hosting scene
  57214. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57215. * @param invertY defines if texture must be stored with Y axis inverted
  57216. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57217. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57218. */
  57219. function RawTexture3D(data, width, height, depth,
  57220. /** Gets or sets the texture format to use */
  57221. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  57222. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57223. if (invertY === void 0) { invertY = false; }
  57224. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57225. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57226. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57227. _this.format = format;
  57228. _this._engine = scene.getEngine();
  57229. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  57230. _this.is3D = true;
  57231. return _this;
  57232. }
  57233. /**
  57234. * Update the texture with new data
  57235. * @param data defines the data to store in the texture
  57236. */
  57237. RawTexture3D.prototype.update = function (data) {
  57238. if (!this._texture) {
  57239. return;
  57240. }
  57241. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57242. };
  57243. return RawTexture3D;
  57244. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57245. /***/ }),
  57246. /***/ "./Materials/Textures/refractionTexture.ts":
  57247. /*!*************************************************!*\
  57248. !*** ./Materials/Textures/refractionTexture.ts ***!
  57249. \*************************************************/
  57250. /*! exports provided: RefractionTexture */
  57251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57252. "use strict";
  57253. __webpack_require__.r(__webpack_exports__);
  57254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  57255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57256. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57257. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57258. /**
  57259. * Creates a refraction texture used by refraction channel of the standard material.
  57260. * It is like a mirror but to see through a material.
  57261. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57262. */
  57263. var RefractionTexture = /** @class */ (function (_super) {
  57264. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  57265. /**
  57266. * Creates a refraction texture used by refraction channel of the standard material.
  57267. * It is like a mirror but to see through a material.
  57268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57269. * @param name Define the texture name
  57270. * @param size Define the size of the underlying texture
  57271. * @param scene Define the scene the refraction belongs to
  57272. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57273. */
  57274. function RefractionTexture(name, size, scene, generateMipMaps) {
  57275. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  57276. /**
  57277. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57278. * 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.
  57279. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57280. */
  57281. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57282. /**
  57283. * Define how deep under the surface we should see.
  57284. */
  57285. _this.depth = 2.0;
  57286. _this.onBeforeRenderObservable.add(function () {
  57287. scene.clipPlane = _this.refractionPlane;
  57288. });
  57289. _this.onAfterRenderObservable.add(function () {
  57290. delete scene.clipPlane;
  57291. });
  57292. return _this;
  57293. }
  57294. /**
  57295. * Clone the refraction texture.
  57296. * @returns the cloned texture
  57297. */
  57298. RefractionTexture.prototype.clone = function () {
  57299. var scene = this.getScene();
  57300. if (!scene) {
  57301. return this;
  57302. }
  57303. var textureSize = this.getSize();
  57304. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  57305. // Base texture
  57306. newTexture.hasAlpha = this.hasAlpha;
  57307. newTexture.level = this.level;
  57308. // Refraction Texture
  57309. newTexture.refractionPlane = this.refractionPlane.clone();
  57310. if (this.renderList) {
  57311. newTexture.renderList = this.renderList.slice(0);
  57312. }
  57313. newTexture.depth = this.depth;
  57314. return newTexture;
  57315. };
  57316. /**
  57317. * Serialize the texture to a JSON representation you could use in Parse later on
  57318. * @returns the serialized JSON representation
  57319. */
  57320. RefractionTexture.prototype.serialize = function () {
  57321. if (!this.name) {
  57322. return null;
  57323. }
  57324. var serializationObject = _super.prototype.serialize.call(this);
  57325. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  57326. serializationObject.depth = this.depth;
  57327. return serializationObject;
  57328. };
  57329. return RefractionTexture;
  57330. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57331. /***/ }),
  57332. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  57333. /*!***********************************************************!*\
  57334. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  57335. \***********************************************************/
  57336. /*! exports provided: RenderTargetCreationOptions */
  57337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57338. "use strict";
  57339. __webpack_require__.r(__webpack_exports__);
  57340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  57341. /**
  57342. * Define options used to create a render target texture
  57343. */
  57344. var RenderTargetCreationOptions = /** @class */ (function () {
  57345. function RenderTargetCreationOptions() {
  57346. }
  57347. return RenderTargetCreationOptions;
  57348. }());
  57349. /***/ }),
  57350. /***/ "./Materials/Textures/renderTargetTexture.ts":
  57351. /*!***************************************************!*\
  57352. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  57353. \***************************************************/
  57354. /*! exports provided: RenderTargetTexture */
  57355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57356. "use strict";
  57357. __webpack_require__.r(__webpack_exports__);
  57358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  57359. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57360. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57361. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57362. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57363. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57364. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  57365. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  57366. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57367. /**
  57368. * This Helps creating a texture that will be created from a camera in your scene.
  57369. * It is basically a dynamic texture that could be used to create special effects for instance.
  57370. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  57371. */
  57372. var RenderTargetTexture = /** @class */ (function (_super) {
  57373. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  57374. /**
  57375. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  57376. * or used a shadow, depth texture...
  57377. * @param name The friendly name of the texture
  57378. * @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)
  57379. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  57380. * @param generateMipMaps True if mip maps need to be generated after render.
  57381. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  57382. * @param type The type of the buffer in the RTT (int, half float, float...)
  57383. * @param isCube True if a cube texture needs to be created
  57384. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  57385. * @param generateDepthBuffer True to generate a depth buffer
  57386. * @param generateStencilBuffer True to generate a stencil buffer
  57387. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  57388. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  57389. * @param delayAllocation if the texture allocation should be delayed (default: false)
  57390. */
  57391. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  57392. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  57393. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57394. if (isCube === void 0) { isCube = false; }
  57395. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57396. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  57397. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  57398. if (isMulti === void 0) { isMulti = false; }
  57399. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  57400. if (delayAllocation === void 0) { delayAllocation = false; }
  57401. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  57402. _this.isCube = isCube;
  57403. /**
  57404. * Define if particles should be rendered in your texture.
  57405. */
  57406. _this.renderParticles = true;
  57407. /**
  57408. * Define if sprites should be rendered in your texture.
  57409. */
  57410. _this.renderSprites = false;
  57411. /**
  57412. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  57413. */
  57414. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  57415. /**
  57416. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  57417. */
  57418. _this.ignoreCameraViewport = false;
  57419. /**
  57420. * An event triggered when the texture is unbind.
  57421. */
  57422. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57423. /**
  57424. * An event triggered when the texture is unbind.
  57425. */
  57426. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57427. /**
  57428. * An event triggered before rendering the texture
  57429. */
  57430. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57431. /**
  57432. * An event triggered after rendering the texture
  57433. */
  57434. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57435. /**
  57436. * An event triggered after the texture clear
  57437. */
  57438. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57439. _this._currentRefreshId = -1;
  57440. _this._refreshRate = 1;
  57441. _this._samples = 1;
  57442. /**
  57443. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  57444. * It must define where the camera used to render the texture is set
  57445. */
  57446. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57447. scene = _this.getScene();
  57448. if (!scene) {
  57449. return _this;
  57450. }
  57451. _this.renderList = new Array();
  57452. _this._engine = scene.getEngine();
  57453. _this.name = name;
  57454. _this.isRenderTarget = true;
  57455. _this._initialSizeParameter = size;
  57456. _this._processSizeParameter(size);
  57457. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  57458. });
  57459. _this._generateMipMaps = generateMipMaps ? true : false;
  57460. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  57461. // Rendering groups
  57462. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  57463. _this._renderingManager._useSceneAutoClearSetup = true;
  57464. if (isMulti) {
  57465. return _this;
  57466. }
  57467. _this._renderTargetOptions = {
  57468. generateMipMaps: generateMipMaps,
  57469. type: type,
  57470. format: format,
  57471. samplingMode: samplingMode,
  57472. generateDepthBuffer: generateDepthBuffer,
  57473. generateStencilBuffer: generateStencilBuffer
  57474. };
  57475. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  57476. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57477. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57478. }
  57479. if (!delayAllocation) {
  57480. if (isCube) {
  57481. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  57482. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  57483. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57484. }
  57485. else {
  57486. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  57487. }
  57488. }
  57489. return _this;
  57490. }
  57491. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  57492. /**
  57493. * Use this list to define the list of mesh you want to render.
  57494. */
  57495. get: function () {
  57496. return this._renderList;
  57497. },
  57498. set: function (value) {
  57499. this._renderList = value;
  57500. if (this._renderList) {
  57501. this._hookArray(this._renderList);
  57502. }
  57503. },
  57504. enumerable: true,
  57505. configurable: true
  57506. });
  57507. RenderTargetTexture.prototype._hookArray = function (array) {
  57508. var _this = this;
  57509. var oldPush = array.push;
  57510. array.push = function () {
  57511. var items = [];
  57512. for (var _i = 0; _i < arguments.length; _i++) {
  57513. items[_i] = arguments[_i];
  57514. }
  57515. var wasEmpty = array.length === 0;
  57516. var result = oldPush.apply(array, items);
  57517. if (wasEmpty) {
  57518. _this.getScene().meshes.forEach(function (mesh) {
  57519. mesh._markSubMeshesAsLightDirty();
  57520. });
  57521. }
  57522. return result;
  57523. };
  57524. var oldSplice = array.splice;
  57525. array.splice = function (index, deleteCount) {
  57526. var deleted = oldSplice.apply(array, [index, deleteCount]);
  57527. if (array.length === 0) {
  57528. _this.getScene().meshes.forEach(function (mesh) {
  57529. mesh._markSubMeshesAsLightDirty();
  57530. });
  57531. }
  57532. return deleted;
  57533. };
  57534. };
  57535. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  57536. /**
  57537. * Set a after unbind callback in the texture.
  57538. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  57539. */
  57540. set: function (callback) {
  57541. if (this._onAfterUnbindObserver) {
  57542. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  57543. }
  57544. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  57545. },
  57546. enumerable: true,
  57547. configurable: true
  57548. });
  57549. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  57550. /**
  57551. * Set a before render callback in the texture.
  57552. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  57553. */
  57554. set: function (callback) {
  57555. if (this._onBeforeRenderObserver) {
  57556. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57557. }
  57558. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57559. },
  57560. enumerable: true,
  57561. configurable: true
  57562. });
  57563. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57564. /**
  57565. * Set a after render callback in the texture.
  57566. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57567. */
  57568. set: function (callback) {
  57569. if (this._onAfterRenderObserver) {
  57570. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57571. }
  57572. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57573. },
  57574. enumerable: true,
  57575. configurable: true
  57576. });
  57577. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57578. /**
  57579. * Set a clear callback in the texture.
  57580. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57581. */
  57582. set: function (callback) {
  57583. if (this._onClearObserver) {
  57584. this.onClearObservable.remove(this._onClearObserver);
  57585. }
  57586. this._onClearObserver = this.onClearObservable.add(callback);
  57587. },
  57588. enumerable: true,
  57589. configurable: true
  57590. });
  57591. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57592. /**
  57593. * Gets render target creation options that were used.
  57594. */
  57595. get: function () {
  57596. return this._renderTargetOptions;
  57597. },
  57598. enumerable: true,
  57599. configurable: true
  57600. });
  57601. RenderTargetTexture.prototype._onRatioRescale = function () {
  57602. if (this._sizeRatio) {
  57603. this.resize(this._initialSizeParameter);
  57604. }
  57605. };
  57606. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57607. get: function () {
  57608. return this._boundingBoxSize;
  57609. },
  57610. /**
  57611. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57612. * When defined, the cubemap will switch to local mode
  57613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57614. * @example https://www.babylonjs-playground.com/#RNASML
  57615. */
  57616. set: function (value) {
  57617. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57618. return;
  57619. }
  57620. this._boundingBoxSize = value;
  57621. var scene = this.getScene();
  57622. if (scene) {
  57623. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57624. }
  57625. },
  57626. enumerable: true,
  57627. configurable: true
  57628. });
  57629. /**
  57630. * Creates a depth stencil texture.
  57631. * This is only available in WebGL 2 or with the depth texture extension available.
  57632. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57633. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57634. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57635. */
  57636. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57637. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57638. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57639. if (generateStencil === void 0) { generateStencil = false; }
  57640. if (!this.getScene()) {
  57641. return;
  57642. }
  57643. var engine = this.getScene().getEngine();
  57644. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57645. bilinearFiltering: bilinearFiltering,
  57646. comparisonFunction: comparisonFunction,
  57647. generateStencil: generateStencil,
  57648. isCube: this.isCube
  57649. });
  57650. engine.setFrameBufferDepthStencilTexture(this);
  57651. };
  57652. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57653. if (size.ratio) {
  57654. this._sizeRatio = size.ratio;
  57655. this._size = {
  57656. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57657. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57658. };
  57659. }
  57660. else {
  57661. this._size = size;
  57662. }
  57663. };
  57664. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57665. /**
  57666. * Define the number of samples to use in case of MSAA.
  57667. * It defaults to one meaning no MSAA has been enabled.
  57668. */
  57669. get: function () {
  57670. return this._samples;
  57671. },
  57672. set: function (value) {
  57673. if (this._samples === value) {
  57674. return;
  57675. }
  57676. var scene = this.getScene();
  57677. if (!scene) {
  57678. return;
  57679. }
  57680. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57681. },
  57682. enumerable: true,
  57683. configurable: true
  57684. });
  57685. /**
  57686. * Resets the refresh counter of the texture and start bak from scratch.
  57687. * Could be useful to regenerate the texture if it is setup to render only once.
  57688. */
  57689. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57690. this._currentRefreshId = -1;
  57691. };
  57692. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57693. /**
  57694. * Define the refresh rate of the texture or the rendering frequency.
  57695. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57696. */
  57697. get: function () {
  57698. return this._refreshRate;
  57699. },
  57700. set: function (value) {
  57701. this._refreshRate = value;
  57702. this.resetRefreshCounter();
  57703. },
  57704. enumerable: true,
  57705. configurable: true
  57706. });
  57707. /**
  57708. * Adds a post process to the render target rendering passes.
  57709. * @param postProcess define the post process to add
  57710. */
  57711. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  57712. if (!this._postProcessManager) {
  57713. var scene = this.getScene();
  57714. if (!scene) {
  57715. return;
  57716. }
  57717. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  57718. this._postProcesses = new Array();
  57719. }
  57720. this._postProcesses.push(postProcess);
  57721. this._postProcesses[0].autoClear = false;
  57722. };
  57723. /**
  57724. * Clear all the post processes attached to the render target
  57725. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  57726. */
  57727. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  57728. if (dispose === void 0) { dispose = false; }
  57729. if (!this._postProcesses) {
  57730. return;
  57731. }
  57732. if (dispose) {
  57733. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  57734. var postProcess = _a[_i];
  57735. postProcess.dispose();
  57736. }
  57737. }
  57738. this._postProcesses = [];
  57739. };
  57740. /**
  57741. * Remove one of the post process from the list of attached post processes to the texture
  57742. * @param postProcess define the post process to remove from the list
  57743. */
  57744. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  57745. if (!this._postProcesses) {
  57746. return;
  57747. }
  57748. var index = this._postProcesses.indexOf(postProcess);
  57749. if (index === -1) {
  57750. return;
  57751. }
  57752. this._postProcesses.splice(index, 1);
  57753. if (this._postProcesses.length > 0) {
  57754. this._postProcesses[0].autoClear = false;
  57755. }
  57756. };
  57757. /** @hidden */
  57758. RenderTargetTexture.prototype._shouldRender = function () {
  57759. if (this._currentRefreshId === -1) { // At least render once
  57760. this._currentRefreshId = 1;
  57761. return true;
  57762. }
  57763. if (this.refreshRate === this._currentRefreshId) {
  57764. this._currentRefreshId = 1;
  57765. return true;
  57766. }
  57767. this._currentRefreshId++;
  57768. return false;
  57769. };
  57770. /**
  57771. * Gets the actual render size of the texture.
  57772. * @returns the width of the render size
  57773. */
  57774. RenderTargetTexture.prototype.getRenderSize = function () {
  57775. return this.getRenderWidth();
  57776. };
  57777. /**
  57778. * Gets the actual render width of the texture.
  57779. * @returns the width of the render size
  57780. */
  57781. RenderTargetTexture.prototype.getRenderWidth = function () {
  57782. if (this._size.width) {
  57783. return this._size.width;
  57784. }
  57785. return this._size;
  57786. };
  57787. /**
  57788. * Gets the actual render height of the texture.
  57789. * @returns the height of the render size
  57790. */
  57791. RenderTargetTexture.prototype.getRenderHeight = function () {
  57792. if (this._size.width) {
  57793. return this._size.height;
  57794. }
  57795. return this._size;
  57796. };
  57797. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  57798. /**
  57799. * Get if the texture can be rescaled or not.
  57800. */
  57801. get: function () {
  57802. return true;
  57803. },
  57804. enumerable: true,
  57805. configurable: true
  57806. });
  57807. /**
  57808. * Resize the texture using a ratio.
  57809. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  57810. */
  57811. RenderTargetTexture.prototype.scale = function (ratio) {
  57812. var newSize = this.getRenderSize() * ratio;
  57813. this.resize(newSize);
  57814. };
  57815. /**
  57816. * Get the texture reflection matrix used to rotate/transform the reflection.
  57817. * @returns the reflection matrix
  57818. */
  57819. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  57820. if (this.isCube) {
  57821. return this._textureMatrix;
  57822. }
  57823. return _super.prototype.getReflectionTextureMatrix.call(this);
  57824. };
  57825. /**
  57826. * Resize the texture to a new desired size.
  57827. * Be carrefull as it will recreate all the data in the new texture.
  57828. * @param size Define the new size. It can be:
  57829. * - a number for squared texture,
  57830. * - an object containing { width: number, height: number }
  57831. * - or an object containing a ratio { ratio: number }
  57832. */
  57833. RenderTargetTexture.prototype.resize = function (size) {
  57834. this.releaseInternalTexture();
  57835. var scene = this.getScene();
  57836. if (!scene) {
  57837. return;
  57838. }
  57839. this._processSizeParameter(size);
  57840. if (this.isCube) {
  57841. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  57842. }
  57843. else {
  57844. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  57845. }
  57846. };
  57847. /**
  57848. * Renders all the objects from the render list into the texture.
  57849. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  57850. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  57851. */
  57852. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  57853. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  57854. if (dumpForDebug === void 0) { dumpForDebug = false; }
  57855. var scene = this.getScene();
  57856. if (!scene) {
  57857. return;
  57858. }
  57859. var engine = scene.getEngine();
  57860. if (this.useCameraPostProcesses !== undefined) {
  57861. useCameraPostProcess = this.useCameraPostProcesses;
  57862. }
  57863. if (this._waitingRenderList) {
  57864. this.renderList = [];
  57865. for (var index = 0; index < this._waitingRenderList.length; index++) {
  57866. var id = this._waitingRenderList[index];
  57867. var mesh_1 = scene.getMeshByID(id);
  57868. if (mesh_1) {
  57869. this.renderList.push(mesh_1);
  57870. }
  57871. }
  57872. delete this._waitingRenderList;
  57873. }
  57874. // Is predicate defined?
  57875. if (this.renderListPredicate) {
  57876. if (this.renderList) {
  57877. this.renderList.length = 0; // Clear previous renderList
  57878. }
  57879. else {
  57880. this.renderList = [];
  57881. }
  57882. var scene = this.getScene();
  57883. if (!scene) {
  57884. return;
  57885. }
  57886. var sceneMeshes = scene.meshes;
  57887. for (var index = 0; index < sceneMeshes.length; index++) {
  57888. var mesh = sceneMeshes[index];
  57889. if (this.renderListPredicate(mesh)) {
  57890. this.renderList.push(mesh);
  57891. }
  57892. }
  57893. }
  57894. this.onBeforeBindObservable.notifyObservers(this);
  57895. // Set custom projection.
  57896. // Needs to be before binding to prevent changing the aspect ratio.
  57897. var camera;
  57898. if (this.activeCamera) {
  57899. camera = this.activeCamera;
  57900. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57901. if (this.activeCamera !== scene.activeCamera) {
  57902. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  57903. }
  57904. }
  57905. else {
  57906. camera = scene.activeCamera;
  57907. if (camera) {
  57908. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57909. }
  57910. }
  57911. // Prepare renderingManager
  57912. this._renderingManager.reset();
  57913. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  57914. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  57915. var sceneRenderId = scene.getRenderId();
  57916. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  57917. var mesh = currentRenderList[meshIndex];
  57918. if (mesh) {
  57919. if (!mesh.isReady(this.refreshRate === 0)) {
  57920. this.resetRefreshCounter();
  57921. continue;
  57922. }
  57923. mesh._preActivateForIntermediateRendering(sceneRenderId);
  57924. var isMasked = void 0;
  57925. if (!this.renderList && camera) {
  57926. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  57927. }
  57928. else {
  57929. isMasked = false;
  57930. }
  57931. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  57932. mesh._activate(sceneRenderId);
  57933. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  57934. var subMesh = mesh.subMeshes[subIndex];
  57935. scene._activeIndices.addCount(subMesh.indexCount, false);
  57936. this._renderingManager.dispatch(subMesh, mesh);
  57937. }
  57938. }
  57939. }
  57940. }
  57941. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  57942. var particleSystem = scene.particleSystems[particleIndex];
  57943. var emitter = particleSystem.emitter;
  57944. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  57945. continue;
  57946. }
  57947. if (currentRenderList.indexOf(emitter) >= 0) {
  57948. this._renderingManager.dispatchParticles(particleSystem);
  57949. }
  57950. }
  57951. if (this.isCube) {
  57952. for (var face = 0; face < 6; face++) {
  57953. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  57954. scene.incrementRenderId();
  57955. scene.resetCachedMaterial();
  57956. }
  57957. }
  57958. else {
  57959. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  57960. }
  57961. this.onAfterUnbindObservable.notifyObservers(this);
  57962. if (scene.activeCamera) {
  57963. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  57964. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  57965. }
  57966. engine.setViewport(scene.activeCamera.viewport);
  57967. }
  57968. scene.resetCachedMaterial();
  57969. };
  57970. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  57971. var minimum = 128;
  57972. var x = renderDimension * scale;
  57973. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  57974. // Ensure we don't exceed the render dimension (while staying POT)
  57975. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  57976. };
  57977. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57978. var _this = this;
  57979. if (!this._texture) {
  57980. return;
  57981. }
  57982. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  57983. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57984. });
  57985. };
  57986. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  57987. var scene = this.getScene();
  57988. if (!scene) {
  57989. return;
  57990. }
  57991. var engine = scene.getEngine();
  57992. if (!this._texture) {
  57993. return;
  57994. }
  57995. // Bind
  57996. if (this._postProcessManager) {
  57997. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  57998. }
  57999. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  58000. if (this._texture) {
  58001. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  58002. }
  58003. }
  58004. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  58005. // Clear
  58006. if (this.onClearObservable.hasObservers()) {
  58007. this.onClearObservable.notifyObservers(engine);
  58008. }
  58009. else {
  58010. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  58011. }
  58012. if (!this._doNotChangeAspectRatio) {
  58013. scene.updateTransformMatrix(true);
  58014. }
  58015. // Before Camera Draw
  58016. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  58017. var step = _a[_i];
  58018. step.action(this);
  58019. }
  58020. // Render
  58021. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  58022. // After Camera Draw
  58023. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  58024. var step = _c[_b];
  58025. step.action(this);
  58026. }
  58027. if (this._postProcessManager) {
  58028. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  58029. }
  58030. else if (useCameraPostProcess) {
  58031. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  58032. }
  58033. if (!this._doNotChangeAspectRatio) {
  58034. scene.updateTransformMatrix(true);
  58035. }
  58036. // Dump ?
  58037. if (dumpForDebug) {
  58038. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  58039. }
  58040. // Unbind
  58041. if (!this.isCube || faceIndex === 5) {
  58042. if (this.isCube) {
  58043. if (faceIndex === 5) {
  58044. engine.generateMipMapsForCubemap(this._texture);
  58045. }
  58046. }
  58047. this.unbindFrameBuffer(engine, faceIndex);
  58048. }
  58049. else {
  58050. this.onAfterRenderObservable.notifyObservers(faceIndex);
  58051. }
  58052. };
  58053. /**
  58054. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  58055. * This allowed control for front to back rendering or reversly depending of the special needs.
  58056. *
  58057. * @param renderingGroupId The rendering group id corresponding to its index
  58058. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  58059. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  58060. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  58061. */
  58062. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  58063. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  58064. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  58065. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  58066. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  58067. };
  58068. /**
  58069. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  58070. *
  58071. * @param renderingGroupId The rendering group id corresponding to its index
  58072. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58073. */
  58074. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  58075. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  58076. this._renderingManager._useSceneAutoClearSetup = false;
  58077. };
  58078. /**
  58079. * Clones the texture.
  58080. * @returns the cloned texture
  58081. */
  58082. RenderTargetTexture.prototype.clone = function () {
  58083. var textureSize = this.getSize();
  58084. 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);
  58085. // Base texture
  58086. newTexture.hasAlpha = this.hasAlpha;
  58087. newTexture.level = this.level;
  58088. // RenderTarget Texture
  58089. newTexture.coordinatesMode = this.coordinatesMode;
  58090. if (this.renderList) {
  58091. newTexture.renderList = this.renderList.slice(0);
  58092. }
  58093. return newTexture;
  58094. };
  58095. /**
  58096. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58097. * @returns The JSON representation of the texture
  58098. */
  58099. RenderTargetTexture.prototype.serialize = function () {
  58100. if (!this.name) {
  58101. return null;
  58102. }
  58103. var serializationObject = _super.prototype.serialize.call(this);
  58104. serializationObject.renderTargetSize = this.getRenderSize();
  58105. serializationObject.renderList = [];
  58106. if (this.renderList) {
  58107. for (var index = 0; index < this.renderList.length; index++) {
  58108. serializationObject.renderList.push(this.renderList[index].id);
  58109. }
  58110. }
  58111. return serializationObject;
  58112. };
  58113. /**
  58114. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  58115. */
  58116. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  58117. var objBuffer = this.getInternalTexture();
  58118. var scene = this.getScene();
  58119. if (objBuffer && scene) {
  58120. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  58121. }
  58122. };
  58123. /**
  58124. * Dispose the texture and release its associated resources.
  58125. */
  58126. RenderTargetTexture.prototype.dispose = function () {
  58127. if (this._postProcessManager) {
  58128. this._postProcessManager.dispose();
  58129. this._postProcessManager = null;
  58130. }
  58131. this.clearPostProcesses(true);
  58132. if (this._resizeObserver) {
  58133. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  58134. this._resizeObserver = null;
  58135. }
  58136. this.renderList = null;
  58137. // Remove from custom render targets
  58138. var scene = this.getScene();
  58139. if (!scene) {
  58140. return;
  58141. }
  58142. var index = scene.customRenderTargets.indexOf(this);
  58143. if (index >= 0) {
  58144. scene.customRenderTargets.splice(index, 1);
  58145. }
  58146. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  58147. var camera = _a[_i];
  58148. index = camera.customRenderTargets.indexOf(this);
  58149. if (index >= 0) {
  58150. camera.customRenderTargets.splice(index, 1);
  58151. }
  58152. }
  58153. _super.prototype.dispose.call(this);
  58154. };
  58155. /** @hidden */
  58156. RenderTargetTexture.prototype._rebuild = function () {
  58157. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  58158. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  58159. }
  58160. if (this._postProcessManager) {
  58161. this._postProcessManager._rebuild();
  58162. }
  58163. };
  58164. /**
  58165. * Clear the info related to rendering groups preventing retention point in material dispose.
  58166. */
  58167. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  58168. if (this._renderingManager) {
  58169. this._renderingManager.freeRenderingGroups();
  58170. }
  58171. };
  58172. /**
  58173. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  58174. */
  58175. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  58176. /**
  58177. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  58178. */
  58179. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  58180. /**
  58181. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  58182. * the central point of your effect and can save a lot of performances.
  58183. */
  58184. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  58185. return RenderTargetTexture;
  58186. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58187. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58188. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  58189. };
  58190. /***/ }),
  58191. /***/ "./Materials/Textures/texture.ts":
  58192. /*!***************************************!*\
  58193. !*** ./Materials/Textures/texture.ts ***!
  58194. \***************************************/
  58195. /*! exports provided: Texture */
  58196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58197. "use strict";
  58198. __webpack_require__.r(__webpack_exports__);
  58199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  58200. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58201. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58202. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58203. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58204. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58205. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58206. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58207. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58208. /**
  58209. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58210. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58211. */
  58212. var Texture = /** @class */ (function (_super) {
  58213. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  58214. /**
  58215. * Instantiates a new texture.
  58216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58218. * @param url define the url of the picture to load as a texture
  58219. * @param scene define the scene the texture will belong to
  58220. * @param noMipmap define if the texture will require mip maps or not
  58221. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58222. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58223. * @param onLoad define a callback triggered when the texture has been loaded
  58224. * @param onError define a callback triggered when an error occurred during the loading session
  58225. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58226. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58228. */
  58229. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  58230. if (noMipmap === void 0) { noMipmap = false; }
  58231. if (invertY === void 0) { invertY = true; }
  58232. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58233. if (onLoad === void 0) { onLoad = null; }
  58234. if (onError === void 0) { onError = null; }
  58235. if (buffer === void 0) { buffer = null; }
  58236. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58237. var _this = _super.call(this, scene) || this;
  58238. /**
  58239. * Define an offset on the texture to offset the u coordinates of the UVs
  58240. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58241. */
  58242. _this.uOffset = 0;
  58243. /**
  58244. * Define an offset on the texture to offset the v coordinates of the UVs
  58245. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58246. */
  58247. _this.vOffset = 0;
  58248. /**
  58249. * Define an offset on the texture to scale the u coordinates of the UVs
  58250. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58251. */
  58252. _this.uScale = 1.0;
  58253. /**
  58254. * Define an offset on the texture to scale the v coordinates of the UVs
  58255. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58256. */
  58257. _this.vScale = 1.0;
  58258. /**
  58259. * Define an offset on the texture to rotate around the u coordinates of the UVs
  58260. * @see http://doc.babylonjs.com/how_to/more_materials
  58261. */
  58262. _this.uAng = 0;
  58263. /**
  58264. * Define an offset on the texture to rotate around the v coordinates of the UVs
  58265. * @see http://doc.babylonjs.com/how_to/more_materials
  58266. */
  58267. _this.vAng = 0;
  58268. /**
  58269. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  58270. * @see http://doc.babylonjs.com/how_to/more_materials
  58271. */
  58272. _this.wAng = 0;
  58273. /**
  58274. * Defines the center of rotation (U)
  58275. */
  58276. _this.uRotationCenter = 0.5;
  58277. /**
  58278. * Defines the center of rotation (V)
  58279. */
  58280. _this.vRotationCenter = 0.5;
  58281. /**
  58282. * Defines the center of rotation (W)
  58283. */
  58284. _this.wRotationCenter = 0.5;
  58285. /** @hidden */
  58286. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  58287. /**
  58288. * Observable triggered once the texture has been loaded.
  58289. */
  58290. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58291. _this._isBlocking = true;
  58292. _this.name = url || "";
  58293. _this.url = url;
  58294. _this._noMipmap = noMipmap;
  58295. _this._invertY = invertY;
  58296. _this._initialSamplingMode = samplingMode;
  58297. _this._buffer = buffer;
  58298. _this._deleteBuffer = deleteBuffer;
  58299. if (format) {
  58300. _this._format = format;
  58301. }
  58302. scene = _this.getScene();
  58303. if (!scene) {
  58304. return _this;
  58305. }
  58306. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  58307. var load = function () {
  58308. if (_this._texture && _this._texture._invertVScale) {
  58309. _this.vScale = -1;
  58310. }
  58311. if (_this.onLoadObservable.hasObservers()) {
  58312. _this.onLoadObservable.notifyObservers(_this);
  58313. }
  58314. if (onLoad) {
  58315. onLoad();
  58316. }
  58317. if (!_this.isBlocking && scene) {
  58318. scene.resetCachedMaterial();
  58319. }
  58320. };
  58321. if (!_this.url) {
  58322. _this._delayedOnLoad = load;
  58323. _this._delayedOnError = onError;
  58324. return _this;
  58325. }
  58326. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  58327. if (!_this._texture) {
  58328. if (!scene.useDelayedTextureLoading) {
  58329. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  58330. if (deleteBuffer) {
  58331. delete _this._buffer;
  58332. }
  58333. }
  58334. else {
  58335. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58336. _this._delayedOnLoad = load;
  58337. _this._delayedOnError = onError;
  58338. }
  58339. }
  58340. else {
  58341. if (_this._texture.isReady) {
  58342. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  58343. }
  58344. else {
  58345. _this._texture.onLoadedObservable.add(load);
  58346. }
  58347. }
  58348. return _this;
  58349. }
  58350. Object.defineProperty(Texture.prototype, "noMipmap", {
  58351. /**
  58352. * Are mip maps generated for this texture or not.
  58353. */
  58354. get: function () {
  58355. return this._noMipmap;
  58356. },
  58357. enumerable: true,
  58358. configurable: true
  58359. });
  58360. Object.defineProperty(Texture.prototype, "isBlocking", {
  58361. get: function () {
  58362. return this._isBlocking;
  58363. },
  58364. /**
  58365. * Is the texture preventing material to render while loading.
  58366. * If false, a default texture will be used instead of the loading one during the preparation step.
  58367. */
  58368. set: function (value) {
  58369. this._isBlocking = value;
  58370. },
  58371. enumerable: true,
  58372. configurable: true
  58373. });
  58374. Object.defineProperty(Texture.prototype, "samplingMode", {
  58375. /**
  58376. * Get the current sampling mode associated with the texture.
  58377. */
  58378. get: function () {
  58379. if (!this._texture) {
  58380. return this._initialSamplingMode;
  58381. }
  58382. return this._texture.samplingMode;
  58383. },
  58384. enumerable: true,
  58385. configurable: true
  58386. });
  58387. Object.defineProperty(Texture.prototype, "invertY", {
  58388. /**
  58389. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  58390. */
  58391. get: function () {
  58392. return this._invertY;
  58393. },
  58394. enumerable: true,
  58395. configurable: true
  58396. });
  58397. /**
  58398. * Update the url (and optional buffer) of this texture if url was null during construction.
  58399. * @param url the url of the texture
  58400. * @param buffer the buffer of the texture (defaults to null)
  58401. * @param onLoad callback called when the texture is loaded (defaults to null)
  58402. */
  58403. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  58404. if (buffer === void 0) { buffer = null; }
  58405. if (this.url) {
  58406. this.releaseInternalTexture();
  58407. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58408. }
  58409. this.url = url;
  58410. this._buffer = buffer;
  58411. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58412. if (onLoad) {
  58413. this._delayedOnLoad = onLoad;
  58414. }
  58415. this.delayLoad();
  58416. };
  58417. /**
  58418. * Finish the loading sequence of a texture flagged as delayed load.
  58419. * @hidden
  58420. */
  58421. Texture.prototype.delayLoad = function () {
  58422. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58423. return;
  58424. }
  58425. var scene = this.getScene();
  58426. if (!scene) {
  58427. return;
  58428. }
  58429. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58430. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  58431. if (!this._texture) {
  58432. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  58433. if (this._deleteBuffer) {
  58434. delete this._buffer;
  58435. }
  58436. }
  58437. else {
  58438. if (this._delayedOnLoad) {
  58439. if (this._texture.isReady) {
  58440. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  58441. }
  58442. else {
  58443. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  58444. }
  58445. }
  58446. }
  58447. this._delayedOnLoad = null;
  58448. this._delayedOnError = null;
  58449. };
  58450. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  58451. x *= this.uScale;
  58452. y *= this.vScale;
  58453. x -= this.uRotationCenter * this.uScale;
  58454. y -= this.vRotationCenter * this.vScale;
  58455. z -= this.wRotationCenter;
  58456. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  58457. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  58458. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  58459. t.z += this.wRotationCenter;
  58460. };
  58461. /**
  58462. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  58463. * @returns the transform matrix of the texture.
  58464. */
  58465. Texture.prototype.getTextureMatrix = function () {
  58466. var _this = this;
  58467. if (this.uOffset === this._cachedUOffset &&
  58468. this.vOffset === this._cachedVOffset &&
  58469. this.uScale === this._cachedUScale &&
  58470. this.vScale === this._cachedVScale &&
  58471. this.uAng === this._cachedUAng &&
  58472. this.vAng === this._cachedVAng &&
  58473. this.wAng === this._cachedWAng) {
  58474. return this._cachedTextureMatrix;
  58475. }
  58476. this._cachedUOffset = this.uOffset;
  58477. this._cachedVOffset = this.vOffset;
  58478. this._cachedUScale = this.uScale;
  58479. this._cachedVScale = this.vScale;
  58480. this._cachedUAng = this.uAng;
  58481. this._cachedVAng = this.vAng;
  58482. this._cachedWAng = this.wAng;
  58483. if (!this._cachedTextureMatrix) {
  58484. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58485. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  58486. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58487. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58488. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58489. }
  58490. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  58491. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  58492. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  58493. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  58494. this._t1.subtractInPlace(this._t0);
  58495. this._t2.subtractInPlace(this._t0);
  58496. _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);
  58497. var scene = this.getScene();
  58498. if (!scene) {
  58499. return this._cachedTextureMatrix;
  58500. }
  58501. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58502. return mat.hasTexture(_this);
  58503. });
  58504. return this._cachedTextureMatrix;
  58505. };
  58506. /**
  58507. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  58508. * @returns The reflection texture transform
  58509. */
  58510. Texture.prototype.getReflectionTextureMatrix = function () {
  58511. var _this = this;
  58512. var scene = this.getScene();
  58513. if (!scene) {
  58514. return this._cachedTextureMatrix;
  58515. }
  58516. if (this.uOffset === this._cachedUOffset &&
  58517. this.vOffset === this._cachedVOffset &&
  58518. this.uScale === this._cachedUScale &&
  58519. this.vScale === this._cachedVScale &&
  58520. this.coordinatesMode === this._cachedCoordinatesMode) {
  58521. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  58522. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  58523. return this._cachedTextureMatrix;
  58524. }
  58525. }
  58526. else {
  58527. return this._cachedTextureMatrix;
  58528. }
  58529. }
  58530. if (!this._cachedTextureMatrix) {
  58531. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58532. }
  58533. if (!this._projectionModeMatrix) {
  58534. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58535. }
  58536. this._cachedUOffset = this.uOffset;
  58537. this._cachedVOffset = this.vOffset;
  58538. this._cachedUScale = this.uScale;
  58539. this._cachedVScale = this.vScale;
  58540. this._cachedCoordinatesMode = this.coordinatesMode;
  58541. switch (this.coordinatesMode) {
  58542. case Texture.PLANAR_MODE:
  58543. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58544. this._cachedTextureMatrix[0] = this.uScale;
  58545. this._cachedTextureMatrix[5] = this.vScale;
  58546. this._cachedTextureMatrix[12] = this.uOffset;
  58547. this._cachedTextureMatrix[13] = this.vOffset;
  58548. break;
  58549. case Texture.PROJECTION_MODE:
  58550. _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);
  58551. var projectionMatrix = scene.getProjectionMatrix();
  58552. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  58553. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  58554. break;
  58555. default:
  58556. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58557. break;
  58558. }
  58559. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58560. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58561. });
  58562. return this._cachedTextureMatrix;
  58563. };
  58564. /**
  58565. * Clones the texture.
  58566. * @returns the cloned texture
  58567. */
  58568. Texture.prototype.clone = function () {
  58569. var _this = this;
  58570. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58571. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58572. }, this);
  58573. };
  58574. /**
  58575. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58576. * @returns The JSON representation of the texture
  58577. */
  58578. Texture.prototype.serialize = function () {
  58579. var serializationObject = _super.prototype.serialize.call(this);
  58580. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58581. serializationObject.base64String = this._buffer;
  58582. serializationObject.name = serializationObject.name.replace("data:", "");
  58583. }
  58584. serializationObject.invertY = this._invertY;
  58585. serializationObject.samplingMode = this.samplingMode;
  58586. return serializationObject;
  58587. };
  58588. /**
  58589. * Get the current class name of the texture useful for serialization or dynamic coding.
  58590. * @returns "Texture"
  58591. */
  58592. Texture.prototype.getClassName = function () {
  58593. return "Texture";
  58594. };
  58595. /**
  58596. * Dispose the texture and release its associated resources.
  58597. */
  58598. Texture.prototype.dispose = function () {
  58599. _super.prototype.dispose.call(this);
  58600. this.onLoadObservable.clear();
  58601. this._delayedOnLoad = null;
  58602. this._delayedOnError = null;
  58603. };
  58604. /**
  58605. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58606. * @param parsedTexture Define the JSON representation of the texture
  58607. * @param scene Define the scene the parsed texture should be instantiated in
  58608. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58609. * @returns The parsed texture if successful
  58610. */
  58611. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58612. if (parsedTexture.customType) {
  58613. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58614. // Update Sampling Mode
  58615. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58616. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58617. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58618. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58619. }
  58620. }
  58621. return parsedCustomTexture;
  58622. }
  58623. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58624. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58625. }
  58626. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58627. return null;
  58628. }
  58629. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58630. var generateMipMaps = true;
  58631. if (parsedTexture.noMipmap) {
  58632. generateMipMaps = false;
  58633. }
  58634. if (parsedTexture.mirrorPlane) {
  58635. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58636. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58637. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58638. return mirrorTexture;
  58639. }
  58640. else if (parsedTexture.isRenderTarget) {
  58641. var renderTargetTexture = null;
  58642. if (parsedTexture.isCube) {
  58643. // Search for an existing reflection probe (which contains a cube render target texture)
  58644. if (scene.reflectionProbes) {
  58645. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58646. var probe = scene.reflectionProbes[index];
  58647. if (probe.name === parsedTexture.name) {
  58648. return probe.cubeTexture;
  58649. }
  58650. }
  58651. }
  58652. }
  58653. else {
  58654. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58655. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58656. }
  58657. return renderTargetTexture;
  58658. }
  58659. else {
  58660. var texture;
  58661. if (parsedTexture.base64String) {
  58662. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58663. }
  58664. else {
  58665. var url = rootUrl + parsedTexture.name;
  58666. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58667. url = parsedTexture.url;
  58668. }
  58669. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58670. }
  58671. return texture;
  58672. }
  58673. }, parsedTexture, scene);
  58674. // Update Sampling Mode
  58675. if (parsedTexture.samplingMode) {
  58676. var sampling = parsedTexture.samplingMode;
  58677. if (texture && texture.samplingMode !== sampling) {
  58678. texture.updateSamplingMode(sampling);
  58679. }
  58680. }
  58681. // Animations
  58682. if (texture && parsedTexture.animations) {
  58683. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58684. var parsedAnimation = parsedTexture.animations[animationIndex];
  58685. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58686. if (internalClass) {
  58687. texture.animations.push(internalClass.Parse(parsedAnimation));
  58688. }
  58689. }
  58690. }
  58691. return texture;
  58692. };
  58693. /**
  58694. * Creates a texture from its base 64 representation.
  58695. * @param data Define the base64 payload without the data: prefix
  58696. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58697. * @param scene Define the scene the texture should belong to
  58698. * @param noMipmap Forces the texture to not create mip map information if true
  58699. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58700. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58701. * @param onLoad define a callback triggered when the texture has been loaded
  58702. * @param onError define a callback triggered when an error occurred during the loading session
  58703. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58704. * @returns the created texture
  58705. */
  58706. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58707. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58708. if (onLoad === void 0) { onLoad = null; }
  58709. if (onError === void 0) { onError = null; }
  58710. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58711. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  58712. };
  58713. /**
  58714. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  58715. * @param data Define the base64 payload without the data: prefix
  58716. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58717. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58718. * @param scene Define the scene the texture should belong to
  58719. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58720. * @param noMipmap Forces the texture to not create mip map information if true
  58721. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58722. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58723. * @param onLoad define a callback triggered when the texture has been loaded
  58724. * @param onError define a callback triggered when an error occurred during the loading session
  58725. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58726. * @returns the created texture
  58727. */
  58728. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58729. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58730. if (noMipmap === void 0) { noMipmap = false; }
  58731. if (invertY === void 0) { invertY = true; }
  58732. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58733. if (onLoad === void 0) { onLoad = null; }
  58734. if (onError === void 0) { onError = null; }
  58735. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58736. if (name.substr(0, 5) !== "data:") {
  58737. name = "data:" + name;
  58738. }
  58739. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  58740. };
  58741. /** @hidden */
  58742. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  58743. throw "CubeTexture needs to be imported before being deserialized.";
  58744. };
  58745. /** @hidden */
  58746. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58747. throw "MirrorTexture needs to be imported before being deserialized.";
  58748. };
  58749. /** @hidden */
  58750. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58751. throw "RenderTargetTexture needs to be imported before being deserialized.";
  58752. };
  58753. /** nearest is mag = nearest and min = nearest and mip = linear */
  58754. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  58755. /** nearest is mag = nearest and min = nearest and mip = linear */
  58756. 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
  58757. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58758. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  58759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58760. 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
  58761. /** Trilinear is mag = linear and min = linear and mip = linear */
  58762. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  58763. /** Trilinear is mag = linear and min = linear and mip = linear */
  58764. 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
  58765. /** mag = nearest and min = nearest and mip = nearest */
  58766. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  58767. /** mag = nearest and min = linear and mip = nearest */
  58768. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  58769. /** mag = nearest and min = linear and mip = linear */
  58770. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  58771. /** mag = nearest and min = linear and mip = none */
  58772. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  58773. /** mag = nearest and min = nearest and mip = none */
  58774. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  58775. /** mag = linear and min = nearest and mip = nearest */
  58776. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  58777. /** mag = linear and min = nearest and mip = linear */
  58778. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  58779. /** mag = linear and min = linear and mip = none */
  58780. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  58781. /** mag = linear and min = nearest and mip = none */
  58782. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  58783. /** Explicit coordinates mode */
  58784. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  58785. /** Spherical coordinates mode */
  58786. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  58787. /** Planar coordinates mode */
  58788. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  58789. /** Cubic coordinates mode */
  58790. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  58791. /** Projection coordinates mode */
  58792. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  58793. /** Inverse Cubic coordinates mode */
  58794. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  58795. /** Inverse Cubic coordinates mode */
  58796. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  58797. /** Equirectangular coordinates mode */
  58798. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  58799. /** Equirectangular Fixed coordinates mode */
  58800. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  58801. /** Equirectangular Fixed Mirrored coordinates mode */
  58802. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  58803. /** Texture is not repeating outside of 0..1 UVs */
  58804. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58805. /** Texture is repeating outside of 0..1 UVs */
  58806. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58807. /** Texture is repeating and mirrored */
  58808. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  58809. /**
  58810. * 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
  58811. */
  58812. Texture.UseSerializedUrlIfAny = false;
  58813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58815. ], Texture.prototype, "url", void 0);
  58816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58818. ], Texture.prototype, "uOffset", void 0);
  58819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58821. ], Texture.prototype, "vOffset", void 0);
  58822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58824. ], Texture.prototype, "uScale", void 0);
  58825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58827. ], Texture.prototype, "vScale", void 0);
  58828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58830. ], Texture.prototype, "uAng", void 0);
  58831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58833. ], Texture.prototype, "vAng", void 0);
  58834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58836. ], Texture.prototype, "wAng", void 0);
  58837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58839. ], Texture.prototype, "uRotationCenter", void 0);
  58840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58842. ], Texture.prototype, "vRotationCenter", void 0);
  58843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58845. ], Texture.prototype, "wRotationCenter", void 0);
  58846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58848. ], Texture.prototype, "isBlocking", null);
  58849. return Texture;
  58850. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  58851. // References the dependencies.
  58852. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  58853. /***/ }),
  58854. /***/ "./Materials/Textures/videoTexture.ts":
  58855. /*!********************************************!*\
  58856. !*** ./Materials/Textures/videoTexture.ts ***!
  58857. \********************************************/
  58858. /*! exports provided: VideoTexture */
  58859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58860. "use strict";
  58861. __webpack_require__.r(__webpack_exports__);
  58862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  58863. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58864. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58865. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58866. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58867. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58868. /**
  58869. * If you want to display a video in your scene, this is the special texture for that.
  58870. * This special texture works similar to other textures, with the exception of a few parameters.
  58871. * @see https://doc.babylonjs.com/how_to/video_texture
  58872. */
  58873. var VideoTexture = /** @class */ (function (_super) {
  58874. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  58875. /**
  58876. * Creates a video texture.
  58877. * If you want to display a video in your scene, this is the special texture for that.
  58878. * This special texture works similar to other textures, with the exception of a few parameters.
  58879. * @see https://doc.babylonjs.com/how_to/video_texture
  58880. * @param name optional name, will detect from video source, if not defined
  58881. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  58882. * @param scene is obviously the current scene.
  58883. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  58884. * @param invertY is false by default but can be used to invert video on Y axis
  58885. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  58886. * @param settings allows finer control over video usage
  58887. */
  58888. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  58889. if (generateMipMaps === void 0) { generateMipMaps = false; }
  58890. if (invertY === void 0) { invertY = false; }
  58891. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58892. if (settings === void 0) { settings = {
  58893. autoPlay: true,
  58894. loop: true,
  58895. autoUpdateTexture: true,
  58896. }; }
  58897. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  58898. _this._onUserActionRequestedObservable = null;
  58899. _this._stillImageCaptured = false;
  58900. _this._displayingPosterTexture = false;
  58901. _this._createInternalTexture = function () {
  58902. if (_this._texture != null) {
  58903. if (_this._displayingPosterTexture) {
  58904. _this._texture.dispose();
  58905. _this._displayingPosterTexture = false;
  58906. }
  58907. else {
  58908. return;
  58909. }
  58910. }
  58911. if (!_this._engine.needPOTTextures ||
  58912. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  58913. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58914. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58915. }
  58916. else {
  58917. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58918. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58919. _this._generateMipMaps = false;
  58920. }
  58921. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  58922. if (!_this.video.autoplay && !_this._settings.poster) {
  58923. var oldHandler_1 = _this.video.onplaying;
  58924. var error_1 = false;
  58925. _this.video.onplaying = function () {
  58926. _this.video.onplaying = oldHandler_1;
  58927. _this._texture.isReady = true;
  58928. _this._updateInternalTexture();
  58929. if (!error_1) {
  58930. _this.video.pause();
  58931. }
  58932. if (_this.onLoadObservable.hasObservers()) {
  58933. _this.onLoadObservable.notifyObservers(_this);
  58934. }
  58935. };
  58936. var playing = _this.video.play();
  58937. if (playing) {
  58938. playing.then(function () {
  58939. // Everything is good.
  58940. })
  58941. .catch(function () {
  58942. error_1 = true;
  58943. // On Chrome for instance, new policies might prevent playing without user interaction.
  58944. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  58945. _this._onUserActionRequestedObservable.notifyObservers(_this);
  58946. }
  58947. });
  58948. }
  58949. else {
  58950. _this.video.onplaying = oldHandler_1;
  58951. _this._texture.isReady = true;
  58952. _this._updateInternalTexture();
  58953. if (_this.onLoadObservable.hasObservers()) {
  58954. _this.onLoadObservable.notifyObservers(_this);
  58955. }
  58956. }
  58957. }
  58958. else {
  58959. _this._texture.isReady = true;
  58960. _this._updateInternalTexture();
  58961. if (_this.onLoadObservable.hasObservers()) {
  58962. _this.onLoadObservable.notifyObservers(_this);
  58963. }
  58964. }
  58965. };
  58966. _this.reset = function () {
  58967. if (_this._texture == null) {
  58968. return;
  58969. }
  58970. if (!_this._displayingPosterTexture) {
  58971. _this._texture.dispose();
  58972. _this._texture = null;
  58973. }
  58974. };
  58975. _this._updateInternalTexture = function () {
  58976. if (_this._texture == null || !_this._texture.isReady) {
  58977. return;
  58978. }
  58979. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  58980. return;
  58981. }
  58982. if (_this._displayingPosterTexture) {
  58983. return;
  58984. }
  58985. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  58986. };
  58987. _this._engine = _this.getScene().getEngine();
  58988. _this._generateMipMaps = generateMipMaps;
  58989. _this._initialSamplingMode = samplingMode;
  58990. _this.autoUpdateTexture = settings.autoUpdateTexture;
  58991. _this.name = name || _this._getName(src);
  58992. _this.video = _this._getVideo(src);
  58993. _this._settings = settings;
  58994. if (settings.poster) {
  58995. _this.video.poster = settings.poster;
  58996. }
  58997. if (settings.autoPlay !== undefined) {
  58998. _this.video.autoplay = settings.autoPlay;
  58999. }
  59000. if (settings.loop !== undefined) {
  59001. _this.video.loop = settings.loop;
  59002. }
  59003. _this.video.setAttribute("playsinline", "");
  59004. _this.video.addEventListener("paused", _this._updateInternalTexture);
  59005. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  59006. _this.video.addEventListener("emptied", _this.reset);
  59007. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  59008. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  59009. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  59010. if (settings.poster &&
  59011. (!settings.autoPlay || !videoHasEnoughData)) {
  59012. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  59013. _this._displayingPosterTexture = true;
  59014. }
  59015. else if (videoHasEnoughData) {
  59016. _this._createInternalTexture();
  59017. }
  59018. return _this;
  59019. }
  59020. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  59021. /**
  59022. * Event triggerd when a dom action is required by the user to play the video.
  59023. * This happens due to recent changes in browser policies preventing video to auto start.
  59024. */
  59025. get: function () {
  59026. if (!this._onUserActionRequestedObservable) {
  59027. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59028. }
  59029. return this._onUserActionRequestedObservable;
  59030. },
  59031. enumerable: true,
  59032. configurable: true
  59033. });
  59034. VideoTexture.prototype._getName = function (src) {
  59035. if (src instanceof HTMLVideoElement) {
  59036. return src.currentSrc;
  59037. }
  59038. if (typeof src === "object") {
  59039. return src.toString();
  59040. }
  59041. return src;
  59042. };
  59043. VideoTexture.prototype._getVideo = function (src) {
  59044. if (src instanceof HTMLVideoElement) {
  59045. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  59046. return src;
  59047. }
  59048. var video = document.createElement("video");
  59049. if (typeof src === "string") {
  59050. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  59051. video.src = src;
  59052. }
  59053. else {
  59054. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  59055. src.forEach(function (url) {
  59056. var source = document.createElement("source");
  59057. source.src = url;
  59058. video.appendChild(source);
  59059. });
  59060. }
  59061. return video;
  59062. };
  59063. /**
  59064. * @hidden Internal method to initiate `update`.
  59065. */
  59066. VideoTexture.prototype._rebuild = function () {
  59067. this.update();
  59068. };
  59069. /**
  59070. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  59071. */
  59072. VideoTexture.prototype.update = function () {
  59073. if (!this.autoUpdateTexture) {
  59074. // Expecting user to call `updateTexture` manually
  59075. return;
  59076. }
  59077. this.updateTexture(true);
  59078. };
  59079. /**
  59080. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  59081. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  59082. */
  59083. VideoTexture.prototype.updateTexture = function (isVisible) {
  59084. if (!isVisible) {
  59085. return;
  59086. }
  59087. if (this.video.paused && this._stillImageCaptured) {
  59088. return;
  59089. }
  59090. this._stillImageCaptured = true;
  59091. this._updateInternalTexture();
  59092. };
  59093. /**
  59094. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  59095. * @param url New url.
  59096. */
  59097. VideoTexture.prototype.updateURL = function (url) {
  59098. this.video.src = url;
  59099. };
  59100. /**
  59101. * Dispose the texture and release its associated resources.
  59102. */
  59103. VideoTexture.prototype.dispose = function () {
  59104. _super.prototype.dispose.call(this);
  59105. if (this._onUserActionRequestedObservable) {
  59106. this._onUserActionRequestedObservable.clear();
  59107. this._onUserActionRequestedObservable = null;
  59108. }
  59109. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  59110. this.video.removeEventListener("paused", this._updateInternalTexture);
  59111. this.video.removeEventListener("seeked", this._updateInternalTexture);
  59112. this.video.removeEventListener("emptied", this.reset);
  59113. this.video.pause();
  59114. };
  59115. /**
  59116. * Creates a video texture straight from your WebCam video feed.
  59117. * @param scene Define the scene the texture should be created in
  59118. * @param onReady Define a callback to triggered once the texture will be ready
  59119. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  59120. */
  59121. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  59122. var video = document.createElement("video");
  59123. video.setAttribute('autoplay', '');
  59124. video.setAttribute('muted', '');
  59125. video.setAttribute('playsinline', '');
  59126. var constraintsDeviceId;
  59127. if (constraints && constraints.deviceId) {
  59128. constraintsDeviceId = {
  59129. exact: constraints.deviceId,
  59130. };
  59131. }
  59132. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  59133. if (navigator.mediaDevices) {
  59134. navigator.mediaDevices.getUserMedia({ video: constraints })
  59135. .then(function (stream) {
  59136. if (video.mozSrcObject !== undefined) {
  59137. // hack for Firefox < 19
  59138. video.mozSrcObject = stream;
  59139. }
  59140. else {
  59141. video.srcObject = stream;
  59142. }
  59143. var onPlaying = function () {
  59144. if (onReady) {
  59145. onReady(new VideoTexture("video", video, scene, true, true));
  59146. }
  59147. video.removeEventListener("playing", onPlaying);
  59148. };
  59149. video.addEventListener("playing", onPlaying);
  59150. video.play();
  59151. })
  59152. .catch(function (err) {
  59153. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  59154. });
  59155. }
  59156. else {
  59157. navigator.getUserMedia =
  59158. navigator.getUserMedia ||
  59159. navigator.webkitGetUserMedia ||
  59160. navigator.mozGetUserMedia ||
  59161. navigator.msGetUserMedia;
  59162. if (navigator.getUserMedia) {
  59163. navigator.getUserMedia({
  59164. video: {
  59165. deviceId: constraintsDeviceId,
  59166. width: {
  59167. min: (constraints && constraints.minWidth) || 256,
  59168. max: (constraints && constraints.maxWidth) || 640,
  59169. },
  59170. height: {
  59171. min: (constraints && constraints.minHeight) || 256,
  59172. max: (constraints && constraints.maxHeight) || 480,
  59173. },
  59174. },
  59175. }, function (stream) {
  59176. if (video.mozSrcObject !== undefined) {
  59177. // hack for Firefox < 19
  59178. video.mozSrcObject = stream;
  59179. }
  59180. else {
  59181. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  59182. }
  59183. video.play();
  59184. if (onReady) {
  59185. onReady(new VideoTexture("video", video, scene, true, true));
  59186. }
  59187. }, function (e) {
  59188. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  59189. });
  59190. }
  59191. }
  59192. };
  59193. return VideoTexture;
  59194. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59195. /***/ }),
  59196. /***/ "./Materials/colorCurves.ts":
  59197. /*!**********************************!*\
  59198. !*** ./Materials/colorCurves.ts ***!
  59199. \**********************************/
  59200. /*! exports provided: ColorCurves */
  59201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59202. "use strict";
  59203. __webpack_require__.r(__webpack_exports__);
  59204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  59205. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59206. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  59207. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  59208. /**
  59209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59211. * 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;
  59212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59213. */
  59214. var ColorCurves = /** @class */ (function () {
  59215. function ColorCurves() {
  59216. this._dirty = true;
  59217. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59218. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59219. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59220. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59221. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59222. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59223. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59224. this._globalHue = 30;
  59225. this._globalDensity = 0;
  59226. this._globalSaturation = 0;
  59227. this._globalExposure = 0;
  59228. this._highlightsHue = 30;
  59229. this._highlightsDensity = 0;
  59230. this._highlightsSaturation = 0;
  59231. this._highlightsExposure = 0;
  59232. this._midtonesHue = 30;
  59233. this._midtonesDensity = 0;
  59234. this._midtonesSaturation = 0;
  59235. this._midtonesExposure = 0;
  59236. this._shadowsHue = 30;
  59237. this._shadowsDensity = 0;
  59238. this._shadowsSaturation = 0;
  59239. this._shadowsExposure = 0;
  59240. }
  59241. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  59242. /**
  59243. * Gets the global Hue value.
  59244. * 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).
  59245. */
  59246. get: function () {
  59247. return this._globalHue;
  59248. },
  59249. /**
  59250. * Sets the global Hue value.
  59251. * 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).
  59252. */
  59253. set: function (value) {
  59254. this._globalHue = value;
  59255. this._dirty = true;
  59256. },
  59257. enumerable: true,
  59258. configurable: true
  59259. });
  59260. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  59261. /**
  59262. * Gets the global Density value.
  59263. * 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.
  59264. * Values less than zero provide a filter of opposite hue.
  59265. */
  59266. get: function () {
  59267. return this._globalDensity;
  59268. },
  59269. /**
  59270. * Sets the global Density value.
  59271. * 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.
  59272. * Values less than zero provide a filter of opposite hue.
  59273. */
  59274. set: function (value) {
  59275. this._globalDensity = value;
  59276. this._dirty = true;
  59277. },
  59278. enumerable: true,
  59279. configurable: true
  59280. });
  59281. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  59282. /**
  59283. * Gets the global Saturation value.
  59284. * 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.
  59285. */
  59286. get: function () {
  59287. return this._globalSaturation;
  59288. },
  59289. /**
  59290. * Sets the global Saturation value.
  59291. * 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.
  59292. */
  59293. set: function (value) {
  59294. this._globalSaturation = value;
  59295. this._dirty = true;
  59296. },
  59297. enumerable: true,
  59298. configurable: true
  59299. });
  59300. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  59301. /**
  59302. * Gets the global Exposure value.
  59303. * 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.
  59304. */
  59305. get: function () {
  59306. return this._globalExposure;
  59307. },
  59308. /**
  59309. * Sets the global Exposure value.
  59310. * 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.
  59311. */
  59312. set: function (value) {
  59313. this._globalExposure = value;
  59314. this._dirty = true;
  59315. },
  59316. enumerable: true,
  59317. configurable: true
  59318. });
  59319. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  59320. /**
  59321. * Gets the highlights Hue value.
  59322. * 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).
  59323. */
  59324. get: function () {
  59325. return this._highlightsHue;
  59326. },
  59327. /**
  59328. * Sets the highlights Hue value.
  59329. * 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).
  59330. */
  59331. set: function (value) {
  59332. this._highlightsHue = value;
  59333. this._dirty = true;
  59334. },
  59335. enumerable: true,
  59336. configurable: true
  59337. });
  59338. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  59339. /**
  59340. * Gets the highlights Density value.
  59341. * 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.
  59342. * Values less than zero provide a filter of opposite hue.
  59343. */
  59344. get: function () {
  59345. return this._highlightsDensity;
  59346. },
  59347. /**
  59348. * Sets the highlights Density value.
  59349. * 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.
  59350. * Values less than zero provide a filter of opposite hue.
  59351. */
  59352. set: function (value) {
  59353. this._highlightsDensity = value;
  59354. this._dirty = true;
  59355. },
  59356. enumerable: true,
  59357. configurable: true
  59358. });
  59359. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  59360. /**
  59361. * Gets the highlights Saturation value.
  59362. * 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.
  59363. */
  59364. get: function () {
  59365. return this._highlightsSaturation;
  59366. },
  59367. /**
  59368. * Sets the highlights Saturation value.
  59369. * 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.
  59370. */
  59371. set: function (value) {
  59372. this._highlightsSaturation = value;
  59373. this._dirty = true;
  59374. },
  59375. enumerable: true,
  59376. configurable: true
  59377. });
  59378. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  59379. /**
  59380. * Gets the highlights Exposure value.
  59381. * 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.
  59382. */
  59383. get: function () {
  59384. return this._highlightsExposure;
  59385. },
  59386. /**
  59387. * Sets the highlights Exposure value.
  59388. * 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.
  59389. */
  59390. set: function (value) {
  59391. this._highlightsExposure = value;
  59392. this._dirty = true;
  59393. },
  59394. enumerable: true,
  59395. configurable: true
  59396. });
  59397. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  59398. /**
  59399. * Gets the midtones Hue value.
  59400. * 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).
  59401. */
  59402. get: function () {
  59403. return this._midtonesHue;
  59404. },
  59405. /**
  59406. * Sets the midtones Hue value.
  59407. * 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).
  59408. */
  59409. set: function (value) {
  59410. this._midtonesHue = value;
  59411. this._dirty = true;
  59412. },
  59413. enumerable: true,
  59414. configurable: true
  59415. });
  59416. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  59417. /**
  59418. * Gets the midtones Density value.
  59419. * 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.
  59420. * Values less than zero provide a filter of opposite hue.
  59421. */
  59422. get: function () {
  59423. return this._midtonesDensity;
  59424. },
  59425. /**
  59426. * Sets the midtones Density value.
  59427. * 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.
  59428. * Values less than zero provide a filter of opposite hue.
  59429. */
  59430. set: function (value) {
  59431. this._midtonesDensity = value;
  59432. this._dirty = true;
  59433. },
  59434. enumerable: true,
  59435. configurable: true
  59436. });
  59437. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  59438. /**
  59439. * Gets the midtones Saturation value.
  59440. * 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.
  59441. */
  59442. get: function () {
  59443. return this._midtonesSaturation;
  59444. },
  59445. /**
  59446. * Sets the midtones Saturation value.
  59447. * 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.
  59448. */
  59449. set: function (value) {
  59450. this._midtonesSaturation = value;
  59451. this._dirty = true;
  59452. },
  59453. enumerable: true,
  59454. configurable: true
  59455. });
  59456. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  59457. /**
  59458. * Gets the midtones Exposure value.
  59459. * 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.
  59460. */
  59461. get: function () {
  59462. return this._midtonesExposure;
  59463. },
  59464. /**
  59465. * Sets the midtones Exposure value.
  59466. * 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.
  59467. */
  59468. set: function (value) {
  59469. this._midtonesExposure = value;
  59470. this._dirty = true;
  59471. },
  59472. enumerable: true,
  59473. configurable: true
  59474. });
  59475. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  59476. /**
  59477. * Gets the shadows Hue value.
  59478. * 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).
  59479. */
  59480. get: function () {
  59481. return this._shadowsHue;
  59482. },
  59483. /**
  59484. * Sets the shadows Hue value.
  59485. * 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).
  59486. */
  59487. set: function (value) {
  59488. this._shadowsHue = value;
  59489. this._dirty = true;
  59490. },
  59491. enumerable: true,
  59492. configurable: true
  59493. });
  59494. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  59495. /**
  59496. * Gets the shadows Density value.
  59497. * 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.
  59498. * Values less than zero provide a filter of opposite hue.
  59499. */
  59500. get: function () {
  59501. return this._shadowsDensity;
  59502. },
  59503. /**
  59504. * Sets the shadows Density value.
  59505. * 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.
  59506. * Values less than zero provide a filter of opposite hue.
  59507. */
  59508. set: function (value) {
  59509. this._shadowsDensity = value;
  59510. this._dirty = true;
  59511. },
  59512. enumerable: true,
  59513. configurable: true
  59514. });
  59515. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  59516. /**
  59517. * Gets the shadows Saturation value.
  59518. * 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.
  59519. */
  59520. get: function () {
  59521. return this._shadowsSaturation;
  59522. },
  59523. /**
  59524. * Sets the shadows Saturation value.
  59525. * 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.
  59526. */
  59527. set: function (value) {
  59528. this._shadowsSaturation = value;
  59529. this._dirty = true;
  59530. },
  59531. enumerable: true,
  59532. configurable: true
  59533. });
  59534. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  59535. /**
  59536. * Gets the shadows Exposure value.
  59537. * 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.
  59538. */
  59539. get: function () {
  59540. return this._shadowsExposure;
  59541. },
  59542. /**
  59543. * Sets the shadows Exposure value.
  59544. * 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.
  59545. */
  59546. set: function (value) {
  59547. this._shadowsExposure = value;
  59548. this._dirty = true;
  59549. },
  59550. enumerable: true,
  59551. configurable: true
  59552. });
  59553. /**
  59554. * Returns the class name
  59555. * @returns The class name
  59556. */
  59557. ColorCurves.prototype.getClassName = function () {
  59558. return "ColorCurves";
  59559. };
  59560. /**
  59561. * Binds the color curves to the shader.
  59562. * @param colorCurves The color curve to bind
  59563. * @param effect The effect to bind to
  59564. * @param positiveUniform The positive uniform shader parameter
  59565. * @param neutralUniform The neutral uniform shader parameter
  59566. * @param negativeUniform The negative uniform shader parameter
  59567. */
  59568. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59569. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59570. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59571. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59572. if (colorCurves._dirty) {
  59573. colorCurves._dirty = false;
  59574. // Fill in global info.
  59575. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59576. // Compute highlights info.
  59577. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59578. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59579. // Compute midtones info.
  59580. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59581. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59582. // Compute shadows info.
  59583. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59584. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59585. // Compute deltas (neutral is midtones).
  59586. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59587. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59588. }
  59589. if (effect) {
  59590. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59591. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59592. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59593. }
  59594. };
  59595. /**
  59596. * Prepare the list of uniforms associated with the ColorCurves effects.
  59597. * @param uniformsList The list of uniforms used in the effect
  59598. */
  59599. ColorCurves.PrepareUniforms = function (uniformsList) {
  59600. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59601. };
  59602. /**
  59603. * Returns color grading data based on a hue, density, saturation and exposure value.
  59604. * @param filterHue The hue of the color filter.
  59605. * @param filterDensity The density of the color filter.
  59606. * @param saturation The saturation.
  59607. * @param exposure The exposure.
  59608. * @param result The result data container.
  59609. */
  59610. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59611. if (hue == null) {
  59612. return;
  59613. }
  59614. hue = ColorCurves.clamp(hue, 0, 360);
  59615. density = ColorCurves.clamp(density, -100, 100);
  59616. saturation = ColorCurves.clamp(saturation, -100, 100);
  59617. exposure = ColorCurves.clamp(exposure, -100, 100);
  59618. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59619. // so that the maximum filter density is only 50% control. This provides fine control
  59620. // for small values and reasonable range.
  59621. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59622. density *= 0.5;
  59623. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59624. if (density < 0) {
  59625. density *= -1;
  59626. hue = (hue + 180) % 360;
  59627. }
  59628. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59629. result.scaleToRef(2, result);
  59630. result.a = 1 + 0.01 * saturation;
  59631. };
  59632. /**
  59633. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59634. * @param value The input slider value in range [-100,100].
  59635. * @returns Adjusted value.
  59636. */
  59637. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59638. value /= 100;
  59639. var x = Math.abs(value);
  59640. x = Math.pow(x, 2);
  59641. if (value < 0) {
  59642. x *= -1;
  59643. }
  59644. x *= 100;
  59645. return x;
  59646. };
  59647. /**
  59648. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59649. * @param hue The hue (H) input.
  59650. * @param saturation The saturation (S) input.
  59651. * @param brightness The brightness (B) input.
  59652. * @result An RGBA color represented as Vector4.
  59653. */
  59654. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59655. var h = ColorCurves.clamp(hue, 0, 360);
  59656. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59657. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59658. if (s === 0) {
  59659. result.r = v;
  59660. result.g = v;
  59661. result.b = v;
  59662. }
  59663. else {
  59664. // sector 0 to 5
  59665. h /= 60;
  59666. var i = Math.floor(h);
  59667. // fractional part of h
  59668. var f = h - i;
  59669. var p = v * (1 - s);
  59670. var q = v * (1 - s * f);
  59671. var t = v * (1 - s * (1 - f));
  59672. switch (i) {
  59673. case 0:
  59674. result.r = v;
  59675. result.g = t;
  59676. result.b = p;
  59677. break;
  59678. case 1:
  59679. result.r = q;
  59680. result.g = v;
  59681. result.b = p;
  59682. break;
  59683. case 2:
  59684. result.r = p;
  59685. result.g = v;
  59686. result.b = t;
  59687. break;
  59688. case 3:
  59689. result.r = p;
  59690. result.g = q;
  59691. result.b = v;
  59692. break;
  59693. case 4:
  59694. result.r = t;
  59695. result.g = p;
  59696. result.b = v;
  59697. break;
  59698. default: // case 5:
  59699. result.r = v;
  59700. result.g = p;
  59701. result.b = q;
  59702. break;
  59703. }
  59704. }
  59705. result.a = 1;
  59706. };
  59707. /**
  59708. * Returns a value clamped between min and max
  59709. * @param value The value to clamp
  59710. * @param min The minimum of value
  59711. * @param max The maximum of value
  59712. * @returns The clamped value.
  59713. */
  59714. ColorCurves.clamp = function (value, min, max) {
  59715. return Math.min(Math.max(value, min), max);
  59716. };
  59717. /**
  59718. * Clones the current color curve instance.
  59719. * @return The cloned curves
  59720. */
  59721. ColorCurves.prototype.clone = function () {
  59722. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  59723. };
  59724. /**
  59725. * Serializes the current color curve instance to a json representation.
  59726. * @return a JSON representation
  59727. */
  59728. ColorCurves.prototype.serialize = function () {
  59729. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  59730. };
  59731. /**
  59732. * Parses the color curve from a json representation.
  59733. * @param source the JSON source to parse
  59734. * @return The parsed curves
  59735. */
  59736. ColorCurves.Parse = function (source) {
  59737. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  59738. };
  59739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59741. ], ColorCurves.prototype, "_globalHue", void 0);
  59742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59744. ], ColorCurves.prototype, "_globalDensity", void 0);
  59745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59747. ], ColorCurves.prototype, "_globalSaturation", void 0);
  59748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59750. ], ColorCurves.prototype, "_globalExposure", void 0);
  59751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59753. ], ColorCurves.prototype, "_highlightsHue", void 0);
  59754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59756. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  59757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59759. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  59760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59762. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  59763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59765. ], ColorCurves.prototype, "_midtonesHue", void 0);
  59766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59768. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  59769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59771. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  59772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59774. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  59775. return ColorCurves;
  59776. }());
  59777. // References the dependencies.
  59778. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  59779. /***/ }),
  59780. /***/ "./Materials/effect.ts":
  59781. /*!*****************************!*\
  59782. !*** ./Materials/effect.ts ***!
  59783. \*****************************/
  59784. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  59785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59786. "use strict";
  59787. __webpack_require__.r(__webpack_exports__);
  59788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  59789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  59790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  59791. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  59792. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  59793. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  59794. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  59795. /**
  59796. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  59797. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  59798. */
  59799. var EffectFallbacks = /** @class */ (function () {
  59800. function EffectFallbacks() {
  59801. this._defines = {};
  59802. this._currentRank = 32;
  59803. this._maxRank = -1;
  59804. }
  59805. /**
  59806. * Removes the fallback from the bound mesh.
  59807. */
  59808. EffectFallbacks.prototype.unBindMesh = function () {
  59809. this._mesh = null;
  59810. };
  59811. /**
  59812. * Adds a fallback on the specified property.
  59813. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59814. * @param define The name of the define in the shader
  59815. */
  59816. EffectFallbacks.prototype.addFallback = function (rank, define) {
  59817. if (!this._defines[rank]) {
  59818. if (rank < this._currentRank) {
  59819. this._currentRank = rank;
  59820. }
  59821. if (rank > this._maxRank) {
  59822. this._maxRank = rank;
  59823. }
  59824. this._defines[rank] = new Array();
  59825. }
  59826. this._defines[rank].push(define);
  59827. };
  59828. /**
  59829. * Sets the mesh to use CPU skinning when needing to fallback.
  59830. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59831. * @param mesh The mesh to use the fallbacks.
  59832. */
  59833. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  59834. this._mesh = mesh;
  59835. if (rank < this._currentRank) {
  59836. this._currentRank = rank;
  59837. }
  59838. if (rank > this._maxRank) {
  59839. this._maxRank = rank;
  59840. }
  59841. };
  59842. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  59843. /**
  59844. * Checks to see if more fallbacks are still availible.
  59845. */
  59846. get: function () {
  59847. return this._currentRank <= this._maxRank;
  59848. },
  59849. enumerable: true,
  59850. configurable: true
  59851. });
  59852. /**
  59853. * Removes the defines that shoould be removed when falling back.
  59854. * @param currentDefines defines the current define statements for the shader.
  59855. * @param effect defines the current effect we try to compile
  59856. * @returns The resulting defines with defines of the current rank removed.
  59857. */
  59858. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  59859. // First we try to switch to CPU skinning
  59860. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  59861. this._mesh.computeBonesUsingShaders = false;
  59862. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  59863. effect._bonesComputationForcedToCPU = true;
  59864. var scene = this._mesh.getScene();
  59865. for (var index = 0; index < scene.meshes.length; index++) {
  59866. var otherMesh = scene.meshes[index];
  59867. if (!otherMesh.material) {
  59868. continue;
  59869. }
  59870. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  59871. continue;
  59872. }
  59873. if (otherMesh.material.getEffect() === effect) {
  59874. otherMesh.computeBonesUsingShaders = false;
  59875. }
  59876. else if (otherMesh.subMeshes) {
  59877. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  59878. var subMesh = _a[_i];
  59879. var subMeshEffect = subMesh.effect;
  59880. if (subMeshEffect === effect) {
  59881. otherMesh.computeBonesUsingShaders = false;
  59882. break;
  59883. }
  59884. }
  59885. }
  59886. }
  59887. }
  59888. else {
  59889. var currentFallbacks = this._defines[this._currentRank];
  59890. if (currentFallbacks) {
  59891. for (var index = 0; index < currentFallbacks.length; index++) {
  59892. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  59893. }
  59894. }
  59895. this._currentRank++;
  59896. }
  59897. return currentDefines;
  59898. };
  59899. return EffectFallbacks;
  59900. }());
  59901. /**
  59902. * Options to be used when creating an effect.
  59903. */
  59904. var EffectCreationOptions = /** @class */ (function () {
  59905. function EffectCreationOptions() {
  59906. }
  59907. return EffectCreationOptions;
  59908. }());
  59909. /**
  59910. * Effect containing vertex and fragment shader that can be executed on an object.
  59911. */
  59912. var Effect = /** @class */ (function () {
  59913. /**
  59914. * Instantiates an effect.
  59915. * An effect can be used to create/manage/execute vertex and fragment shaders.
  59916. * @param baseName Name of the effect.
  59917. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  59918. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  59919. * @param samplers List of sampler variables that will be passed to the shader.
  59920. * @param engine Engine to be used to render the effect
  59921. * @param defines Define statements to be added to the shader.
  59922. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  59923. * @param onCompiled Callback that will be called when the shader is compiled.
  59924. * @param onError Callback that will be called if an error occurs during shader compilation.
  59925. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  59926. */
  59927. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  59928. if (samplers === void 0) { samplers = null; }
  59929. if (defines === void 0) { defines = null; }
  59930. if (fallbacks === void 0) { fallbacks = null; }
  59931. if (onCompiled === void 0) { onCompiled = null; }
  59932. if (onError === void 0) { onError = null; }
  59933. var _this = this;
  59934. /**
  59935. * Unique ID of the effect.
  59936. */
  59937. this.uniqueId = 0;
  59938. /**
  59939. * Observable that will be called when the shader is compiled.
  59940. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  59941. */
  59942. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59943. /**
  59944. * Observable that will be called if an error occurs during shader compilation.
  59945. */
  59946. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59947. /** @hidden */
  59948. this._bonesComputationForcedToCPU = false;
  59949. this._uniformBuffersNames = {};
  59950. this._isReady = false;
  59951. this._compilationError = "";
  59952. this.name = baseName;
  59953. if (attributesNamesOrOptions.attributes) {
  59954. var options = attributesNamesOrOptions;
  59955. this._engine = uniformsNamesOrEngine;
  59956. this._attributesNames = options.attributes;
  59957. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  59958. this._samplers = options.samplers.slice();
  59959. this.defines = options.defines;
  59960. this.onError = options.onError;
  59961. this.onCompiled = options.onCompiled;
  59962. this._fallbacks = options.fallbacks;
  59963. this._indexParameters = options.indexParameters;
  59964. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  59965. if (options.uniformBuffersNames) {
  59966. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  59967. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  59968. }
  59969. }
  59970. }
  59971. else {
  59972. this._engine = engine;
  59973. this.defines = defines;
  59974. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  59975. this._samplers = samplers ? samplers.slice() : [];
  59976. this._attributesNames = attributesNamesOrOptions;
  59977. this.onError = onError;
  59978. this.onCompiled = onCompiled;
  59979. this._indexParameters = indexParameters;
  59980. this._fallbacks = fallbacks;
  59981. }
  59982. this.uniqueId = Effect._uniqueIdSeed++;
  59983. var vertexSource;
  59984. var fragmentSource;
  59985. if (baseName.vertexElement) {
  59986. vertexSource = document.getElementById(baseName.vertexElement);
  59987. if (!vertexSource) {
  59988. vertexSource = baseName.vertexElement;
  59989. }
  59990. }
  59991. else {
  59992. vertexSource = baseName.vertex || baseName;
  59993. }
  59994. if (baseName.fragmentElement) {
  59995. fragmentSource = document.getElementById(baseName.fragmentElement);
  59996. if (!fragmentSource) {
  59997. fragmentSource = baseName.fragmentElement;
  59998. }
  59999. }
  60000. else {
  60001. fragmentSource = baseName.fragment || baseName;
  60002. }
  60003. this._loadVertexShader(vertexSource, function (vertexCode) {
  60004. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  60005. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  60006. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  60007. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  60008. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  60009. if (baseName) {
  60010. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  60011. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  60012. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  60013. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  60014. }
  60015. else {
  60016. _this._vertexSourceCode = migratedVertexCode;
  60017. _this._fragmentSourceCode = migratedFragmentCode;
  60018. }
  60019. _this._prepareEffect();
  60020. });
  60021. });
  60022. });
  60023. });
  60024. });
  60025. });
  60026. }
  60027. Object.defineProperty(Effect.prototype, "onBindObservable", {
  60028. /**
  60029. * Observable that will be called when effect is bound.
  60030. */
  60031. get: function () {
  60032. if (!this._onBindObservable) {
  60033. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60034. }
  60035. return this._onBindObservable;
  60036. },
  60037. enumerable: true,
  60038. configurable: true
  60039. });
  60040. Object.defineProperty(Effect.prototype, "key", {
  60041. /**
  60042. * Unique key for this effect
  60043. */
  60044. get: function () {
  60045. return this._key;
  60046. },
  60047. enumerable: true,
  60048. configurable: true
  60049. });
  60050. /**
  60051. * If the effect has been compiled and prepared.
  60052. * @returns if the effect is compiled and prepared.
  60053. */
  60054. Effect.prototype.isReady = function () {
  60055. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  60056. return this._engine._isProgramCompiled(this._program);
  60057. }
  60058. return this._isReady;
  60059. };
  60060. /**
  60061. * The engine the effect was initialized with.
  60062. * @returns the engine.
  60063. */
  60064. Effect.prototype.getEngine = function () {
  60065. return this._engine;
  60066. };
  60067. /**
  60068. * The compiled webGL program for the effect
  60069. * @returns the webGL program.
  60070. */
  60071. Effect.prototype.getProgram = function () {
  60072. return this._program;
  60073. };
  60074. /**
  60075. * The set of names of attribute variables for the shader.
  60076. * @returns An array of attribute names.
  60077. */
  60078. Effect.prototype.getAttributesNames = function () {
  60079. return this._attributesNames;
  60080. };
  60081. /**
  60082. * Returns the attribute at the given index.
  60083. * @param index The index of the attribute.
  60084. * @returns The location of the attribute.
  60085. */
  60086. Effect.prototype.getAttributeLocation = function (index) {
  60087. return this._attributes[index];
  60088. };
  60089. /**
  60090. * Returns the attribute based on the name of the variable.
  60091. * @param name of the attribute to look up.
  60092. * @returns the attribute location.
  60093. */
  60094. Effect.prototype.getAttributeLocationByName = function (name) {
  60095. var index = this._attributesNames.indexOf(name);
  60096. return this._attributes[index];
  60097. };
  60098. /**
  60099. * The number of attributes.
  60100. * @returns the numnber of attributes.
  60101. */
  60102. Effect.prototype.getAttributesCount = function () {
  60103. return this._attributes.length;
  60104. };
  60105. /**
  60106. * Gets the index of a uniform variable.
  60107. * @param uniformName of the uniform to look up.
  60108. * @returns the index.
  60109. */
  60110. Effect.prototype.getUniformIndex = function (uniformName) {
  60111. return this._uniformsNames.indexOf(uniformName);
  60112. };
  60113. /**
  60114. * Returns the attribute based on the name of the variable.
  60115. * @param uniformName of the uniform to look up.
  60116. * @returns the location of the uniform.
  60117. */
  60118. Effect.prototype.getUniform = function (uniformName) {
  60119. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  60120. };
  60121. /**
  60122. * Returns an array of sampler variable names
  60123. * @returns The array of sampler variable neames.
  60124. */
  60125. Effect.prototype.getSamplers = function () {
  60126. return this._samplers;
  60127. };
  60128. /**
  60129. * The error from the last compilation.
  60130. * @returns the error string.
  60131. */
  60132. Effect.prototype.getCompilationError = function () {
  60133. return this._compilationError;
  60134. };
  60135. /**
  60136. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  60137. * @param func The callback to be used.
  60138. */
  60139. Effect.prototype.executeWhenCompiled = function (func) {
  60140. var _this = this;
  60141. if (this.isReady()) {
  60142. func(this);
  60143. return;
  60144. }
  60145. this.onCompileObservable.add(function (effect) {
  60146. func(effect);
  60147. });
  60148. if (!this._program || this._program.isParallelCompiled) {
  60149. setTimeout(function () {
  60150. _this._checkIsReady();
  60151. }, 16);
  60152. }
  60153. };
  60154. Effect.prototype._checkIsReady = function () {
  60155. var _this = this;
  60156. if (this.isReady()) {
  60157. return;
  60158. }
  60159. setTimeout(function () {
  60160. _this._checkIsReady();
  60161. }, 16);
  60162. };
  60163. /** @hidden */
  60164. Effect.prototype._loadVertexShader = function (vertex, callback) {
  60165. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60166. // DOM element ?
  60167. if (vertex instanceof HTMLElement) {
  60168. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  60169. callback(vertexCode);
  60170. return;
  60171. }
  60172. }
  60173. // Base64 encoded ?
  60174. if (vertex.substr(0, 7) === "base64:") {
  60175. var vertexBinary = window.atob(vertex.substr(7));
  60176. callback(vertexBinary);
  60177. return;
  60178. }
  60179. // Is in local store ?
  60180. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  60181. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  60182. return;
  60183. }
  60184. var vertexShaderUrl;
  60185. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  60186. vertexShaderUrl = vertex;
  60187. }
  60188. else {
  60189. vertexShaderUrl = Effect.ShadersRepository + vertex;
  60190. }
  60191. // Vertex shader
  60192. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  60193. };
  60194. /** @hidden */
  60195. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  60196. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60197. // DOM element ?
  60198. if (fragment instanceof HTMLElement) {
  60199. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  60200. callback(fragmentCode);
  60201. return;
  60202. }
  60203. }
  60204. // Base64 encoded ?
  60205. if (fragment.substr(0, 7) === "base64:") {
  60206. var fragmentBinary = window.atob(fragment.substr(7));
  60207. callback(fragmentBinary);
  60208. return;
  60209. }
  60210. // Is in local store ?
  60211. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  60212. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  60213. return;
  60214. }
  60215. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  60216. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  60217. return;
  60218. }
  60219. var fragmentShaderUrl;
  60220. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  60221. fragmentShaderUrl = fragment;
  60222. }
  60223. else {
  60224. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  60225. }
  60226. // Fragment shader
  60227. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  60228. };
  60229. /** @hidden */
  60230. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  60231. // Rebuild shaders source code
  60232. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  60233. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  60234. vertexCode = prefix + vertexCode;
  60235. fragmentCode = prefix + fragmentCode;
  60236. // Number lines of shaders source code
  60237. var i = 2;
  60238. var regex = /\n/gm;
  60239. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60240. i = 2;
  60241. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60242. // Dump shaders name and formatted source code
  60243. if (this.name.vertexElement) {
  60244. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  60245. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  60246. }
  60247. else if (this.name.vertex) {
  60248. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  60249. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  60250. }
  60251. else {
  60252. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  60253. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  60254. }
  60255. };
  60256. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  60257. var preparedSourceCode = this._processPrecision(sourceCode);
  60258. if (this._engine.webGLVersion == 1) {
  60259. callback(preparedSourceCode);
  60260. return;
  60261. }
  60262. // Already converted
  60263. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  60264. callback(preparedSourceCode.replace("#version 300 es", ""));
  60265. return;
  60266. }
  60267. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  60268. // Remove extensions
  60269. // #extension GL_OES_standard_derivatives : enable
  60270. // #extension GL_EXT_shader_texture_lod : enable
  60271. // #extension GL_EXT_frag_depth : enable
  60272. // #extension GL_EXT_draw_buffers : require
  60273. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  60274. var result = preparedSourceCode.replace(regex, "");
  60275. // Migrate to GLSL v300
  60276. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  60277. result = result.replace(/attribute[ \t]/g, "in ");
  60278. result = result.replace(/[ \t]attribute/g, " in");
  60279. result = result.replace(/texture2D\s*\(/g, "texture(");
  60280. if (isFragment) {
  60281. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  60282. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  60283. result = result.replace(/textureCube\s*\(/g, "texture(");
  60284. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  60285. result = result.replace(/gl_FragColor/g, "glFragColor");
  60286. result = result.replace(/gl_FragData/g, "glFragData");
  60287. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  60288. }
  60289. callback(result);
  60290. };
  60291. Effect.prototype._processIncludes = function (sourceCode, callback) {
  60292. var _this = this;
  60293. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  60294. var match = regex.exec(sourceCode);
  60295. var returnValue = new String(sourceCode);
  60296. while (match != null) {
  60297. var includeFile = match[1];
  60298. // Uniform declaration
  60299. if (includeFile.indexOf("__decl__") !== -1) {
  60300. includeFile = includeFile.replace(/__decl__/, "");
  60301. if (this._engine.supportsUniformBuffers) {
  60302. includeFile = includeFile.replace(/Vertex/, "Ubo");
  60303. includeFile = includeFile.replace(/Fragment/, "Ubo");
  60304. }
  60305. includeFile = includeFile + "Declaration";
  60306. }
  60307. if (Effect.IncludesShadersStore[includeFile]) {
  60308. // Substitution
  60309. var includeContent = Effect.IncludesShadersStore[includeFile];
  60310. if (match[2]) {
  60311. var splits = match[3].split(",");
  60312. for (var index = 0; index < splits.length; index += 2) {
  60313. var source = new RegExp(splits[index], "g");
  60314. var dest = splits[index + 1];
  60315. includeContent = includeContent.replace(source, dest);
  60316. }
  60317. }
  60318. if (match[4]) {
  60319. var indexString = match[5];
  60320. if (indexString.indexOf("..") !== -1) {
  60321. var indexSplits = indexString.split("..");
  60322. var minIndex = parseInt(indexSplits[0]);
  60323. var maxIndex = parseInt(indexSplits[1]);
  60324. var sourceIncludeContent = includeContent.slice(0);
  60325. includeContent = "";
  60326. if (isNaN(maxIndex)) {
  60327. maxIndex = this._indexParameters[indexSplits[1]];
  60328. }
  60329. for (var i = minIndex; i < maxIndex; i++) {
  60330. if (!this._engine.supportsUniformBuffers) {
  60331. // Ubo replacement
  60332. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60333. return p1 + "{X}";
  60334. });
  60335. }
  60336. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  60337. }
  60338. }
  60339. else {
  60340. if (!this._engine.supportsUniformBuffers) {
  60341. // Ubo replacement
  60342. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60343. return p1 + "{X}";
  60344. });
  60345. }
  60346. includeContent = includeContent.replace(/\{X\}/g, indexString);
  60347. }
  60348. }
  60349. // Replace
  60350. returnValue = returnValue.replace(match[0], includeContent);
  60351. }
  60352. else {
  60353. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  60354. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  60355. Effect.IncludesShadersStore[includeFile] = fileContent;
  60356. _this._processIncludes(returnValue, callback);
  60357. });
  60358. return;
  60359. }
  60360. match = regex.exec(sourceCode);
  60361. }
  60362. callback(returnValue);
  60363. };
  60364. Effect.prototype._processPrecision = function (source) {
  60365. if (source.indexOf("precision highp float") === -1) {
  60366. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  60367. source = "precision mediump float;\n" + source;
  60368. }
  60369. else {
  60370. source = "precision highp float;\n" + source;
  60371. }
  60372. }
  60373. else {
  60374. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  60375. source = source.replace("precision highp float", "precision mediump float");
  60376. }
  60377. }
  60378. return source;
  60379. };
  60380. /**
  60381. * Recompiles the webGL program
  60382. * @param vertexSourceCode The source code for the vertex shader.
  60383. * @param fragmentSourceCode The source code for the fragment shader.
  60384. * @param onCompiled Callback called when completed.
  60385. * @param onError Callback called on error.
  60386. * @hidden
  60387. */
  60388. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  60389. var _this = this;
  60390. this._isReady = false;
  60391. this._vertexSourceCodeOverride = vertexSourceCode;
  60392. this._fragmentSourceCodeOverride = fragmentSourceCode;
  60393. this.onError = function (effect, error) {
  60394. if (onError) {
  60395. onError(error);
  60396. }
  60397. };
  60398. this.onCompiled = function () {
  60399. var scenes = _this.getEngine().scenes;
  60400. for (var i = 0; i < scenes.length; i++) {
  60401. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  60402. }
  60403. if (onCompiled) {
  60404. onCompiled(_this._program);
  60405. }
  60406. };
  60407. this._fallbacks = null;
  60408. this._prepareEffect();
  60409. };
  60410. /**
  60411. * Gets the uniform locations of the the specified variable names
  60412. * @param names THe names of the variables to lookup.
  60413. * @returns Array of locations in the same order as variable names.
  60414. */
  60415. Effect.prototype.getSpecificUniformLocations = function (names) {
  60416. var engine = this._engine;
  60417. return engine.getUniforms(this._program, names);
  60418. };
  60419. /**
  60420. * Prepares the effect
  60421. * @hidden
  60422. */
  60423. Effect.prototype._prepareEffect = function () {
  60424. var _this = this;
  60425. var attributesNames = this._attributesNames;
  60426. var defines = this.defines;
  60427. var fallbacks = this._fallbacks;
  60428. this._valueCache = {};
  60429. var previousProgram = this._program;
  60430. try {
  60431. var engine_1 = this._engine;
  60432. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  60433. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  60434. }
  60435. else {
  60436. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  60437. }
  60438. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  60439. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  60440. if (engine_1.supportsUniformBuffers) {
  60441. for (var name in _this._uniformBuffersNames) {
  60442. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  60443. }
  60444. }
  60445. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  60446. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  60447. var index;
  60448. for (index = 0; index < _this._samplers.length; index++) {
  60449. var sampler = _this.getUniform(_this._samplers[index]);
  60450. if (sampler == null) {
  60451. _this._samplers.splice(index, 1);
  60452. index--;
  60453. }
  60454. }
  60455. engine_1.bindSamplers(_this);
  60456. _this._compilationError = "";
  60457. _this._isReady = true;
  60458. if (_this.onCompiled) {
  60459. _this.onCompiled(_this);
  60460. }
  60461. _this.onCompileObservable.notifyObservers(_this);
  60462. _this.onCompileObservable.clear();
  60463. // Unbind mesh reference in fallbacks
  60464. if (_this._fallbacks) {
  60465. _this._fallbacks.unBindMesh();
  60466. }
  60467. if (previousProgram) {
  60468. _this.getEngine()._deleteProgram(previousProgram);
  60469. }
  60470. });
  60471. if (this._program.isParallelCompiled) {
  60472. this._checkIsReady();
  60473. }
  60474. }
  60475. catch (e) {
  60476. this._compilationError = e.message;
  60477. // Let's go through fallbacks then
  60478. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  60479. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  60480. return " " + uniform;
  60481. }));
  60482. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  60483. return " " + attribute;
  60484. }));
  60485. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  60486. if (previousProgram) {
  60487. this._program = previousProgram;
  60488. this._isReady = true;
  60489. if (this.onError) {
  60490. this.onError(this, this._compilationError);
  60491. }
  60492. this.onErrorObservable.notifyObservers(this);
  60493. }
  60494. if (fallbacks && fallbacks.isMoreFallbacks) {
  60495. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  60496. this.defines = fallbacks.reduce(this.defines, this);
  60497. this._prepareEffect();
  60498. }
  60499. else { // Sorry we did everything we can
  60500. if (this.onError) {
  60501. this.onError(this, this._compilationError);
  60502. }
  60503. this.onErrorObservable.notifyObservers(this);
  60504. this.onErrorObservable.clear();
  60505. // Unbind mesh reference in fallbacks
  60506. if (this._fallbacks) {
  60507. this._fallbacks.unBindMesh();
  60508. }
  60509. }
  60510. }
  60511. };
  60512. Object.defineProperty(Effect.prototype, "isSupported", {
  60513. /**
  60514. * Checks if the effect is supported. (Must be called after compilation)
  60515. */
  60516. get: function () {
  60517. return this._compilationError === "";
  60518. },
  60519. enumerable: true,
  60520. configurable: true
  60521. });
  60522. /**
  60523. * Binds a texture to the engine to be used as output of the shader.
  60524. * @param channel Name of the output variable.
  60525. * @param texture Texture to bind.
  60526. * @hidden
  60527. */
  60528. Effect.prototype._bindTexture = function (channel, texture) {
  60529. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  60530. };
  60531. /**
  60532. * Sets a texture on the engine to be used in the shader.
  60533. * @param channel Name of the sampler variable.
  60534. * @param texture Texture to set.
  60535. */
  60536. Effect.prototype.setTexture = function (channel, texture) {
  60537. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60538. };
  60539. /**
  60540. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  60541. * @param channel Name of the sampler variable.
  60542. * @param texture Texture to set.
  60543. */
  60544. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  60545. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60546. };
  60547. /**
  60548. * Sets an array of textures on the engine to be used in the shader.
  60549. * @param channel Name of the variable.
  60550. * @param textures Textures to set.
  60551. */
  60552. Effect.prototype.setTextureArray = function (channel, textures) {
  60553. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60554. var initialPos = this._samplers.indexOf(channel);
  60555. for (var index = 1; index < textures.length; index++) {
  60556. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60557. }
  60558. }
  60559. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60560. };
  60561. /**
  60562. * 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)
  60563. * @param channel Name of the sampler variable.
  60564. * @param postProcess Post process to get the input texture from.
  60565. */
  60566. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60567. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60568. };
  60569. /**
  60570. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60571. * 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)
  60572. * @param channel Name of the sampler variable.
  60573. * @param postProcess Post process to get the output texture from.
  60574. */
  60575. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60576. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60577. };
  60578. /** @hidden */
  60579. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60580. var cache = this._valueCache[uniformName];
  60581. var flag = matrix.updateFlag;
  60582. if (cache !== undefined && cache === flag) {
  60583. return false;
  60584. }
  60585. this._valueCache[uniformName] = flag;
  60586. return true;
  60587. };
  60588. /** @hidden */
  60589. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60590. var cache = this._valueCache[uniformName];
  60591. if (!cache) {
  60592. cache = [x, y];
  60593. this._valueCache[uniformName] = cache;
  60594. return true;
  60595. }
  60596. var changed = false;
  60597. if (cache[0] !== x) {
  60598. cache[0] = x;
  60599. changed = true;
  60600. }
  60601. if (cache[1] !== y) {
  60602. cache[1] = y;
  60603. changed = true;
  60604. }
  60605. return changed;
  60606. };
  60607. /** @hidden */
  60608. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60609. var cache = this._valueCache[uniformName];
  60610. if (!cache) {
  60611. cache = [x, y, z];
  60612. this._valueCache[uniformName] = cache;
  60613. return true;
  60614. }
  60615. var changed = false;
  60616. if (cache[0] !== x) {
  60617. cache[0] = x;
  60618. changed = true;
  60619. }
  60620. if (cache[1] !== y) {
  60621. cache[1] = y;
  60622. changed = true;
  60623. }
  60624. if (cache[2] !== z) {
  60625. cache[2] = z;
  60626. changed = true;
  60627. }
  60628. return changed;
  60629. };
  60630. /** @hidden */
  60631. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60632. var cache = this._valueCache[uniformName];
  60633. if (!cache) {
  60634. cache = [x, y, z, w];
  60635. this._valueCache[uniformName] = cache;
  60636. return true;
  60637. }
  60638. var changed = false;
  60639. if (cache[0] !== x) {
  60640. cache[0] = x;
  60641. changed = true;
  60642. }
  60643. if (cache[1] !== y) {
  60644. cache[1] = y;
  60645. changed = true;
  60646. }
  60647. if (cache[2] !== z) {
  60648. cache[2] = z;
  60649. changed = true;
  60650. }
  60651. if (cache[3] !== w) {
  60652. cache[3] = w;
  60653. changed = true;
  60654. }
  60655. return changed;
  60656. };
  60657. /**
  60658. * Binds a buffer to a uniform.
  60659. * @param buffer Buffer to bind.
  60660. * @param name Name of the uniform variable to bind to.
  60661. */
  60662. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60663. var bufferName = this._uniformBuffersNames[name];
  60664. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60665. return;
  60666. }
  60667. Effect._baseCache[bufferName] = buffer;
  60668. this._engine.bindUniformBufferBase(buffer, bufferName);
  60669. };
  60670. /**
  60671. * Binds block to a uniform.
  60672. * @param blockName Name of the block to bind.
  60673. * @param index Index to bind.
  60674. */
  60675. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60676. this._engine.bindUniformBlock(this._program, blockName, index);
  60677. };
  60678. /**
  60679. * Sets an interger value on a uniform variable.
  60680. * @param uniformName Name of the variable.
  60681. * @param value Value to be set.
  60682. * @returns this effect.
  60683. */
  60684. Effect.prototype.setInt = function (uniformName, value) {
  60685. var cache = this._valueCache[uniformName];
  60686. if (cache !== undefined && cache === value) {
  60687. return this;
  60688. }
  60689. this._valueCache[uniformName] = value;
  60690. this._engine.setInt(this.getUniform(uniformName), value);
  60691. return this;
  60692. };
  60693. /**
  60694. * Sets an int array on a uniform variable.
  60695. * @param uniformName Name of the variable.
  60696. * @param array array to be set.
  60697. * @returns this effect.
  60698. */
  60699. Effect.prototype.setIntArray = function (uniformName, array) {
  60700. this._valueCache[uniformName] = null;
  60701. this._engine.setIntArray(this.getUniform(uniformName), array);
  60702. return this;
  60703. };
  60704. /**
  60705. * 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)
  60706. * @param uniformName Name of the variable.
  60707. * @param array array to be set.
  60708. * @returns this effect.
  60709. */
  60710. Effect.prototype.setIntArray2 = function (uniformName, array) {
  60711. this._valueCache[uniformName] = null;
  60712. this._engine.setIntArray2(this.getUniform(uniformName), array);
  60713. return this;
  60714. };
  60715. /**
  60716. * 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)
  60717. * @param uniformName Name of the variable.
  60718. * @param array array to be set.
  60719. * @returns this effect.
  60720. */
  60721. Effect.prototype.setIntArray3 = function (uniformName, array) {
  60722. this._valueCache[uniformName] = null;
  60723. this._engine.setIntArray3(this.getUniform(uniformName), array);
  60724. return this;
  60725. };
  60726. /**
  60727. * 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)
  60728. * @param uniformName Name of the variable.
  60729. * @param array array to be set.
  60730. * @returns this effect.
  60731. */
  60732. Effect.prototype.setIntArray4 = function (uniformName, array) {
  60733. this._valueCache[uniformName] = null;
  60734. this._engine.setIntArray4(this.getUniform(uniformName), array);
  60735. return this;
  60736. };
  60737. /**
  60738. * Sets an float array on a uniform variable.
  60739. * @param uniformName Name of the variable.
  60740. * @param array array to be set.
  60741. * @returns this effect.
  60742. */
  60743. Effect.prototype.setFloatArray = function (uniformName, array) {
  60744. this._valueCache[uniformName] = null;
  60745. this._engine.setFloatArray(this.getUniform(uniformName), array);
  60746. return this;
  60747. };
  60748. /**
  60749. * 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)
  60750. * @param uniformName Name of the variable.
  60751. * @param array array to be set.
  60752. * @returns this effect.
  60753. */
  60754. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  60755. this._valueCache[uniformName] = null;
  60756. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  60757. return this;
  60758. };
  60759. /**
  60760. * 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)
  60761. * @param uniformName Name of the variable.
  60762. * @param array array to be set.
  60763. * @returns this effect.
  60764. */
  60765. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  60766. this._valueCache[uniformName] = null;
  60767. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  60768. return this;
  60769. };
  60770. /**
  60771. * 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)
  60772. * @param uniformName Name of the variable.
  60773. * @param array array to be set.
  60774. * @returns this effect.
  60775. */
  60776. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  60777. this._valueCache[uniformName] = null;
  60778. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  60779. return this;
  60780. };
  60781. /**
  60782. * Sets an array on a uniform variable.
  60783. * @param uniformName Name of the variable.
  60784. * @param array array to be set.
  60785. * @returns this effect.
  60786. */
  60787. Effect.prototype.setArray = function (uniformName, array) {
  60788. this._valueCache[uniformName] = null;
  60789. this._engine.setArray(this.getUniform(uniformName), array);
  60790. return this;
  60791. };
  60792. /**
  60793. * 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)
  60794. * @param uniformName Name of the variable.
  60795. * @param array array to be set.
  60796. * @returns this effect.
  60797. */
  60798. Effect.prototype.setArray2 = function (uniformName, array) {
  60799. this._valueCache[uniformName] = null;
  60800. this._engine.setArray2(this.getUniform(uniformName), array);
  60801. return this;
  60802. };
  60803. /**
  60804. * 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)
  60805. * @param uniformName Name of the variable.
  60806. * @param array array to be set.
  60807. * @returns this effect.
  60808. */
  60809. Effect.prototype.setArray3 = function (uniformName, array) {
  60810. this._valueCache[uniformName] = null;
  60811. this._engine.setArray3(this.getUniform(uniformName), array);
  60812. return this;
  60813. };
  60814. /**
  60815. * 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)
  60816. * @param uniformName Name of the variable.
  60817. * @param array array to be set.
  60818. * @returns this effect.
  60819. */
  60820. Effect.prototype.setArray4 = function (uniformName, array) {
  60821. this._valueCache[uniformName] = null;
  60822. this._engine.setArray4(this.getUniform(uniformName), array);
  60823. return this;
  60824. };
  60825. /**
  60826. * Sets matrices on a uniform variable.
  60827. * @param uniformName Name of the variable.
  60828. * @param matrices matrices to be set.
  60829. * @returns this effect.
  60830. */
  60831. Effect.prototype.setMatrices = function (uniformName, matrices) {
  60832. if (!matrices) {
  60833. return this;
  60834. }
  60835. this._valueCache[uniformName] = null;
  60836. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  60837. return this;
  60838. };
  60839. /**
  60840. * Sets matrix on a uniform variable.
  60841. * @param uniformName Name of the variable.
  60842. * @param matrix matrix to be set.
  60843. * @returns this effect.
  60844. */
  60845. Effect.prototype.setMatrix = function (uniformName, matrix) {
  60846. if (this._cacheMatrix(uniformName, matrix)) {
  60847. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  60848. }
  60849. return this;
  60850. };
  60851. /**
  60852. * 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)
  60853. * @param uniformName Name of the variable.
  60854. * @param matrix matrix to be set.
  60855. * @returns this effect.
  60856. */
  60857. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  60858. this._valueCache[uniformName] = null;
  60859. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  60860. return this;
  60861. };
  60862. /**
  60863. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  60864. * @param uniformName Name of the variable.
  60865. * @param matrix matrix to be set.
  60866. * @returns this effect.
  60867. */
  60868. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  60869. this._valueCache[uniformName] = null;
  60870. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  60871. return this;
  60872. };
  60873. /**
  60874. * Sets a float on a uniform variable.
  60875. * @param uniformName Name of the variable.
  60876. * @param value value to be set.
  60877. * @returns this effect.
  60878. */
  60879. Effect.prototype.setFloat = function (uniformName, value) {
  60880. var cache = this._valueCache[uniformName];
  60881. if (cache !== undefined && cache === value) {
  60882. return this;
  60883. }
  60884. this._valueCache[uniformName] = value;
  60885. this._engine.setFloat(this.getUniform(uniformName), value);
  60886. return this;
  60887. };
  60888. /**
  60889. * Sets a boolean on a uniform variable.
  60890. * @param uniformName Name of the variable.
  60891. * @param bool value to be set.
  60892. * @returns this effect.
  60893. */
  60894. Effect.prototype.setBool = function (uniformName, bool) {
  60895. var cache = this._valueCache[uniformName];
  60896. if (cache !== undefined && cache === bool) {
  60897. return this;
  60898. }
  60899. this._valueCache[uniformName] = bool;
  60900. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  60901. return this;
  60902. };
  60903. /**
  60904. * Sets a Vector2 on a uniform variable.
  60905. * @param uniformName Name of the variable.
  60906. * @param vector2 vector2 to be set.
  60907. * @returns this effect.
  60908. */
  60909. Effect.prototype.setVector2 = function (uniformName, vector2) {
  60910. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  60911. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  60912. }
  60913. return this;
  60914. };
  60915. /**
  60916. * Sets a float2 on a uniform variable.
  60917. * @param uniformName Name of the variable.
  60918. * @param x First float in float2.
  60919. * @param y Second float in float2.
  60920. * @returns this effect.
  60921. */
  60922. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  60923. if (this._cacheFloat2(uniformName, x, y)) {
  60924. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  60925. }
  60926. return this;
  60927. };
  60928. /**
  60929. * Sets a Vector3 on a uniform variable.
  60930. * @param uniformName Name of the variable.
  60931. * @param vector3 Value to be set.
  60932. * @returns this effect.
  60933. */
  60934. Effect.prototype.setVector3 = function (uniformName, vector3) {
  60935. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  60936. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  60937. }
  60938. return this;
  60939. };
  60940. /**
  60941. * Sets a float3 on a uniform variable.
  60942. * @param uniformName Name of the variable.
  60943. * @param x First float in float3.
  60944. * @param y Second float in float3.
  60945. * @param z Third float in float3.
  60946. * @returns this effect.
  60947. */
  60948. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  60949. if (this._cacheFloat3(uniformName, x, y, z)) {
  60950. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  60951. }
  60952. return this;
  60953. };
  60954. /**
  60955. * Sets a Vector4 on a uniform variable.
  60956. * @param uniformName Name of the variable.
  60957. * @param vector4 Value to be set.
  60958. * @returns this effect.
  60959. */
  60960. Effect.prototype.setVector4 = function (uniformName, vector4) {
  60961. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  60962. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  60963. }
  60964. return this;
  60965. };
  60966. /**
  60967. * Sets a float4 on a uniform variable.
  60968. * @param uniformName Name of the variable.
  60969. * @param x First float in float4.
  60970. * @param y Second float in float4.
  60971. * @param z Third float in float4.
  60972. * @param w Fourth float in float4.
  60973. * @returns this effect.
  60974. */
  60975. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  60976. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  60977. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  60978. }
  60979. return this;
  60980. };
  60981. /**
  60982. * Sets a Color3 on a uniform variable.
  60983. * @param uniformName Name of the variable.
  60984. * @param color3 Value to be set.
  60985. * @returns this effect.
  60986. */
  60987. Effect.prototype.setColor3 = function (uniformName, color3) {
  60988. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  60989. this._engine.setColor3(this.getUniform(uniformName), color3);
  60990. }
  60991. return this;
  60992. };
  60993. /**
  60994. * Sets a Color4 on a uniform variable.
  60995. * @param uniformName Name of the variable.
  60996. * @param color3 Value to be set.
  60997. * @param alpha Alpha value to be set.
  60998. * @returns this effect.
  60999. */
  61000. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  61001. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  61002. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  61003. }
  61004. return this;
  61005. };
  61006. /**
  61007. * Sets a Color4 on a uniform variable
  61008. * @param uniformName defines the name of the variable
  61009. * @param color4 defines the value to be set
  61010. * @returns this effect.
  61011. */
  61012. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  61013. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  61014. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  61015. }
  61016. return this;
  61017. };
  61018. /**
  61019. * This function will add a new shader to the shader store
  61020. * @param name the name of the shader
  61021. * @param pixelShader optional pixel shader content
  61022. * @param vertexShader optional vertex shader content
  61023. */
  61024. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  61025. if (pixelShader) {
  61026. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  61027. }
  61028. if (vertexShader) {
  61029. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  61030. }
  61031. };
  61032. /**
  61033. * Resets the cache of effects.
  61034. */
  61035. Effect.ResetCache = function () {
  61036. Effect._baseCache = {};
  61037. };
  61038. /**
  61039. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  61040. */
  61041. Effect.ShadersRepository = "src/Shaders/";
  61042. Effect._uniqueIdSeed = 0;
  61043. Effect._baseCache = {};
  61044. /**
  61045. * Store of each shader (The can be looked up using effect.key)
  61046. */
  61047. Effect.ShadersStore = {};
  61048. /**
  61049. * Store of each included file for a shader (The can be looked up using effect.key)
  61050. */
  61051. Effect.IncludesShadersStore = {};
  61052. return Effect;
  61053. }());
  61054. /***/ }),
  61055. /***/ "./Materials/fresnelParameters.ts":
  61056. /*!****************************************!*\
  61057. !*** ./Materials/fresnelParameters.ts ***!
  61058. \****************************************/
  61059. /*! exports provided: FresnelParameters */
  61060. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61061. "use strict";
  61062. __webpack_require__.r(__webpack_exports__);
  61063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  61064. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  61065. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61066. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  61067. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61068. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61069. /**
  61070. * This represents all the required information to add a fresnel effect on a material:
  61071. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  61072. */
  61073. var FresnelParameters = /** @class */ (function () {
  61074. function FresnelParameters() {
  61075. this._isEnabled = true;
  61076. /**
  61077. * Define the color used on edges (grazing angle)
  61078. */
  61079. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  61080. /**
  61081. * Define the color used on center
  61082. */
  61083. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  61084. /**
  61085. * Define bias applied to computed fresnel term
  61086. */
  61087. this.bias = 0;
  61088. /**
  61089. * Defined the power exponent applied to fresnel term
  61090. */
  61091. this.power = 1;
  61092. }
  61093. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  61094. /**
  61095. * Define if the fresnel effect is enable or not.
  61096. */
  61097. get: function () {
  61098. return this._isEnabled;
  61099. },
  61100. set: function (value) {
  61101. if (this._isEnabled === value) {
  61102. return;
  61103. }
  61104. this._isEnabled = value;
  61105. _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);
  61106. },
  61107. enumerable: true,
  61108. configurable: true
  61109. });
  61110. /**
  61111. * Clones the current fresnel and its valuues
  61112. * @returns a clone fresnel configuration
  61113. */
  61114. FresnelParameters.prototype.clone = function () {
  61115. var newFresnelParameters = new FresnelParameters();
  61116. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  61117. return newFresnelParameters;
  61118. };
  61119. /**
  61120. * Serializes the current fresnel parameters to a JSON representation.
  61121. * @return the JSON serialization
  61122. */
  61123. FresnelParameters.prototype.serialize = function () {
  61124. var serializationObject = {};
  61125. serializationObject.isEnabled = this.isEnabled;
  61126. serializationObject.leftColor = this.leftColor.asArray();
  61127. serializationObject.rightColor = this.rightColor.asArray();
  61128. serializationObject.bias = this.bias;
  61129. serializationObject.power = this.power;
  61130. return serializationObject;
  61131. };
  61132. /**
  61133. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  61134. * @param parsedFresnelParameters Define the JSON representation
  61135. * @returns the parsed parameters
  61136. */
  61137. FresnelParameters.Parse = function (parsedFresnelParameters) {
  61138. var fresnelParameters = new FresnelParameters();
  61139. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  61140. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  61141. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  61142. fresnelParameters.bias = parsedFresnelParameters.bias;
  61143. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  61144. return fresnelParameters;
  61145. };
  61146. return FresnelParameters;
  61147. }());
  61148. // References the dependencies.
  61149. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  61150. /***/ }),
  61151. /***/ "./Materials/imageProcessingConfiguration.ts":
  61152. /*!***************************************************!*\
  61153. !*** ./Materials/imageProcessingConfiguration.ts ***!
  61154. \***************************************************/
  61155. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  61156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61157. "use strict";
  61158. __webpack_require__.r(__webpack_exports__);
  61159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  61160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  61161. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61162. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61163. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61164. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61166. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  61167. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  61168. /**
  61169. * @hidden
  61170. */
  61171. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  61172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  61173. function ImageProcessingConfigurationDefines() {
  61174. var _this = _super.call(this) || this;
  61175. _this.IMAGEPROCESSING = false;
  61176. _this.VIGNETTE = false;
  61177. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  61178. _this.VIGNETTEBLENDMODEOPAQUE = false;
  61179. _this.TONEMAPPING = false;
  61180. _this.TONEMAPPING_ACES = false;
  61181. _this.CONTRAST = false;
  61182. _this.COLORCURVES = false;
  61183. _this.COLORGRADING = false;
  61184. _this.COLORGRADING3D = false;
  61185. _this.SAMPLER3DGREENDEPTH = false;
  61186. _this.SAMPLER3DBGRMAP = false;
  61187. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  61188. _this.EXPOSURE = false;
  61189. _this.rebuild();
  61190. return _this;
  61191. }
  61192. return ImageProcessingConfigurationDefines;
  61193. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  61194. /**
  61195. * This groups together the common properties used for image processing either in direct forward pass
  61196. * or through post processing effect depending on the use of the image processing pipeline in your scene
  61197. * or not.
  61198. */
  61199. var ImageProcessingConfiguration = /** @class */ (function () {
  61200. function ImageProcessingConfiguration() {
  61201. /**
  61202. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  61203. */
  61204. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  61205. this._colorCurvesEnabled = false;
  61206. this._colorGradingEnabled = false;
  61207. this._colorGradingWithGreenDepth = true;
  61208. this._colorGradingBGR = true;
  61209. /** @hidden */
  61210. this._exposure = 1.0;
  61211. this._toneMappingEnabled = false;
  61212. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  61213. this._contrast = 1.0;
  61214. /**
  61215. * Vignette stretch size.
  61216. */
  61217. this.vignetteStretch = 0;
  61218. /**
  61219. * Vignette centre X Offset.
  61220. */
  61221. this.vignetteCentreX = 0;
  61222. /**
  61223. * Vignette centre Y Offset.
  61224. */
  61225. this.vignetteCentreY = 0;
  61226. /**
  61227. * Vignette weight or intensity of the vignette effect.
  61228. */
  61229. this.vignetteWeight = 1.5;
  61230. /**
  61231. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  61232. * if vignetteEnabled is set to true.
  61233. */
  61234. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  61235. /**
  61236. * Camera field of view used by the Vignette effect.
  61237. */
  61238. this.vignetteCameraFov = 0.5;
  61239. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  61240. this._vignetteEnabled = false;
  61241. this._applyByPostProcess = false;
  61242. this._isEnabled = true;
  61243. /**
  61244. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  61245. */
  61246. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61247. }
  61248. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  61249. /**
  61250. * Gets wether the color curves effect is enabled.
  61251. */
  61252. get: function () {
  61253. return this._colorCurvesEnabled;
  61254. },
  61255. /**
  61256. * Sets wether the color curves effect is enabled.
  61257. */
  61258. set: function (value) {
  61259. if (this._colorCurvesEnabled === value) {
  61260. return;
  61261. }
  61262. this._colorCurvesEnabled = value;
  61263. this._updateParameters();
  61264. },
  61265. enumerable: true,
  61266. configurable: true
  61267. });
  61268. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  61269. /**
  61270. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61271. */
  61272. get: function () {
  61273. return this._colorGradingTexture;
  61274. },
  61275. /**
  61276. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61277. */
  61278. set: function (value) {
  61279. if (this._colorGradingTexture === value) {
  61280. return;
  61281. }
  61282. this._colorGradingTexture = value;
  61283. this._updateParameters();
  61284. },
  61285. enumerable: true,
  61286. configurable: true
  61287. });
  61288. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  61289. /**
  61290. * Gets wether the color grading effect is enabled.
  61291. */
  61292. get: function () {
  61293. return this._colorGradingEnabled;
  61294. },
  61295. /**
  61296. * Sets wether the color grading effect is enabled.
  61297. */
  61298. set: function (value) {
  61299. if (this._colorGradingEnabled === value) {
  61300. return;
  61301. }
  61302. this._colorGradingEnabled = value;
  61303. this._updateParameters();
  61304. },
  61305. enumerable: true,
  61306. configurable: true
  61307. });
  61308. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  61309. /**
  61310. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  61311. */
  61312. get: function () {
  61313. return this._colorGradingWithGreenDepth;
  61314. },
  61315. /**
  61316. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  61317. */
  61318. set: function (value) {
  61319. if (this._colorGradingWithGreenDepth === value) {
  61320. return;
  61321. }
  61322. this._colorGradingWithGreenDepth = value;
  61323. this._updateParameters();
  61324. },
  61325. enumerable: true,
  61326. configurable: true
  61327. });
  61328. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  61329. /**
  61330. * Gets wether the color grading texture contains BGR values.
  61331. */
  61332. get: function () {
  61333. return this._colorGradingBGR;
  61334. },
  61335. /**
  61336. * Sets wether the color grading texture contains BGR values.
  61337. */
  61338. set: function (value) {
  61339. if (this._colorGradingBGR === value) {
  61340. return;
  61341. }
  61342. this._colorGradingBGR = value;
  61343. this._updateParameters();
  61344. },
  61345. enumerable: true,
  61346. configurable: true
  61347. });
  61348. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  61349. /**
  61350. * Gets the Exposure used in the effect.
  61351. */
  61352. get: function () {
  61353. return this._exposure;
  61354. },
  61355. /**
  61356. * Sets the Exposure used in the effect.
  61357. */
  61358. set: function (value) {
  61359. if (this._exposure === value) {
  61360. return;
  61361. }
  61362. this._exposure = value;
  61363. this._updateParameters();
  61364. },
  61365. enumerable: true,
  61366. configurable: true
  61367. });
  61368. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  61369. /**
  61370. * Gets wether the tone mapping effect is enabled.
  61371. */
  61372. get: function () {
  61373. return this._toneMappingEnabled;
  61374. },
  61375. /**
  61376. * Sets wether the tone mapping effect is enabled.
  61377. */
  61378. set: function (value) {
  61379. if (this._toneMappingEnabled === value) {
  61380. return;
  61381. }
  61382. this._toneMappingEnabled = value;
  61383. this._updateParameters();
  61384. },
  61385. enumerable: true,
  61386. configurable: true
  61387. });
  61388. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  61389. /**
  61390. * Gets the type of tone mapping effect.
  61391. */
  61392. get: function () {
  61393. return this._toneMappingType;
  61394. },
  61395. /**
  61396. * Sets the type of tone mapping effect used in BabylonJS.
  61397. */
  61398. set: function (value) {
  61399. if (this._toneMappingType === value) {
  61400. return;
  61401. }
  61402. this._toneMappingType = value;
  61403. this._updateParameters();
  61404. },
  61405. enumerable: true,
  61406. configurable: true
  61407. });
  61408. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  61409. /**
  61410. * Gets the contrast used in the effect.
  61411. */
  61412. get: function () {
  61413. return this._contrast;
  61414. },
  61415. /**
  61416. * Sets the contrast used in the effect.
  61417. */
  61418. set: function (value) {
  61419. if (this._contrast === value) {
  61420. return;
  61421. }
  61422. this._contrast = value;
  61423. this._updateParameters();
  61424. },
  61425. enumerable: true,
  61426. configurable: true
  61427. });
  61428. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  61429. /**
  61430. * Gets the vignette blend mode allowing different kind of effect.
  61431. */
  61432. get: function () {
  61433. return this._vignetteBlendMode;
  61434. },
  61435. /**
  61436. * Sets the vignette blend mode allowing different kind of effect.
  61437. */
  61438. set: function (value) {
  61439. if (this._vignetteBlendMode === value) {
  61440. return;
  61441. }
  61442. this._vignetteBlendMode = value;
  61443. this._updateParameters();
  61444. },
  61445. enumerable: true,
  61446. configurable: true
  61447. });
  61448. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  61449. /**
  61450. * Gets wether the vignette effect is enabled.
  61451. */
  61452. get: function () {
  61453. return this._vignetteEnabled;
  61454. },
  61455. /**
  61456. * Sets wether the vignette effect is enabled.
  61457. */
  61458. set: function (value) {
  61459. if (this._vignetteEnabled === value) {
  61460. return;
  61461. }
  61462. this._vignetteEnabled = value;
  61463. this._updateParameters();
  61464. },
  61465. enumerable: true,
  61466. configurable: true
  61467. });
  61468. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  61469. /**
  61470. * Gets wether the image processing is applied through a post process or not.
  61471. */
  61472. get: function () {
  61473. return this._applyByPostProcess;
  61474. },
  61475. /**
  61476. * Sets wether the image processing is applied through a post process or not.
  61477. */
  61478. set: function (value) {
  61479. if (this._applyByPostProcess === value) {
  61480. return;
  61481. }
  61482. this._applyByPostProcess = value;
  61483. this._updateParameters();
  61484. },
  61485. enumerable: true,
  61486. configurable: true
  61487. });
  61488. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  61489. /**
  61490. * Gets wether the image processing is enabled or not.
  61491. */
  61492. get: function () {
  61493. return this._isEnabled;
  61494. },
  61495. /**
  61496. * Sets wether the image processing is enabled or not.
  61497. */
  61498. set: function (value) {
  61499. if (this._isEnabled === value) {
  61500. return;
  61501. }
  61502. this._isEnabled = value;
  61503. this._updateParameters();
  61504. },
  61505. enumerable: true,
  61506. configurable: true
  61507. });
  61508. /**
  61509. * Method called each time the image processing information changes requires to recompile the effect.
  61510. */
  61511. ImageProcessingConfiguration.prototype._updateParameters = function () {
  61512. this.onUpdateParameters.notifyObservers(this);
  61513. };
  61514. /**
  61515. * Gets the current class name.
  61516. * @return "ImageProcessingConfiguration"
  61517. */
  61518. ImageProcessingConfiguration.prototype.getClassName = function () {
  61519. return "ImageProcessingConfiguration";
  61520. };
  61521. /**
  61522. * Prepare the list of uniforms associated with the Image Processing effects.
  61523. * @param uniforms The list of uniforms used in the effect
  61524. * @param defines the list of defines currently in use
  61525. */
  61526. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  61527. if (defines.EXPOSURE) {
  61528. uniforms.push("exposureLinear");
  61529. }
  61530. if (defines.CONTRAST) {
  61531. uniforms.push("contrast");
  61532. }
  61533. if (defines.COLORGRADING) {
  61534. uniforms.push("colorTransformSettings");
  61535. }
  61536. if (defines.VIGNETTE) {
  61537. uniforms.push("vInverseScreenSize");
  61538. uniforms.push("vignetteSettings1");
  61539. uniforms.push("vignetteSettings2");
  61540. }
  61541. if (defines.COLORCURVES) {
  61542. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  61543. }
  61544. };
  61545. /**
  61546. * Prepare the list of samplers associated with the Image Processing effects.
  61547. * @param samplersList The list of uniforms used in the effect
  61548. * @param defines the list of defines currently in use
  61549. */
  61550. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  61551. if (defines.COLORGRADING) {
  61552. samplersList.push("txColorTransform");
  61553. }
  61554. };
  61555. /**
  61556. * Prepare the list of defines associated to the shader.
  61557. * @param defines the list of defines to complete
  61558. * @param forPostProcess Define if we are currently in post process mode or not
  61559. */
  61560. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61561. if (forPostProcess === void 0) { forPostProcess = false; }
  61562. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61563. defines.VIGNETTE = false;
  61564. defines.TONEMAPPING = false;
  61565. defines.TONEMAPPING_ACES = false;
  61566. defines.CONTRAST = false;
  61567. defines.EXPOSURE = false;
  61568. defines.COLORCURVES = false;
  61569. defines.COLORGRADING = false;
  61570. defines.COLORGRADING3D = false;
  61571. defines.IMAGEPROCESSING = false;
  61572. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61573. return;
  61574. }
  61575. defines.VIGNETTE = this.vignetteEnabled;
  61576. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61577. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61578. defines.TONEMAPPING = this.toneMappingEnabled;
  61579. switch (this._toneMappingType) {
  61580. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61581. defines.TONEMAPPING_ACES = true;
  61582. break;
  61583. default:
  61584. defines.TONEMAPPING_ACES = false;
  61585. break;
  61586. }
  61587. defines.CONTRAST = (this.contrast !== 1.0);
  61588. defines.EXPOSURE = (this.exposure !== 1.0);
  61589. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61590. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61591. if (defines.COLORGRADING) {
  61592. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61593. }
  61594. else {
  61595. defines.COLORGRADING3D = false;
  61596. }
  61597. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61598. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61599. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61600. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61601. };
  61602. /**
  61603. * Returns true if all the image processing information are ready.
  61604. * @returns True if ready, otherwise, false
  61605. */
  61606. ImageProcessingConfiguration.prototype.isReady = function () {
  61607. // Color Grading texure can not be none blocking.
  61608. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61609. };
  61610. /**
  61611. * Binds the image processing to the shader.
  61612. * @param effect The effect to bind to
  61613. * @param aspectRatio Define the current aspect ratio of the effect
  61614. */
  61615. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61616. if (aspectRatio === void 0) { aspectRatio = 1; }
  61617. // Color Curves
  61618. if (this._colorCurvesEnabled && this.colorCurves) {
  61619. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61620. }
  61621. // Vignette
  61622. if (this._vignetteEnabled) {
  61623. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61624. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61625. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61626. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61627. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61628. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61629. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61630. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61631. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61632. var vignettePower = -2.0 * this.vignetteWeight;
  61633. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61634. }
  61635. // Exposure
  61636. effect.setFloat("exposureLinear", this.exposure);
  61637. // Contrast
  61638. effect.setFloat("contrast", this.contrast);
  61639. // Color transform settings
  61640. if (this.colorGradingTexture) {
  61641. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61642. var textureSize = this.colorGradingTexture.getSize().height;
  61643. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61644. 0.5 / textureSize, // textureOffset
  61645. textureSize, // textureSize
  61646. this.colorGradingTexture.level // weight
  61647. );
  61648. }
  61649. };
  61650. /**
  61651. * Clones the current image processing instance.
  61652. * @return The cloned image processing
  61653. */
  61654. ImageProcessingConfiguration.prototype.clone = function () {
  61655. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61656. };
  61657. /**
  61658. * Serializes the current image processing instance to a json representation.
  61659. * @return a JSON representation
  61660. */
  61661. ImageProcessingConfiguration.prototype.serialize = function () {
  61662. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61663. };
  61664. /**
  61665. * Parses the image processing from a json representation.
  61666. * @param source the JSON source to parse
  61667. * @return The parsed image processing
  61668. */
  61669. ImageProcessingConfiguration.Parse = function (source) {
  61670. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61671. };
  61672. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61673. /**
  61674. * Used to apply the vignette as a mix with the pixel color.
  61675. */
  61676. get: function () {
  61677. return this._VIGNETTEMODE_MULTIPLY;
  61678. },
  61679. enumerable: true,
  61680. configurable: true
  61681. });
  61682. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61683. /**
  61684. * Used to apply the vignette as a replacement of the pixel color.
  61685. */
  61686. get: function () {
  61687. return this._VIGNETTEMODE_OPAQUE;
  61688. },
  61689. enumerable: true,
  61690. configurable: true
  61691. });
  61692. /**
  61693. * Default tone mapping applied in BabylonJS.
  61694. */
  61695. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61696. /**
  61697. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61698. * to other engines rendering to increase portability.
  61699. */
  61700. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61701. // Static constants associated to the image processing.
  61702. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  61703. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  61704. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61705. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  61706. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  61707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61709. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  61710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  61712. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  61713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61715. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  61716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61718. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  61719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61721. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  61722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61724. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  61725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61727. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  61728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61730. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  61731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61733. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  61734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61736. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  61737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61739. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  61740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61742. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  61743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61745. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  61746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  61748. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  61749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61751. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  61752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61754. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  61755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61757. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  61758. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61759. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61760. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  61761. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61763. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  61764. return ImageProcessingConfiguration;
  61765. }());
  61766. // References the dependencies.
  61767. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  61768. /***/ }),
  61769. /***/ "./Materials/index.ts":
  61770. /*!****************************!*\
  61771. !*** ./Materials/index.ts ***!
  61772. \****************************/
  61773. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, MultiRenderTarget, ProceduralTexture, ProceduralTextureSceneComponent, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture */
  61774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61775. "use strict";
  61776. __webpack_require__.r(__webpack_exports__);
  61777. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  61778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  61779. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  61780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  61781. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  61782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  61783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  61784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  61785. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  61786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  61787. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  61788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  61789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  61790. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  61791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  61792. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  61793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  61794. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  61795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  61796. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  61797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  61798. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  61799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  61800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  61801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  61802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  61803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  61804. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  61805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  61806. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  61807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  61808. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  61809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  61810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  61811. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  61812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  61813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  61814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  61815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  61816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  61817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  61818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  61819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  61820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  61821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  61822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  61823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  61824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  61825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  61826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  61827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  61828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  61829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  61830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  61831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  61832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  61833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  61834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  61835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  61836. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  61838. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  61839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  61840. /***/ }),
  61841. /***/ "./Materials/material.ts":
  61842. /*!*******************************!*\
  61843. !*** ./Materials/material.ts ***!
  61844. \*******************************/
  61845. /*! exports provided: Material */
  61846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61847. "use strict";
  61848. __webpack_require__.r(__webpack_exports__);
  61849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  61850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61851. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61852. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61853. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61855. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  61856. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  61857. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61858. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61859. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  61860. /**
  61861. * Base class for the main features of a material in Babylon.js
  61862. */
  61863. var Material = /** @class */ (function () {
  61864. /**
  61865. * Creates a material instance
  61866. * @param name defines the name of the material
  61867. * @param scene defines the scene to reference
  61868. * @param doNotAdd specifies if the material should be added to the scene
  61869. */
  61870. function Material(name, scene, doNotAdd) {
  61871. /**
  61872. * Gets or sets user defined metadata
  61873. */
  61874. this.metadata = null;
  61875. /**
  61876. * For internal use only. Please do not use.
  61877. */
  61878. this.reservedDataStore = null;
  61879. /**
  61880. * Specifies if the ready state should be checked on each call
  61881. */
  61882. this.checkReadyOnEveryCall = false;
  61883. /**
  61884. * Specifies if the ready state should be checked once
  61885. */
  61886. this.checkReadyOnlyOnce = false;
  61887. /**
  61888. * The state of the material
  61889. */
  61890. this.state = "";
  61891. /**
  61892. * The alpha value of the material
  61893. */
  61894. this._alpha = 1.0;
  61895. /**
  61896. * Specifies if back face culling is enabled
  61897. */
  61898. this._backFaceCulling = true;
  61899. /**
  61900. * Specifies if the material should be serialized
  61901. */
  61902. this.doNotSerialize = false;
  61903. /**
  61904. * @hidden
  61905. */
  61906. this._storeEffectOnSubMeshes = false;
  61907. /**
  61908. * An event triggered when the material is disposed
  61909. */
  61910. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61911. /**
  61912. * Stores the value of the alpha mode
  61913. */
  61914. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  61915. /**
  61916. * Stores the state of the need depth pre-pass value
  61917. */
  61918. this._needDepthPrePass = false;
  61919. /**
  61920. * Specifies if depth writing should be disabled
  61921. */
  61922. this.disableDepthWrite = false;
  61923. /**
  61924. * Specifies if depth writing should be forced
  61925. */
  61926. this.forceDepthWrite = false;
  61927. /**
  61928. * Specifies if there should be a separate pass for culling
  61929. */
  61930. this.separateCullingPass = false;
  61931. /**
  61932. * Stores the state specifing if fog should be enabled
  61933. */
  61934. this._fogEnabled = true;
  61935. /**
  61936. * Stores the size of points
  61937. */
  61938. this.pointSize = 1.0;
  61939. /**
  61940. * Stores the z offset value
  61941. */
  61942. this.zOffset = 0;
  61943. /**
  61944. * @hidden
  61945. * Specifies if the material was previously ready
  61946. */
  61947. this._wasPreviouslyReady = false;
  61948. /**
  61949. * Stores the fill mode state
  61950. */
  61951. this._fillMode = Material.TriangleFillMode;
  61952. /** @hidden */
  61953. this._indexInSceneMaterialArray = -1;
  61954. this.name = name;
  61955. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  61956. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  61957. this.uniqueId = this._scene.getUniqueId();
  61958. if (this._scene.useRightHandedSystem) {
  61959. this.sideOrientation = Material.ClockWiseSideOrientation;
  61960. }
  61961. else {
  61962. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  61963. }
  61964. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  61965. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  61966. if (!doNotAdd) {
  61967. this._scene.addMaterial(this);
  61968. }
  61969. if (this._scene.useMaterialMeshMap) {
  61970. this.meshMap = {};
  61971. }
  61972. }
  61973. Object.defineProperty(Material.prototype, "alpha", {
  61974. /**
  61975. * Gets the alpha value of the material
  61976. */
  61977. get: function () {
  61978. return this._alpha;
  61979. },
  61980. /**
  61981. * Sets the alpha value of the material
  61982. */
  61983. set: function (value) {
  61984. if (this._alpha === value) {
  61985. return;
  61986. }
  61987. this._alpha = value;
  61988. this.markAsDirty(Material.MiscDirtyFlag);
  61989. },
  61990. enumerable: true,
  61991. configurable: true
  61992. });
  61993. Object.defineProperty(Material.prototype, "backFaceCulling", {
  61994. /**
  61995. * Gets the back-face culling state
  61996. */
  61997. get: function () {
  61998. return this._backFaceCulling;
  61999. },
  62000. /**
  62001. * Sets the back-face culling state
  62002. */
  62003. set: function (value) {
  62004. if (this._backFaceCulling === value) {
  62005. return;
  62006. }
  62007. this._backFaceCulling = value;
  62008. this.markAsDirty(Material.TextureDirtyFlag);
  62009. },
  62010. enumerable: true,
  62011. configurable: true
  62012. });
  62013. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  62014. /**
  62015. * Gets a boolean indicating that current material needs to register RTT
  62016. */
  62017. get: function () {
  62018. return false;
  62019. },
  62020. enumerable: true,
  62021. configurable: true
  62022. });
  62023. Object.defineProperty(Material.prototype, "onDispose", {
  62024. /**
  62025. * Called during a dispose event
  62026. */
  62027. set: function (callback) {
  62028. if (this._onDisposeObserver) {
  62029. this.onDisposeObservable.remove(this._onDisposeObserver);
  62030. }
  62031. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  62032. },
  62033. enumerable: true,
  62034. configurable: true
  62035. });
  62036. Object.defineProperty(Material.prototype, "onBindObservable", {
  62037. /**
  62038. * An event triggered when the material is bound
  62039. */
  62040. get: function () {
  62041. if (!this._onBindObservable) {
  62042. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62043. }
  62044. return this._onBindObservable;
  62045. },
  62046. enumerable: true,
  62047. configurable: true
  62048. });
  62049. Object.defineProperty(Material.prototype, "onBind", {
  62050. /**
  62051. * Called during a bind event
  62052. */
  62053. set: function (callback) {
  62054. if (this._onBindObserver) {
  62055. this.onBindObservable.remove(this._onBindObserver);
  62056. }
  62057. this._onBindObserver = this.onBindObservable.add(callback);
  62058. },
  62059. enumerable: true,
  62060. configurable: true
  62061. });
  62062. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  62063. /**
  62064. * An event triggered when the material is unbound
  62065. */
  62066. get: function () {
  62067. if (!this._onUnBindObservable) {
  62068. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62069. }
  62070. return this._onUnBindObservable;
  62071. },
  62072. enumerable: true,
  62073. configurable: true
  62074. });
  62075. Object.defineProperty(Material.prototype, "alphaMode", {
  62076. /**
  62077. * Gets the value of the alpha mode
  62078. */
  62079. get: function () {
  62080. return this._alphaMode;
  62081. },
  62082. /**
  62083. * Sets the value of the alpha mode.
  62084. *
  62085. * | Value | Type | Description |
  62086. * | --- | --- | --- |
  62087. * | 0 | ALPHA_DISABLE | |
  62088. * | 1 | ALPHA_ADD | |
  62089. * | 2 | ALPHA_COMBINE | |
  62090. * | 3 | ALPHA_SUBTRACT | |
  62091. * | 4 | ALPHA_MULTIPLY | |
  62092. * | 5 | ALPHA_MAXIMIZED | |
  62093. * | 6 | ALPHA_ONEONE | |
  62094. * | 7 | ALPHA_PREMULTIPLIED | |
  62095. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  62096. * | 9 | ALPHA_INTERPOLATE | |
  62097. * | 10 | ALPHA_SCREENMODE | |
  62098. *
  62099. */
  62100. set: function (value) {
  62101. if (this._alphaMode === value) {
  62102. return;
  62103. }
  62104. this._alphaMode = value;
  62105. this.markAsDirty(Material.TextureDirtyFlag);
  62106. },
  62107. enumerable: true,
  62108. configurable: true
  62109. });
  62110. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  62111. /**
  62112. * Gets the depth pre-pass value
  62113. */
  62114. get: function () {
  62115. return this._needDepthPrePass;
  62116. },
  62117. /**
  62118. * Sets the need depth pre-pass value
  62119. */
  62120. set: function (value) {
  62121. if (this._needDepthPrePass === value) {
  62122. return;
  62123. }
  62124. this._needDepthPrePass = value;
  62125. if (this._needDepthPrePass) {
  62126. this.checkReadyOnEveryCall = true;
  62127. }
  62128. },
  62129. enumerable: true,
  62130. configurable: true
  62131. });
  62132. Object.defineProperty(Material.prototype, "fogEnabled", {
  62133. /**
  62134. * Gets the value of the fog enabled state
  62135. */
  62136. get: function () {
  62137. return this._fogEnabled;
  62138. },
  62139. /**
  62140. * Sets the state for enabling fog
  62141. */
  62142. set: function (value) {
  62143. if (this._fogEnabled === value) {
  62144. return;
  62145. }
  62146. this._fogEnabled = value;
  62147. this.markAsDirty(Material.MiscDirtyFlag);
  62148. },
  62149. enumerable: true,
  62150. configurable: true
  62151. });
  62152. Object.defineProperty(Material.prototype, "wireframe", {
  62153. /**
  62154. * Gets a value specifying if wireframe mode is enabled
  62155. */
  62156. get: function () {
  62157. switch (this._fillMode) {
  62158. case Material.WireFrameFillMode:
  62159. case Material.LineListDrawMode:
  62160. case Material.LineLoopDrawMode:
  62161. case Material.LineStripDrawMode:
  62162. return true;
  62163. }
  62164. return this._scene.forceWireframe;
  62165. },
  62166. /**
  62167. * Sets the state of wireframe mode
  62168. */
  62169. set: function (value) {
  62170. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  62171. },
  62172. enumerable: true,
  62173. configurable: true
  62174. });
  62175. Object.defineProperty(Material.prototype, "pointsCloud", {
  62176. /**
  62177. * Gets the value specifying if point clouds are enabled
  62178. */
  62179. get: function () {
  62180. switch (this._fillMode) {
  62181. case Material.PointFillMode:
  62182. case Material.PointListDrawMode:
  62183. return true;
  62184. }
  62185. return this._scene.forcePointsCloud;
  62186. },
  62187. /**
  62188. * Sets the state of point cloud mode
  62189. */
  62190. set: function (value) {
  62191. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  62192. },
  62193. enumerable: true,
  62194. configurable: true
  62195. });
  62196. Object.defineProperty(Material.prototype, "fillMode", {
  62197. /**
  62198. * Gets the material fill mode
  62199. */
  62200. get: function () {
  62201. return this._fillMode;
  62202. },
  62203. /**
  62204. * Sets the material fill mode
  62205. */
  62206. set: function (value) {
  62207. if (this._fillMode === value) {
  62208. return;
  62209. }
  62210. this._fillMode = value;
  62211. this.markAsDirty(Material.MiscDirtyFlag);
  62212. },
  62213. enumerable: true,
  62214. configurable: true
  62215. });
  62216. /**
  62217. * Returns a string representation of the current material
  62218. * @param fullDetails defines a boolean indicating which levels of logging is desired
  62219. * @returns a string with material information
  62220. */
  62221. Material.prototype.toString = function (fullDetails) {
  62222. var ret = "Name: " + this.name;
  62223. if (fullDetails) {
  62224. }
  62225. return ret;
  62226. };
  62227. /**
  62228. * Gets the class name of the material
  62229. * @returns a string with the class name of the material
  62230. */
  62231. Material.prototype.getClassName = function () {
  62232. return "Material";
  62233. };
  62234. Object.defineProperty(Material.prototype, "isFrozen", {
  62235. /**
  62236. * Specifies if updates for the material been locked
  62237. */
  62238. get: function () {
  62239. return this.checkReadyOnlyOnce;
  62240. },
  62241. enumerable: true,
  62242. configurable: true
  62243. });
  62244. /**
  62245. * Locks updates for the material
  62246. */
  62247. Material.prototype.freeze = function () {
  62248. this.checkReadyOnlyOnce = true;
  62249. };
  62250. /**
  62251. * Unlocks updates for the material
  62252. */
  62253. Material.prototype.unfreeze = function () {
  62254. this.checkReadyOnlyOnce = false;
  62255. };
  62256. /**
  62257. * Specifies if the material is ready to be used
  62258. * @param mesh defines the mesh to check
  62259. * @param useInstances specifies if instances should be used
  62260. * @returns a boolean indicating if the material is ready to be used
  62261. */
  62262. Material.prototype.isReady = function (mesh, useInstances) {
  62263. return true;
  62264. };
  62265. /**
  62266. * Specifies that the submesh is ready to be used
  62267. * @param mesh defines the mesh to check
  62268. * @param subMesh defines which submesh to check
  62269. * @param useInstances specifies that instances should be used
  62270. * @returns a boolean indicating that the submesh is ready or not
  62271. */
  62272. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  62273. return false;
  62274. };
  62275. /**
  62276. * Returns the material effect
  62277. * @returns the effect associated with the material
  62278. */
  62279. Material.prototype.getEffect = function () {
  62280. return this._effect;
  62281. };
  62282. /**
  62283. * Returns the current scene
  62284. * @returns a Scene
  62285. */
  62286. Material.prototype.getScene = function () {
  62287. return this._scene;
  62288. };
  62289. /**
  62290. * Specifies if the material will require alpha blending
  62291. * @returns a boolean specifying if alpha blending is needed
  62292. */
  62293. Material.prototype.needAlphaBlending = function () {
  62294. return (this.alpha < 1.0);
  62295. };
  62296. /**
  62297. * Specifies if the mesh will require alpha blending
  62298. * @param mesh defines the mesh to check
  62299. * @returns a boolean specifying if alpha blending is needed for the mesh
  62300. */
  62301. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  62302. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  62303. };
  62304. /**
  62305. * Specifies if this material should be rendered in alpha test mode
  62306. * @returns a boolean specifying if an alpha test is needed.
  62307. */
  62308. Material.prototype.needAlphaTesting = function () {
  62309. return false;
  62310. };
  62311. /**
  62312. * Gets the texture used for the alpha test
  62313. * @returns the texture to use for alpha testing
  62314. */
  62315. Material.prototype.getAlphaTestTexture = function () {
  62316. return null;
  62317. };
  62318. /**
  62319. * Marks the material to indicate that it needs to be re-calculated
  62320. */
  62321. Material.prototype.markDirty = function () {
  62322. this._wasPreviouslyReady = false;
  62323. };
  62324. /** @hidden */
  62325. Material.prototype._preBind = function (effect, overrideOrientation) {
  62326. if (overrideOrientation === void 0) { overrideOrientation = null; }
  62327. var engine = this._scene.getEngine();
  62328. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  62329. var reverse = orientation === Material.ClockWiseSideOrientation;
  62330. engine.enableEffect(effect ? effect : this._effect);
  62331. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  62332. return reverse;
  62333. };
  62334. /**
  62335. * Binds the material to the mesh
  62336. * @param world defines the world transformation matrix
  62337. * @param mesh defines the mesh to bind the material to
  62338. */
  62339. Material.prototype.bind = function (world, mesh) {
  62340. };
  62341. /**
  62342. * Binds the submesh to the material
  62343. * @param world defines the world transformation matrix
  62344. * @param mesh defines the mesh containing the submesh
  62345. * @param subMesh defines the submesh to bind the material to
  62346. */
  62347. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  62348. };
  62349. /**
  62350. * Binds the world matrix to the material
  62351. * @param world defines the world transformation matrix
  62352. */
  62353. Material.prototype.bindOnlyWorldMatrix = function (world) {
  62354. };
  62355. /**
  62356. * Binds the scene's uniform buffer to the effect.
  62357. * @param effect defines the effect to bind to the scene uniform buffer
  62358. * @param sceneUbo defines the uniform buffer storing scene data
  62359. */
  62360. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  62361. sceneUbo.bindToEffect(effect, "Scene");
  62362. };
  62363. /**
  62364. * Binds the view matrix to the effect
  62365. * @param effect defines the effect to bind the view matrix to
  62366. */
  62367. Material.prototype.bindView = function (effect) {
  62368. if (!this._useUBO) {
  62369. effect.setMatrix("view", this.getScene().getViewMatrix());
  62370. }
  62371. else {
  62372. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62373. }
  62374. };
  62375. /**
  62376. * Binds the view projection matrix to the effect
  62377. * @param effect defines the effect to bind the view projection matrix to
  62378. */
  62379. Material.prototype.bindViewProjection = function (effect) {
  62380. if (!this._useUBO) {
  62381. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  62382. }
  62383. else {
  62384. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62385. }
  62386. };
  62387. /**
  62388. * Specifies if material alpha testing should be turned on for the mesh
  62389. * @param mesh defines the mesh to check
  62390. */
  62391. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  62392. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  62393. };
  62394. /**
  62395. * Processes to execute after binding the material to a mesh
  62396. * @param mesh defines the rendered mesh
  62397. */
  62398. Material.prototype._afterBind = function (mesh) {
  62399. this._scene._cachedMaterial = this;
  62400. if (mesh) {
  62401. this._scene._cachedVisibility = mesh.visibility;
  62402. }
  62403. else {
  62404. this._scene._cachedVisibility = 1;
  62405. }
  62406. if (this._onBindObservable && mesh) {
  62407. this._onBindObservable.notifyObservers(mesh);
  62408. }
  62409. if (this.disableDepthWrite) {
  62410. var engine = this._scene.getEngine();
  62411. this._cachedDepthWriteState = engine.getDepthWrite();
  62412. engine.setDepthWrite(false);
  62413. }
  62414. };
  62415. /**
  62416. * Unbinds the material from the mesh
  62417. */
  62418. Material.prototype.unbind = function () {
  62419. if (this._onUnBindObservable) {
  62420. this._onUnBindObservable.notifyObservers(this);
  62421. }
  62422. if (this.disableDepthWrite) {
  62423. var engine = this._scene.getEngine();
  62424. engine.setDepthWrite(this._cachedDepthWriteState);
  62425. }
  62426. };
  62427. /**
  62428. * Gets the active textures from the material
  62429. * @returns an array of textures
  62430. */
  62431. Material.prototype.getActiveTextures = function () {
  62432. return [];
  62433. };
  62434. /**
  62435. * Specifies if the material uses a texture
  62436. * @param texture defines the texture to check against the material
  62437. * @returns a boolean specifying if the material uses the texture
  62438. */
  62439. Material.prototype.hasTexture = function (texture) {
  62440. return false;
  62441. };
  62442. /**
  62443. * Makes a duplicate of the material, and gives it a new name
  62444. * @param name defines the new name for the duplicated material
  62445. * @returns the cloned material
  62446. */
  62447. Material.prototype.clone = function (name) {
  62448. return null;
  62449. };
  62450. /**
  62451. * Gets the meshes bound to the material
  62452. * @returns an array of meshes bound to the material
  62453. */
  62454. Material.prototype.getBindedMeshes = function () {
  62455. var _this = this;
  62456. if (this.meshMap) {
  62457. var result = new Array();
  62458. for (var meshId in this.meshMap) {
  62459. var mesh = this.meshMap[meshId];
  62460. if (mesh) {
  62461. result.push(mesh);
  62462. }
  62463. }
  62464. return result;
  62465. }
  62466. else {
  62467. var meshes = this._scene.meshes;
  62468. return meshes.filter(function (mesh) { return mesh.material === _this; });
  62469. }
  62470. };
  62471. /**
  62472. * Force shader compilation
  62473. * @param mesh defines the mesh associated with this material
  62474. * @param onCompiled defines a function to execute once the material is compiled
  62475. * @param options defines the options to configure the compilation
  62476. */
  62477. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  62478. var _this = this;
  62479. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  62480. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  62481. var scene = this.getScene();
  62482. var checkReady = function () {
  62483. if (!_this._scene || !_this._scene.getEngine()) {
  62484. return;
  62485. }
  62486. if (subMesh._materialDefines) {
  62487. subMesh._materialDefines._renderId = -1;
  62488. }
  62489. var clipPlaneState = scene.clipPlane;
  62490. if (localOptions.clipPlane) {
  62491. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  62492. }
  62493. if (_this._storeEffectOnSubMeshes) {
  62494. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  62495. if (onCompiled) {
  62496. onCompiled(_this);
  62497. }
  62498. }
  62499. else {
  62500. setTimeout(checkReady, 16);
  62501. }
  62502. }
  62503. else {
  62504. if (_this.isReady()) {
  62505. if (onCompiled) {
  62506. onCompiled(_this);
  62507. }
  62508. }
  62509. else {
  62510. setTimeout(checkReady, 16);
  62511. }
  62512. }
  62513. if (localOptions.clipPlane) {
  62514. scene.clipPlane = clipPlaneState;
  62515. }
  62516. };
  62517. checkReady();
  62518. };
  62519. /**
  62520. * Force shader compilation
  62521. * @param mesh defines the mesh that will use this material
  62522. * @param options defines additional options for compiling the shaders
  62523. * @returns a promise that resolves when the compilation completes
  62524. */
  62525. Material.prototype.forceCompilationAsync = function (mesh, options) {
  62526. var _this = this;
  62527. return new Promise(function (resolve) {
  62528. _this.forceCompilation(mesh, function () {
  62529. resolve();
  62530. }, options);
  62531. });
  62532. };
  62533. /**
  62534. * Marks a define in the material to indicate that it needs to be re-computed
  62535. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  62536. */
  62537. Material.prototype.markAsDirty = function (flag) {
  62538. if (this.getScene().blockMaterialDirtyMechanism) {
  62539. return;
  62540. }
  62541. Material._DirtyCallbackArray.length = 0;
  62542. if (flag & Material.TextureDirtyFlag) {
  62543. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  62544. }
  62545. if (flag & Material.LightDirtyFlag) {
  62546. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  62547. }
  62548. if (flag & Material.FresnelDirtyFlag) {
  62549. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  62550. }
  62551. if (flag & Material.AttributesDirtyFlag) {
  62552. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  62553. }
  62554. if (flag & Material.MiscDirtyFlag) {
  62555. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62556. }
  62557. if (Material._DirtyCallbackArray.length) {
  62558. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62559. }
  62560. this.getScene().resetCachedMaterial();
  62561. };
  62562. /**
  62563. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62564. * @param func defines a function which checks material defines against the submeshes
  62565. */
  62566. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62567. if (this.getScene().blockMaterialDirtyMechanism) {
  62568. return;
  62569. }
  62570. var meshes = this.getScene().meshes;
  62571. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62572. var mesh = meshes_1[_i];
  62573. if (!mesh.subMeshes) {
  62574. continue;
  62575. }
  62576. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62577. var subMesh = _b[_a];
  62578. if (subMesh.getMaterial() !== this) {
  62579. continue;
  62580. }
  62581. if (!subMesh._materialDefines) {
  62582. continue;
  62583. }
  62584. func(subMesh._materialDefines);
  62585. }
  62586. }
  62587. };
  62588. /**
  62589. * Indicates that image processing needs to be re-calculated for all submeshes
  62590. */
  62591. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62592. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62593. };
  62594. /**
  62595. * Indicates that textures need to be re-calculated for all submeshes
  62596. */
  62597. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62598. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62599. };
  62600. /**
  62601. * Indicates that fresnel needs to be re-calculated for all submeshes
  62602. */
  62603. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62604. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62605. };
  62606. /**
  62607. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62608. */
  62609. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62610. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62611. };
  62612. /**
  62613. * Indicates that lights need to be re-calculated for all submeshes
  62614. */
  62615. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62616. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62617. };
  62618. /**
  62619. * Indicates that attributes need to be re-calculated for all submeshes
  62620. */
  62621. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62622. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62623. };
  62624. /**
  62625. * Indicates that misc needs to be re-calculated for all submeshes
  62626. */
  62627. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62628. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62629. };
  62630. /**
  62631. * Indicates that textures and misc need to be re-calculated for all submeshes
  62632. */
  62633. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62634. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62635. };
  62636. /**
  62637. * Disposes the material
  62638. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62639. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62640. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62641. */
  62642. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62643. var scene = this.getScene();
  62644. // Animations
  62645. scene.stopAnimation(this);
  62646. scene.freeProcessedMaterials();
  62647. // Remove from scene
  62648. scene.removeMaterial(this);
  62649. if (notBoundToMesh !== true) {
  62650. // Remove from meshes
  62651. if (this.meshMap) {
  62652. for (var meshId in this.meshMap) {
  62653. var mesh = this.meshMap[meshId];
  62654. if (mesh) {
  62655. mesh.material = null; // will set the entry in the map to undefined
  62656. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62657. }
  62658. }
  62659. }
  62660. else {
  62661. var meshes = scene.meshes;
  62662. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62663. var mesh = meshes_2[_i];
  62664. if (mesh.material === this) {
  62665. mesh.material = null;
  62666. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62667. }
  62668. }
  62669. }
  62670. }
  62671. this._uniformBuffer.dispose();
  62672. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62673. if (forceDisposeEffect && this._effect) {
  62674. if (!this._storeEffectOnSubMeshes) {
  62675. scene.getEngine()._releaseEffect(this._effect);
  62676. }
  62677. this._effect = null;
  62678. }
  62679. // Callback
  62680. this.onDisposeObservable.notifyObservers(this);
  62681. this.onDisposeObservable.clear();
  62682. if (this._onBindObservable) {
  62683. this._onBindObservable.clear();
  62684. }
  62685. if (this._onUnBindObservable) {
  62686. this._onUnBindObservable.clear();
  62687. }
  62688. };
  62689. /** @hidden */
  62690. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62691. if (mesh.geometry) {
  62692. var geometry = (mesh.geometry);
  62693. var scene = this.getScene();
  62694. if (this._storeEffectOnSubMeshes) {
  62695. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62696. var subMesh = _a[_i];
  62697. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62698. if (forceDisposeEffect && subMesh._materialEffect) {
  62699. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62700. }
  62701. }
  62702. }
  62703. else {
  62704. geometry._releaseVertexArrayObject(this._effect);
  62705. }
  62706. }
  62707. };
  62708. /**
  62709. * Serializes this material
  62710. * @returns the serialized material object
  62711. */
  62712. Material.prototype.serialize = function () {
  62713. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62714. };
  62715. /**
  62716. * Creates a material from parsed material data
  62717. * @param parsedMaterial defines parsed material data
  62718. * @param scene defines the hosting scene
  62719. * @param rootUrl defines the root URL to use to load textures
  62720. * @returns a new material
  62721. */
  62722. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  62723. if (!parsedMaterial.customType) {
  62724. parsedMaterial.customType = "BABYLON.StandardMaterial";
  62725. }
  62726. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  62727. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  62728. if (!BABYLON.LegacyPBRMaterial) {
  62729. _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.");
  62730. return;
  62731. }
  62732. }
  62733. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  62734. return materialType.Parse(parsedMaterial, scene, rootUrl);
  62735. };
  62736. /**
  62737. * Returns the triangle fill mode
  62738. */
  62739. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  62740. /**
  62741. * Returns the wireframe mode
  62742. */
  62743. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  62744. /**
  62745. * Returns the point fill mode
  62746. */
  62747. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  62748. /**
  62749. * Returns the point list draw mode
  62750. */
  62751. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  62752. /**
  62753. * Returns the line list draw mode
  62754. */
  62755. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  62756. /**
  62757. * Returns the line loop draw mode
  62758. */
  62759. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  62760. /**
  62761. * Returns the line strip draw mode
  62762. */
  62763. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  62764. /**
  62765. * Returns the triangle strip draw mode
  62766. */
  62767. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  62768. /**
  62769. * Returns the triangle fan draw mode
  62770. */
  62771. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  62772. /**
  62773. * Stores the clock-wise side orientation
  62774. */
  62775. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  62776. /**
  62777. * Stores the counter clock-wise side orientation
  62778. */
  62779. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  62780. /**
  62781. * The dirty texture flag value
  62782. */
  62783. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  62784. /**
  62785. * The dirty light flag value
  62786. */
  62787. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  62788. /**
  62789. * The dirty fresnel flag value
  62790. */
  62791. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  62792. /**
  62793. * The dirty attribute flag value
  62794. */
  62795. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  62796. /**
  62797. * The dirty misc flag value
  62798. */
  62799. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  62800. /**
  62801. * The all dirty flag value
  62802. */
  62803. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  62804. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  62805. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  62806. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  62807. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  62808. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  62809. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  62810. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  62811. Material._FresnelDirtyCallBack(defines);
  62812. Material._MiscDirtyCallBack(defines);
  62813. };
  62814. Material._TextureAndMiscDirtyCallBack = function (defines) {
  62815. Material._TextureDirtyCallBack(defines);
  62816. Material._MiscDirtyCallBack(defines);
  62817. };
  62818. Material._DirtyCallbackArray = [];
  62819. Material._RunDirtyCallBacks = function (defines) {
  62820. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  62821. var cb = _a[_i];
  62822. cb(defines);
  62823. }
  62824. };
  62825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62827. ], Material.prototype, "id", void 0);
  62828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62830. ], Material.prototype, "uniqueId", void 0);
  62831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62833. ], Material.prototype, "name", void 0);
  62834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62836. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  62837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62839. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  62840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62842. ], Material.prototype, "state", void 0);
  62843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  62845. ], Material.prototype, "_alpha", void 0);
  62846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  62848. ], Material.prototype, "_backFaceCulling", void 0);
  62849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62851. ], Material.prototype, "sideOrientation", void 0);
  62852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  62854. ], Material.prototype, "_alphaMode", void 0);
  62855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62857. ], Material.prototype, "_needDepthPrePass", void 0);
  62858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62860. ], Material.prototype, "disableDepthWrite", void 0);
  62861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62863. ], Material.prototype, "forceDepthWrite", void 0);
  62864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62866. ], Material.prototype, "separateCullingPass", void 0);
  62867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  62869. ], Material.prototype, "_fogEnabled", void 0);
  62870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62872. ], Material.prototype, "pointSize", void 0);
  62873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62875. ], Material.prototype, "zOffset", void 0);
  62876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62878. ], Material.prototype, "wireframe", null);
  62879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62881. ], Material.prototype, "pointsCloud", null);
  62882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62884. ], Material.prototype, "fillMode", null);
  62885. return Material;
  62886. }());
  62887. /***/ }),
  62888. /***/ "./Materials/materialDefines.ts":
  62889. /*!**************************************!*\
  62890. !*** ./Materials/materialDefines.ts ***!
  62891. \**************************************/
  62892. /*! exports provided: MaterialDefines */
  62893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62894. "use strict";
  62895. __webpack_require__.r(__webpack_exports__);
  62896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  62897. /**
  62898. * Manages the defines for the Material
  62899. */
  62900. var MaterialDefines = /** @class */ (function () {
  62901. function MaterialDefines() {
  62902. this._isDirty = true;
  62903. /** @hidden */
  62904. this._areLightsDirty = true;
  62905. /** @hidden */
  62906. this._areAttributesDirty = true;
  62907. /** @hidden */
  62908. this._areTexturesDirty = true;
  62909. /** @hidden */
  62910. this._areFresnelDirty = true;
  62911. /** @hidden */
  62912. this._areMiscDirty = true;
  62913. /** @hidden */
  62914. this._areImageProcessingDirty = true;
  62915. /** @hidden */
  62916. this._normals = false;
  62917. /** @hidden */
  62918. this._uvs = false;
  62919. /** @hidden */
  62920. this._needNormals = false;
  62921. /** @hidden */
  62922. this._needUVs = false;
  62923. }
  62924. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  62925. /**
  62926. * Specifies if the material needs to be re-calculated
  62927. */
  62928. get: function () {
  62929. return this._isDirty;
  62930. },
  62931. enumerable: true,
  62932. configurable: true
  62933. });
  62934. /**
  62935. * Marks the material to indicate that it has been re-calculated
  62936. */
  62937. MaterialDefines.prototype.markAsProcessed = function () {
  62938. this._isDirty = false;
  62939. this._areAttributesDirty = false;
  62940. this._areTexturesDirty = false;
  62941. this._areFresnelDirty = false;
  62942. this._areLightsDirty = false;
  62943. this._areMiscDirty = false;
  62944. this._areImageProcessingDirty = false;
  62945. };
  62946. /**
  62947. * Marks the material to indicate that it needs to be re-calculated
  62948. */
  62949. MaterialDefines.prototype.markAsUnprocessed = function () {
  62950. this._isDirty = true;
  62951. };
  62952. /**
  62953. * Marks the material to indicate all of its defines need to be re-calculated
  62954. */
  62955. MaterialDefines.prototype.markAllAsDirty = function () {
  62956. this._areTexturesDirty = true;
  62957. this._areAttributesDirty = true;
  62958. this._areLightsDirty = true;
  62959. this._areFresnelDirty = true;
  62960. this._areMiscDirty = true;
  62961. this._areImageProcessingDirty = true;
  62962. this._isDirty = true;
  62963. };
  62964. /**
  62965. * Marks the material to indicate that image processing needs to be re-calculated
  62966. */
  62967. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  62968. this._areImageProcessingDirty = true;
  62969. this._isDirty = true;
  62970. };
  62971. /**
  62972. * Marks the material to indicate the lights need to be re-calculated
  62973. */
  62974. MaterialDefines.prototype.markAsLightDirty = function () {
  62975. this._areLightsDirty = true;
  62976. this._isDirty = true;
  62977. };
  62978. /**
  62979. * Marks the attribute state as changed
  62980. */
  62981. MaterialDefines.prototype.markAsAttributesDirty = function () {
  62982. this._areAttributesDirty = true;
  62983. this._isDirty = true;
  62984. };
  62985. /**
  62986. * Marks the texture state as changed
  62987. */
  62988. MaterialDefines.prototype.markAsTexturesDirty = function () {
  62989. this._areTexturesDirty = true;
  62990. this._isDirty = true;
  62991. };
  62992. /**
  62993. * Marks the fresnel state as changed
  62994. */
  62995. MaterialDefines.prototype.markAsFresnelDirty = function () {
  62996. this._areFresnelDirty = true;
  62997. this._isDirty = true;
  62998. };
  62999. /**
  63000. * Marks the misc state as changed
  63001. */
  63002. MaterialDefines.prototype.markAsMiscDirty = function () {
  63003. this._areMiscDirty = true;
  63004. this._isDirty = true;
  63005. };
  63006. /**
  63007. * Rebuilds the material defines
  63008. */
  63009. MaterialDefines.prototype.rebuild = function () {
  63010. if (this._keys) {
  63011. delete this._keys;
  63012. }
  63013. this._keys = [];
  63014. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  63015. var key = _a[_i];
  63016. if (key[0] === "_") {
  63017. continue;
  63018. }
  63019. this._keys.push(key);
  63020. }
  63021. };
  63022. /**
  63023. * Specifies if two material defines are equal
  63024. * @param other - A material define instance to compare to
  63025. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63026. */
  63027. MaterialDefines.prototype.isEqual = function (other) {
  63028. if (this._keys.length !== other._keys.length) {
  63029. return false;
  63030. }
  63031. for (var index = 0; index < this._keys.length; index++) {
  63032. var prop = this._keys[index];
  63033. if (this[prop] !== other[prop]) {
  63034. return false;
  63035. }
  63036. }
  63037. return true;
  63038. };
  63039. /**
  63040. * Clones this instance's defines to another instance
  63041. * @param other - material defines to clone values to
  63042. */
  63043. MaterialDefines.prototype.cloneTo = function (other) {
  63044. if (this._keys.length !== other._keys.length) {
  63045. other._keys = this._keys.slice(0);
  63046. }
  63047. for (var index = 0; index < this._keys.length; index++) {
  63048. var prop = this._keys[index];
  63049. other[prop] = this[prop];
  63050. }
  63051. };
  63052. /**
  63053. * Resets the material define values
  63054. */
  63055. MaterialDefines.prototype.reset = function () {
  63056. for (var index = 0; index < this._keys.length; index++) {
  63057. var prop = this._keys[index];
  63058. var type = typeof this[prop];
  63059. switch (type) {
  63060. case "number":
  63061. this[prop] = 0;
  63062. break;
  63063. case "string":
  63064. this[prop] = "";
  63065. break;
  63066. default:
  63067. this[prop] = false;
  63068. break;
  63069. }
  63070. }
  63071. };
  63072. /**
  63073. * Converts the material define values to a string
  63074. * @returns - String of material define information
  63075. */
  63076. MaterialDefines.prototype.toString = function () {
  63077. var result = "";
  63078. for (var index = 0; index < this._keys.length; index++) {
  63079. var prop = this._keys[index];
  63080. var value = this[prop];
  63081. var type = typeof value;
  63082. switch (type) {
  63083. case "number":
  63084. case "string":
  63085. result += "#define " + prop + " " + value + "\n";
  63086. break;
  63087. default:
  63088. if (value) {
  63089. result += "#define " + prop + "\n";
  63090. }
  63091. break;
  63092. }
  63093. }
  63094. return result;
  63095. };
  63096. return MaterialDefines;
  63097. }());
  63098. /***/ }),
  63099. /***/ "./Materials/materialFlags.ts":
  63100. /*!************************************!*\
  63101. !*** ./Materials/materialFlags.ts ***!
  63102. \************************************/
  63103. /*! exports provided: MaterialFlags */
  63104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63105. "use strict";
  63106. __webpack_require__.r(__webpack_exports__);
  63107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  63108. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63109. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63110. /**
  63111. * This groups all the flags used to control the materials channel.
  63112. */
  63113. var MaterialFlags = /** @class */ (function () {
  63114. function MaterialFlags() {
  63115. }
  63116. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  63117. /**
  63118. * Are diffuse textures enabled in the application.
  63119. */
  63120. get: function () {
  63121. return this._DiffuseTextureEnabled;
  63122. },
  63123. set: function (value) {
  63124. if (this._DiffuseTextureEnabled === value) {
  63125. return;
  63126. }
  63127. this._DiffuseTextureEnabled = value;
  63128. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63129. },
  63130. enumerable: true,
  63131. configurable: true
  63132. });
  63133. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  63134. /**
  63135. * Are ambient textures enabled in the application.
  63136. */
  63137. get: function () {
  63138. return this._AmbientTextureEnabled;
  63139. },
  63140. set: function (value) {
  63141. if (this._AmbientTextureEnabled === value) {
  63142. return;
  63143. }
  63144. this._AmbientTextureEnabled = value;
  63145. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63146. },
  63147. enumerable: true,
  63148. configurable: true
  63149. });
  63150. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  63151. /**
  63152. * Are opacity textures enabled in the application.
  63153. */
  63154. get: function () {
  63155. return this._OpacityTextureEnabled;
  63156. },
  63157. set: function (value) {
  63158. if (this._OpacityTextureEnabled === value) {
  63159. return;
  63160. }
  63161. this._OpacityTextureEnabled = value;
  63162. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63163. },
  63164. enumerable: true,
  63165. configurable: true
  63166. });
  63167. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  63168. /**
  63169. * Are reflection textures enabled in the application.
  63170. */
  63171. get: function () {
  63172. return this._ReflectionTextureEnabled;
  63173. },
  63174. set: function (value) {
  63175. if (this._ReflectionTextureEnabled === value) {
  63176. return;
  63177. }
  63178. this._ReflectionTextureEnabled = value;
  63179. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63180. },
  63181. enumerable: true,
  63182. configurable: true
  63183. });
  63184. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  63185. /**
  63186. * Are emissive textures enabled in the application.
  63187. */
  63188. get: function () {
  63189. return this._EmissiveTextureEnabled;
  63190. },
  63191. set: function (value) {
  63192. if (this._EmissiveTextureEnabled === value) {
  63193. return;
  63194. }
  63195. this._EmissiveTextureEnabled = value;
  63196. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63197. },
  63198. enumerable: true,
  63199. configurable: true
  63200. });
  63201. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  63202. /**
  63203. * Are specular textures enabled in the application.
  63204. */
  63205. get: function () {
  63206. return this._SpecularTextureEnabled;
  63207. },
  63208. set: function (value) {
  63209. if (this._SpecularTextureEnabled === value) {
  63210. return;
  63211. }
  63212. this._SpecularTextureEnabled = value;
  63213. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63214. },
  63215. enumerable: true,
  63216. configurable: true
  63217. });
  63218. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  63219. /**
  63220. * Are bump textures enabled in the application.
  63221. */
  63222. get: function () {
  63223. return this._BumpTextureEnabled;
  63224. },
  63225. set: function (value) {
  63226. if (this._BumpTextureEnabled === value) {
  63227. return;
  63228. }
  63229. this._BumpTextureEnabled = value;
  63230. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63231. },
  63232. enumerable: true,
  63233. configurable: true
  63234. });
  63235. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  63236. /**
  63237. * Are lightmap textures enabled in the application.
  63238. */
  63239. get: function () {
  63240. return this._LightmapTextureEnabled;
  63241. },
  63242. set: function (value) {
  63243. if (this._LightmapTextureEnabled === value) {
  63244. return;
  63245. }
  63246. this._LightmapTextureEnabled = value;
  63247. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63248. },
  63249. enumerable: true,
  63250. configurable: true
  63251. });
  63252. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  63253. /**
  63254. * Are refraction textures enabled in the application.
  63255. */
  63256. get: function () {
  63257. return this._RefractionTextureEnabled;
  63258. },
  63259. set: function (value) {
  63260. if (this._RefractionTextureEnabled === value) {
  63261. return;
  63262. }
  63263. this._RefractionTextureEnabled = value;
  63264. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63265. },
  63266. enumerable: true,
  63267. configurable: true
  63268. });
  63269. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  63270. /**
  63271. * Are color grading textures enabled in the application.
  63272. */
  63273. get: function () {
  63274. return this._ColorGradingTextureEnabled;
  63275. },
  63276. set: function (value) {
  63277. if (this._ColorGradingTextureEnabled === value) {
  63278. return;
  63279. }
  63280. this._ColorGradingTextureEnabled = value;
  63281. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63282. },
  63283. enumerable: true,
  63284. configurable: true
  63285. });
  63286. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  63287. /**
  63288. * Are fresnels enabled in the application.
  63289. */
  63290. get: function () {
  63291. return this._FresnelEnabled;
  63292. },
  63293. set: function (value) {
  63294. if (this._FresnelEnabled === value) {
  63295. return;
  63296. }
  63297. this._FresnelEnabled = value;
  63298. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  63299. },
  63300. enumerable: true,
  63301. configurable: true
  63302. });
  63303. // Flags used to enable or disable a type of texture for all Standard Materials
  63304. MaterialFlags._DiffuseTextureEnabled = true;
  63305. MaterialFlags._AmbientTextureEnabled = true;
  63306. MaterialFlags._OpacityTextureEnabled = true;
  63307. MaterialFlags._ReflectionTextureEnabled = true;
  63308. MaterialFlags._EmissiveTextureEnabled = true;
  63309. MaterialFlags._SpecularTextureEnabled = true;
  63310. MaterialFlags._BumpTextureEnabled = true;
  63311. MaterialFlags._LightmapTextureEnabled = true;
  63312. MaterialFlags._RefractionTextureEnabled = true;
  63313. MaterialFlags._ColorGradingTextureEnabled = true;
  63314. MaterialFlags._FresnelEnabled = true;
  63315. return MaterialFlags;
  63316. }());
  63317. /***/ }),
  63318. /***/ "./Materials/materialHelper.ts":
  63319. /*!*************************************!*\
  63320. !*** ./Materials/materialHelper.ts ***!
  63321. \*************************************/
  63322. /*! exports provided: MaterialHelper */
  63323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63324. "use strict";
  63325. __webpack_require__.r(__webpack_exports__);
  63326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  63327. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63328. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  63329. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63330. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63331. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63332. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  63333. /**
  63334. * "Static Class" containing the most commonly used helper while dealing with material for
  63335. * rendering purpose.
  63336. *
  63337. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  63338. *
  63339. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  63340. */
  63341. var MaterialHelper = /** @class */ (function () {
  63342. function MaterialHelper() {
  63343. }
  63344. /**
  63345. * Bind the current view position to an effect.
  63346. * @param effect The effect to be bound
  63347. * @param scene The scene the eyes position is used from
  63348. */
  63349. MaterialHelper.BindEyePosition = function (effect, scene) {
  63350. if (scene._forcedViewPosition) {
  63351. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  63352. return;
  63353. }
  63354. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  63355. };
  63356. /**
  63357. * Helps preparing the defines values about the UVs in used in the effect.
  63358. * UVs are shared as much as we can accross channels in the shaders.
  63359. * @param texture The texture we are preparing the UVs for
  63360. * @param defines The defines to update
  63361. * @param key The channel key "diffuse", "specular"... used in the shader
  63362. */
  63363. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  63364. defines._needUVs = true;
  63365. defines[key] = true;
  63366. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  63367. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  63368. if (texture.coordinatesIndex === 0) {
  63369. defines["MAINUV1"] = true;
  63370. }
  63371. else {
  63372. defines["MAINUV2"] = true;
  63373. }
  63374. }
  63375. else {
  63376. defines[key + "DIRECTUV"] = 0;
  63377. }
  63378. };
  63379. /**
  63380. * Binds a texture matrix value to its corrsponding uniform
  63381. * @param texture The texture to bind the matrix for
  63382. * @param uniformBuffer The uniform buffer receivin the data
  63383. * @param key The channel key "diffuse", "specular"... used in the shader
  63384. */
  63385. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  63386. var matrix = texture.getTextureMatrix();
  63387. if (!matrix.isIdentityAs3x2()) {
  63388. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  63389. }
  63390. };
  63391. /**
  63392. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  63393. * @param mesh defines the current mesh
  63394. * @param scene defines the current scene
  63395. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  63396. * @param pointsCloud defines if point cloud rendering has to be turned on
  63397. * @param fogEnabled defines if fog has to be turned on
  63398. * @param alphaTest defines if alpha testing has to be turned on
  63399. * @param defines defines the current list of defines
  63400. */
  63401. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  63402. if (defines._areMiscDirty) {
  63403. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  63404. defines["POINTSIZE"] = pointsCloud;
  63405. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  63406. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  63407. defines["ALPHATEST"] = alphaTest;
  63408. }
  63409. };
  63410. /**
  63411. * Helper used to prepare the list of defines associated with frame values for shader compilation
  63412. * @param scene defines the current scene
  63413. * @param engine defines the current engine
  63414. * @param defines specifies the list of active defines
  63415. * @param useInstances defines if instances have to be turned on
  63416. * @param useClipPlane defines if clip plane have to be turned on
  63417. */
  63418. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  63419. if (useClipPlane === void 0) { useClipPlane = null; }
  63420. var changed = false;
  63421. var useClipPlane1 = false;
  63422. var useClipPlane2 = false;
  63423. var useClipPlane3 = false;
  63424. var useClipPlane4 = false;
  63425. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  63426. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  63427. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  63428. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  63429. if (defines["CLIPPLANE"] !== useClipPlane1) {
  63430. defines["CLIPPLANE"] = useClipPlane1;
  63431. changed = true;
  63432. }
  63433. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  63434. defines["CLIPPLANE2"] = useClipPlane2;
  63435. changed = true;
  63436. }
  63437. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  63438. defines["CLIPPLANE3"] = useClipPlane3;
  63439. changed = true;
  63440. }
  63441. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  63442. defines["CLIPPLANE4"] = useClipPlane4;
  63443. changed = true;
  63444. }
  63445. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  63446. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  63447. changed = true;
  63448. }
  63449. if (defines["INSTANCES"] !== useInstances) {
  63450. defines["INSTANCES"] = useInstances;
  63451. changed = true;
  63452. }
  63453. if (changed) {
  63454. defines.markAsUnprocessed();
  63455. }
  63456. };
  63457. /**
  63458. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  63459. * @param mesh The mesh containing the geometry data we will draw
  63460. * @param defines The defines to update
  63461. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  63462. * @param useBones Precise whether bones should be used or not (override mesh info)
  63463. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  63464. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  63465. * @returns false if defines are considered not dirty and have not been checked
  63466. */
  63467. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  63468. if (useMorphTargets === void 0) { useMorphTargets = false; }
  63469. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  63470. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  63471. return false;
  63472. }
  63473. defines._normals = defines._needNormals;
  63474. defines._uvs = defines._needUVs;
  63475. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  63476. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  63477. defines["TANGENT"] = true;
  63478. }
  63479. if (defines._needUVs) {
  63480. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  63481. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  63482. }
  63483. else {
  63484. defines["UV1"] = false;
  63485. defines["UV2"] = false;
  63486. }
  63487. if (useVertexColor) {
  63488. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  63489. defines["VERTEXCOLOR"] = hasVertexColors;
  63490. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  63491. }
  63492. if (useBones) {
  63493. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63494. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  63495. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  63496. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  63497. defines["BONETEXTURE"] = true;
  63498. }
  63499. else {
  63500. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  63501. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  63502. }
  63503. }
  63504. else {
  63505. defines["NUM_BONE_INFLUENCERS"] = 0;
  63506. defines["BonesPerMesh"] = 0;
  63507. }
  63508. }
  63509. if (useMorphTargets) {
  63510. var manager = mesh.morphTargetManager;
  63511. if (manager) {
  63512. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  63513. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  63514. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  63515. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  63516. }
  63517. else {
  63518. defines["MORPHTARGETS_TANGENT"] = false;
  63519. defines["MORPHTARGETS_NORMAL"] = false;
  63520. defines["MORPHTARGETS"] = false;
  63521. defines["NUM_MORPH_INFLUENCERS"] = 0;
  63522. }
  63523. }
  63524. return true;
  63525. };
  63526. /**
  63527. * Prepares the defines related to the light information passed in parameter
  63528. * @param scene The scene we are intending to draw
  63529. * @param mesh The mesh the effect is compiling for
  63530. * @param defines The defines to update
  63531. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  63532. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  63533. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  63534. * @returns true if normals will be required for the rest of the effect
  63535. */
  63536. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  63537. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63538. if (disableLighting === void 0) { disableLighting = false; }
  63539. if (!defines._areLightsDirty) {
  63540. return defines._needNormals;
  63541. }
  63542. var lightIndex = 0;
  63543. var needNormals = false;
  63544. var needRebuild = false;
  63545. var lightmapMode = false;
  63546. var shadowEnabled = false;
  63547. var specularEnabled = false;
  63548. if (scene.lightsEnabled && !disableLighting) {
  63549. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  63550. var light = _a[_i];
  63551. needNormals = true;
  63552. if (defines["LIGHT" + lightIndex] === undefined) {
  63553. needRebuild = true;
  63554. }
  63555. defines["LIGHT" + lightIndex] = true;
  63556. defines["SPOTLIGHT" + lightIndex] = false;
  63557. defines["HEMILIGHT" + lightIndex] = false;
  63558. defines["POINTLIGHT" + lightIndex] = false;
  63559. defines["DIRLIGHT" + lightIndex] = false;
  63560. light.prepareLightSpecificDefines(defines, lightIndex);
  63561. // FallOff.
  63562. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63563. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63564. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63565. switch (light.falloffType) {
  63566. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63567. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63568. break;
  63569. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63570. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63571. break;
  63572. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63573. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63574. break;
  63575. }
  63576. // Specular
  63577. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63578. specularEnabled = true;
  63579. }
  63580. // Shadows
  63581. defines["SHADOW" + lightIndex] = false;
  63582. defines["SHADOWPCF" + lightIndex] = false;
  63583. defines["SHADOWPCSS" + lightIndex] = false;
  63584. defines["SHADOWPOISSON" + lightIndex] = false;
  63585. defines["SHADOWESM" + lightIndex] = false;
  63586. defines["SHADOWCUBE" + lightIndex] = false;
  63587. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63588. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63589. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63590. var shadowGenerator = light.getShadowGenerator();
  63591. if (shadowGenerator) {
  63592. var shadowMap = shadowGenerator.getShadowMap();
  63593. if (shadowMap) {
  63594. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63595. shadowEnabled = true;
  63596. shadowGenerator.prepareDefines(defines, lightIndex);
  63597. }
  63598. }
  63599. }
  63600. }
  63601. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63602. lightmapMode = true;
  63603. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63604. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63605. }
  63606. else {
  63607. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63608. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63609. }
  63610. lightIndex++;
  63611. if (lightIndex === maxSimultaneousLights) {
  63612. break;
  63613. }
  63614. }
  63615. }
  63616. defines["SPECULARTERM"] = specularEnabled;
  63617. defines["SHADOWS"] = shadowEnabled;
  63618. // Resetting all other lights if any
  63619. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63620. if (defines["LIGHT" + index] !== undefined) {
  63621. defines["LIGHT" + index] = false;
  63622. defines["HEMILIGHT" + lightIndex] = false;
  63623. defines["POINTLIGHT" + lightIndex] = false;
  63624. defines["DIRLIGHT" + lightIndex] = false;
  63625. defines["SPOTLIGHT" + lightIndex] = false;
  63626. defines["SHADOW" + lightIndex] = false;
  63627. }
  63628. }
  63629. var caps = scene.getEngine().getCaps();
  63630. if (defines["SHADOWFLOAT"] === undefined) {
  63631. needRebuild = true;
  63632. }
  63633. defines["SHADOWFLOAT"] = shadowEnabled &&
  63634. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63635. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63636. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63637. if (needRebuild) {
  63638. defines.rebuild();
  63639. }
  63640. return needNormals;
  63641. };
  63642. /**
  63643. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63644. * that won t be acctive due to defines being turned off.
  63645. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63646. * @param samplersList The samplers list
  63647. * @param defines The defines helping in the list generation
  63648. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63649. */
  63650. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63651. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63652. var uniformsList;
  63653. var uniformBuffersList = null;
  63654. if (uniformsListOrOptions.uniformsNames) {
  63655. var options = uniformsListOrOptions;
  63656. uniformsList = options.uniformsNames;
  63657. uniformBuffersList = options.uniformBuffersNames;
  63658. samplersList = options.samplers;
  63659. defines = options.defines;
  63660. maxSimultaneousLights = options.maxSimultaneousLights;
  63661. }
  63662. else {
  63663. uniformsList = uniformsListOrOptions;
  63664. if (!samplersList) {
  63665. samplersList = [];
  63666. }
  63667. }
  63668. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63669. if (!defines["LIGHT" + lightIndex]) {
  63670. break;
  63671. }
  63672. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63673. if (uniformBuffersList) {
  63674. uniformBuffersList.push("Light" + lightIndex);
  63675. }
  63676. samplersList.push("shadowSampler" + lightIndex);
  63677. samplersList.push("depthSampler" + lightIndex);
  63678. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63679. samplersList.push("projectionLightSampler" + lightIndex);
  63680. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63681. }
  63682. }
  63683. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63684. uniformsList.push("morphTargetInfluences");
  63685. }
  63686. };
  63687. /**
  63688. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63689. * @param defines The defines to update while falling back
  63690. * @param fallbacks The authorized effect fallbacks
  63691. * @param maxSimultaneousLights The maximum number of lights allowed
  63692. * @param rank the current rank of the Effect
  63693. * @returns The newly affected rank
  63694. */
  63695. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  63696. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63697. if (rank === void 0) { rank = 0; }
  63698. var lightFallbackRank = 0;
  63699. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63700. if (!defines["LIGHT" + lightIndex]) {
  63701. break;
  63702. }
  63703. if (lightIndex > 0) {
  63704. lightFallbackRank = rank + lightIndex;
  63705. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  63706. }
  63707. if (!defines["SHADOWS"]) {
  63708. if (defines["SHADOW" + lightIndex]) {
  63709. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  63710. }
  63711. if (defines["SHADOWPCF" + lightIndex]) {
  63712. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  63713. }
  63714. if (defines["SHADOWPCSS" + lightIndex]) {
  63715. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  63716. }
  63717. if (defines["SHADOWPOISSON" + lightIndex]) {
  63718. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  63719. }
  63720. if (defines["SHADOWESM" + lightIndex]) {
  63721. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  63722. }
  63723. }
  63724. }
  63725. return lightFallbackRank++;
  63726. };
  63727. /**
  63728. * Prepares the list of attributes required for morph targets according to the effect defines.
  63729. * @param attribs The current list of supported attribs
  63730. * @param mesh The mesh to prepare the morph targets attributes for
  63731. * @param defines The current Defines of the effect
  63732. */
  63733. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  63734. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  63735. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  63736. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  63737. var manager = mesh.morphTargetManager;
  63738. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  63739. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  63740. for (var index = 0; index < influencers; index++) {
  63741. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  63742. if (normal) {
  63743. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  63744. }
  63745. if (tangent) {
  63746. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  63747. }
  63748. if (attribs.length > maxAttributesCount) {
  63749. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  63750. }
  63751. }
  63752. }
  63753. };
  63754. /**
  63755. * Prepares the list of attributes required for bones according to the effect defines.
  63756. * @param attribs The current list of supported attribs
  63757. * @param mesh The mesh to prepare the bones attributes for
  63758. * @param defines The current Defines of the effect
  63759. * @param fallbacks The current efffect fallback strategy
  63760. */
  63761. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  63762. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  63763. fallbacks.addCPUSkinningFallback(0, mesh);
  63764. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  63765. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  63766. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  63767. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  63768. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  63769. }
  63770. }
  63771. };
  63772. /**
  63773. * Prepares the list of attributes required for instances according to the effect defines.
  63774. * @param attribs The current list of supported attribs
  63775. * @param defines The current Defines of the effect
  63776. */
  63777. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  63778. if (defines["INSTANCES"]) {
  63779. attribs.push("world0");
  63780. attribs.push("world1");
  63781. attribs.push("world2");
  63782. attribs.push("world3");
  63783. }
  63784. };
  63785. /**
  63786. * Binds the light shadow information to the effect for the given mesh.
  63787. * @param light The light containing the generator
  63788. * @param scene The scene the lights belongs to
  63789. * @param mesh The mesh we are binding the information to render
  63790. * @param lightIndex The light index in the effect used to render the mesh
  63791. * @param effect The effect we are binding the data to
  63792. */
  63793. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  63794. if (light.shadowEnabled && mesh.receiveShadows) {
  63795. var shadowGenerator = light.getShadowGenerator();
  63796. if (shadowGenerator) {
  63797. shadowGenerator.bindShadowLight(lightIndex, effect);
  63798. }
  63799. }
  63800. };
  63801. /**
  63802. * Binds the light information to the effect.
  63803. * @param light The light containing the generator
  63804. * @param effect The effect we are binding the data to
  63805. * @param lightIndex The light index in the effect used to render
  63806. */
  63807. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  63808. light.transferToEffect(effect, lightIndex + "");
  63809. };
  63810. /**
  63811. * Binds the lights information from the scene to the effect for the given mesh.
  63812. * @param scene The scene the lights belongs to
  63813. * @param mesh The mesh we are binding the information to render
  63814. * @param effect The effect we are binding the data to
  63815. * @param defines The generated defines for the effect
  63816. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  63817. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  63818. */
  63819. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  63820. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63821. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  63822. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  63823. for (var i = 0; i < len; i++) {
  63824. var light = mesh._lightSources[i];
  63825. var iAsString = i.toString();
  63826. var scaledIntensity = light.getScaledIntensity();
  63827. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  63828. MaterialHelper.BindLightProperties(light, effect, i);
  63829. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  63830. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  63831. if (defines["SPECULARTERM"]) {
  63832. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  63833. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  63834. }
  63835. // Shadows
  63836. if (scene.shadowsEnabled) {
  63837. this.BindLightShadow(light, mesh, iAsString, effect);
  63838. }
  63839. light._uniformBuffer.update();
  63840. }
  63841. };
  63842. /**
  63843. * Binds the fog information from the scene to the effect for the given mesh.
  63844. * @param scene The scene the lights belongs to
  63845. * @param mesh The mesh we are binding the information to render
  63846. * @param effect The effect we are binding the data to
  63847. * @param linearSpace Defines if the fog effect is applied in linear space
  63848. */
  63849. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  63850. if (linearSpace === void 0) { linearSpace = false; }
  63851. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  63852. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  63853. // Convert fog color to linear space if used in a linear space computed shader.
  63854. if (linearSpace) {
  63855. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  63856. effect.setColor3("vFogColor", this._tempFogColor);
  63857. }
  63858. else {
  63859. effect.setColor3("vFogColor", scene.fogColor);
  63860. }
  63861. }
  63862. };
  63863. /**
  63864. * Binds the bones information from the mesh to the effect.
  63865. * @param mesh The mesh we are binding the information to render
  63866. * @param effect The effect we are binding the data to
  63867. */
  63868. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  63869. if (!effect || !mesh) {
  63870. return;
  63871. }
  63872. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  63873. mesh.computeBonesUsingShaders = false;
  63874. }
  63875. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63876. var skeleton = mesh.skeleton;
  63877. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  63878. var boneTexture = skeleton.getTransformMatrixTexture();
  63879. effect.setTexture("boneSampler", boneTexture);
  63880. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  63881. }
  63882. else {
  63883. var matrices = skeleton.getTransformMatrices(mesh);
  63884. if (matrices) {
  63885. effect.setMatrices("mBones", matrices);
  63886. }
  63887. }
  63888. }
  63889. };
  63890. /**
  63891. * Binds the morph targets information from the mesh to the effect.
  63892. * @param abstractMesh The mesh we are binding the information to render
  63893. * @param effect The effect we are binding the data to
  63894. */
  63895. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  63896. var manager = abstractMesh.morphTargetManager;
  63897. if (!abstractMesh || !manager) {
  63898. return;
  63899. }
  63900. effect.setFloatArray("morphTargetInfluences", manager.influences);
  63901. };
  63902. /**
  63903. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  63904. * @param defines The generated defines used in the effect
  63905. * @param effect The effect we are binding the data to
  63906. * @param scene The scene we are willing to render with logarithmic scale for
  63907. */
  63908. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  63909. if (defines["LOGARITHMICDEPTH"]) {
  63910. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  63911. }
  63912. };
  63913. /**
  63914. * Binds the clip plane information from the scene to the effect.
  63915. * @param scene The scene the clip plane information are extracted from
  63916. * @param effect The effect we are binding the data to
  63917. */
  63918. MaterialHelper.BindClipPlane = function (effect, scene) {
  63919. if (scene.clipPlane) {
  63920. var clipPlane = scene.clipPlane;
  63921. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63922. }
  63923. if (scene.clipPlane2) {
  63924. var clipPlane = scene.clipPlane2;
  63925. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63926. }
  63927. if (scene.clipPlane3) {
  63928. var clipPlane = scene.clipPlane3;
  63929. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63930. }
  63931. if (scene.clipPlane4) {
  63932. var clipPlane = scene.clipPlane4;
  63933. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63934. }
  63935. };
  63936. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  63937. return MaterialHelper;
  63938. }());
  63939. /***/ }),
  63940. /***/ "./Materials/multiMaterial.ts":
  63941. /*!************************************!*\
  63942. !*** ./Materials/multiMaterial.ts ***!
  63943. \************************************/
  63944. /*! exports provided: MultiMaterial */
  63945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63946. "use strict";
  63947. __webpack_require__.r(__webpack_exports__);
  63948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  63949. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63950. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63951. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  63952. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63953. /**
  63954. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63955. * separate meshes. This can be use to improve performances.
  63956. * @see http://doc.babylonjs.com/how_to/multi_materials
  63957. */
  63958. var MultiMaterial = /** @class */ (function (_super) {
  63959. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  63960. /**
  63961. * Instantiates a new Multi Material
  63962. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63963. * separate meshes. This can be use to improve performances.
  63964. * @see http://doc.babylonjs.com/how_to/multi_materials
  63965. * @param name Define the name in the scene
  63966. * @param scene Define the scene the material belongs to
  63967. */
  63968. function MultiMaterial(name, scene) {
  63969. var _this = _super.call(this, name, scene, true) || this;
  63970. scene.multiMaterials.push(_this);
  63971. _this.subMaterials = new Array();
  63972. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  63973. return _this;
  63974. }
  63975. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  63976. /**
  63977. * Gets or Sets the list of Materials used within the multi material.
  63978. * They need to be ordered according to the submeshes order in the associated mesh
  63979. */
  63980. get: function () {
  63981. return this._subMaterials;
  63982. },
  63983. set: function (value) {
  63984. this._subMaterials = value;
  63985. this._hookArray(value);
  63986. },
  63987. enumerable: true,
  63988. configurable: true
  63989. });
  63990. /**
  63991. * Function used to align with Node.getChildren()
  63992. * @returns the list of Materials used within the multi material
  63993. */
  63994. MultiMaterial.prototype.getChildren = function () {
  63995. return this.subMaterials;
  63996. };
  63997. MultiMaterial.prototype._hookArray = function (array) {
  63998. var _this = this;
  63999. var oldPush = array.push;
  64000. array.push = function () {
  64001. var items = [];
  64002. for (var _i = 0; _i < arguments.length; _i++) {
  64003. items[_i] = arguments[_i];
  64004. }
  64005. var result = oldPush.apply(array, items);
  64006. _this._markAllSubMeshesAsTexturesDirty();
  64007. return result;
  64008. };
  64009. var oldSplice = array.splice;
  64010. array.splice = function (index, deleteCount) {
  64011. var deleted = oldSplice.apply(array, [index, deleteCount]);
  64012. _this._markAllSubMeshesAsTexturesDirty();
  64013. return deleted;
  64014. };
  64015. };
  64016. /**
  64017. * Get one of the submaterial by its index in the submaterials array
  64018. * @param index The index to look the sub material at
  64019. * @returns The Material if the index has been defined
  64020. */
  64021. MultiMaterial.prototype.getSubMaterial = function (index) {
  64022. if (index < 0 || index >= this.subMaterials.length) {
  64023. return this.getScene().defaultMaterial;
  64024. }
  64025. return this.subMaterials[index];
  64026. };
  64027. /**
  64028. * Get the list of active textures for the whole sub materials list.
  64029. * @returns All the textures that will be used during the rendering
  64030. */
  64031. MultiMaterial.prototype.getActiveTextures = function () {
  64032. var _a;
  64033. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  64034. if (subMaterial) {
  64035. return subMaterial.getActiveTextures();
  64036. }
  64037. else {
  64038. return [];
  64039. }
  64040. }));
  64041. };
  64042. /**
  64043. * Gets the current class name of the material e.g. "MultiMaterial"
  64044. * Mainly use in serialization.
  64045. * @returns the class name
  64046. */
  64047. MultiMaterial.prototype.getClassName = function () {
  64048. return "MultiMaterial";
  64049. };
  64050. /**
  64051. * Checks if the material is ready to render the requested sub mesh
  64052. * @param mesh Define the mesh the submesh belongs to
  64053. * @param subMesh Define the sub mesh to look readyness for
  64054. * @param useInstances Define whether or not the material is used with instances
  64055. * @returns true if ready, otherwise false
  64056. */
  64057. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64058. for (var index = 0; index < this.subMaterials.length; index++) {
  64059. var subMaterial = this.subMaterials[index];
  64060. if (subMaterial) {
  64061. if (subMaterial._storeEffectOnSubMeshes) {
  64062. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  64063. return false;
  64064. }
  64065. continue;
  64066. }
  64067. if (!subMaterial.isReady(mesh)) {
  64068. return false;
  64069. }
  64070. }
  64071. }
  64072. return true;
  64073. };
  64074. /**
  64075. * Clones the current material and its related sub materials
  64076. * @param name Define the name of the newly cloned material
  64077. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64078. * @returns the cloned material
  64079. */
  64080. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  64081. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  64082. for (var index = 0; index < this.subMaterials.length; index++) {
  64083. var subMaterial = null;
  64084. var current = this.subMaterials[index];
  64085. if (cloneChildren && current) {
  64086. subMaterial = current.clone(name + "-" + current.name);
  64087. }
  64088. else {
  64089. subMaterial = this.subMaterials[index];
  64090. }
  64091. newMultiMaterial.subMaterials.push(subMaterial);
  64092. }
  64093. return newMultiMaterial;
  64094. };
  64095. /**
  64096. * Serializes the materials into a JSON representation.
  64097. * @returns the JSON representation
  64098. */
  64099. MultiMaterial.prototype.serialize = function () {
  64100. var serializationObject = {};
  64101. serializationObject.name = this.name;
  64102. serializationObject.id = this.id;
  64103. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64104. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  64105. }
  64106. serializationObject.materials = [];
  64107. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  64108. var subMat = this.subMaterials[matIndex];
  64109. if (subMat) {
  64110. serializationObject.materials.push(subMat.id);
  64111. }
  64112. else {
  64113. serializationObject.materials.push(null);
  64114. }
  64115. }
  64116. return serializationObject;
  64117. };
  64118. /**
  64119. * Dispose the material and release its associated resources
  64120. * @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)
  64121. * @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)
  64122. * @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)
  64123. */
  64124. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  64125. var scene = this.getScene();
  64126. if (!scene) {
  64127. return;
  64128. }
  64129. if (forceDisposeChildren) {
  64130. for (var index = 0; index < this.subMaterials.length; index++) {
  64131. var subMaterial = this.subMaterials[index];
  64132. if (subMaterial) {
  64133. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  64134. }
  64135. }
  64136. }
  64137. var index = scene.multiMaterials.indexOf(this);
  64138. if (index >= 0) {
  64139. scene.multiMaterials.splice(index, 1);
  64140. }
  64141. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  64142. };
  64143. /**
  64144. * Creates a MultiMaterial from parsed MultiMaterial data.
  64145. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64146. * @param scene defines the hosting scene
  64147. * @returns a new MultiMaterial
  64148. */
  64149. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  64150. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  64151. multiMaterial.id = parsedMultiMaterial.id;
  64152. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64153. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  64154. }
  64155. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  64156. var subMatId = parsedMultiMaterial.materials[matIndex];
  64157. if (subMatId) {
  64158. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  64159. }
  64160. else {
  64161. multiMaterial.subMaterials.push(null);
  64162. }
  64163. }
  64164. return multiMaterial;
  64165. };
  64166. return MultiMaterial;
  64167. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  64168. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  64169. /***/ }),
  64170. /***/ "./Materials/pushMaterial.ts":
  64171. /*!***********************************!*\
  64172. !*** ./Materials/pushMaterial.ts ***!
  64173. \***********************************/
  64174. /*! exports provided: PushMaterial */
  64175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64176. "use strict";
  64177. __webpack_require__.r(__webpack_exports__);
  64178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  64179. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64180. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64181. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64182. /**
  64183. * Base class of materials working in push mode in babylon JS
  64184. * @hidden
  64185. */
  64186. var PushMaterial = /** @class */ (function (_super) {
  64187. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  64188. function PushMaterial(name, scene) {
  64189. var _this = _super.call(this, name, scene) || this;
  64190. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  64191. /**
  64192. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  64193. * This means that the material can keep using a previous shader while a new one is being compiled.
  64194. * This is mostly used when shader parallel compilation is supported (true by default)
  64195. */
  64196. _this.allowShaderHotSwapping = true;
  64197. _this._storeEffectOnSubMeshes = true;
  64198. return _this;
  64199. }
  64200. PushMaterial.prototype.getEffect = function () {
  64201. return this._activeEffect;
  64202. };
  64203. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  64204. if (!mesh) {
  64205. return false;
  64206. }
  64207. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  64208. return true;
  64209. }
  64210. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  64211. };
  64212. /**
  64213. * Binds the given world matrix to the active effect
  64214. *
  64215. * @param world the matrix to bind
  64216. */
  64217. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64218. this._activeEffect.setMatrix("world", world);
  64219. };
  64220. /**
  64221. * Binds the given normal matrix to the active effect
  64222. *
  64223. * @param normalMatrix the matrix to bind
  64224. */
  64225. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  64226. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  64227. };
  64228. PushMaterial.prototype.bind = function (world, mesh) {
  64229. if (!mesh) {
  64230. return;
  64231. }
  64232. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  64233. };
  64234. PushMaterial.prototype._afterBind = function (mesh, effect) {
  64235. if (effect === void 0) { effect = null; }
  64236. _super.prototype._afterBind.call(this, mesh);
  64237. this.getScene()._cachedEffect = effect;
  64238. };
  64239. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  64240. if (visibility === void 0) { visibility = 1; }
  64241. return scene.isCachedMaterialInvalid(this, effect, visibility);
  64242. };
  64243. return PushMaterial;
  64244. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  64245. /***/ }),
  64246. /***/ "./Materials/shaderMaterial.ts":
  64247. /*!*************************************!*\
  64248. !*** ./Materials/shaderMaterial.ts ***!
  64249. \*************************************/
  64250. /*! exports provided: ShaderMaterial */
  64251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64252. "use strict";
  64253. __webpack_require__.r(__webpack_exports__);
  64254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  64255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64256. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64257. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64258. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64259. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64260. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64261. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64262. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64263. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64264. /**
  64265. * 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.
  64266. *
  64267. * This returned material effects how the mesh will look based on the code in the shaders.
  64268. *
  64269. * @see http://doc.babylonjs.com/how_to/shader_material
  64270. */
  64271. var ShaderMaterial = /** @class */ (function (_super) {
  64272. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  64273. /**
  64274. * Instantiate a new shader material.
  64275. * 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.
  64276. * This returned material effects how the mesh will look based on the code in the shaders.
  64277. * @see http://doc.babylonjs.com/how_to/shader_material
  64278. * @param name Define the name of the material in the scene
  64279. * @param scene Define the scene the material belongs to
  64280. * @param shaderPath Defines the route to the shader code in one of three ways:
  64281. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  64282. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  64283. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  64284. * @param options Define the options used to create the shader
  64285. */
  64286. function ShaderMaterial(name, scene, shaderPath, options) {
  64287. if (options === void 0) { options = {}; }
  64288. var _this = _super.call(this, name, scene) || this;
  64289. _this._textures = {};
  64290. _this._textureArrays = {};
  64291. _this._floats = {};
  64292. _this._ints = {};
  64293. _this._floatsArrays = {};
  64294. _this._colors3 = {};
  64295. _this._colors3Arrays = {};
  64296. _this._colors4 = {};
  64297. _this._vectors2 = {};
  64298. _this._vectors3 = {};
  64299. _this._vectors4 = {};
  64300. _this._matrices = {};
  64301. _this._matrices3x3 = {};
  64302. _this._matrices2x2 = {};
  64303. _this._vectors2Arrays = {};
  64304. _this._vectors3Arrays = {};
  64305. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  64306. _this._shaderPath = shaderPath;
  64307. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  64308. return _this;
  64309. }
  64310. /**
  64311. * Gets the current class name of the material e.g. "ShaderMaterial"
  64312. * Mainly use in serialization.
  64313. * @returns the class name
  64314. */
  64315. ShaderMaterial.prototype.getClassName = function () {
  64316. return "ShaderMaterial";
  64317. };
  64318. /**
  64319. * Specifies if the material will require alpha blending
  64320. * @returns a boolean specifying if alpha blending is needed
  64321. */
  64322. ShaderMaterial.prototype.needAlphaBlending = function () {
  64323. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  64324. };
  64325. /**
  64326. * Specifies if this material should be rendered in alpha test mode
  64327. * @returns a boolean specifying if an alpha test is needed.
  64328. */
  64329. ShaderMaterial.prototype.needAlphaTesting = function () {
  64330. return this._options.needAlphaTesting;
  64331. };
  64332. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  64333. if (this._options.uniforms.indexOf(uniformName) === -1) {
  64334. this._options.uniforms.push(uniformName);
  64335. }
  64336. };
  64337. /**
  64338. * Set a texture in the shader.
  64339. * @param name Define the name of the uniform samplers as defined in the shader
  64340. * @param texture Define the texture to bind to this sampler
  64341. * @return the material itself allowing "fluent" like uniform updates
  64342. */
  64343. ShaderMaterial.prototype.setTexture = function (name, texture) {
  64344. if (this._options.samplers.indexOf(name) === -1) {
  64345. this._options.samplers.push(name);
  64346. }
  64347. this._textures[name] = texture;
  64348. return this;
  64349. };
  64350. /**
  64351. * Set a texture array in the shader.
  64352. * @param name Define the name of the uniform sampler array as defined in the shader
  64353. * @param textures Define the list of textures to bind to this sampler
  64354. * @return the material itself allowing "fluent" like uniform updates
  64355. */
  64356. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  64357. if (this._options.samplers.indexOf(name) === -1) {
  64358. this._options.samplers.push(name);
  64359. }
  64360. this._checkUniform(name);
  64361. this._textureArrays[name] = textures;
  64362. return this;
  64363. };
  64364. /**
  64365. * Set a float in the shader.
  64366. * @param name Define the name of the uniform as defined in the shader
  64367. * @param value Define the value to give to the uniform
  64368. * @return the material itself allowing "fluent" like uniform updates
  64369. */
  64370. ShaderMaterial.prototype.setFloat = function (name, value) {
  64371. this._checkUniform(name);
  64372. this._floats[name] = value;
  64373. return this;
  64374. };
  64375. /**
  64376. * Set a int in the shader.
  64377. * @param name Define the name of the uniform as defined in the shader
  64378. * @param value Define the value to give to the uniform
  64379. * @return the material itself allowing "fluent" like uniform updates
  64380. */
  64381. ShaderMaterial.prototype.setInt = function (name, value) {
  64382. this._checkUniform(name);
  64383. this._ints[name] = value;
  64384. return this;
  64385. };
  64386. /**
  64387. * Set an array of floats in the shader.
  64388. * @param name Define the name of the uniform as defined in the shader
  64389. * @param value Define the value to give to the uniform
  64390. * @return the material itself allowing "fluent" like uniform updates
  64391. */
  64392. ShaderMaterial.prototype.setFloats = function (name, value) {
  64393. this._checkUniform(name);
  64394. this._floatsArrays[name] = value;
  64395. return this;
  64396. };
  64397. /**
  64398. * Set a vec3 in the shader from a Color3.
  64399. * @param name Define the name of the uniform as defined in the shader
  64400. * @param value Define the value to give to the uniform
  64401. * @return the material itself allowing "fluent" like uniform updates
  64402. */
  64403. ShaderMaterial.prototype.setColor3 = function (name, value) {
  64404. this._checkUniform(name);
  64405. this._colors3[name] = value;
  64406. return this;
  64407. };
  64408. /**
  64409. * Set a vec3 array in the shader from a Color3 array.
  64410. * @param name Define the name of the uniform as defined in the shader
  64411. * @param value Define the value to give to the uniform
  64412. * @return the material itself allowing "fluent" like uniform updates
  64413. */
  64414. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  64415. this._checkUniform(name);
  64416. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  64417. color.toArray(arr, arr.length);
  64418. return arr;
  64419. }, []);
  64420. return this;
  64421. };
  64422. /**
  64423. * Set a vec4 in the shader from a Color4.
  64424. * @param name Define the name of the uniform as defined in the shader
  64425. * @param value Define the value to give to the uniform
  64426. * @return the material itself allowing "fluent" like uniform updates
  64427. */
  64428. ShaderMaterial.prototype.setColor4 = function (name, value) {
  64429. this._checkUniform(name);
  64430. this._colors4[name] = value;
  64431. return this;
  64432. };
  64433. /**
  64434. * Set a vec2 in the shader from a Vector2.
  64435. * @param name Define the name of the uniform as defined in the shader
  64436. * @param value Define the value to give to the uniform
  64437. * @return the material itself allowing "fluent" like uniform updates
  64438. */
  64439. ShaderMaterial.prototype.setVector2 = function (name, value) {
  64440. this._checkUniform(name);
  64441. this._vectors2[name] = value;
  64442. return this;
  64443. };
  64444. /**
  64445. * Set a vec3 in the shader from a Vector3.
  64446. * @param name Define the name of the uniform as defined in the shader
  64447. * @param value Define the value to give to the uniform
  64448. * @return the material itself allowing "fluent" like uniform updates
  64449. */
  64450. ShaderMaterial.prototype.setVector3 = function (name, value) {
  64451. this._checkUniform(name);
  64452. this._vectors3[name] = value;
  64453. return this;
  64454. };
  64455. /**
  64456. * Set a vec4 in the shader from a Vector4.
  64457. * @param name Define the name of the uniform as defined in the shader
  64458. * @param value Define the value to give to the uniform
  64459. * @return the material itself allowing "fluent" like uniform updates
  64460. */
  64461. ShaderMaterial.prototype.setVector4 = function (name, value) {
  64462. this._checkUniform(name);
  64463. this._vectors4[name] = value;
  64464. return this;
  64465. };
  64466. /**
  64467. * Set a mat4 in the shader from a Matrix.
  64468. * @param name Define the name of the uniform as defined in the shader
  64469. * @param value Define the value to give to the uniform
  64470. * @return the material itself allowing "fluent" like uniform updates
  64471. */
  64472. ShaderMaterial.prototype.setMatrix = function (name, value) {
  64473. this._checkUniform(name);
  64474. this._matrices[name] = value;
  64475. return this;
  64476. };
  64477. /**
  64478. * Set a mat3 in the shader from a Float32Array.
  64479. * @param name Define the name of the uniform as defined in the shader
  64480. * @param value Define the value to give to the uniform
  64481. * @return the material itself allowing "fluent" like uniform updates
  64482. */
  64483. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  64484. this._checkUniform(name);
  64485. this._matrices3x3[name] = value;
  64486. return this;
  64487. };
  64488. /**
  64489. * Set a mat2 in the shader from a Float32Array.
  64490. * @param name Define the name of the uniform as defined in the shader
  64491. * @param value Define the value to give to the uniform
  64492. * @return the material itself allowing "fluent" like uniform updates
  64493. */
  64494. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  64495. this._checkUniform(name);
  64496. this._matrices2x2[name] = value;
  64497. return this;
  64498. };
  64499. /**
  64500. * Set a vec2 array in the shader from a number array.
  64501. * @param name Define the name of the uniform as defined in the shader
  64502. * @param value Define the value to give to the uniform
  64503. * @return the material itself allowing "fluent" like uniform updates
  64504. */
  64505. ShaderMaterial.prototype.setArray2 = function (name, value) {
  64506. this._checkUniform(name);
  64507. this._vectors2Arrays[name] = value;
  64508. return this;
  64509. };
  64510. /**
  64511. * Set a vec3 array in the shader from a number array.
  64512. * @param name Define the name of the uniform as defined in the shader
  64513. * @param value Define the value to give to the uniform
  64514. * @return the material itself allowing "fluent" like uniform updates
  64515. */
  64516. ShaderMaterial.prototype.setArray3 = function (name, value) {
  64517. this._checkUniform(name);
  64518. this._vectors3Arrays[name] = value;
  64519. return this;
  64520. };
  64521. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  64522. if (!mesh) {
  64523. return true;
  64524. }
  64525. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  64526. return false;
  64527. }
  64528. return false;
  64529. };
  64530. /**
  64531. * Checks if the material is ready to render the requested mesh
  64532. * @param mesh Define the mesh to render
  64533. * @param useInstances Define whether or not the material is used with instances
  64534. * @returns true if ready, otherwise false
  64535. */
  64536. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  64537. var scene = this.getScene();
  64538. var engine = scene.getEngine();
  64539. if (!this.checkReadyOnEveryCall) {
  64540. if (this._renderId === scene.getRenderId()) {
  64541. if (this._checkCache(mesh, useInstances)) {
  64542. return true;
  64543. }
  64544. }
  64545. }
  64546. // Instances
  64547. var defines = [];
  64548. var attribs = [];
  64549. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  64550. for (var index = 0; index < this._options.defines.length; index++) {
  64551. defines.push(this._options.defines[index]);
  64552. }
  64553. for (var index = 0; index < this._options.attributes.length; index++) {
  64554. attribs.push(this._options.attributes[index]);
  64555. }
  64556. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64557. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64558. defines.push("#define VERTEXCOLOR");
  64559. }
  64560. if (useInstances) {
  64561. defines.push("#define INSTANCES");
  64562. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64563. }
  64564. // Bones
  64565. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64566. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64567. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64568. if (mesh.numBoneInfluencers > 4) {
  64569. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64570. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64571. }
  64572. var skeleton = mesh.skeleton;
  64573. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64574. fallbacks.addCPUSkinningFallback(0, mesh);
  64575. if (skeleton.isUsingTextureForMatrices) {
  64576. defines.push("#define BONETEXTURE");
  64577. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64578. this._options.uniforms.push("boneTextureWidth");
  64579. }
  64580. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64581. this._options.samplers.push("boneSampler");
  64582. }
  64583. }
  64584. else {
  64585. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64586. if (this._options.uniforms.indexOf("mBones") === -1) {
  64587. this._options.uniforms.push("mBones");
  64588. }
  64589. }
  64590. }
  64591. else {
  64592. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64593. }
  64594. // Textures
  64595. for (var name in this._textures) {
  64596. if (!this._textures[name].isReady()) {
  64597. return false;
  64598. }
  64599. }
  64600. // Alpha test
  64601. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64602. defines.push("#define ALPHATEST");
  64603. }
  64604. var previousEffect = this._effect;
  64605. var join = defines.join("\n");
  64606. this._effect = engine.createEffect(this._shaderPath, {
  64607. attributes: attribs,
  64608. uniformsNames: this._options.uniforms,
  64609. uniformBuffersNames: this._options.uniformBuffers,
  64610. samplers: this._options.samplers,
  64611. defines: join,
  64612. fallbacks: fallbacks,
  64613. onCompiled: this.onCompiled,
  64614. onError: this.onError
  64615. }, engine);
  64616. if (!this._effect.isReady()) {
  64617. return false;
  64618. }
  64619. if (previousEffect !== this._effect) {
  64620. scene.resetCachedMaterial();
  64621. }
  64622. this._renderId = scene.getRenderId();
  64623. return true;
  64624. };
  64625. /**
  64626. * Binds the world matrix to the material
  64627. * @param world defines the world transformation matrix
  64628. */
  64629. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64630. var scene = this.getScene();
  64631. if (!this._effect) {
  64632. return;
  64633. }
  64634. if (this._options.uniforms.indexOf("world") !== -1) {
  64635. this._effect.setMatrix("world", world);
  64636. }
  64637. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64638. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64639. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64640. }
  64641. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64642. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64643. }
  64644. };
  64645. /**
  64646. * Binds the material to the mesh
  64647. * @param world defines the world transformation matrix
  64648. * @param mesh defines the mesh to bind the material to
  64649. */
  64650. ShaderMaterial.prototype.bind = function (world, mesh) {
  64651. // Std values
  64652. this.bindOnlyWorldMatrix(world);
  64653. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64654. if (this._options.uniforms.indexOf("view") !== -1) {
  64655. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64656. }
  64657. if (this._options.uniforms.indexOf("projection") !== -1) {
  64658. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64659. }
  64660. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64661. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64662. }
  64663. // Bones
  64664. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64665. var name;
  64666. // Texture
  64667. for (name in this._textures) {
  64668. this._effect.setTexture(name, this._textures[name]);
  64669. }
  64670. // Texture arrays
  64671. for (name in this._textureArrays) {
  64672. this._effect.setTextureArray(name, this._textureArrays[name]);
  64673. }
  64674. // Int
  64675. for (name in this._ints) {
  64676. this._effect.setInt(name, this._ints[name]);
  64677. }
  64678. // Float
  64679. for (name in this._floats) {
  64680. this._effect.setFloat(name, this._floats[name]);
  64681. }
  64682. // Floats
  64683. for (name in this._floatsArrays) {
  64684. this._effect.setArray(name, this._floatsArrays[name]);
  64685. }
  64686. // Color3
  64687. for (name in this._colors3) {
  64688. this._effect.setColor3(name, this._colors3[name]);
  64689. }
  64690. for (name in this._colors3Arrays) {
  64691. this._effect.setArray3(name, this._colors3Arrays[name]);
  64692. }
  64693. // Color4
  64694. for (name in this._colors4) {
  64695. var color = this._colors4[name];
  64696. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  64697. }
  64698. // Vector2
  64699. for (name in this._vectors2) {
  64700. this._effect.setVector2(name, this._vectors2[name]);
  64701. }
  64702. // Vector3
  64703. for (name in this._vectors3) {
  64704. this._effect.setVector3(name, this._vectors3[name]);
  64705. }
  64706. // Vector4
  64707. for (name in this._vectors4) {
  64708. this._effect.setVector4(name, this._vectors4[name]);
  64709. }
  64710. // Matrix
  64711. for (name in this._matrices) {
  64712. this._effect.setMatrix(name, this._matrices[name]);
  64713. }
  64714. // Matrix 3x3
  64715. for (name in this._matrices3x3) {
  64716. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  64717. }
  64718. // Matrix 2x2
  64719. for (name in this._matrices2x2) {
  64720. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  64721. }
  64722. // Vector2Array
  64723. for (name in this._vectors2Arrays) {
  64724. this._effect.setArray2(name, this._vectors2Arrays[name]);
  64725. }
  64726. // Vector3Array
  64727. for (name in this._vectors3Arrays) {
  64728. this._effect.setArray3(name, this._vectors3Arrays[name]);
  64729. }
  64730. }
  64731. this._afterBind(mesh);
  64732. };
  64733. /**
  64734. * Gets the active textures from the material
  64735. * @returns an array of textures
  64736. */
  64737. ShaderMaterial.prototype.getActiveTextures = function () {
  64738. var activeTextures = _super.prototype.getActiveTextures.call(this);
  64739. for (var name in this._textures) {
  64740. activeTextures.push(this._textures[name]);
  64741. }
  64742. for (var name in this._textureArrays) {
  64743. var array = this._textureArrays[name];
  64744. for (var index = 0; index < array.length; index++) {
  64745. activeTextures.push(array[index]);
  64746. }
  64747. }
  64748. return activeTextures;
  64749. };
  64750. /**
  64751. * Specifies if the material uses a texture
  64752. * @param texture defines the texture to check against the material
  64753. * @returns a boolean specifying if the material uses the texture
  64754. */
  64755. ShaderMaterial.prototype.hasTexture = function (texture) {
  64756. if (_super.prototype.hasTexture.call(this, texture)) {
  64757. return true;
  64758. }
  64759. for (var name in this._textures) {
  64760. if (this._textures[name] === texture) {
  64761. return true;
  64762. }
  64763. }
  64764. for (var name in this._textureArrays) {
  64765. var array = this._textureArrays[name];
  64766. for (var index = 0; index < array.length; index++) {
  64767. if (array[index] === texture) {
  64768. return true;
  64769. }
  64770. }
  64771. }
  64772. return false;
  64773. };
  64774. /**
  64775. * Makes a duplicate of the material, and gives it a new name
  64776. * @param name defines the new name for the duplicated material
  64777. * @returns the cloned material
  64778. */
  64779. ShaderMaterial.prototype.clone = function (name) {
  64780. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  64781. return newShaderMaterial;
  64782. };
  64783. /**
  64784. * Disposes the material
  64785. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64786. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64787. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64788. */
  64789. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64790. if (forceDisposeTextures) {
  64791. var name;
  64792. for (name in this._textures) {
  64793. this._textures[name].dispose();
  64794. }
  64795. for (name in this._textureArrays) {
  64796. var array = this._textureArrays[name];
  64797. for (var index = 0; index < array.length; index++) {
  64798. array[index].dispose();
  64799. }
  64800. }
  64801. }
  64802. this._textures = {};
  64803. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  64804. };
  64805. /**
  64806. * Serializes this material in a JSON representation
  64807. * @returns the serialized material object
  64808. */
  64809. ShaderMaterial.prototype.serialize = function () {
  64810. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64811. serializationObject.customType = "ShaderMaterial";
  64812. serializationObject.options = this._options;
  64813. serializationObject.shaderPath = this._shaderPath;
  64814. var name;
  64815. // Texture
  64816. serializationObject.textures = {};
  64817. for (name in this._textures) {
  64818. serializationObject.textures[name] = this._textures[name].serialize();
  64819. }
  64820. // Texture arrays
  64821. serializationObject.textureArrays = {};
  64822. for (name in this._textureArrays) {
  64823. serializationObject.textureArrays[name] = [];
  64824. var array = this._textureArrays[name];
  64825. for (var index = 0; index < array.length; index++) {
  64826. serializationObject.textureArrays[name].push(array[index].serialize());
  64827. }
  64828. }
  64829. // Float
  64830. serializationObject.floats = {};
  64831. for (name in this._floats) {
  64832. serializationObject.floats[name] = this._floats[name];
  64833. }
  64834. // Float s
  64835. serializationObject.FloatArrays = {};
  64836. for (name in this._floatsArrays) {
  64837. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  64838. }
  64839. // Color3
  64840. serializationObject.colors3 = {};
  64841. for (name in this._colors3) {
  64842. serializationObject.colors3[name] = this._colors3[name].asArray();
  64843. }
  64844. // Color3 array
  64845. serializationObject.colors3Arrays = {};
  64846. for (name in this._colors3Arrays) {
  64847. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  64848. }
  64849. // Color4
  64850. serializationObject.colors4 = {};
  64851. for (name in this._colors4) {
  64852. serializationObject.colors4[name] = this._colors4[name].asArray();
  64853. }
  64854. // Vector2
  64855. serializationObject.vectors2 = {};
  64856. for (name in this._vectors2) {
  64857. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  64858. }
  64859. // Vector3
  64860. serializationObject.vectors3 = {};
  64861. for (name in this._vectors3) {
  64862. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  64863. }
  64864. // Vector4
  64865. serializationObject.vectors4 = {};
  64866. for (name in this._vectors4) {
  64867. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  64868. }
  64869. // Matrix
  64870. serializationObject.matrices = {};
  64871. for (name in this._matrices) {
  64872. serializationObject.matrices[name] = this._matrices[name].asArray();
  64873. }
  64874. // Matrix 3x3
  64875. serializationObject.matrices3x3 = {};
  64876. for (name in this._matrices3x3) {
  64877. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  64878. }
  64879. // Matrix 2x2
  64880. serializationObject.matrices2x2 = {};
  64881. for (name in this._matrices2x2) {
  64882. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  64883. }
  64884. // Vector2Array
  64885. serializationObject.vectors2Arrays = {};
  64886. for (name in this._vectors2Arrays) {
  64887. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  64888. }
  64889. // Vector3Array
  64890. serializationObject.vectors3Arrays = {};
  64891. for (name in this._vectors3Arrays) {
  64892. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  64893. }
  64894. return serializationObject;
  64895. };
  64896. /**
  64897. * Creates a shader material from parsed shader material data
  64898. * @param source defines the JSON represnetation of the material
  64899. * @param scene defines the hosting scene
  64900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64901. * @returns a new material
  64902. */
  64903. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  64904. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  64905. var name;
  64906. // Texture
  64907. for (name in source.textures) {
  64908. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  64909. }
  64910. // Texture arrays
  64911. for (name in source.textureArrays) {
  64912. var array = source.textureArrays[name];
  64913. var textureArray = new Array();
  64914. for (var index = 0; index < array.length; index++) {
  64915. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  64916. }
  64917. material.setTextureArray(name, textureArray);
  64918. }
  64919. // Float
  64920. for (name in source.floats) {
  64921. material.setFloat(name, source.floats[name]);
  64922. }
  64923. // Float s
  64924. for (name in source.floatsArrays) {
  64925. material.setFloats(name, source.floatsArrays[name]);
  64926. }
  64927. // Color3
  64928. for (name in source.colors3) {
  64929. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  64930. }
  64931. // Color3 arrays
  64932. for (name in source.colors3Arrays) {
  64933. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  64934. if (i % 3 === 0) {
  64935. arr.push([num]);
  64936. }
  64937. else {
  64938. arr[arr.length - 1].push(num);
  64939. }
  64940. return arr;
  64941. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  64942. material.setColor3Array(name, colors);
  64943. }
  64944. // Color4
  64945. for (name in source.colors4) {
  64946. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  64947. }
  64948. // Vector2
  64949. for (name in source.vectors2) {
  64950. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  64951. }
  64952. // Vector3
  64953. for (name in source.vectors3) {
  64954. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  64955. }
  64956. // Vector4
  64957. for (name in source.vectors4) {
  64958. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  64959. }
  64960. // Matrix
  64961. for (name in source.matrices) {
  64962. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  64963. }
  64964. // Matrix 3x3
  64965. for (name in source.matrices3x3) {
  64966. material.setMatrix3x3(name, source.matrices3x3[name]);
  64967. }
  64968. // Matrix 2x2
  64969. for (name in source.matrices2x2) {
  64970. material.setMatrix2x2(name, source.matrices2x2[name]);
  64971. }
  64972. // Vector2Array
  64973. for (name in source.vectors2Arrays) {
  64974. material.setArray2(name, source.vectors2Arrays[name]);
  64975. }
  64976. // Vector3Array
  64977. for (name in source.vectors3Arrays) {
  64978. material.setArray3(name, source.vectors3Arrays[name]);
  64979. }
  64980. return material;
  64981. };
  64982. return ShaderMaterial;
  64983. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  64984. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  64985. /***/ }),
  64986. /***/ "./Materials/standardMaterial.ts":
  64987. /*!***************************************!*\
  64988. !*** ./Materials/standardMaterial.ts ***!
  64989. \***************************************/
  64990. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  64991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64992. "use strict";
  64993. __webpack_require__.r(__webpack_exports__);
  64994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  64995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  64996. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64997. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64998. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  64999. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65000. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65001. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65002. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65003. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65004. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  65005. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65006. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65007. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65008. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65009. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65010. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  65011. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  65012. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65013. /** @hidden */
  65014. var StandardMaterialDefines = /** @class */ (function (_super) {
  65015. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  65016. function StandardMaterialDefines() {
  65017. var _this = _super.call(this) || this;
  65018. _this.MAINUV1 = false;
  65019. _this.MAINUV2 = false;
  65020. _this.DIFFUSE = false;
  65021. _this.DIFFUSEDIRECTUV = 0;
  65022. _this.AMBIENT = false;
  65023. _this.AMBIENTDIRECTUV = 0;
  65024. _this.OPACITY = false;
  65025. _this.OPACITYDIRECTUV = 0;
  65026. _this.OPACITYRGB = false;
  65027. _this.REFLECTION = false;
  65028. _this.EMISSIVE = false;
  65029. _this.EMISSIVEDIRECTUV = 0;
  65030. _this.SPECULAR = false;
  65031. _this.SPECULARDIRECTUV = 0;
  65032. _this.BUMP = false;
  65033. _this.BUMPDIRECTUV = 0;
  65034. _this.PARALLAX = false;
  65035. _this.PARALLAXOCCLUSION = false;
  65036. _this.SPECULAROVERALPHA = false;
  65037. _this.CLIPPLANE = false;
  65038. _this.CLIPPLANE2 = false;
  65039. _this.CLIPPLANE3 = false;
  65040. _this.CLIPPLANE4 = false;
  65041. _this.ALPHATEST = false;
  65042. _this.DEPTHPREPASS = false;
  65043. _this.ALPHAFROMDIFFUSE = false;
  65044. _this.POINTSIZE = false;
  65045. _this.FOG = false;
  65046. _this.SPECULARTERM = false;
  65047. _this.DIFFUSEFRESNEL = false;
  65048. _this.OPACITYFRESNEL = false;
  65049. _this.REFLECTIONFRESNEL = false;
  65050. _this.REFRACTIONFRESNEL = false;
  65051. _this.EMISSIVEFRESNEL = false;
  65052. _this.FRESNEL = false;
  65053. _this.NORMAL = false;
  65054. _this.UV1 = false;
  65055. _this.UV2 = false;
  65056. _this.VERTEXCOLOR = false;
  65057. _this.VERTEXALPHA = false;
  65058. _this.NUM_BONE_INFLUENCERS = 0;
  65059. _this.BonesPerMesh = 0;
  65060. _this.BONETEXTURE = false;
  65061. _this.INSTANCES = false;
  65062. _this.GLOSSINESS = false;
  65063. _this.ROUGHNESS = false;
  65064. _this.EMISSIVEASILLUMINATION = false;
  65065. _this.LINKEMISSIVEWITHDIFFUSE = false;
  65066. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  65067. _this.LIGHTMAP = false;
  65068. _this.LIGHTMAPDIRECTUV = 0;
  65069. _this.OBJECTSPACE_NORMALMAP = false;
  65070. _this.USELIGHTMAPASSHADOWMAP = false;
  65071. _this.REFLECTIONMAP_3D = false;
  65072. _this.REFLECTIONMAP_SPHERICAL = false;
  65073. _this.REFLECTIONMAP_PLANAR = false;
  65074. _this.REFLECTIONMAP_CUBIC = false;
  65075. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  65076. _this.REFLECTIONMAP_PROJECTION = false;
  65077. _this.REFLECTIONMAP_SKYBOX = false;
  65078. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  65079. _this.REFLECTIONMAP_EXPLICIT = false;
  65080. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  65081. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  65082. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  65083. _this.INVERTCUBICMAP = false;
  65084. _this.LOGARITHMICDEPTH = false;
  65085. _this.REFRACTION = false;
  65086. _this.REFRACTIONMAP_3D = false;
  65087. _this.REFLECTIONOVERALPHA = false;
  65088. _this.TWOSIDEDLIGHTING = false;
  65089. _this.SHADOWFLOAT = false;
  65090. _this.MORPHTARGETS = false;
  65091. _this.MORPHTARGETS_NORMAL = false;
  65092. _this.MORPHTARGETS_TANGENT = false;
  65093. _this.NUM_MORPH_INFLUENCERS = 0;
  65094. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  65095. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  65096. _this.IMAGEPROCESSING = false;
  65097. _this.VIGNETTE = false;
  65098. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  65099. _this.VIGNETTEBLENDMODEOPAQUE = false;
  65100. _this.TONEMAPPING = false;
  65101. _this.TONEMAPPING_ACES = false;
  65102. _this.CONTRAST = false;
  65103. _this.COLORCURVES = false;
  65104. _this.COLORGRADING = false;
  65105. _this.COLORGRADING3D = false;
  65106. _this.SAMPLER3DGREENDEPTH = false;
  65107. _this.SAMPLER3DBGRMAP = false;
  65108. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  65109. /**
  65110. * If the reflection texture on this material is in linear color space
  65111. * @hidden
  65112. */
  65113. _this.IS_REFLECTION_LINEAR = false;
  65114. /**
  65115. * If the refraction texture on this material is in linear color space
  65116. * @hidden
  65117. */
  65118. _this.IS_REFRACTION_LINEAR = false;
  65119. _this.EXPOSURE = false;
  65120. _this.rebuild();
  65121. return _this;
  65122. }
  65123. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  65124. var modes = [
  65125. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  65126. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  65127. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  65128. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  65129. ];
  65130. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  65131. var mode = modes_1[_i];
  65132. this[mode] = (mode === modeToEnable);
  65133. }
  65134. };
  65135. return StandardMaterialDefines;
  65136. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  65137. /**
  65138. * This is the default material used in Babylon. It is the best trade off between quality
  65139. * and performances.
  65140. * @see http://doc.babylonjs.com/babylon101/materials
  65141. */
  65142. var StandardMaterial = /** @class */ (function (_super) {
  65143. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  65144. /**
  65145. * Instantiates a new standard material.
  65146. * This is the default material used in Babylon. It is the best trade off between quality
  65147. * and performances.
  65148. * @see http://doc.babylonjs.com/babylon101/materials
  65149. * @param name Define the name of the material in the scene
  65150. * @param scene Define the scene the material belong to
  65151. */
  65152. function StandardMaterial(name, scene) {
  65153. var _this = _super.call(this, name, scene) || this;
  65154. /**
  65155. * The color of the material lit by the environmental background lighting.
  65156. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  65157. */
  65158. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65159. /**
  65160. * The basic color of the material as viewed under a light.
  65161. */
  65162. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65163. /**
  65164. * Define how the color and intensity of the highlight given by the light in the material.
  65165. */
  65166. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65167. /**
  65168. * Define the color of the material as if self lit.
  65169. * This will be mixed in the final result even in the absence of light.
  65170. */
  65171. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65172. /**
  65173. * Defines how sharp are the highlights in the material.
  65174. * The bigger the value the sharper giving a more glossy feeling to the result.
  65175. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  65176. */
  65177. _this.specularPower = 64;
  65178. _this._useAlphaFromDiffuseTexture = false;
  65179. _this._useEmissiveAsIllumination = false;
  65180. _this._linkEmissiveWithDiffuse = false;
  65181. _this._useSpecularOverAlpha = false;
  65182. _this._useReflectionOverAlpha = false;
  65183. _this._disableLighting = false;
  65184. _this._useObjectSpaceNormalMap = false;
  65185. _this._useParallax = false;
  65186. _this._useParallaxOcclusion = false;
  65187. /**
  65188. * 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.
  65189. */
  65190. _this.parallaxScaleBias = 0.05;
  65191. _this._roughness = 0;
  65192. /**
  65193. * In case of refraction, define the value of the indice of refraction.
  65194. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65195. */
  65196. _this.indexOfRefraction = 0.98;
  65197. /**
  65198. * Invert the refraction texture alongside the y axis.
  65199. * It can be useful with procedural textures or probe for instance.
  65200. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65201. */
  65202. _this.invertRefractionY = true;
  65203. /**
  65204. * Defines the alpha limits in alpha test mode.
  65205. */
  65206. _this.alphaCutOff = 0.4;
  65207. _this._useLightmapAsShadowmap = false;
  65208. _this._useReflectionFresnelFromSpecular = false;
  65209. _this._useGlossinessFromSpecularMapAlpha = false;
  65210. _this._maxSimultaneousLights = 4;
  65211. _this._invertNormalMapX = false;
  65212. _this._invertNormalMapY = false;
  65213. _this._twoSidedLighting = false;
  65214. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  65215. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  65216. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65217. // Setup the default processing configuration to the scene.
  65218. _this._attachImageProcessingConfiguration(null);
  65219. _this.getRenderTargetTextures = function () {
  65220. _this._renderTargets.reset();
  65221. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  65222. _this._renderTargets.push(_this._reflectionTexture);
  65223. }
  65224. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  65225. _this._renderTargets.push(_this._refractionTexture);
  65226. }
  65227. return _this._renderTargets;
  65228. };
  65229. return _this;
  65230. }
  65231. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  65232. /**
  65233. * Gets the image processing configuration used either in this material.
  65234. */
  65235. get: function () {
  65236. return this._imageProcessingConfiguration;
  65237. },
  65238. /**
  65239. * Sets the Default image processing configuration used either in the this material.
  65240. *
  65241. * If sets to null, the scene one is in use.
  65242. */
  65243. set: function (value) {
  65244. this._attachImageProcessingConfiguration(value);
  65245. // Ensure the effect will be rebuilt.
  65246. this._markAllSubMeshesAsTexturesDirty();
  65247. },
  65248. enumerable: true,
  65249. configurable: true
  65250. });
  65251. /**
  65252. * Attaches a new image processing configuration to the Standard Material.
  65253. * @param configuration
  65254. */
  65255. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  65256. var _this = this;
  65257. if (configuration === this._imageProcessingConfiguration) {
  65258. return;
  65259. }
  65260. // Detaches observer.
  65261. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65262. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65263. }
  65264. // Pick the scene configuration if needed.
  65265. if (!configuration) {
  65266. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  65267. }
  65268. else {
  65269. this._imageProcessingConfiguration = configuration;
  65270. }
  65271. // Attaches observer.
  65272. if (this._imageProcessingConfiguration) {
  65273. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  65274. _this._markAllSubMeshesAsImageProcessingDirty();
  65275. });
  65276. }
  65277. };
  65278. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  65279. /**
  65280. * Gets wether the color curves effect is enabled.
  65281. */
  65282. get: function () {
  65283. return this.imageProcessingConfiguration.colorCurvesEnabled;
  65284. },
  65285. /**
  65286. * Sets wether the color curves effect is enabled.
  65287. */
  65288. set: function (value) {
  65289. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  65290. },
  65291. enumerable: true,
  65292. configurable: true
  65293. });
  65294. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  65295. /**
  65296. * Gets wether the color grading effect is enabled.
  65297. */
  65298. get: function () {
  65299. return this.imageProcessingConfiguration.colorGradingEnabled;
  65300. },
  65301. /**
  65302. * Gets wether the color grading effect is enabled.
  65303. */
  65304. set: function (value) {
  65305. this.imageProcessingConfiguration.colorGradingEnabled = value;
  65306. },
  65307. enumerable: true,
  65308. configurable: true
  65309. });
  65310. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  65311. /**
  65312. * Gets wether tonemapping is enabled or not.
  65313. */
  65314. get: function () {
  65315. return this._imageProcessingConfiguration.toneMappingEnabled;
  65316. },
  65317. /**
  65318. * Sets wether tonemapping is enabled or not
  65319. */
  65320. set: function (value) {
  65321. this._imageProcessingConfiguration.toneMappingEnabled = value;
  65322. },
  65323. enumerable: true,
  65324. configurable: true
  65325. });
  65326. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  65327. /**
  65328. * The camera exposure used on this material.
  65329. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65330. * This corresponds to a photographic exposure.
  65331. */
  65332. get: function () {
  65333. return this._imageProcessingConfiguration.exposure;
  65334. },
  65335. /**
  65336. * The camera exposure used on this material.
  65337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65338. * This corresponds to a photographic exposure.
  65339. */
  65340. set: function (value) {
  65341. this._imageProcessingConfiguration.exposure = value;
  65342. },
  65343. enumerable: true,
  65344. configurable: true
  65345. });
  65346. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  65347. /**
  65348. * Gets The camera contrast used on this material.
  65349. */
  65350. get: function () {
  65351. return this._imageProcessingConfiguration.contrast;
  65352. },
  65353. /**
  65354. * Sets The camera contrast used on this material.
  65355. */
  65356. set: function (value) {
  65357. this._imageProcessingConfiguration.contrast = value;
  65358. },
  65359. enumerable: true,
  65360. configurable: true
  65361. });
  65362. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  65363. /**
  65364. * Gets the Color Grading 2D Lookup Texture.
  65365. */
  65366. get: function () {
  65367. return this._imageProcessingConfiguration.colorGradingTexture;
  65368. },
  65369. /**
  65370. * Sets the Color Grading 2D Lookup Texture.
  65371. */
  65372. set: function (value) {
  65373. this._imageProcessingConfiguration.colorGradingTexture = value;
  65374. },
  65375. enumerable: true,
  65376. configurable: true
  65377. });
  65378. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  65379. /**
  65380. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65381. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65382. * 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;
  65383. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65384. */
  65385. get: function () {
  65386. return this._imageProcessingConfiguration.colorCurves;
  65387. },
  65388. /**
  65389. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65390. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65391. * 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;
  65392. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65393. */
  65394. set: function (value) {
  65395. this._imageProcessingConfiguration.colorCurves = value;
  65396. },
  65397. enumerable: true,
  65398. configurable: true
  65399. });
  65400. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  65401. /**
  65402. * Gets a boolean indicating that current material needs to register RTT
  65403. */
  65404. get: function () {
  65405. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65406. return true;
  65407. }
  65408. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65409. return true;
  65410. }
  65411. return false;
  65412. },
  65413. enumerable: true,
  65414. configurable: true
  65415. });
  65416. /**
  65417. * Gets the current class name of the material e.g. "StandardMaterial"
  65418. * Mainly use in serialization.
  65419. * @returns the class name
  65420. */
  65421. StandardMaterial.prototype.getClassName = function () {
  65422. return "StandardMaterial";
  65423. };
  65424. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  65425. /**
  65426. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  65427. * You can try switching to logarithmic depth.
  65428. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  65429. */
  65430. get: function () {
  65431. return this._useLogarithmicDepth;
  65432. },
  65433. set: function (value) {
  65434. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  65435. this._markAllSubMeshesAsMiscDirty();
  65436. },
  65437. enumerable: true,
  65438. configurable: true
  65439. });
  65440. /**
  65441. * Specifies if the material will require alpha blending
  65442. * @returns a boolean specifying if alpha blending is needed
  65443. */
  65444. StandardMaterial.prototype.needAlphaBlending = function () {
  65445. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  65446. };
  65447. /**
  65448. * Specifies if this material should be rendered in alpha test mode
  65449. * @returns a boolean specifying if an alpha test is needed.
  65450. */
  65451. StandardMaterial.prototype.needAlphaTesting = function () {
  65452. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  65453. };
  65454. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  65455. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  65456. };
  65457. /**
  65458. * Get the texture used for alpha test purpose.
  65459. * @returns the diffuse texture in case of the standard material.
  65460. */
  65461. StandardMaterial.prototype.getAlphaTestTexture = function () {
  65462. return this._diffuseTexture;
  65463. };
  65464. /**
  65465. * Get if the submesh is ready to be used and all its information available.
  65466. * Child classes can use it to update shaders
  65467. * @param mesh defines the mesh to check
  65468. * @param subMesh defines which submesh to check
  65469. * @param useInstances specifies that instances should be used
  65470. * @returns a boolean indicating that the submesh is ready or not
  65471. */
  65472. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65473. if (useInstances === void 0) { useInstances = false; }
  65474. if (subMesh.effect && this.isFrozen) {
  65475. if (this._wasPreviouslyReady) {
  65476. return true;
  65477. }
  65478. }
  65479. if (!subMesh._materialDefines) {
  65480. subMesh._materialDefines = new StandardMaterialDefines();
  65481. }
  65482. var scene = this.getScene();
  65483. var defines = subMesh._materialDefines;
  65484. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  65485. if (defines._renderId === scene.getRenderId()) {
  65486. return true;
  65487. }
  65488. }
  65489. var engine = scene.getEngine();
  65490. // Lights
  65491. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  65492. // Textures
  65493. if (defines._areTexturesDirty) {
  65494. defines._needUVs = false;
  65495. defines.MAINUV1 = false;
  65496. defines.MAINUV2 = false;
  65497. if (scene.texturesEnabled) {
  65498. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65499. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  65500. return false;
  65501. }
  65502. else {
  65503. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  65504. }
  65505. }
  65506. else {
  65507. defines.DIFFUSE = false;
  65508. }
  65509. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65510. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  65511. return false;
  65512. }
  65513. else {
  65514. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  65515. }
  65516. }
  65517. else {
  65518. defines.AMBIENT = false;
  65519. }
  65520. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65521. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  65522. return false;
  65523. }
  65524. else {
  65525. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  65526. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  65527. }
  65528. }
  65529. else {
  65530. defines.OPACITY = false;
  65531. }
  65532. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65533. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  65534. return false;
  65535. }
  65536. else {
  65537. defines._needNormals = true;
  65538. defines.REFLECTION = true;
  65539. defines.ROUGHNESS = (this._roughness > 0);
  65540. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  65541. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  65542. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  65543. switch (this._reflectionTexture.coordinatesMode) {
  65544. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  65545. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  65546. break;
  65547. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  65548. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  65549. break;
  65550. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  65551. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  65552. break;
  65553. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65554. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65555. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65556. break;
  65557. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65558. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65559. break;
  65560. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65561. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65562. break;
  65563. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65564. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65565. break;
  65566. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65567. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65568. break;
  65569. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65570. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65571. default:
  65572. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65573. break;
  65574. }
  65575. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65576. }
  65577. }
  65578. else {
  65579. defines.REFLECTION = false;
  65580. }
  65581. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65582. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65583. return false;
  65584. }
  65585. else {
  65586. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65587. }
  65588. }
  65589. else {
  65590. defines.EMISSIVE = false;
  65591. }
  65592. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65593. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65594. return false;
  65595. }
  65596. else {
  65597. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65598. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65599. }
  65600. }
  65601. else {
  65602. defines.LIGHTMAP = false;
  65603. }
  65604. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65605. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65606. return false;
  65607. }
  65608. else {
  65609. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65610. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65611. }
  65612. }
  65613. else {
  65614. defines.SPECULAR = false;
  65615. }
  65616. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65617. // Bump texure can not be not blocking.
  65618. if (!this._bumpTexture.isReady()) {
  65619. return false;
  65620. }
  65621. else {
  65622. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65623. defines.PARALLAX = this._useParallax;
  65624. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65625. }
  65626. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65627. }
  65628. else {
  65629. defines.BUMP = false;
  65630. }
  65631. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65632. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65633. return false;
  65634. }
  65635. else {
  65636. defines._needUVs = true;
  65637. defines.REFRACTION = true;
  65638. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65639. }
  65640. }
  65641. else {
  65642. defines.REFRACTION = false;
  65643. }
  65644. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65645. }
  65646. else {
  65647. defines.DIFFUSE = false;
  65648. defines.AMBIENT = false;
  65649. defines.OPACITY = false;
  65650. defines.REFLECTION = false;
  65651. defines.EMISSIVE = false;
  65652. defines.LIGHTMAP = false;
  65653. defines.BUMP = false;
  65654. defines.REFRACTION = false;
  65655. }
  65656. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65657. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65658. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65659. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65660. 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);
  65661. }
  65662. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65663. if (!this._imageProcessingConfiguration.isReady()) {
  65664. return false;
  65665. }
  65666. this._imageProcessingConfiguration.prepareDefines(defines);
  65667. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65668. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65669. }
  65670. if (defines._areFresnelDirty) {
  65671. if (StandardMaterial.FresnelEnabled) {
  65672. // Fresnel
  65673. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65674. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65675. this._reflectionFresnelParameters) {
  65676. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65677. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65678. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65679. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65680. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65681. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65682. defines._needNormals = true;
  65683. defines.FRESNEL = true;
  65684. }
  65685. }
  65686. else {
  65687. defines.FRESNEL = false;
  65688. }
  65689. }
  65690. // Misc.
  65691. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65692. // Attribs
  65693. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65694. // Values that need to be evaluated on every frame
  65695. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  65696. // Get correct effect
  65697. if (defines.isDirty) {
  65698. defines.markAsProcessed();
  65699. // Fallbacks
  65700. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  65701. if (defines.REFLECTION) {
  65702. fallbacks.addFallback(0, "REFLECTION");
  65703. }
  65704. if (defines.SPECULAR) {
  65705. fallbacks.addFallback(0, "SPECULAR");
  65706. }
  65707. if (defines.BUMP) {
  65708. fallbacks.addFallback(0, "BUMP");
  65709. }
  65710. if (defines.PARALLAX) {
  65711. fallbacks.addFallback(1, "PARALLAX");
  65712. }
  65713. if (defines.PARALLAXOCCLUSION) {
  65714. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  65715. }
  65716. if (defines.SPECULAROVERALPHA) {
  65717. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  65718. }
  65719. if (defines.FOG) {
  65720. fallbacks.addFallback(1, "FOG");
  65721. }
  65722. if (defines.POINTSIZE) {
  65723. fallbacks.addFallback(0, "POINTSIZE");
  65724. }
  65725. if (defines.LOGARITHMICDEPTH) {
  65726. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  65727. }
  65728. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  65729. if (defines.SPECULARTERM) {
  65730. fallbacks.addFallback(0, "SPECULARTERM");
  65731. }
  65732. if (defines.DIFFUSEFRESNEL) {
  65733. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  65734. }
  65735. if (defines.OPACITYFRESNEL) {
  65736. fallbacks.addFallback(2, "OPACITYFRESNEL");
  65737. }
  65738. if (defines.REFLECTIONFRESNEL) {
  65739. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  65740. }
  65741. if (defines.EMISSIVEFRESNEL) {
  65742. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  65743. }
  65744. if (defines.FRESNEL) {
  65745. fallbacks.addFallback(4, "FRESNEL");
  65746. }
  65747. //Attributes
  65748. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  65749. if (defines.NORMAL) {
  65750. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  65751. }
  65752. if (defines.UV1) {
  65753. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  65754. }
  65755. if (defines.UV2) {
  65756. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  65757. }
  65758. if (defines.VERTEXCOLOR) {
  65759. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  65760. }
  65761. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  65762. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  65763. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  65764. var shaderName = "default";
  65765. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  65766. "vFogInfos", "vFogColor", "pointSize",
  65767. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  65768. "mBones",
  65769. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  65770. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  65771. "vReflectionPosition", "vReflectionSize",
  65772. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  65773. ];
  65774. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  65775. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  65776. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  65777. var uniformBuffers = ["Material", "Scene"];
  65778. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  65779. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  65780. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  65781. }
  65782. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  65783. uniformsNames: uniforms,
  65784. uniformBuffersNames: uniformBuffers,
  65785. samplers: samplers,
  65786. defines: defines,
  65787. maxSimultaneousLights: this._maxSimultaneousLights
  65788. });
  65789. if (this.customShaderNameResolve) {
  65790. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  65791. }
  65792. var join = defines.toString();
  65793. var previousEffect = subMesh.effect;
  65794. var effect = scene.getEngine().createEffect(shaderName, {
  65795. attributes: attribs,
  65796. uniformsNames: uniforms,
  65797. uniformBuffersNames: uniformBuffers,
  65798. samplers: samplers,
  65799. defines: join,
  65800. fallbacks: fallbacks,
  65801. onCompiled: this.onCompiled,
  65802. onError: this.onError,
  65803. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  65804. }, engine);
  65805. if (effect) {
  65806. // Use previous effect while new one is compiling
  65807. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  65808. effect = previousEffect;
  65809. defines.markAsUnprocessed();
  65810. }
  65811. else {
  65812. scene.resetCachedMaterial();
  65813. subMesh.setEffect(effect, defines);
  65814. this.buildUniformLayout();
  65815. }
  65816. }
  65817. }
  65818. if (!subMesh.effect || !subMesh.effect.isReady()) {
  65819. return false;
  65820. }
  65821. defines._renderId = scene.getRenderId();
  65822. this._wasPreviouslyReady = true;
  65823. return true;
  65824. };
  65825. /**
  65826. * Builds the material UBO layouts.
  65827. * Used internally during the effect preparation.
  65828. */
  65829. StandardMaterial.prototype.buildUniformLayout = function () {
  65830. // Order is important !
  65831. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  65832. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  65833. this._uniformBuffer.addUniform("opacityParts", 4);
  65834. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  65835. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  65836. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  65837. this._uniformBuffer.addUniform("refractionRightColor", 4);
  65838. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  65839. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  65840. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  65841. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  65842. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  65843. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  65844. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  65845. this._uniformBuffer.addUniform("vReflectionSize", 3);
  65846. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  65847. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  65848. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  65849. this._uniformBuffer.addUniform("vBumpInfos", 3);
  65850. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  65851. this._uniformBuffer.addUniform("ambientMatrix", 16);
  65852. this._uniformBuffer.addUniform("opacityMatrix", 16);
  65853. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  65854. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  65855. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  65856. this._uniformBuffer.addUniform("specularMatrix", 16);
  65857. this._uniformBuffer.addUniform("bumpMatrix", 16);
  65858. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  65859. this._uniformBuffer.addUniform("refractionMatrix", 16);
  65860. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  65861. this._uniformBuffer.addUniform("vSpecularColor", 4);
  65862. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  65863. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  65864. this._uniformBuffer.addUniform("pointSize", 1);
  65865. this._uniformBuffer.create();
  65866. };
  65867. /**
  65868. * Unbinds the material from the mesh
  65869. */
  65870. StandardMaterial.prototype.unbind = function () {
  65871. if (this._activeEffect) {
  65872. var needFlag = false;
  65873. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65874. this._activeEffect.setTexture("reflection2DSampler", null);
  65875. needFlag = true;
  65876. }
  65877. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65878. this._activeEffect.setTexture("refraction2DSampler", null);
  65879. needFlag = true;
  65880. }
  65881. if (needFlag) {
  65882. this._markAllSubMeshesAsTexturesDirty();
  65883. }
  65884. }
  65885. _super.prototype.unbind.call(this);
  65886. };
  65887. /**
  65888. * Binds the submesh to this material by preparing the effect and shader to draw
  65889. * @param world defines the world transformation matrix
  65890. * @param mesh defines the mesh containing the submesh
  65891. * @param subMesh defines the submesh to bind the material to
  65892. */
  65893. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65894. var scene = this.getScene();
  65895. var defines = subMesh._materialDefines;
  65896. if (!defines) {
  65897. return;
  65898. }
  65899. var effect = subMesh.effect;
  65900. if (!effect) {
  65901. return;
  65902. }
  65903. this._activeEffect = effect;
  65904. // Matrices
  65905. this.bindOnlyWorldMatrix(world);
  65906. // Normal Matrix
  65907. if (defines.OBJECTSPACE_NORMALMAP) {
  65908. world.toNormalMatrix(this._normalMatrix);
  65909. this.bindOnlyNormalMatrix(this._normalMatrix);
  65910. }
  65911. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  65912. // Bones
  65913. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  65914. if (mustRebind) {
  65915. this._uniformBuffer.bindToEffect(effect, "Material");
  65916. this.bindViewProjection(effect);
  65917. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  65918. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  65919. // Fresnel
  65920. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  65921. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  65922. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  65923. }
  65924. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  65925. this._uniformBuffer.updateColor4("opacityParts", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
  65926. }
  65927. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  65928. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  65929. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  65930. }
  65931. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  65932. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  65933. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  65934. }
  65935. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  65936. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  65937. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  65938. }
  65939. }
  65940. // Textures
  65941. if (scene.texturesEnabled) {
  65942. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65943. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  65944. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  65945. if (this._diffuseTexture.hasAlpha) {
  65946. effect.setFloat("alphaCutOff", this.alphaCutOff);
  65947. }
  65948. }
  65949. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65950. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  65951. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  65952. }
  65953. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65954. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  65955. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  65956. }
  65957. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65958. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  65959. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  65960. if (this._reflectionTexture.boundingBoxSize) {
  65961. var cubeTexture = this._reflectionTexture;
  65962. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  65963. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  65964. }
  65965. }
  65966. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65967. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  65968. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  65969. }
  65970. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65971. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  65972. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  65973. }
  65974. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65975. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  65976. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  65977. }
  65978. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65979. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  65980. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  65981. if (scene._mirroredCameraPosition) {
  65982. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  65983. }
  65984. else {
  65985. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  65986. }
  65987. }
  65988. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65989. var depth = 1.0;
  65990. if (!this._refractionTexture.isCube) {
  65991. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  65992. if (this._refractionTexture.depth) {
  65993. depth = this._refractionTexture.depth;
  65994. }
  65995. }
  65996. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  65997. }
  65998. }
  65999. // Point size
  66000. if (this.pointsCloud) {
  66001. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  66002. }
  66003. if (defines.SPECULARTERM) {
  66004. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  66005. }
  66006. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  66007. // Diffuse
  66008. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  66009. }
  66010. // Textures
  66011. if (scene.texturesEnabled) {
  66012. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66013. effect.setTexture("diffuseSampler", this._diffuseTexture);
  66014. }
  66015. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66016. effect.setTexture("ambientSampler", this._ambientTexture);
  66017. }
  66018. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66019. effect.setTexture("opacitySampler", this._opacityTexture);
  66020. }
  66021. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66022. if (this._reflectionTexture.isCube) {
  66023. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  66024. }
  66025. else {
  66026. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  66027. }
  66028. }
  66029. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66030. effect.setTexture("emissiveSampler", this._emissiveTexture);
  66031. }
  66032. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66033. effect.setTexture("lightmapSampler", this._lightmapTexture);
  66034. }
  66035. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66036. effect.setTexture("specularSampler", this._specularTexture);
  66037. }
  66038. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66039. effect.setTexture("bumpSampler", this._bumpTexture);
  66040. }
  66041. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66042. var depth = 1.0;
  66043. if (this._refractionTexture.isCube) {
  66044. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  66045. }
  66046. else {
  66047. effect.setTexture("refraction2DSampler", this._refractionTexture);
  66048. }
  66049. }
  66050. }
  66051. // Clip plane
  66052. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  66053. // Colors
  66054. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  66055. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  66056. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  66057. }
  66058. if (mustRebind || !this.isFrozen) {
  66059. // Lights
  66060. if (scene.lightsEnabled && !this._disableLighting) {
  66061. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  66062. }
  66063. // View
  66064. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  66065. this.bindView(effect);
  66066. }
  66067. // Fog
  66068. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  66069. // Morph targets
  66070. if (defines.NUM_MORPH_INFLUENCERS) {
  66071. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  66072. }
  66073. // Log. depth
  66074. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  66075. // image processing
  66076. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  66077. this._imageProcessingConfiguration.bind(this._activeEffect);
  66078. }
  66079. }
  66080. this._uniformBuffer.update();
  66081. this._afterBind(mesh, this._activeEffect);
  66082. };
  66083. /**
  66084. * Get the list of animatables in the material.
  66085. * @returns the list of animatables object used in the material
  66086. */
  66087. StandardMaterial.prototype.getAnimatables = function () {
  66088. var results = [];
  66089. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  66090. results.push(this._diffuseTexture);
  66091. }
  66092. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  66093. results.push(this._ambientTexture);
  66094. }
  66095. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  66096. results.push(this._opacityTexture);
  66097. }
  66098. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  66099. results.push(this._reflectionTexture);
  66100. }
  66101. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  66102. results.push(this._emissiveTexture);
  66103. }
  66104. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  66105. results.push(this._specularTexture);
  66106. }
  66107. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  66108. results.push(this._bumpTexture);
  66109. }
  66110. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  66111. results.push(this._lightmapTexture);
  66112. }
  66113. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  66114. results.push(this._refractionTexture);
  66115. }
  66116. return results;
  66117. };
  66118. /**
  66119. * Gets the active textures from the material
  66120. * @returns an array of textures
  66121. */
  66122. StandardMaterial.prototype.getActiveTextures = function () {
  66123. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66124. if (this._diffuseTexture) {
  66125. activeTextures.push(this._diffuseTexture);
  66126. }
  66127. if (this._ambientTexture) {
  66128. activeTextures.push(this._ambientTexture);
  66129. }
  66130. if (this._opacityTexture) {
  66131. activeTextures.push(this._opacityTexture);
  66132. }
  66133. if (this._reflectionTexture) {
  66134. activeTextures.push(this._reflectionTexture);
  66135. }
  66136. if (this._emissiveTexture) {
  66137. activeTextures.push(this._emissiveTexture);
  66138. }
  66139. if (this._specularTexture) {
  66140. activeTextures.push(this._specularTexture);
  66141. }
  66142. if (this._bumpTexture) {
  66143. activeTextures.push(this._bumpTexture);
  66144. }
  66145. if (this._lightmapTexture) {
  66146. activeTextures.push(this._lightmapTexture);
  66147. }
  66148. if (this._refractionTexture) {
  66149. activeTextures.push(this._refractionTexture);
  66150. }
  66151. return activeTextures;
  66152. };
  66153. /**
  66154. * Specifies if the material uses a texture
  66155. * @param texture defines the texture to check against the material
  66156. * @returns a boolean specifying if the material uses the texture
  66157. */
  66158. StandardMaterial.prototype.hasTexture = function (texture) {
  66159. if (_super.prototype.hasTexture.call(this, texture)) {
  66160. return true;
  66161. }
  66162. if (this._diffuseTexture === texture) {
  66163. return true;
  66164. }
  66165. if (this._ambientTexture === texture) {
  66166. return true;
  66167. }
  66168. if (this._opacityTexture === texture) {
  66169. return true;
  66170. }
  66171. if (this._reflectionTexture === texture) {
  66172. return true;
  66173. }
  66174. if (this._emissiveTexture === texture) {
  66175. return true;
  66176. }
  66177. if (this._specularTexture === texture) {
  66178. return true;
  66179. }
  66180. if (this._bumpTexture === texture) {
  66181. return true;
  66182. }
  66183. if (this._lightmapTexture === texture) {
  66184. return true;
  66185. }
  66186. if (this._refractionTexture === texture) {
  66187. return true;
  66188. }
  66189. return false;
  66190. };
  66191. /**
  66192. * Disposes the material
  66193. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66194. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66195. */
  66196. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  66197. if (forceDisposeTextures) {
  66198. if (this._diffuseTexture) {
  66199. this._diffuseTexture.dispose();
  66200. }
  66201. if (this._ambientTexture) {
  66202. this._ambientTexture.dispose();
  66203. }
  66204. if (this._opacityTexture) {
  66205. this._opacityTexture.dispose();
  66206. }
  66207. if (this._reflectionTexture) {
  66208. this._reflectionTexture.dispose();
  66209. }
  66210. if (this._emissiveTexture) {
  66211. this._emissiveTexture.dispose();
  66212. }
  66213. if (this._specularTexture) {
  66214. this._specularTexture.dispose();
  66215. }
  66216. if (this._bumpTexture) {
  66217. this._bumpTexture.dispose();
  66218. }
  66219. if (this._lightmapTexture) {
  66220. this._lightmapTexture.dispose();
  66221. }
  66222. if (this._refractionTexture) {
  66223. this._refractionTexture.dispose();
  66224. }
  66225. }
  66226. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66227. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66228. }
  66229. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66230. };
  66231. /**
  66232. * Makes a duplicate of the material, and gives it a new name
  66233. * @param name defines the new name for the duplicated material
  66234. * @returns the cloned material
  66235. */
  66236. StandardMaterial.prototype.clone = function (name) {
  66237. var _this = this;
  66238. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  66239. result.name = name;
  66240. result.id = name;
  66241. return result;
  66242. };
  66243. /**
  66244. * Serializes this material in a JSON representation
  66245. * @returns the serialized material object
  66246. */
  66247. StandardMaterial.prototype.serialize = function () {
  66248. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66249. };
  66250. /**
  66251. * Creates a standard material from parsed material data
  66252. * @param source defines the JSON representation of the material
  66253. * @param scene defines the hosting scene
  66254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66255. * @returns a new standard material
  66256. */
  66257. StandardMaterial.Parse = function (source, scene, rootUrl) {
  66258. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  66259. };
  66260. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  66261. // Flags used to enable or disable a type of texture for all Standard Materials
  66262. /**
  66263. * Are diffuse textures enabled in the application.
  66264. */
  66265. get: function () {
  66266. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  66267. },
  66268. set: function (value) {
  66269. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  66270. },
  66271. enumerable: true,
  66272. configurable: true
  66273. });
  66274. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  66275. /**
  66276. * Are ambient textures enabled in the application.
  66277. */
  66278. get: function () {
  66279. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  66280. },
  66281. set: function (value) {
  66282. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  66283. },
  66284. enumerable: true,
  66285. configurable: true
  66286. });
  66287. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  66288. /**
  66289. * Are opacity textures enabled in the application.
  66290. */
  66291. get: function () {
  66292. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  66293. },
  66294. set: function (value) {
  66295. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  66296. },
  66297. enumerable: true,
  66298. configurable: true
  66299. });
  66300. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  66301. /**
  66302. * Are reflection textures enabled in the application.
  66303. */
  66304. get: function () {
  66305. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  66306. },
  66307. set: function (value) {
  66308. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  66309. },
  66310. enumerable: true,
  66311. configurable: true
  66312. });
  66313. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  66314. /**
  66315. * Are emissive textures enabled in the application.
  66316. */
  66317. get: function () {
  66318. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  66319. },
  66320. set: function (value) {
  66321. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  66322. },
  66323. enumerable: true,
  66324. configurable: true
  66325. });
  66326. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  66327. /**
  66328. * Are specular textures enabled in the application.
  66329. */
  66330. get: function () {
  66331. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  66332. },
  66333. set: function (value) {
  66334. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  66335. },
  66336. enumerable: true,
  66337. configurable: true
  66338. });
  66339. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  66340. /**
  66341. * Are bump textures enabled in the application.
  66342. */
  66343. get: function () {
  66344. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  66345. },
  66346. set: function (value) {
  66347. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  66348. },
  66349. enumerable: true,
  66350. configurable: true
  66351. });
  66352. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  66353. /**
  66354. * Are lightmap textures enabled in the application.
  66355. */
  66356. get: function () {
  66357. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  66358. },
  66359. set: function (value) {
  66360. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  66361. },
  66362. enumerable: true,
  66363. configurable: true
  66364. });
  66365. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  66366. /**
  66367. * Are refraction textures enabled in the application.
  66368. */
  66369. get: function () {
  66370. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  66371. },
  66372. set: function (value) {
  66373. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  66374. },
  66375. enumerable: true,
  66376. configurable: true
  66377. });
  66378. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  66379. /**
  66380. * Are color grading textures enabled in the application.
  66381. */
  66382. get: function () {
  66383. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  66384. },
  66385. set: function (value) {
  66386. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  66387. },
  66388. enumerable: true,
  66389. configurable: true
  66390. });
  66391. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  66392. /**
  66393. * Are fresnels enabled in the application.
  66394. */
  66395. get: function () {
  66396. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  66397. },
  66398. set: function (value) {
  66399. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  66400. },
  66401. enumerable: true,
  66402. configurable: true
  66403. });
  66404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  66406. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  66407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66409. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  66410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  66412. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  66413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66415. ], StandardMaterial.prototype, "ambientTexture", void 0);
  66416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  66418. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  66419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66421. ], StandardMaterial.prototype, "opacityTexture", void 0);
  66422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  66424. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  66425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66427. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  66428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  66430. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  66431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66433. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  66434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  66436. ], StandardMaterial.prototype, "_specularTexture", void 0);
  66437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66439. ], StandardMaterial.prototype, "specularTexture", void 0);
  66440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  66442. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  66443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66445. ], StandardMaterial.prototype, "bumpTexture", void 0);
  66446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  66448. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  66449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66451. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  66452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  66454. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  66455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66457. ], StandardMaterial.prototype, "refractionTexture", void 0);
  66458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  66460. ], StandardMaterial.prototype, "ambientColor", void 0);
  66461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  66463. ], StandardMaterial.prototype, "diffuseColor", void 0);
  66464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  66466. ], StandardMaterial.prototype, "specularColor", void 0);
  66467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  66469. ], StandardMaterial.prototype, "emissiveColor", void 0);
  66470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66472. ], StandardMaterial.prototype, "specularPower", void 0);
  66473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  66475. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  66476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66478. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  66479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  66481. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  66482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66484. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  66485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  66487. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  66488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66490. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  66491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  66493. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  66494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66496. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  66497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  66499. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  66500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66502. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  66503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  66505. ], StandardMaterial.prototype, "_disableLighting", void 0);
  66506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66508. ], StandardMaterial.prototype, "disableLighting", void 0);
  66509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  66511. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  66512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66514. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  66515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  66517. ], StandardMaterial.prototype, "_useParallax", void 0);
  66518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66520. ], StandardMaterial.prototype, "useParallax", void 0);
  66521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  66523. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  66524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66526. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  66527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66529. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  66530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  66532. ], StandardMaterial.prototype, "_roughness", void 0);
  66533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66535. ], StandardMaterial.prototype, "roughness", void 0);
  66536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66538. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  66539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66541. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  66542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66544. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  66545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  66547. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  66548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66550. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  66551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  66553. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66556. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66559. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66562. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66565. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66568. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66571. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66574. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66576. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66577. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66580. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66583. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66586. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66589. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66592. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66595. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66598. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66601. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66604. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66607. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66610. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66613. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66616. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66619. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66620. return StandardMaterial;
  66621. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66622. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66623. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66624. return new StandardMaterial("default material", scene);
  66625. };
  66626. /***/ }),
  66627. /***/ "./Materials/uniformBuffer.ts":
  66628. /*!************************************!*\
  66629. !*** ./Materials/uniformBuffer.ts ***!
  66630. \************************************/
  66631. /*! exports provided: UniformBuffer */
  66632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66633. "use strict";
  66634. __webpack_require__.r(__webpack_exports__);
  66635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66636. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66637. /**
  66638. * Uniform buffer objects.
  66639. *
  66640. * Handles blocks of uniform on the GPU.
  66641. *
  66642. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66643. *
  66644. * For more information, please refer to :
  66645. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66646. */
  66647. var UniformBuffer = /** @class */ (function () {
  66648. /**
  66649. * Instantiates a new Uniform buffer objects.
  66650. *
  66651. * Handles blocks of uniform on the GPU.
  66652. *
  66653. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66654. *
  66655. * For more information, please refer to :
  66656. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66657. * @param engine Define the engine the buffer is associated with
  66658. * @param data Define the data contained in the buffer
  66659. * @param dynamic Define if the buffer is updatable
  66660. */
  66661. function UniformBuffer(engine, data, dynamic) {
  66662. this._engine = engine;
  66663. this._noUBO = !engine.supportsUniformBuffers;
  66664. this._dynamic = dynamic;
  66665. this._data = data || [];
  66666. this._uniformLocations = {};
  66667. this._uniformSizes = {};
  66668. this._uniformLocationPointer = 0;
  66669. this._needSync = false;
  66670. if (this._noUBO) {
  66671. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66672. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66673. this.updateFloat = this._updateFloatForEffect;
  66674. this.updateFloat2 = this._updateFloat2ForEffect;
  66675. this.updateFloat3 = this._updateFloat3ForEffect;
  66676. this.updateFloat4 = this._updateFloat4ForEffect;
  66677. this.updateMatrix = this._updateMatrixForEffect;
  66678. this.updateVector3 = this._updateVector3ForEffect;
  66679. this.updateVector4 = this._updateVector4ForEffect;
  66680. this.updateColor3 = this._updateColor3ForEffect;
  66681. this.updateColor4 = this._updateColor4ForEffect;
  66682. }
  66683. else {
  66684. this._engine._uniformBuffers.push(this);
  66685. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66686. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66687. this.updateFloat = this._updateFloatForUniform;
  66688. this.updateFloat2 = this._updateFloat2ForUniform;
  66689. this.updateFloat3 = this._updateFloat3ForUniform;
  66690. this.updateFloat4 = this._updateFloat4ForUniform;
  66691. this.updateMatrix = this._updateMatrixForUniform;
  66692. this.updateVector3 = this._updateVector3ForUniform;
  66693. this.updateVector4 = this._updateVector4ForUniform;
  66694. this.updateColor3 = this._updateColor3ForUniform;
  66695. this.updateColor4 = this._updateColor4ForUniform;
  66696. }
  66697. }
  66698. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  66699. /**
  66700. * Indicates if the buffer is using the WebGL2 UBO implementation,
  66701. * or just falling back on setUniformXXX calls.
  66702. */
  66703. get: function () {
  66704. return !this._noUBO;
  66705. },
  66706. enumerable: true,
  66707. configurable: true
  66708. });
  66709. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  66710. /**
  66711. * Indicates if the WebGL underlying uniform buffer is in sync
  66712. * with the javascript cache data.
  66713. */
  66714. get: function () {
  66715. return !this._needSync;
  66716. },
  66717. enumerable: true,
  66718. configurable: true
  66719. });
  66720. /**
  66721. * Indicates if the WebGL underlying uniform buffer is dynamic.
  66722. * Also, a dynamic UniformBuffer will disable cache verification and always
  66723. * update the underlying WebGL uniform buffer to the GPU.
  66724. * @returns if Dynamic, otherwise false
  66725. */
  66726. UniformBuffer.prototype.isDynamic = function () {
  66727. return this._dynamic !== undefined;
  66728. };
  66729. /**
  66730. * The data cache on JS side.
  66731. * @returns the underlying data as a float array
  66732. */
  66733. UniformBuffer.prototype.getData = function () {
  66734. return this._bufferData;
  66735. };
  66736. /**
  66737. * The underlying WebGL Uniform buffer.
  66738. * @returns the webgl buffer
  66739. */
  66740. UniformBuffer.prototype.getBuffer = function () {
  66741. return this._buffer;
  66742. };
  66743. /**
  66744. * std140 layout specifies how to align data within an UBO structure.
  66745. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  66746. * for specs.
  66747. */
  66748. UniformBuffer.prototype._fillAlignment = function (size) {
  66749. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  66750. // and 4x4 matrices
  66751. // TODO : change if other types are used
  66752. var alignment;
  66753. if (size <= 2) {
  66754. alignment = size;
  66755. }
  66756. else {
  66757. alignment = 4;
  66758. }
  66759. if ((this._uniformLocationPointer % alignment) !== 0) {
  66760. var oldPointer = this._uniformLocationPointer;
  66761. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  66762. var diff = this._uniformLocationPointer - oldPointer;
  66763. for (var i = 0; i < diff; i++) {
  66764. this._data.push(0);
  66765. }
  66766. }
  66767. };
  66768. /**
  66769. * Adds an uniform in the buffer.
  66770. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  66771. * for the layout to be correct !
  66772. * @param name Name of the uniform, as used in the uniform block in the shader.
  66773. * @param size Data size, or data directly.
  66774. */
  66775. UniformBuffer.prototype.addUniform = function (name, size) {
  66776. if (this._noUBO) {
  66777. return;
  66778. }
  66779. if (this._uniformLocations[name] !== undefined) {
  66780. // Already existing uniform
  66781. return;
  66782. }
  66783. // This function must be called in the order of the shader layout !
  66784. // size can be the size of the uniform, or data directly
  66785. var data;
  66786. if (size instanceof Array) {
  66787. data = size;
  66788. size = data.length;
  66789. }
  66790. else {
  66791. size = size;
  66792. data = [];
  66793. // Fill with zeros
  66794. for (var i = 0; i < size; i++) {
  66795. data.push(0);
  66796. }
  66797. }
  66798. this._fillAlignment(size);
  66799. this._uniformSizes[name] = size;
  66800. this._uniformLocations[name] = this._uniformLocationPointer;
  66801. this._uniformLocationPointer += size;
  66802. for (var i = 0; i < size; i++) {
  66803. this._data.push(data[i]);
  66804. }
  66805. this._needSync = true;
  66806. };
  66807. /**
  66808. * Adds a Matrix 4x4 to the uniform buffer.
  66809. * @param name Name of the uniform, as used in the uniform block in the shader.
  66810. * @param mat A 4x4 matrix.
  66811. */
  66812. UniformBuffer.prototype.addMatrix = function (name, mat) {
  66813. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  66814. };
  66815. /**
  66816. * Adds a vec2 to the uniform buffer.
  66817. * @param name Name of the uniform, as used in the uniform block in the shader.
  66818. * @param x Define the x component value of the vec2
  66819. * @param y Define the y component value of the vec2
  66820. */
  66821. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  66822. var temp = [x, y];
  66823. this.addUniform(name, temp);
  66824. };
  66825. /**
  66826. * Adds a vec3 to the uniform buffer.
  66827. * @param name Name of the uniform, as used in the uniform block in the shader.
  66828. * @param x Define the x component value of the vec3
  66829. * @param y Define the y component value of the vec3
  66830. * @param z Define the z component value of the vec3
  66831. */
  66832. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  66833. var temp = [x, y, z];
  66834. this.addUniform(name, temp);
  66835. };
  66836. /**
  66837. * Adds a vec3 to the uniform buffer.
  66838. * @param name Name of the uniform, as used in the uniform block in the shader.
  66839. * @param color Define the vec3 from a Color
  66840. */
  66841. UniformBuffer.prototype.addColor3 = function (name, color) {
  66842. var temp = new Array();
  66843. color.toArray(temp);
  66844. this.addUniform(name, temp);
  66845. };
  66846. /**
  66847. * Adds a vec4 to the uniform buffer.
  66848. * @param name Name of the uniform, as used in the uniform block in the shader.
  66849. * @param color Define the rgb components from a Color
  66850. * @param alpha Define the a component of the vec4
  66851. */
  66852. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  66853. var temp = new Array();
  66854. color.toArray(temp);
  66855. temp.push(alpha);
  66856. this.addUniform(name, temp);
  66857. };
  66858. /**
  66859. * Adds a vec3 to the uniform buffer.
  66860. * @param name Name of the uniform, as used in the uniform block in the shader.
  66861. * @param vector Define the vec3 components from a Vector
  66862. */
  66863. UniformBuffer.prototype.addVector3 = function (name, vector) {
  66864. var temp = new Array();
  66865. vector.toArray(temp);
  66866. this.addUniform(name, temp);
  66867. };
  66868. /**
  66869. * Adds a Matrix 3x3 to the uniform buffer.
  66870. * @param name Name of the uniform, as used in the uniform block in the shader.
  66871. */
  66872. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  66873. this.addUniform(name, 12);
  66874. };
  66875. /**
  66876. * Adds a Matrix 2x2 to the uniform buffer.
  66877. * @param name Name of the uniform, as used in the uniform block in the shader.
  66878. */
  66879. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  66880. this.addUniform(name, 8);
  66881. };
  66882. /**
  66883. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  66884. */
  66885. UniformBuffer.prototype.create = function () {
  66886. if (this._noUBO) {
  66887. return;
  66888. }
  66889. if (this._buffer) {
  66890. return; // nothing to do
  66891. }
  66892. // See spec, alignment must be filled as a vec4
  66893. this._fillAlignment(4);
  66894. this._bufferData = new Float32Array(this._data);
  66895. this._rebuild();
  66896. this._needSync = true;
  66897. };
  66898. /** @hidden */
  66899. UniformBuffer.prototype._rebuild = function () {
  66900. if (this._noUBO) {
  66901. return;
  66902. }
  66903. if (this._dynamic) {
  66904. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  66905. }
  66906. else {
  66907. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  66908. }
  66909. };
  66910. /**
  66911. * Updates the WebGL Uniform Buffer on the GPU.
  66912. * If the `dynamic` flag is set to true, no cache comparison is done.
  66913. * Otherwise, the buffer will be updated only if the cache differs.
  66914. */
  66915. UniformBuffer.prototype.update = function () {
  66916. if (!this._buffer) {
  66917. this.create();
  66918. return;
  66919. }
  66920. if (!this._dynamic && !this._needSync) {
  66921. return;
  66922. }
  66923. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  66924. this._needSync = false;
  66925. };
  66926. /**
  66927. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  66928. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66929. * @param data Define the flattened data
  66930. * @param size Define the size of the data.
  66931. */
  66932. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  66933. var location = this._uniformLocations[uniformName];
  66934. if (location === undefined) {
  66935. if (this._buffer) {
  66936. // Cannot add an uniform if the buffer is already created
  66937. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  66938. return;
  66939. }
  66940. this.addUniform(uniformName, size);
  66941. location = this._uniformLocations[uniformName];
  66942. }
  66943. if (!this._buffer) {
  66944. this.create();
  66945. }
  66946. if (!this._dynamic) {
  66947. // Cache for static uniform buffers
  66948. var changed = false;
  66949. for (var i = 0; i < size; i++) {
  66950. if (this._bufferData[location + i] !== data[i]) {
  66951. changed = true;
  66952. this._bufferData[location + i] = data[i];
  66953. }
  66954. }
  66955. this._needSync = this._needSync || changed;
  66956. }
  66957. else {
  66958. // No cache for dynamic
  66959. for (var i = 0; i < size; i++) {
  66960. this._bufferData[location + i] = data[i];
  66961. }
  66962. }
  66963. };
  66964. // Update methods
  66965. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  66966. // To match std140, matrix must be realigned
  66967. for (var i = 0; i < 3; i++) {
  66968. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  66969. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  66970. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  66971. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66972. }
  66973. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  66974. };
  66975. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  66976. this._currentEffect.setMatrix3x3(name, matrix);
  66977. };
  66978. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  66979. this._currentEffect.setMatrix2x2(name, matrix);
  66980. };
  66981. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  66982. // To match std140, matrix must be realigned
  66983. for (var i = 0; i < 2; i++) {
  66984. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  66985. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  66986. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  66987. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66988. }
  66989. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  66990. };
  66991. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  66992. this._currentEffect.setFloat(name, x);
  66993. };
  66994. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  66995. UniformBuffer._tempBuffer[0] = x;
  66996. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  66997. };
  66998. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  66999. if (suffix === void 0) { suffix = ""; }
  67000. this._currentEffect.setFloat2(name + suffix, x, y);
  67001. };
  67002. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  67003. UniformBuffer._tempBuffer[0] = x;
  67004. UniformBuffer._tempBuffer[1] = y;
  67005. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  67006. };
  67007. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  67008. if (suffix === void 0) { suffix = ""; }
  67009. this._currentEffect.setFloat3(name + suffix, x, y, z);
  67010. };
  67011. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  67012. UniformBuffer._tempBuffer[0] = x;
  67013. UniformBuffer._tempBuffer[1] = y;
  67014. UniformBuffer._tempBuffer[2] = z;
  67015. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67016. };
  67017. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  67018. if (suffix === void 0) { suffix = ""; }
  67019. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  67020. };
  67021. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  67022. UniformBuffer._tempBuffer[0] = x;
  67023. UniformBuffer._tempBuffer[1] = y;
  67024. UniformBuffer._tempBuffer[2] = z;
  67025. UniformBuffer._tempBuffer[3] = w;
  67026. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67027. };
  67028. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  67029. this._currentEffect.setMatrix(name, mat);
  67030. };
  67031. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  67032. this.updateUniform(name, mat.toArray(), 16);
  67033. };
  67034. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  67035. this._currentEffect.setVector3(name, vector);
  67036. };
  67037. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  67038. vector.toArray(UniformBuffer._tempBuffer);
  67039. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67040. };
  67041. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  67042. this._currentEffect.setVector4(name, vector);
  67043. };
  67044. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  67045. vector.toArray(UniformBuffer._tempBuffer);
  67046. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67047. };
  67048. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  67049. if (suffix === void 0) { suffix = ""; }
  67050. this._currentEffect.setColor3(name + suffix, color);
  67051. };
  67052. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  67053. color.toArray(UniformBuffer._tempBuffer);
  67054. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67055. };
  67056. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  67057. if (suffix === void 0) { suffix = ""; }
  67058. this._currentEffect.setColor4(name + suffix, color, alpha);
  67059. };
  67060. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  67061. color.toArray(UniformBuffer._tempBuffer);
  67062. UniformBuffer._tempBuffer[3] = alpha;
  67063. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67064. };
  67065. /**
  67066. * Sets a sampler uniform on the effect.
  67067. * @param name Define the name of the sampler.
  67068. * @param texture Define the texture to set in the sampler
  67069. */
  67070. UniformBuffer.prototype.setTexture = function (name, texture) {
  67071. this._currentEffect.setTexture(name, texture);
  67072. };
  67073. /**
  67074. * Directly updates the value of the uniform in the cache AND on the GPU.
  67075. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67076. * @param data Define the flattened data
  67077. */
  67078. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  67079. this.updateUniform(uniformName, data, data.length);
  67080. this.update();
  67081. };
  67082. /**
  67083. * Binds this uniform buffer to an effect.
  67084. * @param effect Define the effect to bind the buffer to
  67085. * @param name Name of the uniform block in the shader.
  67086. */
  67087. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  67088. this._currentEffect = effect;
  67089. if (this._noUBO || !this._buffer) {
  67090. return;
  67091. }
  67092. effect.bindUniformBuffer(this._buffer, name);
  67093. };
  67094. /**
  67095. * Disposes the uniform buffer.
  67096. */
  67097. UniformBuffer.prototype.dispose = function () {
  67098. if (this._noUBO) {
  67099. return;
  67100. }
  67101. var uniformBuffers = this._engine._uniformBuffers;
  67102. var index = uniformBuffers.indexOf(this);
  67103. if (index !== -1) {
  67104. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  67105. uniformBuffers.pop();
  67106. }
  67107. if (!this._buffer) {
  67108. return;
  67109. }
  67110. if (this._engine._releaseBuffer(this._buffer)) {
  67111. this._buffer = null;
  67112. }
  67113. };
  67114. // Pool for avoiding memory leaks
  67115. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  67116. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  67117. return UniformBuffer;
  67118. }());
  67119. /***/ }),
  67120. /***/ "./Maths/index.ts":
  67121. /*!************************!*\
  67122. !*** ./Maths/index.ts ***!
  67123. \************************/
  67124. /*! exports provided: Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics */
  67125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67126. "use strict";
  67127. __webpack_require__.r(__webpack_exports__);
  67128. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  67130. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  67131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  67132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  67133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  67134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  67135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  67136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  67137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  67138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  67139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  67140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  67141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  67142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  67143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  67144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  67145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  67146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  67147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  67148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  67149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  67150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  67151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  67152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  67153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  67154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  67155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  67156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  67157. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  67158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  67159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  67160. /***/ }),
  67161. /***/ "./Maths/math.scalar.ts":
  67162. /*!******************************!*\
  67163. !*** ./Maths/math.scalar.ts ***!
  67164. \******************************/
  67165. /*! exports provided: Scalar */
  67166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67167. "use strict";
  67168. __webpack_require__.r(__webpack_exports__);
  67169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  67170. /**
  67171. * Scalar computation library
  67172. */
  67173. var Scalar = /** @class */ (function () {
  67174. function Scalar() {
  67175. }
  67176. /**
  67177. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67178. * @param a number
  67179. * @param b number
  67180. * @param epsilon (default = 1.401298E-45)
  67181. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67182. */
  67183. Scalar.WithinEpsilon = function (a, b, epsilon) {
  67184. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  67185. var num = a - b;
  67186. return -epsilon <= num && num <= epsilon;
  67187. };
  67188. /**
  67189. * Returns a string : the upper case translation of the number i to hexadecimal.
  67190. * @param i number
  67191. * @returns the upper case translation of the number i to hexadecimal.
  67192. */
  67193. Scalar.ToHex = function (i) {
  67194. var str = i.toString(16);
  67195. if (i <= 15) {
  67196. return ("0" + str).toUpperCase();
  67197. }
  67198. return str.toUpperCase();
  67199. };
  67200. /**
  67201. * Returns -1 if value is negative and +1 is value is positive.
  67202. * @param value the value
  67203. * @returns the value itself if it's equal to zero.
  67204. */
  67205. Scalar.Sign = function (value) {
  67206. value = +value; // convert to a number
  67207. if (value === 0 || isNaN(value)) {
  67208. return value;
  67209. }
  67210. return value > 0 ? 1 : -1;
  67211. };
  67212. /**
  67213. * Returns the value itself if it's between min and max.
  67214. * Returns min if the value is lower than min.
  67215. * Returns max if the value is greater than max.
  67216. * @param value the value to clmap
  67217. * @param min the min value to clamp to (default: 0)
  67218. * @param max the max value to clamp to (default: 1)
  67219. * @returns the clamped value
  67220. */
  67221. Scalar.Clamp = function (value, min, max) {
  67222. if (min === void 0) { min = 0; }
  67223. if (max === void 0) { max = 1; }
  67224. return Math.min(max, Math.max(min, value));
  67225. };
  67226. /**
  67227. * the log2 of value.
  67228. * @param value the value to compute log2 of
  67229. * @returns the log2 of value.
  67230. */
  67231. Scalar.Log2 = function (value) {
  67232. return Math.log(value) * Math.LOG2E;
  67233. };
  67234. /**
  67235. * Loops the value, so that it is never larger than length and never smaller than 0.
  67236. *
  67237. * This is similar to the modulo operator but it works with floating point numbers.
  67238. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67239. * With t = 5 and length = 2.5, the result would be 0.0.
  67240. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67241. * @param value the value
  67242. * @param length the length
  67243. * @returns the looped value
  67244. */
  67245. Scalar.Repeat = function (value, length) {
  67246. return value - Math.floor(value / length) * length;
  67247. };
  67248. /**
  67249. * Normalize the value between 0.0 and 1.0 using min and max values
  67250. * @param value value to normalize
  67251. * @param min max to normalize between
  67252. * @param max min to normalize between
  67253. * @returns the normalized value
  67254. */
  67255. Scalar.Normalize = function (value, min, max) {
  67256. return (value - min) / (max - min);
  67257. };
  67258. /**
  67259. * Denormalize the value from 0.0 and 1.0 using min and max values
  67260. * @param normalized value to denormalize
  67261. * @param min max to denormalize between
  67262. * @param max min to denormalize between
  67263. * @returns the denormalized value
  67264. */
  67265. Scalar.Denormalize = function (normalized, min, max) {
  67266. return (normalized * (max - min) + min);
  67267. };
  67268. /**
  67269. * Calculates the shortest difference between two given angles given in degrees.
  67270. * @param current current angle in degrees
  67271. * @param target target angle in degrees
  67272. * @returns the delta
  67273. */
  67274. Scalar.DeltaAngle = function (current, target) {
  67275. var num = Scalar.Repeat(target - current, 360.0);
  67276. if (num > 180.0) {
  67277. num -= 360.0;
  67278. }
  67279. return num;
  67280. };
  67281. /**
  67282. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67283. * @param tx value
  67284. * @param length length
  67285. * @returns The returned value will move back and forth between 0 and length
  67286. */
  67287. Scalar.PingPong = function (tx, length) {
  67288. var t = Scalar.Repeat(tx, length * 2.0);
  67289. return length - Math.abs(t - length);
  67290. };
  67291. /**
  67292. * Interpolates between min and max with smoothing at the limits.
  67293. *
  67294. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67295. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67296. * @param from from
  67297. * @param to to
  67298. * @param tx value
  67299. * @returns the smooth stepped value
  67300. */
  67301. Scalar.SmoothStep = function (from, to, tx) {
  67302. var t = Scalar.Clamp(tx);
  67303. t = -2.0 * t * t * t + 3.0 * t * t;
  67304. return to * t + from * (1.0 - t);
  67305. };
  67306. /**
  67307. * Moves a value current towards target.
  67308. *
  67309. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67310. * Negative values of maxDelta pushes the value away from target.
  67311. * @param current current value
  67312. * @param target target value
  67313. * @param maxDelta max distance to move
  67314. * @returns resulting value
  67315. */
  67316. Scalar.MoveTowards = function (current, target, maxDelta) {
  67317. var result = 0;
  67318. if (Math.abs(target - current) <= maxDelta) {
  67319. result = target;
  67320. }
  67321. else {
  67322. result = current + Scalar.Sign(target - current) * maxDelta;
  67323. }
  67324. return result;
  67325. };
  67326. /**
  67327. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67328. *
  67329. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67330. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67331. * @param current current value
  67332. * @param target target value
  67333. * @param maxDelta max distance to move
  67334. * @returns resulting angle
  67335. */
  67336. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  67337. var num = Scalar.DeltaAngle(current, target);
  67338. var result = 0;
  67339. if (-maxDelta < num && num < maxDelta) {
  67340. result = target;
  67341. }
  67342. else {
  67343. target = current + num;
  67344. result = Scalar.MoveTowards(current, target, maxDelta);
  67345. }
  67346. return result;
  67347. };
  67348. /**
  67349. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67350. * @param start start value
  67351. * @param end target value
  67352. * @param amount amount to lerp between
  67353. * @returns the lerped value
  67354. */
  67355. Scalar.Lerp = function (start, end, amount) {
  67356. return start + ((end - start) * amount);
  67357. };
  67358. /**
  67359. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67360. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67361. * @param start start value
  67362. * @param end target value
  67363. * @param amount amount to lerp between
  67364. * @returns the lerped value
  67365. */
  67366. Scalar.LerpAngle = function (start, end, amount) {
  67367. var num = Scalar.Repeat(end - start, 360.0);
  67368. if (num > 180.0) {
  67369. num -= 360.0;
  67370. }
  67371. return start + num * Scalar.Clamp(amount);
  67372. };
  67373. /**
  67374. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67375. * @param a start value
  67376. * @param b target value
  67377. * @param value value between a and b
  67378. * @returns the inverseLerp value
  67379. */
  67380. Scalar.InverseLerp = function (a, b, value) {
  67381. var result = 0;
  67382. if (a != b) {
  67383. result = Scalar.Clamp((value - a) / (b - a));
  67384. }
  67385. else {
  67386. result = 0.0;
  67387. }
  67388. return result;
  67389. };
  67390. /**
  67391. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67392. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67393. * @param value1 spline value
  67394. * @param tangent1 spline value
  67395. * @param value2 spline value
  67396. * @param tangent2 spline value
  67397. * @param amount input value
  67398. * @returns hermite result
  67399. */
  67400. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  67401. var squared = amount * amount;
  67402. var cubed = amount * squared;
  67403. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  67404. var part2 = (-2.0 * cubed) + (3.0 * squared);
  67405. var part3 = (cubed - (2.0 * squared)) + amount;
  67406. var part4 = cubed - squared;
  67407. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  67408. };
  67409. /**
  67410. * Returns a random float number between and min and max values
  67411. * @param min min value of random
  67412. * @param max max value of random
  67413. * @returns random value
  67414. */
  67415. Scalar.RandomRange = function (min, max) {
  67416. if (min === max) {
  67417. return min;
  67418. }
  67419. return ((Math.random() * (max - min)) + min);
  67420. };
  67421. /**
  67422. * This function returns percentage of a number in a given range.
  67423. *
  67424. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67425. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67426. * @param number to convert to percentage
  67427. * @param min min range
  67428. * @param max max range
  67429. * @returns the percentage
  67430. */
  67431. Scalar.RangeToPercent = function (number, min, max) {
  67432. return ((number - min) / (max - min));
  67433. };
  67434. /**
  67435. * This function returns number that corresponds to the percentage in a given range.
  67436. *
  67437. * PercentToRange(0.34,0,100) will return 34.
  67438. * @param percent to convert to number
  67439. * @param min min range
  67440. * @param max max range
  67441. * @returns the number
  67442. */
  67443. Scalar.PercentToRange = function (percent, min, max) {
  67444. return ((max - min) * percent + min);
  67445. };
  67446. /**
  67447. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67448. * @param angle The angle to normalize in radian.
  67449. * @return The converted angle.
  67450. */
  67451. Scalar.NormalizeRadians = function (angle) {
  67452. // More precise but slower version kept for reference.
  67453. // angle = angle % Tools.TwoPi;
  67454. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  67455. //if (angle > Math.PI) {
  67456. // angle -= Tools.TwoPi;
  67457. //}
  67458. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  67459. return angle;
  67460. };
  67461. /**
  67462. * Two pi constants convenient for computation.
  67463. */
  67464. Scalar.TwoPi = Math.PI * 2;
  67465. return Scalar;
  67466. }());
  67467. /***/ }),
  67468. /***/ "./Maths/math.ts":
  67469. /*!***********************!*\
  67470. !*** ./Maths/math.ts ***!
  67471. \***********************/
  67472. /*! 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 */
  67473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67474. "use strict";
  67475. __webpack_require__.r(__webpack_exports__);
  67476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  67477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  67478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  67479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  67480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  67481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  67482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  67483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  67484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  67485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  67486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  67487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  67488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  67489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  67490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  67491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  67492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  67493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  67494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  67495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  67496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  67497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  67498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  67499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  67500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  67501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  67502. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  67503. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67504. /**
  67505. * Constant used to convert a value to gamma space
  67506. * @ignorenaming
  67507. */
  67508. var ToGammaSpace = 1 / 2.2;
  67509. /**
  67510. * Constant used to convert a value to linear space
  67511. * @ignorenaming
  67512. */
  67513. var ToLinearSpace = 2.2;
  67514. /**
  67515. * Constant used to define the minimal number value in Babylon.js
  67516. * @ignorenaming
  67517. */
  67518. var Epsilon = 0.001;
  67519. /**
  67520. * Class used to hold a RBG color
  67521. */
  67522. var Color3 = /** @class */ (function () {
  67523. /**
  67524. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67525. * @param r defines the red component (between 0 and 1, default is 0)
  67526. * @param g defines the green component (between 0 and 1, default is 0)
  67527. * @param b defines the blue component (between 0 and 1, default is 0)
  67528. */
  67529. function Color3(
  67530. /**
  67531. * Defines the red component (between 0 and 1, default is 0)
  67532. */
  67533. r,
  67534. /**
  67535. * Defines the green component (between 0 and 1, default is 0)
  67536. */
  67537. g,
  67538. /**
  67539. * Defines the blue component (between 0 and 1, default is 0)
  67540. */
  67541. b) {
  67542. if (r === void 0) { r = 0; }
  67543. if (g === void 0) { g = 0; }
  67544. if (b === void 0) { b = 0; }
  67545. this.r = r;
  67546. this.g = g;
  67547. this.b = b;
  67548. }
  67549. /**
  67550. * Creates a string with the Color3 current values
  67551. * @returns the string representation of the Color3 object
  67552. */
  67553. Color3.prototype.toString = function () {
  67554. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67555. };
  67556. /**
  67557. * Returns the string "Color3"
  67558. * @returns "Color3"
  67559. */
  67560. Color3.prototype.getClassName = function () {
  67561. return "Color3";
  67562. };
  67563. /**
  67564. * Compute the Color3 hash code
  67565. * @returns an unique number that can be used to hash Color3 objects
  67566. */
  67567. Color3.prototype.getHashCode = function () {
  67568. var hash = this.r || 0;
  67569. hash = (hash * 397) ^ (this.g || 0);
  67570. hash = (hash * 397) ^ (this.b || 0);
  67571. return hash;
  67572. };
  67573. // Operators
  67574. /**
  67575. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67576. * @param array defines the array where to store the r,g,b components
  67577. * @param index defines an optional index in the target array to define where to start storing values
  67578. * @returns the current Color3 object
  67579. */
  67580. Color3.prototype.toArray = function (array, index) {
  67581. if (index === void 0) { index = 0; }
  67582. array[index] = this.r;
  67583. array[index + 1] = this.g;
  67584. array[index + 2] = this.b;
  67585. return this;
  67586. };
  67587. /**
  67588. * Returns a new Color4 object from the current Color3 and the given alpha
  67589. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67590. * @returns a new Color4 object
  67591. */
  67592. Color3.prototype.toColor4 = function (alpha) {
  67593. if (alpha === void 0) { alpha = 1; }
  67594. return new Color4(this.r, this.g, this.b, alpha);
  67595. };
  67596. /**
  67597. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67598. * @returns the new array
  67599. */
  67600. Color3.prototype.asArray = function () {
  67601. var result = new Array();
  67602. this.toArray(result, 0);
  67603. return result;
  67604. };
  67605. /**
  67606. * Returns the luminance value
  67607. * @returns a float value
  67608. */
  67609. Color3.prototype.toLuminance = function () {
  67610. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67611. };
  67612. /**
  67613. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67614. * @param otherColor defines the second operand
  67615. * @returns the new Color3 object
  67616. */
  67617. Color3.prototype.multiply = function (otherColor) {
  67618. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67619. };
  67620. /**
  67621. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67622. * @param otherColor defines the second operand
  67623. * @param result defines the Color3 object where to store the result
  67624. * @returns the current Color3
  67625. */
  67626. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67627. result.r = this.r * otherColor.r;
  67628. result.g = this.g * otherColor.g;
  67629. result.b = this.b * otherColor.b;
  67630. return this;
  67631. };
  67632. /**
  67633. * Determines equality between Color3 objects
  67634. * @param otherColor defines the second operand
  67635. * @returns true if the rgb values are equal to the given ones
  67636. */
  67637. Color3.prototype.equals = function (otherColor) {
  67638. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67639. };
  67640. /**
  67641. * Determines equality between the current Color3 object and a set of r,b,g values
  67642. * @param r defines the red component to check
  67643. * @param g defines the green component to check
  67644. * @param b defines the blue component to check
  67645. * @returns true if the rgb values are equal to the given ones
  67646. */
  67647. Color3.prototype.equalsFloats = function (r, g, b) {
  67648. return this.r === r && this.g === g && this.b === b;
  67649. };
  67650. /**
  67651. * Multiplies in place each rgb value by scale
  67652. * @param scale defines the scaling factor
  67653. * @returns the updated Color3
  67654. */
  67655. Color3.prototype.scale = function (scale) {
  67656. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67657. };
  67658. /**
  67659. * Multiplies the rgb values by scale and stores the result into "result"
  67660. * @param scale defines the scaling factor
  67661. * @param result defines the Color3 object where to store the result
  67662. * @returns the unmodified current Color3
  67663. */
  67664. Color3.prototype.scaleToRef = function (scale, result) {
  67665. result.r = this.r * scale;
  67666. result.g = this.g * scale;
  67667. result.b = this.b * scale;
  67668. return this;
  67669. };
  67670. /**
  67671. * Scale the current Color3 values by a factor and add the result to a given Color3
  67672. * @param scale defines the scale factor
  67673. * @param result defines color to store the result into
  67674. * @returns the unmodified current Color3
  67675. */
  67676. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67677. result.r += this.r * scale;
  67678. result.g += this.g * scale;
  67679. result.b += this.b * scale;
  67680. return this;
  67681. };
  67682. /**
  67683. * Clamps the rgb values by the min and max values and stores the result into "result"
  67684. * @param min defines minimum clamping value (default is 0)
  67685. * @param max defines maximum clamping value (default is 1)
  67686. * @param result defines color to store the result into
  67687. * @returns the original Color3
  67688. */
  67689. Color3.prototype.clampToRef = function (min, max, result) {
  67690. if (min === void 0) { min = 0; }
  67691. if (max === void 0) { max = 1; }
  67692. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67693. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67694. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67695. return this;
  67696. };
  67697. /**
  67698. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  67699. * @param otherColor defines the second operand
  67700. * @returns the new Color3
  67701. */
  67702. Color3.prototype.add = function (otherColor) {
  67703. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  67704. };
  67705. /**
  67706. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  67707. * @param otherColor defines the second operand
  67708. * @param result defines Color3 object to store the result into
  67709. * @returns the unmodified current Color3
  67710. */
  67711. Color3.prototype.addToRef = function (otherColor, result) {
  67712. result.r = this.r + otherColor.r;
  67713. result.g = this.g + otherColor.g;
  67714. result.b = this.b + otherColor.b;
  67715. return this;
  67716. };
  67717. /**
  67718. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  67719. * @param otherColor defines the second operand
  67720. * @returns the new Color3
  67721. */
  67722. Color3.prototype.subtract = function (otherColor) {
  67723. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  67724. };
  67725. /**
  67726. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  67727. * @param otherColor defines the second operand
  67728. * @param result defines Color3 object to store the result into
  67729. * @returns the unmodified current Color3
  67730. */
  67731. Color3.prototype.subtractToRef = function (otherColor, result) {
  67732. result.r = this.r - otherColor.r;
  67733. result.g = this.g - otherColor.g;
  67734. result.b = this.b - otherColor.b;
  67735. return this;
  67736. };
  67737. /**
  67738. * Copy the current object
  67739. * @returns a new Color3 copied the current one
  67740. */
  67741. Color3.prototype.clone = function () {
  67742. return new Color3(this.r, this.g, this.b);
  67743. };
  67744. /**
  67745. * Copies the rgb values from the source in the current Color3
  67746. * @param source defines the source Color3 object
  67747. * @returns the updated Color3 object
  67748. */
  67749. Color3.prototype.copyFrom = function (source) {
  67750. this.r = source.r;
  67751. this.g = source.g;
  67752. this.b = source.b;
  67753. return this;
  67754. };
  67755. /**
  67756. * Updates the Color3 rgb values from the given floats
  67757. * @param r defines the red component to read from
  67758. * @param g defines the green component to read from
  67759. * @param b defines the blue component to read from
  67760. * @returns the current Color3 object
  67761. */
  67762. Color3.prototype.copyFromFloats = function (r, g, b) {
  67763. this.r = r;
  67764. this.g = g;
  67765. this.b = b;
  67766. return this;
  67767. };
  67768. /**
  67769. * Updates the Color3 rgb values from the given floats
  67770. * @param r defines the red component to read from
  67771. * @param g defines the green component to read from
  67772. * @param b defines the blue component to read from
  67773. * @returns the current Color3 object
  67774. */
  67775. Color3.prototype.set = function (r, g, b) {
  67776. return this.copyFromFloats(r, g, b);
  67777. };
  67778. /**
  67779. * Compute the Color3 hexadecimal code as a string
  67780. * @returns a string containing the hexadecimal representation of the Color3 object
  67781. */
  67782. Color3.prototype.toHexString = function () {
  67783. var intR = (this.r * 255) | 0;
  67784. var intG = (this.g * 255) | 0;
  67785. var intB = (this.b * 255) | 0;
  67786. 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);
  67787. };
  67788. /**
  67789. * Computes a new Color3 converted from the current one to linear space
  67790. * @returns a new Color3 object
  67791. */
  67792. Color3.prototype.toLinearSpace = function () {
  67793. var convertedColor = new Color3();
  67794. this.toLinearSpaceToRef(convertedColor);
  67795. return convertedColor;
  67796. };
  67797. /**
  67798. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  67799. * @param convertedColor defines the Color3 object where to store the linear space version
  67800. * @returns the unmodified Color3
  67801. */
  67802. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  67803. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67804. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67805. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67806. return this;
  67807. };
  67808. /**
  67809. * Computes a new Color3 converted from the current one to gamma space
  67810. * @returns a new Color3 object
  67811. */
  67812. Color3.prototype.toGammaSpace = function () {
  67813. var convertedColor = new Color3();
  67814. this.toGammaSpaceToRef(convertedColor);
  67815. return convertedColor;
  67816. };
  67817. /**
  67818. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  67819. * @param convertedColor defines the Color3 object where to store the gamma space version
  67820. * @returns the unmodified Color3
  67821. */
  67822. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  67823. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67824. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67825. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67826. return this;
  67827. };
  67828. /**
  67829. * Creates a new Color3 from the string containing valid hexadecimal values
  67830. * @param hex defines a string containing valid hexadecimal values
  67831. * @returns a new Color3 object
  67832. */
  67833. Color3.FromHexString = function (hex) {
  67834. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  67835. return new Color3(0, 0, 0);
  67836. }
  67837. var r = parseInt(hex.substring(1, 3), 16);
  67838. var g = parseInt(hex.substring(3, 5), 16);
  67839. var b = parseInt(hex.substring(5, 7), 16);
  67840. return Color3.FromInts(r, g, b);
  67841. };
  67842. /**
  67843. * Creates a new Vector3 from the starting index of the given array
  67844. * @param array defines the source array
  67845. * @param offset defines an offset in the source array
  67846. * @returns a new Color3 object
  67847. */
  67848. Color3.FromArray = function (array, offset) {
  67849. if (offset === void 0) { offset = 0; }
  67850. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  67851. };
  67852. /**
  67853. * Creates a new Color3 from integer values (< 256)
  67854. * @param r defines the red component to read from (value between 0 and 255)
  67855. * @param g defines the green component to read from (value between 0 and 255)
  67856. * @param b defines the blue component to read from (value between 0 and 255)
  67857. * @returns a new Color3 object
  67858. */
  67859. Color3.FromInts = function (r, g, b) {
  67860. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  67861. };
  67862. /**
  67863. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67864. * @param start defines the start Color3 value
  67865. * @param end defines the end Color3 value
  67866. * @param amount defines the gradient value between start and end
  67867. * @returns a new Color3 object
  67868. */
  67869. Color3.Lerp = function (start, end, amount) {
  67870. var result = new Color3(0.0, 0.0, 0.0);
  67871. Color3.LerpToRef(start, end, amount, result);
  67872. return result;
  67873. };
  67874. /**
  67875. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67876. * @param left defines the start value
  67877. * @param right defines the end value
  67878. * @param amount defines the gradient factor
  67879. * @param result defines the Color3 object where to store the result
  67880. */
  67881. Color3.LerpToRef = function (left, right, amount, result) {
  67882. result.r = left.r + ((right.r - left.r) * amount);
  67883. result.g = left.g + ((right.g - left.g) * amount);
  67884. result.b = left.b + ((right.b - left.b) * amount);
  67885. };
  67886. /**
  67887. * Returns a Color3 value containing a red color
  67888. * @returns a new Color3 object
  67889. */
  67890. Color3.Red = function () { return new Color3(1, 0, 0); };
  67891. /**
  67892. * Returns a Color3 value containing a green color
  67893. * @returns a new Color3 object
  67894. */
  67895. Color3.Green = function () { return new Color3(0, 1, 0); };
  67896. /**
  67897. * Returns a Color3 value containing a blue color
  67898. * @returns a new Color3 object
  67899. */
  67900. Color3.Blue = function () { return new Color3(0, 0, 1); };
  67901. /**
  67902. * Returns a Color3 value containing a black color
  67903. * @returns a new Color3 object
  67904. */
  67905. Color3.Black = function () { return new Color3(0, 0, 0); };
  67906. Object.defineProperty(Color3, "BlackReadOnly", {
  67907. /**
  67908. * Gets a Color3 value containing a black color that must not be updated
  67909. */
  67910. get: function () {
  67911. return Color3._BlackReadOnly;
  67912. },
  67913. enumerable: true,
  67914. configurable: true
  67915. });
  67916. /**
  67917. * Returns a Color3 value containing a white color
  67918. * @returns a new Color3 object
  67919. */
  67920. Color3.White = function () { return new Color3(1, 1, 1); };
  67921. /**
  67922. * Returns a Color3 value containing a purple color
  67923. * @returns a new Color3 object
  67924. */
  67925. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  67926. /**
  67927. * Returns a Color3 value containing a magenta color
  67928. * @returns a new Color3 object
  67929. */
  67930. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  67931. /**
  67932. * Returns a Color3 value containing a yellow color
  67933. * @returns a new Color3 object
  67934. */
  67935. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  67936. /**
  67937. * Returns a Color3 value containing a gray color
  67938. * @returns a new Color3 object
  67939. */
  67940. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  67941. /**
  67942. * Returns a Color3 value containing a teal color
  67943. * @returns a new Color3 object
  67944. */
  67945. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  67946. /**
  67947. * Returns a Color3 value containing a random color
  67948. * @returns a new Color3 object
  67949. */
  67950. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  67951. // Statics
  67952. Color3._BlackReadOnly = Color3.Black();
  67953. return Color3;
  67954. }());
  67955. /**
  67956. * Class used to hold a RBGA color
  67957. */
  67958. var Color4 = /** @class */ (function () {
  67959. /**
  67960. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  67961. * @param r defines the red component (between 0 and 1, default is 0)
  67962. * @param g defines the green component (between 0 and 1, default is 0)
  67963. * @param b defines the blue component (between 0 and 1, default is 0)
  67964. * @param a defines the alpha component (between 0 and 1, default is 1)
  67965. */
  67966. function Color4(
  67967. /**
  67968. * Defines the red component (between 0 and 1, default is 0)
  67969. */
  67970. r,
  67971. /**
  67972. * Defines the green component (between 0 and 1, default is 0)
  67973. */
  67974. g,
  67975. /**
  67976. * Defines the blue component (between 0 and 1, default is 0)
  67977. */
  67978. b,
  67979. /**
  67980. * Defines the alpha component (between 0 and 1, default is 1)
  67981. */
  67982. a) {
  67983. if (r === void 0) { r = 0; }
  67984. if (g === void 0) { g = 0; }
  67985. if (b === void 0) { b = 0; }
  67986. if (a === void 0) { a = 1; }
  67987. this.r = r;
  67988. this.g = g;
  67989. this.b = b;
  67990. this.a = a;
  67991. }
  67992. // Operators
  67993. /**
  67994. * Adds in place the given Color4 values to the current Color4 object
  67995. * @param right defines the second operand
  67996. * @returns the current updated Color4 object
  67997. */
  67998. Color4.prototype.addInPlace = function (right) {
  67999. this.r += right.r;
  68000. this.g += right.g;
  68001. this.b += right.b;
  68002. this.a += right.a;
  68003. return this;
  68004. };
  68005. /**
  68006. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68007. * @returns the new array
  68008. */
  68009. Color4.prototype.asArray = function () {
  68010. var result = new Array();
  68011. this.toArray(result, 0);
  68012. return result;
  68013. };
  68014. /**
  68015. * Stores from the starting index in the given array the Color4 successive values
  68016. * @param array defines the array where to store the r,g,b components
  68017. * @param index defines an optional index in the target array to define where to start storing values
  68018. * @returns the current Color4 object
  68019. */
  68020. Color4.prototype.toArray = function (array, index) {
  68021. if (index === void 0) { index = 0; }
  68022. array[index] = this.r;
  68023. array[index + 1] = this.g;
  68024. array[index + 2] = this.b;
  68025. array[index + 3] = this.a;
  68026. return this;
  68027. };
  68028. /**
  68029. * Determines equality between Color4 objects
  68030. * @param otherColor defines the second operand
  68031. * @returns true if the rgba values are equal to the given ones
  68032. */
  68033. Color4.prototype.equals = function (otherColor) {
  68034. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  68035. };
  68036. /**
  68037. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68038. * @param right defines the second operand
  68039. * @returns a new Color4 object
  68040. */
  68041. Color4.prototype.add = function (right) {
  68042. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  68043. };
  68044. /**
  68045. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68046. * @param right defines the second operand
  68047. * @returns a new Color4 object
  68048. */
  68049. Color4.prototype.subtract = function (right) {
  68050. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  68051. };
  68052. /**
  68053. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68054. * @param right defines the second operand
  68055. * @param result defines the Color4 object where to store the result
  68056. * @returns the current Color4 object
  68057. */
  68058. Color4.prototype.subtractToRef = function (right, result) {
  68059. result.r = this.r - right.r;
  68060. result.g = this.g - right.g;
  68061. result.b = this.b - right.b;
  68062. result.a = this.a - right.a;
  68063. return this;
  68064. };
  68065. /**
  68066. * Creates a new Color4 with the current Color4 values multiplied by scale
  68067. * @param scale defines the scaling factor to apply
  68068. * @returns a new Color4 object
  68069. */
  68070. Color4.prototype.scale = function (scale) {
  68071. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  68072. };
  68073. /**
  68074. * Multiplies the current Color4 values by scale and stores the result in "result"
  68075. * @param scale defines the scaling factor to apply
  68076. * @param result defines the Color4 object where to store the result
  68077. * @returns the current unmodified Color4
  68078. */
  68079. Color4.prototype.scaleToRef = function (scale, result) {
  68080. result.r = this.r * scale;
  68081. result.g = this.g * scale;
  68082. result.b = this.b * scale;
  68083. result.a = this.a * scale;
  68084. return this;
  68085. };
  68086. /**
  68087. * Scale the current Color4 values by a factor and add the result to a given Color4
  68088. * @param scale defines the scale factor
  68089. * @param result defines the Color4 object where to store the result
  68090. * @returns the unmodified current Color4
  68091. */
  68092. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  68093. result.r += this.r * scale;
  68094. result.g += this.g * scale;
  68095. result.b += this.b * scale;
  68096. result.a += this.a * scale;
  68097. return this;
  68098. };
  68099. /**
  68100. * Clamps the rgb values by the min and max values and stores the result into "result"
  68101. * @param min defines minimum clamping value (default is 0)
  68102. * @param max defines maximum clamping value (default is 1)
  68103. * @param result defines color to store the result into.
  68104. * @returns the cuurent Color4
  68105. */
  68106. Color4.prototype.clampToRef = function (min, max, result) {
  68107. if (min === void 0) { min = 0; }
  68108. if (max === void 0) { max = 1; }
  68109. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68110. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68111. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68112. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  68113. return this;
  68114. };
  68115. /**
  68116. * Multipy an Color4 value by another and return a new Color4 object
  68117. * @param color defines the Color4 value to multiply by
  68118. * @returns a new Color4 object
  68119. */
  68120. Color4.prototype.multiply = function (color) {
  68121. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  68122. };
  68123. /**
  68124. * Multipy a Color4 value by another and push the result in a reference value
  68125. * @param color defines the Color4 value to multiply by
  68126. * @param result defines the Color4 to fill the result in
  68127. * @returns the result Color4
  68128. */
  68129. Color4.prototype.multiplyToRef = function (color, result) {
  68130. result.r = this.r * color.r;
  68131. result.g = this.g * color.g;
  68132. result.b = this.b * color.b;
  68133. result.a = this.a * color.a;
  68134. return result;
  68135. };
  68136. /**
  68137. * Creates a string with the Color4 current values
  68138. * @returns the string representation of the Color4 object
  68139. */
  68140. Color4.prototype.toString = function () {
  68141. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  68142. };
  68143. /**
  68144. * Returns the string "Color4"
  68145. * @returns "Color4"
  68146. */
  68147. Color4.prototype.getClassName = function () {
  68148. return "Color4";
  68149. };
  68150. /**
  68151. * Compute the Color4 hash code
  68152. * @returns an unique number that can be used to hash Color4 objects
  68153. */
  68154. Color4.prototype.getHashCode = function () {
  68155. var hash = this.r || 0;
  68156. hash = (hash * 397) ^ (this.g || 0);
  68157. hash = (hash * 397) ^ (this.b || 0);
  68158. hash = (hash * 397) ^ (this.a || 0);
  68159. return hash;
  68160. };
  68161. /**
  68162. * Creates a new Color4 copied from the current one
  68163. * @returns a new Color4 object
  68164. */
  68165. Color4.prototype.clone = function () {
  68166. return new Color4(this.r, this.g, this.b, this.a);
  68167. };
  68168. /**
  68169. * Copies the given Color4 values into the current one
  68170. * @param source defines the source Color4 object
  68171. * @returns the current updated Color4 object
  68172. */
  68173. Color4.prototype.copyFrom = function (source) {
  68174. this.r = source.r;
  68175. this.g = source.g;
  68176. this.b = source.b;
  68177. this.a = source.a;
  68178. return this;
  68179. };
  68180. /**
  68181. * Copies the given float values into the current one
  68182. * @param r defines the red component to read from
  68183. * @param g defines the green component to read from
  68184. * @param b defines the blue component to read from
  68185. * @param a defines the alpha component to read from
  68186. * @returns the current updated Color4 object
  68187. */
  68188. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  68189. this.r = r;
  68190. this.g = g;
  68191. this.b = b;
  68192. this.a = a;
  68193. return this;
  68194. };
  68195. /**
  68196. * Copies the given float values into the current one
  68197. * @param r defines the red component to read from
  68198. * @param g defines the green component to read from
  68199. * @param b defines the blue component to read from
  68200. * @param a defines the alpha component to read from
  68201. * @returns the current updated Color4 object
  68202. */
  68203. Color4.prototype.set = function (r, g, b, a) {
  68204. return this.copyFromFloats(r, g, b, a);
  68205. };
  68206. /**
  68207. * Compute the Color4 hexadecimal code as a string
  68208. * @returns a string containing the hexadecimal representation of the Color4 object
  68209. */
  68210. Color4.prototype.toHexString = function () {
  68211. var intR = (this.r * 255) | 0;
  68212. var intG = (this.g * 255) | 0;
  68213. var intB = (this.b * 255) | 0;
  68214. var intA = (this.a * 255) | 0;
  68215. 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);
  68216. };
  68217. /**
  68218. * Computes a new Color4 converted from the current one to linear space
  68219. * @returns a new Color4 object
  68220. */
  68221. Color4.prototype.toLinearSpace = function () {
  68222. var convertedColor = new Color4();
  68223. this.toLinearSpaceToRef(convertedColor);
  68224. return convertedColor;
  68225. };
  68226. /**
  68227. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68228. * @param convertedColor defines the Color4 object where to store the linear space version
  68229. * @returns the unmodified Color4
  68230. */
  68231. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  68232. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68233. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68234. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68235. convertedColor.a = this.a;
  68236. return this;
  68237. };
  68238. /**
  68239. * Computes a new Color4 converted from the current one to gamma space
  68240. * @returns a new Color4 object
  68241. */
  68242. Color4.prototype.toGammaSpace = function () {
  68243. var convertedColor = new Color4();
  68244. this.toGammaSpaceToRef(convertedColor);
  68245. return convertedColor;
  68246. };
  68247. /**
  68248. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68249. * @param convertedColor defines the Color4 object where to store the gamma space version
  68250. * @returns the unmodified Color4
  68251. */
  68252. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  68253. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68254. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68255. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68256. convertedColor.a = this.a;
  68257. return this;
  68258. };
  68259. // Statics
  68260. /**
  68261. * Creates a new Color4 from the string containing valid hexadecimal values
  68262. * @param hex defines a string containing valid hexadecimal values
  68263. * @returns a new Color4 object
  68264. */
  68265. Color4.FromHexString = function (hex) {
  68266. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  68267. return new Color4(0.0, 0.0, 0.0, 0.0);
  68268. }
  68269. var r = parseInt(hex.substring(1, 3), 16);
  68270. var g = parseInt(hex.substring(3, 5), 16);
  68271. var b = parseInt(hex.substring(5, 7), 16);
  68272. var a = parseInt(hex.substring(7, 9), 16);
  68273. return Color4.FromInts(r, g, b, a);
  68274. };
  68275. /**
  68276. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68277. * @param left defines the start value
  68278. * @param right defines the end value
  68279. * @param amount defines the gradient factor
  68280. * @returns a new Color4 object
  68281. */
  68282. Color4.Lerp = function (left, right, amount) {
  68283. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  68284. Color4.LerpToRef(left, right, amount, result);
  68285. return result;
  68286. };
  68287. /**
  68288. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68289. * @param left defines the start value
  68290. * @param right defines the end value
  68291. * @param amount defines the gradient factor
  68292. * @param result defines the Color4 object where to store data
  68293. */
  68294. Color4.LerpToRef = function (left, right, amount, result) {
  68295. result.r = left.r + (right.r - left.r) * amount;
  68296. result.g = left.g + (right.g - left.g) * amount;
  68297. result.b = left.b + (right.b - left.b) * amount;
  68298. result.a = left.a + (right.a - left.a) * amount;
  68299. };
  68300. /**
  68301. * Creates a new Color4 from a Color3 and an alpha value
  68302. * @param color3 defines the source Color3 to read from
  68303. * @param alpha defines the alpha component (1.0 by default)
  68304. * @returns a new Color4 object
  68305. */
  68306. Color4.FromColor3 = function (color3, alpha) {
  68307. if (alpha === void 0) { alpha = 1.0; }
  68308. return new Color4(color3.r, color3.g, color3.b, alpha);
  68309. };
  68310. /**
  68311. * Creates a new Color4 from the starting index element of the given array
  68312. * @param array defines the source array to read from
  68313. * @param offset defines the offset in the source array
  68314. * @returns a new Color4 object
  68315. */
  68316. Color4.FromArray = function (array, offset) {
  68317. if (offset === void 0) { offset = 0; }
  68318. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  68319. };
  68320. /**
  68321. * Creates a new Color3 from integer values (< 256)
  68322. * @param r defines the red component to read from (value between 0 and 255)
  68323. * @param g defines the green component to read from (value between 0 and 255)
  68324. * @param b defines the blue component to read from (value between 0 and 255)
  68325. * @param a defines the alpha component to read from (value between 0 and 255)
  68326. * @returns a new Color3 object
  68327. */
  68328. Color4.FromInts = function (r, g, b, a) {
  68329. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  68330. };
  68331. /**
  68332. * Check the content of a given array and convert it to an array containing RGBA data
  68333. * If the original array was already containing count * 4 values then it is returned directly
  68334. * @param colors defines the array to check
  68335. * @param count defines the number of RGBA data to expect
  68336. * @returns an array containing count * 4 values (RGBA)
  68337. */
  68338. Color4.CheckColors4 = function (colors, count) {
  68339. // Check if color3 was used
  68340. if (colors.length === count * 3) {
  68341. var colors4 = [];
  68342. for (var index = 0; index < colors.length; index += 3) {
  68343. var newIndex = (index / 3) * 4;
  68344. colors4[newIndex] = colors[index];
  68345. colors4[newIndex + 1] = colors[index + 1];
  68346. colors4[newIndex + 2] = colors[index + 2];
  68347. colors4[newIndex + 3] = 1.0;
  68348. }
  68349. return colors4;
  68350. }
  68351. return colors;
  68352. };
  68353. return Color4;
  68354. }());
  68355. /**
  68356. * Class representing a vector containing 2 coordinates
  68357. */
  68358. var Vector2 = /** @class */ (function () {
  68359. /**
  68360. * Creates a new Vector2 from the given x and y coordinates
  68361. * @param x defines the first coordinate
  68362. * @param y defines the second coordinate
  68363. */
  68364. function Vector2(
  68365. /** defines the first coordinate */
  68366. x,
  68367. /** defines the second coordinate */
  68368. y) {
  68369. if (x === void 0) { x = 0; }
  68370. if (y === void 0) { y = 0; }
  68371. this.x = x;
  68372. this.y = y;
  68373. }
  68374. /**
  68375. * Gets a string with the Vector2 coordinates
  68376. * @returns a string with the Vector2 coordinates
  68377. */
  68378. Vector2.prototype.toString = function () {
  68379. return "{X: " + this.x + " Y:" + this.y + "}";
  68380. };
  68381. /**
  68382. * Gets class name
  68383. * @returns the string "Vector2"
  68384. */
  68385. Vector2.prototype.getClassName = function () {
  68386. return "Vector2";
  68387. };
  68388. /**
  68389. * Gets current vector hash code
  68390. * @returns the Vector2 hash code as a number
  68391. */
  68392. Vector2.prototype.getHashCode = function () {
  68393. var hash = this.x || 0;
  68394. hash = (hash * 397) ^ (this.y || 0);
  68395. return hash;
  68396. };
  68397. // Operators
  68398. /**
  68399. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68400. * @param array defines the source array
  68401. * @param index defines the offset in source array
  68402. * @returns the current Vector2
  68403. */
  68404. Vector2.prototype.toArray = function (array, index) {
  68405. if (index === void 0) { index = 0; }
  68406. array[index] = this.x;
  68407. array[index + 1] = this.y;
  68408. return this;
  68409. };
  68410. /**
  68411. * Copy the current vector to an array
  68412. * @returns a new array with 2 elements: the Vector2 coordinates.
  68413. */
  68414. Vector2.prototype.asArray = function () {
  68415. var result = new Array();
  68416. this.toArray(result, 0);
  68417. return result;
  68418. };
  68419. /**
  68420. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68421. * @param source defines the source Vector2
  68422. * @returns the current updated Vector2
  68423. */
  68424. Vector2.prototype.copyFrom = function (source) {
  68425. this.x = source.x;
  68426. this.y = source.y;
  68427. return this;
  68428. };
  68429. /**
  68430. * Sets the Vector2 coordinates with the given floats
  68431. * @param x defines the first coordinate
  68432. * @param y defines the second coordinate
  68433. * @returns the current updated Vector2
  68434. */
  68435. Vector2.prototype.copyFromFloats = function (x, y) {
  68436. this.x = x;
  68437. this.y = y;
  68438. return this;
  68439. };
  68440. /**
  68441. * Sets the Vector2 coordinates with the given floats
  68442. * @param x defines the first coordinate
  68443. * @param y defines the second coordinate
  68444. * @returns the current updated Vector2
  68445. */
  68446. Vector2.prototype.set = function (x, y) {
  68447. return this.copyFromFloats(x, y);
  68448. };
  68449. /**
  68450. * Add another vector with the current one
  68451. * @param otherVector defines the other vector
  68452. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68453. */
  68454. Vector2.prototype.add = function (otherVector) {
  68455. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68456. };
  68457. /**
  68458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68459. * @param otherVector defines the other vector
  68460. * @param result defines the target vector
  68461. * @returns the unmodified current Vector2
  68462. */
  68463. Vector2.prototype.addToRef = function (otherVector, result) {
  68464. result.x = this.x + otherVector.x;
  68465. result.y = this.y + otherVector.y;
  68466. return this;
  68467. };
  68468. /**
  68469. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68470. * @param otherVector defines the other vector
  68471. * @returns the current updated Vector2
  68472. */
  68473. Vector2.prototype.addInPlace = function (otherVector) {
  68474. this.x += otherVector.x;
  68475. this.y += otherVector.y;
  68476. return this;
  68477. };
  68478. /**
  68479. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68480. * @param otherVector defines the other vector
  68481. * @returns a new Vector2
  68482. */
  68483. Vector2.prototype.addVector3 = function (otherVector) {
  68484. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68485. };
  68486. /**
  68487. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68488. * @param otherVector defines the other vector
  68489. * @returns a new Vector2
  68490. */
  68491. Vector2.prototype.subtract = function (otherVector) {
  68492. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  68493. };
  68494. /**
  68495. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68496. * @param otherVector defines the other vector
  68497. * @param result defines the target vector
  68498. * @returns the unmodified current Vector2
  68499. */
  68500. Vector2.prototype.subtractToRef = function (otherVector, result) {
  68501. result.x = this.x - otherVector.x;
  68502. result.y = this.y - otherVector.y;
  68503. return this;
  68504. };
  68505. /**
  68506. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68507. * @param otherVector defines the other vector
  68508. * @returns the current updated Vector2
  68509. */
  68510. Vector2.prototype.subtractInPlace = function (otherVector) {
  68511. this.x -= otherVector.x;
  68512. this.y -= otherVector.y;
  68513. return this;
  68514. };
  68515. /**
  68516. * Multiplies in place the current Vector2 coordinates by the given ones
  68517. * @param otherVector defines the other vector
  68518. * @returns the current updated Vector2
  68519. */
  68520. Vector2.prototype.multiplyInPlace = function (otherVector) {
  68521. this.x *= otherVector.x;
  68522. this.y *= otherVector.y;
  68523. return this;
  68524. };
  68525. /**
  68526. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68527. * @param otherVector defines the other vector
  68528. * @returns a new Vector2
  68529. */
  68530. Vector2.prototype.multiply = function (otherVector) {
  68531. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  68532. };
  68533. /**
  68534. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68535. * @param otherVector defines the other vector
  68536. * @param result defines the target vector
  68537. * @returns the unmodified current Vector2
  68538. */
  68539. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  68540. result.x = this.x * otherVector.x;
  68541. result.y = this.y * otherVector.y;
  68542. return this;
  68543. };
  68544. /**
  68545. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68546. * @param x defines the first coordinate
  68547. * @param y defines the second coordinate
  68548. * @returns a new Vector2
  68549. */
  68550. Vector2.prototype.multiplyByFloats = function (x, y) {
  68551. return new Vector2(this.x * x, this.y * y);
  68552. };
  68553. /**
  68554. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68555. * @param otherVector defines the other vector
  68556. * @returns a new Vector2
  68557. */
  68558. Vector2.prototype.divide = function (otherVector) {
  68559. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68560. };
  68561. /**
  68562. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68563. * @param otherVector defines the other vector
  68564. * @param result defines the target vector
  68565. * @returns the unmodified current Vector2
  68566. */
  68567. Vector2.prototype.divideToRef = function (otherVector, result) {
  68568. result.x = this.x / otherVector.x;
  68569. result.y = this.y / otherVector.y;
  68570. return this;
  68571. };
  68572. /**
  68573. * Divides the current Vector2 coordinates by the given ones
  68574. * @param otherVector defines the other vector
  68575. * @returns the current updated Vector2
  68576. */
  68577. Vector2.prototype.divideInPlace = function (otherVector) {
  68578. return this.divideToRef(otherVector, this);
  68579. };
  68580. /**
  68581. * Gets a new Vector2 with current Vector2 negated coordinates
  68582. * @returns a new Vector2
  68583. */
  68584. Vector2.prototype.negate = function () {
  68585. return new Vector2(-this.x, -this.y);
  68586. };
  68587. /**
  68588. * Multiply the Vector2 coordinates by scale
  68589. * @param scale defines the scaling factor
  68590. * @returns the current updated Vector2
  68591. */
  68592. Vector2.prototype.scaleInPlace = function (scale) {
  68593. this.x *= scale;
  68594. this.y *= scale;
  68595. return this;
  68596. };
  68597. /**
  68598. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68599. * @param scale defines the scaling factor
  68600. * @returns a new Vector2
  68601. */
  68602. Vector2.prototype.scale = function (scale) {
  68603. var result = new Vector2(0, 0);
  68604. this.scaleToRef(scale, result);
  68605. return result;
  68606. };
  68607. /**
  68608. * Scale the current Vector2 values by a factor to a given Vector2
  68609. * @param scale defines the scale factor
  68610. * @param result defines the Vector2 object where to store the result
  68611. * @returns the unmodified current Vector2
  68612. */
  68613. Vector2.prototype.scaleToRef = function (scale, result) {
  68614. result.x = this.x * scale;
  68615. result.y = this.y * scale;
  68616. return this;
  68617. };
  68618. /**
  68619. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68620. * @param scale defines the scale factor
  68621. * @param result defines the Vector2 object where to store the result
  68622. * @returns the unmodified current Vector2
  68623. */
  68624. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68625. result.x += this.x * scale;
  68626. result.y += this.y * scale;
  68627. return this;
  68628. };
  68629. /**
  68630. * Gets a boolean if two vectors are equals
  68631. * @param otherVector defines the other vector
  68632. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68633. */
  68634. Vector2.prototype.equals = function (otherVector) {
  68635. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68636. };
  68637. /**
  68638. * Gets a boolean if two vectors are equals (using an epsilon value)
  68639. * @param otherVector defines the other vector
  68640. * @param epsilon defines the minimal distance to consider equality
  68641. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68642. */
  68643. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68644. if (epsilon === void 0) { epsilon = Epsilon; }
  68645. 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);
  68646. };
  68647. /**
  68648. * Gets a new Vector2 from current Vector2 floored values
  68649. * @returns a new Vector2
  68650. */
  68651. Vector2.prototype.floor = function () {
  68652. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68653. };
  68654. /**
  68655. * Gets a new Vector2 from current Vector2 floored values
  68656. * @returns a new Vector2
  68657. */
  68658. Vector2.prototype.fract = function () {
  68659. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68660. };
  68661. // Properties
  68662. /**
  68663. * Gets the length of the vector
  68664. * @returns the vector length (float)
  68665. */
  68666. Vector2.prototype.length = function () {
  68667. return Math.sqrt(this.x * this.x + this.y * this.y);
  68668. };
  68669. /**
  68670. * Gets the vector squared length
  68671. * @returns the vector squared length (float)
  68672. */
  68673. Vector2.prototype.lengthSquared = function () {
  68674. return (this.x * this.x + this.y * this.y);
  68675. };
  68676. // Methods
  68677. /**
  68678. * Normalize the vector
  68679. * @returns the current updated Vector2
  68680. */
  68681. Vector2.prototype.normalize = function () {
  68682. var len = this.length();
  68683. if (len === 0) {
  68684. return this;
  68685. }
  68686. var num = 1.0 / len;
  68687. this.x *= num;
  68688. this.y *= num;
  68689. return this;
  68690. };
  68691. /**
  68692. * Gets a new Vector2 copied from the Vector2
  68693. * @returns a new Vector2
  68694. */
  68695. Vector2.prototype.clone = function () {
  68696. return new Vector2(this.x, this.y);
  68697. };
  68698. // Statics
  68699. /**
  68700. * Gets a new Vector2(0, 0)
  68701. * @returns a new Vector2
  68702. */
  68703. Vector2.Zero = function () {
  68704. return new Vector2(0, 0);
  68705. };
  68706. /**
  68707. * Gets a new Vector2(1, 1)
  68708. * @returns a new Vector2
  68709. */
  68710. Vector2.One = function () {
  68711. return new Vector2(1, 1);
  68712. };
  68713. /**
  68714. * Gets a new Vector2 set from the given index element of the given array
  68715. * @param array defines the data source
  68716. * @param offset defines the offset in the data source
  68717. * @returns a new Vector2
  68718. */
  68719. Vector2.FromArray = function (array, offset) {
  68720. if (offset === void 0) { offset = 0; }
  68721. return new Vector2(array[offset], array[offset + 1]);
  68722. };
  68723. /**
  68724. * Sets "result" from the given index element of the given array
  68725. * @param array defines the data source
  68726. * @param offset defines the offset in the data source
  68727. * @param result defines the target vector
  68728. */
  68729. Vector2.FromArrayToRef = function (array, offset, result) {
  68730. result.x = array[offset];
  68731. result.y = array[offset + 1];
  68732. };
  68733. /**
  68734. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68735. * @param value1 defines 1st point of control
  68736. * @param value2 defines 2nd point of control
  68737. * @param value3 defines 3rd point of control
  68738. * @param value4 defines 4th point of control
  68739. * @param amount defines the interpolation factor
  68740. * @returns a new Vector2
  68741. */
  68742. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  68743. var squared = amount * amount;
  68744. var cubed = amount * squared;
  68745. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  68746. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  68747. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  68748. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  68749. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  68750. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  68751. return new Vector2(x, y);
  68752. };
  68753. /**
  68754. * 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".
  68755. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68756. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68757. * @param value defines the value to clamp
  68758. * @param min defines the lower limit
  68759. * @param max defines the upper limit
  68760. * @returns a new Vector2
  68761. */
  68762. Vector2.Clamp = function (value, min, max) {
  68763. var x = value.x;
  68764. x = (x > max.x) ? max.x : x;
  68765. x = (x < min.x) ? min.x : x;
  68766. var y = value.y;
  68767. y = (y > max.y) ? max.y : y;
  68768. y = (y < min.y) ? min.y : y;
  68769. return new Vector2(x, y);
  68770. };
  68771. /**
  68772. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68773. * @param value1 defines the 1st control point
  68774. * @param tangent1 defines the outgoing tangent
  68775. * @param value2 defines the 2nd control point
  68776. * @param tangent2 defines the incoming tangent
  68777. * @param amount defines the interpolation factor
  68778. * @returns a new Vector2
  68779. */
  68780. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  68781. var squared = amount * amount;
  68782. var cubed = amount * squared;
  68783. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  68784. var part2 = (-2.0 * cubed) + (3.0 * squared);
  68785. var part3 = (cubed - (2.0 * squared)) + amount;
  68786. var part4 = cubed - squared;
  68787. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  68788. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  68789. return new Vector2(x, y);
  68790. };
  68791. /**
  68792. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68793. * @param start defines the start vector
  68794. * @param end defines the end vector
  68795. * @param amount defines the interpolation factor
  68796. * @returns a new Vector2
  68797. */
  68798. Vector2.Lerp = function (start, end, amount) {
  68799. var x = start.x + ((end.x - start.x) * amount);
  68800. var y = start.y + ((end.y - start.y) * amount);
  68801. return new Vector2(x, y);
  68802. };
  68803. /**
  68804. * Gets the dot product of the vector "left" and the vector "right"
  68805. * @param left defines first vector
  68806. * @param right defines second vector
  68807. * @returns the dot product (float)
  68808. */
  68809. Vector2.Dot = function (left, right) {
  68810. return left.x * right.x + left.y * right.y;
  68811. };
  68812. /**
  68813. * Returns a new Vector2 equal to the normalized given vector
  68814. * @param vector defines the vector to normalize
  68815. * @returns a new Vector2
  68816. */
  68817. Vector2.Normalize = function (vector) {
  68818. var newVector = vector.clone();
  68819. newVector.normalize();
  68820. return newVector;
  68821. };
  68822. /**
  68823. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68824. * @param left defines 1st vector
  68825. * @param right defines 2nd vector
  68826. * @returns a new Vector2
  68827. */
  68828. Vector2.Minimize = function (left, right) {
  68829. var x = (left.x < right.x) ? left.x : right.x;
  68830. var y = (left.y < right.y) ? left.y : right.y;
  68831. return new Vector2(x, y);
  68832. };
  68833. /**
  68834. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68835. * @param left defines 1st vector
  68836. * @param right defines 2nd vector
  68837. * @returns a new Vector2
  68838. */
  68839. Vector2.Maximize = function (left, right) {
  68840. var x = (left.x > right.x) ? left.x : right.x;
  68841. var y = (left.y > right.y) ? left.y : right.y;
  68842. return new Vector2(x, y);
  68843. };
  68844. /**
  68845. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68846. * @param vector defines the vector to transform
  68847. * @param transformation defines the matrix to apply
  68848. * @returns a new Vector2
  68849. */
  68850. Vector2.Transform = function (vector, transformation) {
  68851. var r = Vector2.Zero();
  68852. Vector2.TransformToRef(vector, transformation, r);
  68853. return r;
  68854. };
  68855. /**
  68856. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68857. * @param vector defines the vector to transform
  68858. * @param transformation defines the matrix to apply
  68859. * @param result defines the target vector
  68860. */
  68861. Vector2.TransformToRef = function (vector, transformation, result) {
  68862. var m = transformation.m;
  68863. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  68864. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  68865. result.x = x;
  68866. result.y = y;
  68867. };
  68868. /**
  68869. * Determines if a given vector is included in a triangle
  68870. * @param p defines the vector to test
  68871. * @param p0 defines 1st triangle point
  68872. * @param p1 defines 2nd triangle point
  68873. * @param p2 defines 3rd triangle point
  68874. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  68875. */
  68876. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  68877. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  68878. var sign = a < 0 ? -1 : 1;
  68879. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  68880. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  68881. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  68882. };
  68883. /**
  68884. * Gets the distance between the vectors "value1" and "value2"
  68885. * @param value1 defines first vector
  68886. * @param value2 defines second vector
  68887. * @returns the distance between vectors
  68888. */
  68889. Vector2.Distance = function (value1, value2) {
  68890. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  68891. };
  68892. /**
  68893. * Returns the squared distance between the vectors "value1" and "value2"
  68894. * @param value1 defines first vector
  68895. * @param value2 defines second vector
  68896. * @returns the squared distance between vectors
  68897. */
  68898. Vector2.DistanceSquared = function (value1, value2) {
  68899. var x = value1.x - value2.x;
  68900. var y = value1.y - value2.y;
  68901. return (x * x) + (y * y);
  68902. };
  68903. /**
  68904. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  68905. * @param value1 defines first vector
  68906. * @param value2 defines second vector
  68907. * @returns a new Vector2
  68908. */
  68909. Vector2.Center = function (value1, value2) {
  68910. var center = value1.add(value2);
  68911. center.scaleInPlace(0.5);
  68912. return center;
  68913. };
  68914. /**
  68915. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  68916. * @param p defines the middle point
  68917. * @param segA defines one point of the segment
  68918. * @param segB defines the other point of the segment
  68919. * @returns the shortest distance
  68920. */
  68921. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  68922. var l2 = Vector2.DistanceSquared(segA, segB);
  68923. if (l2 === 0.0) {
  68924. return Vector2.Distance(p, segA);
  68925. }
  68926. var v = segB.subtract(segA);
  68927. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  68928. var proj = segA.add(v.multiplyByFloats(t, t));
  68929. return Vector2.Distance(p, proj);
  68930. };
  68931. return Vector2;
  68932. }());
  68933. /**
  68934. * Classed used to store (x,y,z) vector representation
  68935. * A Vector3 is the main object used in 3D geometry
  68936. * It can represent etiher the coordinates of a point the space, either a direction
  68937. * Reminder: js uses a left handed forward facing system
  68938. */
  68939. var Vector3 = /** @class */ (function () {
  68940. /**
  68941. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  68942. * @param x defines the first coordinates (on X axis)
  68943. * @param y defines the second coordinates (on Y axis)
  68944. * @param z defines the third coordinates (on Z axis)
  68945. */
  68946. function Vector3(
  68947. /**
  68948. * Defines the first coordinates (on X axis)
  68949. */
  68950. x,
  68951. /**
  68952. * Defines the second coordinates (on Y axis)
  68953. */
  68954. y,
  68955. /**
  68956. * Defines the third coordinates (on Z axis)
  68957. */
  68958. z) {
  68959. if (x === void 0) { x = 0; }
  68960. if (y === void 0) { y = 0; }
  68961. if (z === void 0) { z = 0; }
  68962. this.x = x;
  68963. this.y = y;
  68964. this.z = z;
  68965. }
  68966. /**
  68967. * Creates a string representation of the Vector3
  68968. * @returns a string with the Vector3 coordinates.
  68969. */
  68970. Vector3.prototype.toString = function () {
  68971. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  68972. };
  68973. /**
  68974. * Gets the class name
  68975. * @returns the string "Vector3"
  68976. */
  68977. Vector3.prototype.getClassName = function () {
  68978. return "Vector3";
  68979. };
  68980. /**
  68981. * Creates the Vector3 hash code
  68982. * @returns a number which tends to be unique between Vector3 instances
  68983. */
  68984. Vector3.prototype.getHashCode = function () {
  68985. var hash = this.x || 0;
  68986. hash = (hash * 397) ^ (this.y || 0);
  68987. hash = (hash * 397) ^ (this.z || 0);
  68988. return hash;
  68989. };
  68990. // Operators
  68991. /**
  68992. * Creates an array containing three elements : the coordinates of the Vector3
  68993. * @returns a new array of numbers
  68994. */
  68995. Vector3.prototype.asArray = function () {
  68996. var result = [];
  68997. this.toArray(result, 0);
  68998. return result;
  68999. };
  69000. /**
  69001. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69002. * @param array defines the destination array
  69003. * @param index defines the offset in the destination array
  69004. * @returns the current Vector3
  69005. */
  69006. Vector3.prototype.toArray = function (array, index) {
  69007. if (index === void 0) { index = 0; }
  69008. array[index] = this.x;
  69009. array[index + 1] = this.y;
  69010. array[index + 2] = this.z;
  69011. return this;
  69012. };
  69013. /**
  69014. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69015. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69016. */
  69017. Vector3.prototype.toQuaternion = function () {
  69018. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  69019. };
  69020. /**
  69021. * Adds the given vector to the current Vector3
  69022. * @param otherVector defines the second operand
  69023. * @returns the current updated Vector3
  69024. */
  69025. Vector3.prototype.addInPlace = function (otherVector) {
  69026. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  69027. };
  69028. /**
  69029. * Adds the given coordinates to the current Vector3
  69030. * @param x defines the x coordinate of the operand
  69031. * @param y defines the y coordinate of the operand
  69032. * @param z defines the z coordinate of the operand
  69033. * @returns the current updated Vector3
  69034. */
  69035. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  69036. this.x += x;
  69037. this.y += y;
  69038. this.z += z;
  69039. return this;
  69040. };
  69041. /**
  69042. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69043. * @param otherVector defines the second operand
  69044. * @returns the resulting Vector3
  69045. */
  69046. Vector3.prototype.add = function (otherVector) {
  69047. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69048. };
  69049. /**
  69050. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69051. * @param otherVector defines the second operand
  69052. * @param result defines the Vector3 object where to store the result
  69053. * @returns the current Vector3
  69054. */
  69055. Vector3.prototype.addToRef = function (otherVector, result) {
  69056. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69057. };
  69058. /**
  69059. * Subtract the given vector from the current Vector3
  69060. * @param otherVector defines the second operand
  69061. * @returns the current updated Vector3
  69062. */
  69063. Vector3.prototype.subtractInPlace = function (otherVector) {
  69064. this.x -= otherVector.x;
  69065. this.y -= otherVector.y;
  69066. this.z -= otherVector.z;
  69067. return this;
  69068. };
  69069. /**
  69070. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69071. * @param otherVector defines the second operand
  69072. * @returns the resulting Vector3
  69073. */
  69074. Vector3.prototype.subtract = function (otherVector) {
  69075. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  69076. };
  69077. /**
  69078. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69079. * @param otherVector defines the second operand
  69080. * @param result defines the Vector3 object where to store the result
  69081. * @returns the current Vector3
  69082. */
  69083. Vector3.prototype.subtractToRef = function (otherVector, result) {
  69084. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  69085. };
  69086. /**
  69087. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69088. * @param x defines the x coordinate of the operand
  69089. * @param y defines the y coordinate of the operand
  69090. * @param z defines the z coordinate of the operand
  69091. * @returns the resulting Vector3
  69092. */
  69093. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  69094. return new Vector3(this.x - x, this.y - y, this.z - z);
  69095. };
  69096. /**
  69097. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69098. * @param x defines the x coordinate of the operand
  69099. * @param y defines the y coordinate of the operand
  69100. * @param z defines the z coordinate of the operand
  69101. * @param result defines the Vector3 object where to store the result
  69102. * @returns the current Vector3
  69103. */
  69104. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  69105. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  69106. };
  69107. /**
  69108. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69109. * @returns a new Vector3
  69110. */
  69111. Vector3.prototype.negate = function () {
  69112. return new Vector3(-this.x, -this.y, -this.z);
  69113. };
  69114. /**
  69115. * Multiplies the Vector3 coordinates by the float "scale"
  69116. * @param scale defines the multiplier factor
  69117. * @returns the current updated Vector3
  69118. */
  69119. Vector3.prototype.scaleInPlace = function (scale) {
  69120. this.x *= scale;
  69121. this.y *= scale;
  69122. this.z *= scale;
  69123. return this;
  69124. };
  69125. /**
  69126. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69127. * @param scale defines the multiplier factor
  69128. * @returns a new Vector3
  69129. */
  69130. Vector3.prototype.scale = function (scale) {
  69131. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  69132. };
  69133. /**
  69134. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69135. * @param scale defines the multiplier factor
  69136. * @param result defines the Vector3 object where to store the result
  69137. * @returns the current Vector3
  69138. */
  69139. Vector3.prototype.scaleToRef = function (scale, result) {
  69140. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69141. };
  69142. /**
  69143. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69144. * @param scale defines the scale factor
  69145. * @param result defines the Vector3 object where to store the result
  69146. * @returns the unmodified current Vector3
  69147. */
  69148. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  69149. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69150. };
  69151. /**
  69152. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69153. * @param otherVector defines the second operand
  69154. * @returns true if both vectors are equals
  69155. */
  69156. Vector3.prototype.equals = function (otherVector) {
  69157. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  69158. };
  69159. /**
  69160. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69161. * @param otherVector defines the second operand
  69162. * @param epsilon defines the minimal distance to define values as equals
  69163. * @returns true if both vectors are distant less than epsilon
  69164. */
  69165. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69166. if (epsilon === void 0) { epsilon = Epsilon; }
  69167. 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);
  69168. };
  69169. /**
  69170. * Returns true if the current Vector3 coordinates equals the given floats
  69171. * @param x defines the x coordinate of the operand
  69172. * @param y defines the y coordinate of the operand
  69173. * @param z defines the z coordinate of the operand
  69174. * @returns true if both vectors are equals
  69175. */
  69176. Vector3.prototype.equalsToFloats = function (x, y, z) {
  69177. return this.x === x && this.y === y && this.z === z;
  69178. };
  69179. /**
  69180. * Multiplies the current Vector3 coordinates by the given ones
  69181. * @param otherVector defines the second operand
  69182. * @returns the current updated Vector3
  69183. */
  69184. Vector3.prototype.multiplyInPlace = function (otherVector) {
  69185. this.x *= otherVector.x;
  69186. this.y *= otherVector.y;
  69187. this.z *= otherVector.z;
  69188. return this;
  69189. };
  69190. /**
  69191. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69192. * @param otherVector defines the second operand
  69193. * @returns the new Vector3
  69194. */
  69195. Vector3.prototype.multiply = function (otherVector) {
  69196. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  69197. };
  69198. /**
  69199. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69200. * @param otherVector defines the second operand
  69201. * @param result defines the Vector3 object where to store the result
  69202. * @returns the current Vector3
  69203. */
  69204. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  69205. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  69206. };
  69207. /**
  69208. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69209. * @param x defines the x coordinate of the operand
  69210. * @param y defines the y coordinate of the operand
  69211. * @param z defines the z coordinate of the operand
  69212. * @returns the new Vector3
  69213. */
  69214. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  69215. return new Vector3(this.x * x, this.y * y, this.z * z);
  69216. };
  69217. /**
  69218. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69219. * @param otherVector defines the second operand
  69220. * @returns the new Vector3
  69221. */
  69222. Vector3.prototype.divide = function (otherVector) {
  69223. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69224. };
  69225. /**
  69226. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69227. * @param otherVector defines the second operand
  69228. * @param result defines the Vector3 object where to store the result
  69229. * @returns the current Vector3
  69230. */
  69231. Vector3.prototype.divideToRef = function (otherVector, result) {
  69232. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69233. };
  69234. /**
  69235. * Divides the current Vector3 coordinates by the given ones.
  69236. * @param otherVector defines the second operand
  69237. * @returns the current updated Vector3
  69238. */
  69239. Vector3.prototype.divideInPlace = function (otherVector) {
  69240. return this.divideToRef(otherVector, this);
  69241. };
  69242. /**
  69243. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69244. * @param other defines the second operand
  69245. * @returns the current updated Vector3
  69246. */
  69247. Vector3.prototype.minimizeInPlace = function (other) {
  69248. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  69249. };
  69250. /**
  69251. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69252. * @param other defines the second operand
  69253. * @returns the current updated Vector3
  69254. */
  69255. Vector3.prototype.maximizeInPlace = function (other) {
  69256. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  69257. };
  69258. /**
  69259. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69260. * @param x defines the x coordinate of the operand
  69261. * @param y defines the y coordinate of the operand
  69262. * @param z defines the z coordinate of the operand
  69263. * @returns the current updated Vector3
  69264. */
  69265. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  69266. if (x < this.x) {
  69267. this.x = x;
  69268. }
  69269. if (y < this.y) {
  69270. this.y = y;
  69271. }
  69272. if (z < this.z) {
  69273. this.z = z;
  69274. }
  69275. return this;
  69276. };
  69277. /**
  69278. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69279. * @param x defines the x coordinate of the operand
  69280. * @param y defines the y coordinate of the operand
  69281. * @param z defines the z coordinate of the operand
  69282. * @returns the current updated Vector3
  69283. */
  69284. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  69285. if (x > this.x) {
  69286. this.x = x;
  69287. }
  69288. if (y > this.y) {
  69289. this.y = y;
  69290. }
  69291. if (z > this.z) {
  69292. this.z = z;
  69293. }
  69294. return this;
  69295. };
  69296. /**
  69297. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69298. * Check if is non uniform within a certain amount of decimal places to account for this
  69299. * @param epsilon the amount the values can differ
  69300. * @returns if the the vector is non uniform to a certain number of decimal places
  69301. */
  69302. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  69303. var absX = Math.abs(this.x);
  69304. var absY = Math.abs(this.y);
  69305. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  69306. return true;
  69307. }
  69308. var absZ = Math.abs(this.z);
  69309. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  69310. return true;
  69311. }
  69312. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  69313. return true;
  69314. }
  69315. return false;
  69316. };
  69317. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  69318. /**
  69319. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69320. */
  69321. get: function () {
  69322. var absX = Math.abs(this.x);
  69323. var absY = Math.abs(this.y);
  69324. if (absX !== absY) {
  69325. return true;
  69326. }
  69327. var absZ = Math.abs(this.z);
  69328. if (absX !== absZ) {
  69329. return true;
  69330. }
  69331. if (absY !== absZ) {
  69332. return true;
  69333. }
  69334. return false;
  69335. },
  69336. enumerable: true,
  69337. configurable: true
  69338. });
  69339. /**
  69340. * Gets a new Vector3 from current Vector3 floored values
  69341. * @returns a new Vector3
  69342. */
  69343. Vector3.prototype.floor = function () {
  69344. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  69345. };
  69346. /**
  69347. * Gets a new Vector3 from current Vector3 floored values
  69348. * @returns a new Vector3
  69349. */
  69350. Vector3.prototype.fract = function () {
  69351. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  69352. };
  69353. // Properties
  69354. /**
  69355. * Gets the length of the Vector3
  69356. * @returns the length of the Vecto3
  69357. */
  69358. Vector3.prototype.length = function () {
  69359. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  69360. };
  69361. /**
  69362. * Gets the squared length of the Vector3
  69363. * @returns squared length of the Vector3
  69364. */
  69365. Vector3.prototype.lengthSquared = function () {
  69366. return (this.x * this.x + this.y * this.y + this.z * this.z);
  69367. };
  69368. /**
  69369. * Normalize the current Vector3.
  69370. * Please note that this is an in place operation.
  69371. * @returns the current updated Vector3
  69372. */
  69373. Vector3.prototype.normalize = function () {
  69374. return this.normalizeFromLength(this.length());
  69375. };
  69376. /**
  69377. * Reorders the x y z properties of the vector in place
  69378. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69379. * @returns the current updated vector
  69380. */
  69381. Vector3.prototype.reorderInPlace = function (order) {
  69382. var _this = this;
  69383. order = order.toLowerCase();
  69384. if (order === "xyz") {
  69385. return this;
  69386. }
  69387. MathTmp.Vector3[0].copyFrom(this);
  69388. ["x", "y", "z"].forEach(function (val, i) {
  69389. _this[val] = MathTmp.Vector3[0][order[i]];
  69390. });
  69391. return this;
  69392. };
  69393. /**
  69394. * Rotates the vector around 0,0,0 by a quaternion
  69395. * @param quaternion the rotation quaternion
  69396. * @param result vector to store the result
  69397. * @returns the resulting vector
  69398. */
  69399. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  69400. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  69401. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  69402. return result;
  69403. };
  69404. /**
  69405. * Rotates a vector around a given point
  69406. * @param quaternion the rotation quaternion
  69407. * @param point the point to rotate around
  69408. * @param result vector to store the result
  69409. * @returns the resulting vector
  69410. */
  69411. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  69412. this.subtractToRef(point, MathTmp.Vector3[0]);
  69413. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  69414. point.addToRef(MathTmp.Vector3[0], result);
  69415. return result;
  69416. };
  69417. /**
  69418. * Normalize the current Vector3 with the given input length.
  69419. * Please note that this is an in place operation.
  69420. * @param len the length of the vector
  69421. * @returns the current updated Vector3
  69422. */
  69423. Vector3.prototype.normalizeFromLength = function (len) {
  69424. if (len === 0 || len === 1.0) {
  69425. return this;
  69426. }
  69427. return this.scaleInPlace(1.0 / len);
  69428. };
  69429. /**
  69430. * Normalize the current Vector3 to a new vector
  69431. * @returns the new Vector3
  69432. */
  69433. Vector3.prototype.normalizeToNew = function () {
  69434. var normalized = new Vector3(0, 0, 0);
  69435. this.normalizeToRef(normalized);
  69436. return normalized;
  69437. };
  69438. /**
  69439. * Normalize the current Vector3 to the reference
  69440. * @param reference define the Vector3 to update
  69441. * @returns the updated Vector3
  69442. */
  69443. Vector3.prototype.normalizeToRef = function (reference) {
  69444. var len = this.length();
  69445. if (len === 0 || len === 1.0) {
  69446. return reference.copyFromFloats(this.x, this.y, this.z);
  69447. }
  69448. return this.scaleToRef(1.0 / len, reference);
  69449. };
  69450. /**
  69451. * Creates a new Vector3 copied from the current Vector3
  69452. * @returns the new Vector3
  69453. */
  69454. Vector3.prototype.clone = function () {
  69455. return new Vector3(this.x, this.y, this.z);
  69456. };
  69457. /**
  69458. * Copies the given vector coordinates to the current Vector3 ones
  69459. * @param source defines the source Vector3
  69460. * @returns the current updated Vector3
  69461. */
  69462. Vector3.prototype.copyFrom = function (source) {
  69463. return this.copyFromFloats(source.x, source.y, source.z);
  69464. };
  69465. /**
  69466. * Copies the given floats to the current Vector3 coordinates
  69467. * @param x defines the x coordinate of the operand
  69468. * @param y defines the y coordinate of the operand
  69469. * @param z defines the z coordinate of the operand
  69470. * @returns the current updated Vector3
  69471. */
  69472. Vector3.prototype.copyFromFloats = function (x, y, z) {
  69473. this.x = x;
  69474. this.y = y;
  69475. this.z = z;
  69476. return this;
  69477. };
  69478. /**
  69479. * Copies the given floats to the current Vector3 coordinates
  69480. * @param x defines the x coordinate of the operand
  69481. * @param y defines the y coordinate of the operand
  69482. * @param z defines the z coordinate of the operand
  69483. * @returns the current updated Vector3
  69484. */
  69485. Vector3.prototype.set = function (x, y, z) {
  69486. return this.copyFromFloats(x, y, z);
  69487. };
  69488. /**
  69489. * Copies the given float to the current Vector3 coordinates
  69490. * @param v defines the x, y and z coordinates of the operand
  69491. * @returns the current updated Vector3
  69492. */
  69493. Vector3.prototype.setAll = function (v) {
  69494. this.x = this.y = this.z = v;
  69495. return this;
  69496. };
  69497. // Statics
  69498. /**
  69499. * Get the clip factor between two vectors
  69500. * @param vector0 defines the first operand
  69501. * @param vector1 defines the second operand
  69502. * @param axis defines the axis to use
  69503. * @param size defines the size along the axis
  69504. * @returns the clip factor
  69505. */
  69506. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  69507. var d0 = Vector3.Dot(vector0, axis) - size;
  69508. var d1 = Vector3.Dot(vector1, axis) - size;
  69509. var s = d0 / (d0 - d1);
  69510. return s;
  69511. };
  69512. /**
  69513. * Get angle between two vectors
  69514. * @param vector0 angle between vector0 and vector1
  69515. * @param vector1 angle between vector0 and vector1
  69516. * @param normal direction of the normal
  69517. * @return the angle between vector0 and vector1
  69518. */
  69519. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  69520. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  69521. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  69522. var dot = Vector3.Dot(v0, v1);
  69523. var n = MathTmp.Vector3[3];
  69524. Vector3.CrossToRef(v0, v1, n);
  69525. if (Vector3.Dot(n, normal) > 0) {
  69526. return Math.acos(dot);
  69527. }
  69528. return -Math.acos(dot);
  69529. };
  69530. /**
  69531. * Returns a new Vector3 set from the index "offset" of the given array
  69532. * @param array defines the source array
  69533. * @param offset defines the offset in the source array
  69534. * @returns the new Vector3
  69535. */
  69536. Vector3.FromArray = function (array, offset) {
  69537. if (offset === void 0) { offset = 0; }
  69538. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  69539. };
  69540. /**
  69541. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69542. * This function is deprecated. Use FromArray instead
  69543. * @param array defines the source array
  69544. * @param offset defines the offset in the source array
  69545. * @returns the new Vector3
  69546. */
  69547. Vector3.FromFloatArray = function (array, offset) {
  69548. return Vector3.FromArray(array, offset);
  69549. };
  69550. /**
  69551. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69552. * @param array defines the source array
  69553. * @param offset defines the offset in the source array
  69554. * @param result defines the Vector3 where to store the result
  69555. */
  69556. Vector3.FromArrayToRef = function (array, offset, result) {
  69557. result.x = array[offset];
  69558. result.y = array[offset + 1];
  69559. result.z = array[offset + 2];
  69560. };
  69561. /**
  69562. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69563. * This function is deprecated. Use FromArrayToRef instead.
  69564. * @param array defines the source array
  69565. * @param offset defines the offset in the source array
  69566. * @param result defines the Vector3 where to store the result
  69567. */
  69568. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69569. return Vector3.FromArrayToRef(array, offset, result);
  69570. };
  69571. /**
  69572. * Sets the given vector "result" with the given floats.
  69573. * @param x defines the x coordinate of the source
  69574. * @param y defines the y coordinate of the source
  69575. * @param z defines the z coordinate of the source
  69576. * @param result defines the Vector3 where to store the result
  69577. */
  69578. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69579. result.copyFromFloats(x, y, z);
  69580. };
  69581. /**
  69582. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69583. * @returns a new empty Vector3
  69584. */
  69585. Vector3.Zero = function () {
  69586. return new Vector3(0.0, 0.0, 0.0);
  69587. };
  69588. /**
  69589. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69590. * @returns a new unit Vector3
  69591. */
  69592. Vector3.One = function () {
  69593. return new Vector3(1.0, 1.0, 1.0);
  69594. };
  69595. /**
  69596. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69597. * @returns a new up Vector3
  69598. */
  69599. Vector3.Up = function () {
  69600. return new Vector3(0.0, 1.0, 0.0);
  69601. };
  69602. Object.defineProperty(Vector3, "UpReadOnly", {
  69603. /**
  69604. * Gets a up Vector3 that must not be updated
  69605. */
  69606. get: function () {
  69607. return Vector3._UpReadOnly;
  69608. },
  69609. enumerable: true,
  69610. configurable: true
  69611. });
  69612. /**
  69613. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69614. * @returns a new down Vector3
  69615. */
  69616. Vector3.Down = function () {
  69617. return new Vector3(0.0, -1.0, 0.0);
  69618. };
  69619. /**
  69620. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69621. * @returns a new forward Vector3
  69622. */
  69623. Vector3.Forward = function () {
  69624. return new Vector3(0.0, 0.0, 1.0);
  69625. };
  69626. /**
  69627. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69628. * @returns a new forward Vector3
  69629. */
  69630. Vector3.Backward = function () {
  69631. return new Vector3(0.0, 0.0, -1.0);
  69632. };
  69633. /**
  69634. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69635. * @returns a new right Vector3
  69636. */
  69637. Vector3.Right = function () {
  69638. return new Vector3(1.0, 0.0, 0.0);
  69639. };
  69640. /**
  69641. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69642. * @returns a new left Vector3
  69643. */
  69644. Vector3.Left = function () {
  69645. return new Vector3(-1.0, 0.0, 0.0);
  69646. };
  69647. /**
  69648. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69649. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69650. * @param vector defines the Vector3 to transform
  69651. * @param transformation defines the transformation matrix
  69652. * @returns the transformed Vector3
  69653. */
  69654. Vector3.TransformCoordinates = function (vector, transformation) {
  69655. var result = Vector3.Zero();
  69656. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69657. return result;
  69658. };
  69659. /**
  69660. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69661. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69662. * @param vector defines the Vector3 to transform
  69663. * @param transformation defines the transformation matrix
  69664. * @param result defines the Vector3 where to store the result
  69665. */
  69666. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69667. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69668. };
  69669. /**
  69670. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69671. * This method computes tranformed coordinates only, not transformed direction vectors
  69672. * @param x define the x coordinate of the source vector
  69673. * @param y define the y coordinate of the source vector
  69674. * @param z define the z coordinate of the source vector
  69675. * @param transformation defines the transformation matrix
  69676. * @param result defines the Vector3 where to store the result
  69677. */
  69678. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69679. var m = transformation.m;
  69680. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69681. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69682. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69683. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69684. result.x = rx * rw;
  69685. result.y = ry * rw;
  69686. result.z = rz * rw;
  69687. };
  69688. /**
  69689. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69690. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69691. * @param vector defines the Vector3 to transform
  69692. * @param transformation defines the transformation matrix
  69693. * @returns the new Vector3
  69694. */
  69695. Vector3.TransformNormal = function (vector, transformation) {
  69696. var result = Vector3.Zero();
  69697. Vector3.TransformNormalToRef(vector, transformation, result);
  69698. return result;
  69699. };
  69700. /**
  69701. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69702. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69703. * @param vector defines the Vector3 to transform
  69704. * @param transformation defines the transformation matrix
  69705. * @param result defines the Vector3 where to store the result
  69706. */
  69707. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  69708. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69709. };
  69710. /**
  69711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69713. * @param x define the x coordinate of the source vector
  69714. * @param y define the y coordinate of the source vector
  69715. * @param z define the z coordinate of the source vector
  69716. * @param transformation defines the transformation matrix
  69717. * @param result defines the Vector3 where to store the result
  69718. */
  69719. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  69720. var m = transformation.m;
  69721. result.x = x * m[0] + y * m[4] + z * m[8];
  69722. result.y = x * m[1] + y * m[5] + z * m[9];
  69723. result.z = x * m[2] + y * m[6] + z * m[10];
  69724. };
  69725. /**
  69726. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69727. * @param value1 defines the first control point
  69728. * @param value2 defines the second control point
  69729. * @param value3 defines the third control point
  69730. * @param value4 defines the fourth control point
  69731. * @param amount defines the amount on the spline to use
  69732. * @returns the new Vector3
  69733. */
  69734. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  69735. var squared = amount * amount;
  69736. var cubed = amount * squared;
  69737. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69738. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69739. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69740. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69741. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69742. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69743. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  69744. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  69745. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  69746. return new Vector3(x, y, z);
  69747. };
  69748. /**
  69749. * 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"
  69750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69752. * @param value defines the current value
  69753. * @param min defines the lower range value
  69754. * @param max defines the upper range value
  69755. * @returns the new Vector3
  69756. */
  69757. Vector3.Clamp = function (value, min, max) {
  69758. var v = new Vector3();
  69759. Vector3.ClampToRef(value, min, max, v);
  69760. return v;
  69761. };
  69762. /**
  69763. * 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"
  69764. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69765. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69766. * @param value defines the current value
  69767. * @param min defines the lower range value
  69768. * @param max defines the upper range value
  69769. * @param result defines the Vector3 where to store the result
  69770. */
  69771. Vector3.ClampToRef = function (value, min, max, result) {
  69772. var x = value.x;
  69773. x = (x > max.x) ? max.x : x;
  69774. x = (x < min.x) ? min.x : x;
  69775. var y = value.y;
  69776. y = (y > max.y) ? max.y : y;
  69777. y = (y < min.y) ? min.y : y;
  69778. var z = value.z;
  69779. z = (z > max.z) ? max.z : z;
  69780. z = (z < min.z) ? min.z : z;
  69781. result.copyFromFloats(x, y, z);
  69782. };
  69783. /**
  69784. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69785. * @param value1 defines the first control point
  69786. * @param tangent1 defines the first tangent vector
  69787. * @param value2 defines the second control point
  69788. * @param tangent2 defines the second tangent vector
  69789. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69790. * @returns the new Vector3
  69791. */
  69792. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69793. var squared = amount * amount;
  69794. var cubed = amount * squared;
  69795. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69796. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69797. var part3 = (cubed - (2.0 * squared)) + amount;
  69798. var part4 = cubed - squared;
  69799. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69800. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69801. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  69802. return new Vector3(x, y, z);
  69803. };
  69804. /**
  69805. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69806. * @param start defines the start value
  69807. * @param end defines the end value
  69808. * @param amount max defines amount between both (between 0 and 1)
  69809. * @returns the new Vector3
  69810. */
  69811. Vector3.Lerp = function (start, end, amount) {
  69812. var result = new Vector3(0, 0, 0);
  69813. Vector3.LerpToRef(start, end, amount, result);
  69814. return result;
  69815. };
  69816. /**
  69817. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69818. * @param start defines the start value
  69819. * @param end defines the end value
  69820. * @param amount max defines amount between both (between 0 and 1)
  69821. * @param result defines the Vector3 where to store the result
  69822. */
  69823. Vector3.LerpToRef = function (start, end, amount, result) {
  69824. result.x = start.x + ((end.x - start.x) * amount);
  69825. result.y = start.y + ((end.y - start.y) * amount);
  69826. result.z = start.z + ((end.z - start.z) * amount);
  69827. };
  69828. /**
  69829. * Returns the dot product (float) between the vectors "left" and "right"
  69830. * @param left defines the left operand
  69831. * @param right defines the right operand
  69832. * @returns the dot product
  69833. */
  69834. Vector3.Dot = function (left, right) {
  69835. return (left.x * right.x + left.y * right.y + left.z * right.z);
  69836. };
  69837. /**
  69838. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69839. * The cross product is then orthogonal to both "left" and "right"
  69840. * @param left defines the left operand
  69841. * @param right defines the right operand
  69842. * @returns the cross product
  69843. */
  69844. Vector3.Cross = function (left, right) {
  69845. var result = Vector3.Zero();
  69846. Vector3.CrossToRef(left, right, result);
  69847. return result;
  69848. };
  69849. /**
  69850. * Sets the given vector "result" with the cross product of "left" and "right"
  69851. * The cross product is then orthogonal to both "left" and "right"
  69852. * @param left defines the left operand
  69853. * @param right defines the right operand
  69854. * @param result defines the Vector3 where to store the result
  69855. */
  69856. Vector3.CrossToRef = function (left, right, result) {
  69857. var x = left.y * right.z - left.z * right.y;
  69858. var y = left.z * right.x - left.x * right.z;
  69859. var z = left.x * right.y - left.y * right.x;
  69860. result.copyFromFloats(x, y, z);
  69861. };
  69862. /**
  69863. * Returns a new Vector3 as the normalization of the given vector
  69864. * @param vector defines the Vector3 to normalize
  69865. * @returns the new Vector3
  69866. */
  69867. Vector3.Normalize = function (vector) {
  69868. var result = Vector3.Zero();
  69869. Vector3.NormalizeToRef(vector, result);
  69870. return result;
  69871. };
  69872. /**
  69873. * Sets the given vector "result" with the normalization of the given first vector
  69874. * @param vector defines the Vector3 to normalize
  69875. * @param result defines the Vector3 where to store the result
  69876. */
  69877. Vector3.NormalizeToRef = function (vector, result) {
  69878. vector.normalizeToRef(result);
  69879. };
  69880. /**
  69881. * Project a Vector3 onto screen space
  69882. * @param vector defines the Vector3 to project
  69883. * @param world defines the world matrix to use
  69884. * @param transform defines the transform (view x projection) matrix to use
  69885. * @param viewport defines the screen viewport to use
  69886. * @returns the new Vector3
  69887. */
  69888. Vector3.Project = function (vector, world, transform, viewport) {
  69889. var cw = viewport.width;
  69890. var ch = viewport.height;
  69891. var cx = viewport.x;
  69892. var cy = viewport.y;
  69893. var viewportMatrix = MathTmp.Matrix[1];
  69894. 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);
  69895. var matrix = MathTmp.Matrix[0];
  69896. world.multiplyToRef(transform, matrix);
  69897. matrix.multiplyToRef(viewportMatrix, matrix);
  69898. return Vector3.TransformCoordinates(vector, matrix);
  69899. };
  69900. /** @hidden */
  69901. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  69902. Vector3.TransformCoordinatesToRef(source, matrix, result);
  69903. var m = matrix.m;
  69904. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  69905. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  69906. result.scaleInPlace(1.0 / num);
  69907. }
  69908. };
  69909. /**
  69910. * Unproject from screen space to object space
  69911. * @param source defines the screen space Vector3 to use
  69912. * @param viewportWidth defines the current width of the viewport
  69913. * @param viewportHeight defines the current height of the viewport
  69914. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69915. * @param transform defines the transform (view x projection) matrix to use
  69916. * @returns the new Vector3
  69917. */
  69918. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  69919. var matrix = MathTmp.Matrix[0];
  69920. world.multiplyToRef(transform, matrix);
  69921. matrix.invert();
  69922. source.x = source.x / viewportWidth * 2 - 1;
  69923. source.y = -(source.y / viewportHeight * 2 - 1);
  69924. var vector = new Vector3();
  69925. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  69926. return vector;
  69927. };
  69928. /**
  69929. * Unproject from screen space to object space
  69930. * @param source defines the screen space Vector3 to use
  69931. * @param viewportWidth defines the current width of the viewport
  69932. * @param viewportHeight defines the current height of the viewport
  69933. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69934. * @param view defines the view matrix to use
  69935. * @param projection defines the projection matrix to use
  69936. * @returns the new Vector3
  69937. */
  69938. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  69939. var result = Vector3.Zero();
  69940. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  69941. return result;
  69942. };
  69943. /**
  69944. * Unproject from screen space to object space
  69945. * @param source defines the screen space Vector3 to use
  69946. * @param viewportWidth defines the current width of the viewport
  69947. * @param viewportHeight defines the current height of the viewport
  69948. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69949. * @param view defines the view matrix to use
  69950. * @param projection defines the projection matrix to use
  69951. * @param result defines the Vector3 where to store the result
  69952. */
  69953. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  69954. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  69955. };
  69956. /**
  69957. * Unproject from screen space to object space
  69958. * @param sourceX defines the screen space x coordinate to use
  69959. * @param sourceY defines the screen space y coordinate to use
  69960. * @param sourceZ defines the screen space z coordinate to use
  69961. * @param viewportWidth defines the current width of the viewport
  69962. * @param viewportHeight defines the current height of the viewport
  69963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69964. * @param view defines the view matrix to use
  69965. * @param projection defines the projection matrix to use
  69966. * @param result defines the Vector3 where to store the result
  69967. */
  69968. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  69969. var matrix = MathTmp.Matrix[0];
  69970. world.multiplyToRef(view, matrix);
  69971. matrix.multiplyToRef(projection, matrix);
  69972. matrix.invert();
  69973. var screenSource = MathTmp.Vector3[0];
  69974. screenSource.x = sourceX / viewportWidth * 2 - 1;
  69975. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  69976. screenSource.z = 2 * sourceZ - 1.0;
  69977. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  69978. };
  69979. /**
  69980. * Gets the minimal coordinate values between two Vector3
  69981. * @param left defines the first operand
  69982. * @param right defines the second operand
  69983. * @returns the new Vector3
  69984. */
  69985. Vector3.Minimize = function (left, right) {
  69986. var min = left.clone();
  69987. min.minimizeInPlace(right);
  69988. return min;
  69989. };
  69990. /**
  69991. * Gets the maximal coordinate values between two Vector3
  69992. * @param left defines the first operand
  69993. * @param right defines the second operand
  69994. * @returns the new Vector3
  69995. */
  69996. Vector3.Maximize = function (left, right) {
  69997. var max = left.clone();
  69998. max.maximizeInPlace(right);
  69999. return max;
  70000. };
  70001. /**
  70002. * Returns the distance between the vectors "value1" and "value2"
  70003. * @param value1 defines the first operand
  70004. * @param value2 defines the second operand
  70005. * @returns the distance
  70006. */
  70007. Vector3.Distance = function (value1, value2) {
  70008. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  70009. };
  70010. /**
  70011. * Returns the squared distance between the vectors "value1" and "value2"
  70012. * @param value1 defines the first operand
  70013. * @param value2 defines the second operand
  70014. * @returns the squared distance
  70015. */
  70016. Vector3.DistanceSquared = function (value1, value2) {
  70017. var x = value1.x - value2.x;
  70018. var y = value1.y - value2.y;
  70019. var z = value1.z - value2.z;
  70020. return (x * x) + (y * y) + (z * z);
  70021. };
  70022. /**
  70023. * Returns a new Vector3 located at the center between "value1" and "value2"
  70024. * @param value1 defines the first operand
  70025. * @param value2 defines the second operand
  70026. * @returns the new Vector3
  70027. */
  70028. Vector3.Center = function (value1, value2) {
  70029. var center = value1.add(value2);
  70030. center.scaleInPlace(0.5);
  70031. return center;
  70032. };
  70033. /**
  70034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70036. * to something in order to rotate it from its local system to the given target system
  70037. * Note: axis1, axis2 and axis3 are normalized during this operation
  70038. * @param axis1 defines the first axis
  70039. * @param axis2 defines the second axis
  70040. * @param axis3 defines the third axis
  70041. * @returns a new Vector3
  70042. */
  70043. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  70044. var rotation = Vector3.Zero();
  70045. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  70046. return rotation;
  70047. };
  70048. /**
  70049. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70050. * @param axis1 defines the first axis
  70051. * @param axis2 defines the second axis
  70052. * @param axis3 defines the third axis
  70053. * @param ref defines the Vector3 where to store the result
  70054. */
  70055. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70056. var quat = MathTmp.Quaternion[0];
  70057. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70058. quat.toEulerAnglesToRef(ref);
  70059. };
  70060. Vector3._UpReadOnly = Vector3.Up();
  70061. return Vector3;
  70062. }());
  70063. /**
  70064. * Vector4 class created for EulerAngle class conversion to Quaternion
  70065. */
  70066. var Vector4 = /** @class */ (function () {
  70067. /**
  70068. * Creates a Vector4 object from the given floats.
  70069. * @param x x value of the vector
  70070. * @param y y value of the vector
  70071. * @param z z value of the vector
  70072. * @param w w value of the vector
  70073. */
  70074. function Vector4(
  70075. /** x value of the vector */
  70076. x,
  70077. /** y value of the vector */
  70078. y,
  70079. /** z value of the vector */
  70080. z,
  70081. /** w value of the vector */
  70082. w) {
  70083. this.x = x;
  70084. this.y = y;
  70085. this.z = z;
  70086. this.w = w;
  70087. }
  70088. /**
  70089. * Returns the string with the Vector4 coordinates.
  70090. * @returns a string containing all the vector values
  70091. */
  70092. Vector4.prototype.toString = function () {
  70093. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70094. };
  70095. /**
  70096. * Returns the string "Vector4".
  70097. * @returns "Vector4"
  70098. */
  70099. Vector4.prototype.getClassName = function () {
  70100. return "Vector4";
  70101. };
  70102. /**
  70103. * Returns the Vector4 hash code.
  70104. * @returns a unique hash code
  70105. */
  70106. Vector4.prototype.getHashCode = function () {
  70107. var hash = this.x || 0;
  70108. hash = (hash * 397) ^ (this.y || 0);
  70109. hash = (hash * 397) ^ (this.z || 0);
  70110. hash = (hash * 397) ^ (this.w || 0);
  70111. return hash;
  70112. };
  70113. // Operators
  70114. /**
  70115. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70116. * @returns the resulting array
  70117. */
  70118. Vector4.prototype.asArray = function () {
  70119. var result = new Array();
  70120. this.toArray(result, 0);
  70121. return result;
  70122. };
  70123. /**
  70124. * Populates the given array from the given index with the Vector4 coordinates.
  70125. * @param array array to populate
  70126. * @param index index of the array to start at (default: 0)
  70127. * @returns the Vector4.
  70128. */
  70129. Vector4.prototype.toArray = function (array, index) {
  70130. if (index === undefined) {
  70131. index = 0;
  70132. }
  70133. array[index] = this.x;
  70134. array[index + 1] = this.y;
  70135. array[index + 2] = this.z;
  70136. array[index + 3] = this.w;
  70137. return this;
  70138. };
  70139. /**
  70140. * Adds the given vector to the current Vector4.
  70141. * @param otherVector the vector to add
  70142. * @returns the updated Vector4.
  70143. */
  70144. Vector4.prototype.addInPlace = function (otherVector) {
  70145. this.x += otherVector.x;
  70146. this.y += otherVector.y;
  70147. this.z += otherVector.z;
  70148. this.w += otherVector.w;
  70149. return this;
  70150. };
  70151. /**
  70152. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70153. * @param otherVector the vector to add
  70154. * @returns the resulting vector
  70155. */
  70156. Vector4.prototype.add = function (otherVector) {
  70157. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  70158. };
  70159. /**
  70160. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70161. * @param otherVector the vector to add
  70162. * @param result the vector to store the result
  70163. * @returns the current Vector4.
  70164. */
  70165. Vector4.prototype.addToRef = function (otherVector, result) {
  70166. result.x = this.x + otherVector.x;
  70167. result.y = this.y + otherVector.y;
  70168. result.z = this.z + otherVector.z;
  70169. result.w = this.w + otherVector.w;
  70170. return this;
  70171. };
  70172. /**
  70173. * Subtract in place the given vector from the current Vector4.
  70174. * @param otherVector the vector to subtract
  70175. * @returns the updated Vector4.
  70176. */
  70177. Vector4.prototype.subtractInPlace = function (otherVector) {
  70178. this.x -= otherVector.x;
  70179. this.y -= otherVector.y;
  70180. this.z -= otherVector.z;
  70181. this.w -= otherVector.w;
  70182. return this;
  70183. };
  70184. /**
  70185. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70186. * @param otherVector the vector to add
  70187. * @returns the new vector with the result
  70188. */
  70189. Vector4.prototype.subtract = function (otherVector) {
  70190. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  70191. };
  70192. /**
  70193. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70194. * @param otherVector the vector to subtract
  70195. * @param result the vector to store the result
  70196. * @returns the current Vector4.
  70197. */
  70198. Vector4.prototype.subtractToRef = function (otherVector, result) {
  70199. result.x = this.x - otherVector.x;
  70200. result.y = this.y - otherVector.y;
  70201. result.z = this.z - otherVector.z;
  70202. result.w = this.w - otherVector.w;
  70203. return this;
  70204. };
  70205. /**
  70206. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70207. */
  70208. /**
  70209. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70210. * @param x value to subtract
  70211. * @param y value to subtract
  70212. * @param z value to subtract
  70213. * @param w value to subtract
  70214. * @returns new vector containing the result
  70215. */
  70216. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  70217. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  70218. };
  70219. /**
  70220. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70221. * @param x value to subtract
  70222. * @param y value to subtract
  70223. * @param z value to subtract
  70224. * @param w value to subtract
  70225. * @param result the vector to store the result in
  70226. * @returns the current Vector4.
  70227. */
  70228. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  70229. result.x = this.x - x;
  70230. result.y = this.y - y;
  70231. result.z = this.z - z;
  70232. result.w = this.w - w;
  70233. return this;
  70234. };
  70235. /**
  70236. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70237. * @returns a new vector with the negated values
  70238. */
  70239. Vector4.prototype.negate = function () {
  70240. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  70241. };
  70242. /**
  70243. * Multiplies the current Vector4 coordinates by scale (float).
  70244. * @param scale the number to scale with
  70245. * @returns the updated Vector4.
  70246. */
  70247. Vector4.prototype.scaleInPlace = function (scale) {
  70248. this.x *= scale;
  70249. this.y *= scale;
  70250. this.z *= scale;
  70251. this.w *= scale;
  70252. return this;
  70253. };
  70254. /**
  70255. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70256. * @param scale the number to scale with
  70257. * @returns a new vector with the result
  70258. */
  70259. Vector4.prototype.scale = function (scale) {
  70260. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  70261. };
  70262. /**
  70263. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70264. * @param scale the number to scale with
  70265. * @param result a vector to store the result in
  70266. * @returns the current Vector4.
  70267. */
  70268. Vector4.prototype.scaleToRef = function (scale, result) {
  70269. result.x = this.x * scale;
  70270. result.y = this.y * scale;
  70271. result.z = this.z * scale;
  70272. result.w = this.w * scale;
  70273. return this;
  70274. };
  70275. /**
  70276. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70277. * @param scale defines the scale factor
  70278. * @param result defines the Vector4 object where to store the result
  70279. * @returns the unmodified current Vector4
  70280. */
  70281. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  70282. result.x += this.x * scale;
  70283. result.y += this.y * scale;
  70284. result.z += this.z * scale;
  70285. result.w += this.w * scale;
  70286. return this;
  70287. };
  70288. /**
  70289. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70290. * @param otherVector the vector to compare against
  70291. * @returns true if they are equal
  70292. */
  70293. Vector4.prototype.equals = function (otherVector) {
  70294. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  70295. };
  70296. /**
  70297. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70298. * @param otherVector vector to compare against
  70299. * @param epsilon (Default: very small number)
  70300. * @returns true if they are equal
  70301. */
  70302. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70303. if (epsilon === void 0) { epsilon = Epsilon; }
  70304. return otherVector
  70305. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  70306. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  70307. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  70308. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  70309. };
  70310. /**
  70311. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70312. * @param x x value to compare against
  70313. * @param y y value to compare against
  70314. * @param z z value to compare against
  70315. * @param w w value to compare against
  70316. * @returns true if equal
  70317. */
  70318. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  70319. return this.x === x && this.y === y && this.z === z && this.w === w;
  70320. };
  70321. /**
  70322. * Multiplies in place the current Vector4 by the given one.
  70323. * @param otherVector vector to multiple with
  70324. * @returns the updated Vector4.
  70325. */
  70326. Vector4.prototype.multiplyInPlace = function (otherVector) {
  70327. this.x *= otherVector.x;
  70328. this.y *= otherVector.y;
  70329. this.z *= otherVector.z;
  70330. this.w *= otherVector.w;
  70331. return this;
  70332. };
  70333. /**
  70334. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70335. * @param otherVector vector to multiple with
  70336. * @returns resulting new vector
  70337. */
  70338. Vector4.prototype.multiply = function (otherVector) {
  70339. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  70340. };
  70341. /**
  70342. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70343. * @param otherVector vector to multiple with
  70344. * @param result vector to store the result
  70345. * @returns the current Vector4.
  70346. */
  70347. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  70348. result.x = this.x * otherVector.x;
  70349. result.y = this.y * otherVector.y;
  70350. result.z = this.z * otherVector.z;
  70351. result.w = this.w * otherVector.w;
  70352. return this;
  70353. };
  70354. /**
  70355. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70356. * @param x x value multiply with
  70357. * @param y y value multiply with
  70358. * @param z z value multiply with
  70359. * @param w w value multiply with
  70360. * @returns resulting new vector
  70361. */
  70362. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  70363. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  70364. };
  70365. /**
  70366. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70367. * @param otherVector vector to devide with
  70368. * @returns resulting new vector
  70369. */
  70370. Vector4.prototype.divide = function (otherVector) {
  70371. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  70372. };
  70373. /**
  70374. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70375. * @param otherVector vector to devide with
  70376. * @param result vector to store the result
  70377. * @returns the current Vector4.
  70378. */
  70379. Vector4.prototype.divideToRef = function (otherVector, result) {
  70380. result.x = this.x / otherVector.x;
  70381. result.y = this.y / otherVector.y;
  70382. result.z = this.z / otherVector.z;
  70383. result.w = this.w / otherVector.w;
  70384. return this;
  70385. };
  70386. /**
  70387. * Divides the current Vector3 coordinates by the given ones.
  70388. * @param otherVector vector to devide with
  70389. * @returns the updated Vector3.
  70390. */
  70391. Vector4.prototype.divideInPlace = function (otherVector) {
  70392. return this.divideToRef(otherVector, this);
  70393. };
  70394. /**
  70395. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70396. * @param other defines the second operand
  70397. * @returns the current updated Vector4
  70398. */
  70399. Vector4.prototype.minimizeInPlace = function (other) {
  70400. if (other.x < this.x) {
  70401. this.x = other.x;
  70402. }
  70403. if (other.y < this.y) {
  70404. this.y = other.y;
  70405. }
  70406. if (other.z < this.z) {
  70407. this.z = other.z;
  70408. }
  70409. if (other.w < this.w) {
  70410. this.w = other.w;
  70411. }
  70412. return this;
  70413. };
  70414. /**
  70415. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70416. * @param other defines the second operand
  70417. * @returns the current updated Vector4
  70418. */
  70419. Vector4.prototype.maximizeInPlace = function (other) {
  70420. if (other.x > this.x) {
  70421. this.x = other.x;
  70422. }
  70423. if (other.y > this.y) {
  70424. this.y = other.y;
  70425. }
  70426. if (other.z > this.z) {
  70427. this.z = other.z;
  70428. }
  70429. if (other.w > this.w) {
  70430. this.w = other.w;
  70431. }
  70432. return this;
  70433. };
  70434. /**
  70435. * Gets a new Vector4 from current Vector4 floored values
  70436. * @returns a new Vector4
  70437. */
  70438. Vector4.prototype.floor = function () {
  70439. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  70440. };
  70441. /**
  70442. * Gets a new Vector4 from current Vector3 floored values
  70443. * @returns a new Vector4
  70444. */
  70445. Vector4.prototype.fract = function () {
  70446. 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));
  70447. };
  70448. // Properties
  70449. /**
  70450. * Returns the Vector4 length (float).
  70451. * @returns the length
  70452. */
  70453. Vector4.prototype.length = function () {
  70454. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70455. };
  70456. /**
  70457. * Returns the Vector4 squared length (float).
  70458. * @returns the length squared
  70459. */
  70460. Vector4.prototype.lengthSquared = function () {
  70461. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70462. };
  70463. // Methods
  70464. /**
  70465. * Normalizes in place the Vector4.
  70466. * @returns the updated Vector4.
  70467. */
  70468. Vector4.prototype.normalize = function () {
  70469. var len = this.length();
  70470. if (len === 0) {
  70471. return this;
  70472. }
  70473. return this.scaleInPlace(1.0 / len);
  70474. };
  70475. /**
  70476. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70477. * @returns this converted to a new vector3
  70478. */
  70479. Vector4.prototype.toVector3 = function () {
  70480. return new Vector3(this.x, this.y, this.z);
  70481. };
  70482. /**
  70483. * Returns a new Vector4 copied from the current one.
  70484. * @returns the new cloned vector
  70485. */
  70486. Vector4.prototype.clone = function () {
  70487. return new Vector4(this.x, this.y, this.z, this.w);
  70488. };
  70489. /**
  70490. * Updates the current Vector4 with the given one coordinates.
  70491. * @param source the source vector to copy from
  70492. * @returns the updated Vector4.
  70493. */
  70494. Vector4.prototype.copyFrom = function (source) {
  70495. this.x = source.x;
  70496. this.y = source.y;
  70497. this.z = source.z;
  70498. this.w = source.w;
  70499. return this;
  70500. };
  70501. /**
  70502. * Updates the current Vector4 coordinates with the given floats.
  70503. * @param x float to copy from
  70504. * @param y float to copy from
  70505. * @param z float to copy from
  70506. * @param w float to copy from
  70507. * @returns the updated Vector4.
  70508. */
  70509. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  70510. this.x = x;
  70511. this.y = y;
  70512. this.z = z;
  70513. this.w = w;
  70514. return this;
  70515. };
  70516. /**
  70517. * Updates the current Vector4 coordinates with the given floats.
  70518. * @param x float to set from
  70519. * @param y float to set from
  70520. * @param z float to set from
  70521. * @param w float to set from
  70522. * @returns the updated Vector4.
  70523. */
  70524. Vector4.prototype.set = function (x, y, z, w) {
  70525. return this.copyFromFloats(x, y, z, w);
  70526. };
  70527. /**
  70528. * Copies the given float to the current Vector3 coordinates
  70529. * @param v defines the x, y, z and w coordinates of the operand
  70530. * @returns the current updated Vector3
  70531. */
  70532. Vector4.prototype.setAll = function (v) {
  70533. this.x = this.y = this.z = this.w = v;
  70534. return this;
  70535. };
  70536. // Statics
  70537. /**
  70538. * Returns a new Vector4 set from the starting index of the given array.
  70539. * @param array the array to pull values from
  70540. * @param offset the offset into the array to start at
  70541. * @returns the new vector
  70542. */
  70543. Vector4.FromArray = function (array, offset) {
  70544. if (!offset) {
  70545. offset = 0;
  70546. }
  70547. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70548. };
  70549. /**
  70550. * Updates the given vector "result" from the starting index of the given array.
  70551. * @param array the array to pull values from
  70552. * @param offset the offset into the array to start at
  70553. * @param result the vector to store the result in
  70554. */
  70555. Vector4.FromArrayToRef = function (array, offset, result) {
  70556. result.x = array[offset];
  70557. result.y = array[offset + 1];
  70558. result.z = array[offset + 2];
  70559. result.w = array[offset + 3];
  70560. };
  70561. /**
  70562. * Updates the given vector "result" from the starting index of the given Float32Array.
  70563. * @param array the array to pull values from
  70564. * @param offset the offset into the array to start at
  70565. * @param result the vector to store the result in
  70566. */
  70567. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70568. Vector4.FromArrayToRef(array, offset, result);
  70569. };
  70570. /**
  70571. * Updates the given vector "result" coordinates from the given floats.
  70572. * @param x float to set from
  70573. * @param y float to set from
  70574. * @param z float to set from
  70575. * @param w float to set from
  70576. * @param result the vector to the floats in
  70577. */
  70578. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70579. result.x = x;
  70580. result.y = y;
  70581. result.z = z;
  70582. result.w = w;
  70583. };
  70584. /**
  70585. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70586. * @returns the new vector
  70587. */
  70588. Vector4.Zero = function () {
  70589. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70590. };
  70591. /**
  70592. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70593. * @returns the new vector
  70594. */
  70595. Vector4.One = function () {
  70596. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70597. };
  70598. /**
  70599. * Returns a new normalized Vector4 from the given one.
  70600. * @param vector the vector to normalize
  70601. * @returns the vector
  70602. */
  70603. Vector4.Normalize = function (vector) {
  70604. var result = Vector4.Zero();
  70605. Vector4.NormalizeToRef(vector, result);
  70606. return result;
  70607. };
  70608. /**
  70609. * Updates the given vector "result" from the normalization of the given one.
  70610. * @param vector the vector to normalize
  70611. * @param result the vector to store the result in
  70612. */
  70613. Vector4.NormalizeToRef = function (vector, result) {
  70614. result.copyFrom(vector);
  70615. result.normalize();
  70616. };
  70617. /**
  70618. * Returns a vector with the minimum values from the left and right vectors
  70619. * @param left left vector to minimize
  70620. * @param right right vector to minimize
  70621. * @returns a new vector with the minimum of the left and right vector values
  70622. */
  70623. Vector4.Minimize = function (left, right) {
  70624. var min = left.clone();
  70625. min.minimizeInPlace(right);
  70626. return min;
  70627. };
  70628. /**
  70629. * Returns a vector with the maximum values from the left and right vectors
  70630. * @param left left vector to maximize
  70631. * @param right right vector to maximize
  70632. * @returns a new vector with the maximum of the left and right vector values
  70633. */
  70634. Vector4.Maximize = function (left, right) {
  70635. var max = left.clone();
  70636. max.maximizeInPlace(right);
  70637. return max;
  70638. };
  70639. /**
  70640. * Returns the distance (float) between the vectors "value1" and "value2".
  70641. * @param value1 value to calulate the distance between
  70642. * @param value2 value to calulate the distance between
  70643. * @return the distance between the two vectors
  70644. */
  70645. Vector4.Distance = function (value1, value2) {
  70646. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70647. };
  70648. /**
  70649. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70650. * @param value1 value to calulate the distance between
  70651. * @param value2 value to calulate the distance between
  70652. * @return the distance between the two vectors squared
  70653. */
  70654. Vector4.DistanceSquared = function (value1, value2) {
  70655. var x = value1.x - value2.x;
  70656. var y = value1.y - value2.y;
  70657. var z = value1.z - value2.z;
  70658. var w = value1.w - value2.w;
  70659. return (x * x) + (y * y) + (z * z) + (w * w);
  70660. };
  70661. /**
  70662. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70663. * @param value1 value to calulate the center between
  70664. * @param value2 value to calulate the center between
  70665. * @return the center between the two vectors
  70666. */
  70667. Vector4.Center = function (value1, value2) {
  70668. var center = value1.add(value2);
  70669. center.scaleInPlace(0.5);
  70670. return center;
  70671. };
  70672. /**
  70673. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70674. * This methods computes transformed normalized direction vectors only.
  70675. * @param vector the vector to transform
  70676. * @param transformation the transformation matrix to apply
  70677. * @returns the new vector
  70678. */
  70679. Vector4.TransformNormal = function (vector, transformation) {
  70680. var result = Vector4.Zero();
  70681. Vector4.TransformNormalToRef(vector, transformation, result);
  70682. return result;
  70683. };
  70684. /**
  70685. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70686. * This methods computes transformed normalized direction vectors only.
  70687. * @param vector the vector to transform
  70688. * @param transformation the transformation matrix to apply
  70689. * @param result the vector to store the result in
  70690. */
  70691. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70692. var m = transformation.m;
  70693. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70694. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70695. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  70696. result.x = x;
  70697. result.y = y;
  70698. result.z = z;
  70699. result.w = vector.w;
  70700. };
  70701. /**
  70702. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70703. * This methods computes transformed normalized direction vectors only.
  70704. * @param x value to transform
  70705. * @param y value to transform
  70706. * @param z value to transform
  70707. * @param w value to transform
  70708. * @param transformation the transformation matrix to apply
  70709. * @param result the vector to store the results in
  70710. */
  70711. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  70712. var m = transformation.m;
  70713. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  70714. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  70715. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  70716. result.w = w;
  70717. };
  70718. /**
  70719. * Creates a new Vector4 from a Vector3
  70720. * @param source defines the source data
  70721. * @param w defines the 4th component (default is 0)
  70722. * @returns a new Vector4
  70723. */
  70724. Vector4.FromVector3 = function (source, w) {
  70725. if (w === void 0) { w = 0; }
  70726. return new Vector4(source.x, source.y, source.z, w);
  70727. };
  70728. return Vector4;
  70729. }());
  70730. /**
  70731. * Size containing widht and height
  70732. */
  70733. var Size = /** @class */ (function () {
  70734. /**
  70735. * Creates a Size object from the given width and height (floats).
  70736. * @param width width of the new size
  70737. * @param height height of the new size
  70738. */
  70739. function Size(width, height) {
  70740. this.width = width;
  70741. this.height = height;
  70742. }
  70743. /**
  70744. * Returns a string with the Size width and height
  70745. * @returns a string with the Size width and height
  70746. */
  70747. Size.prototype.toString = function () {
  70748. return "{W: " + this.width + ", H: " + this.height + "}";
  70749. };
  70750. /**
  70751. * "Size"
  70752. * @returns the string "Size"
  70753. */
  70754. Size.prototype.getClassName = function () {
  70755. return "Size";
  70756. };
  70757. /**
  70758. * Returns the Size hash code.
  70759. * @returns a hash code for a unique width and height
  70760. */
  70761. Size.prototype.getHashCode = function () {
  70762. var hash = this.width || 0;
  70763. hash = (hash * 397) ^ (this.height || 0);
  70764. return hash;
  70765. };
  70766. /**
  70767. * Updates the current size from the given one.
  70768. * @param src the given size
  70769. */
  70770. Size.prototype.copyFrom = function (src) {
  70771. this.width = src.width;
  70772. this.height = src.height;
  70773. };
  70774. /**
  70775. * Updates in place the current Size from the given floats.
  70776. * @param width width of the new size
  70777. * @param height height of the new size
  70778. * @returns the updated Size.
  70779. */
  70780. Size.prototype.copyFromFloats = function (width, height) {
  70781. this.width = width;
  70782. this.height = height;
  70783. return this;
  70784. };
  70785. /**
  70786. * Updates in place the current Size from the given floats.
  70787. * @param width width to set
  70788. * @param height height to set
  70789. * @returns the updated Size.
  70790. */
  70791. Size.prototype.set = function (width, height) {
  70792. return this.copyFromFloats(width, height);
  70793. };
  70794. /**
  70795. * Multiplies the width and height by numbers
  70796. * @param w factor to multiple the width by
  70797. * @param h factor to multiple the height by
  70798. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  70799. */
  70800. Size.prototype.multiplyByFloats = function (w, h) {
  70801. return new Size(this.width * w, this.height * h);
  70802. };
  70803. /**
  70804. * Clones the size
  70805. * @returns a new Size copied from the given one.
  70806. */
  70807. Size.prototype.clone = function () {
  70808. return new Size(this.width, this.height);
  70809. };
  70810. /**
  70811. * True if the current Size and the given one width and height are strictly equal.
  70812. * @param other the other size to compare against
  70813. * @returns True if the current Size and the given one width and height are strictly equal.
  70814. */
  70815. Size.prototype.equals = function (other) {
  70816. if (!other) {
  70817. return false;
  70818. }
  70819. return (this.width === other.width) && (this.height === other.height);
  70820. };
  70821. Object.defineProperty(Size.prototype, "surface", {
  70822. /**
  70823. * The surface of the Size : width * height (float).
  70824. */
  70825. get: function () {
  70826. return this.width * this.height;
  70827. },
  70828. enumerable: true,
  70829. configurable: true
  70830. });
  70831. /**
  70832. * Create a new size of zero
  70833. * @returns a new Size set to (0.0, 0.0)
  70834. */
  70835. Size.Zero = function () {
  70836. return new Size(0.0, 0.0);
  70837. };
  70838. /**
  70839. * Sums the width and height of two sizes
  70840. * @param otherSize size to add to this size
  70841. * @returns a new Size set as the addition result of the current Size and the given one.
  70842. */
  70843. Size.prototype.add = function (otherSize) {
  70844. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  70845. return r;
  70846. };
  70847. /**
  70848. * Subtracts the width and height of two
  70849. * @param otherSize size to subtract to this size
  70850. * @returns a new Size set as the subtraction result of the given one from the current Size.
  70851. */
  70852. Size.prototype.subtract = function (otherSize) {
  70853. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  70854. return r;
  70855. };
  70856. /**
  70857. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  70858. * @param start starting size to lerp between
  70859. * @param end end size to lerp between
  70860. * @param amount amount to lerp between the start and end values
  70861. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  70862. */
  70863. Size.Lerp = function (start, end, amount) {
  70864. var w = start.width + ((end.width - start.width) * amount);
  70865. var h = start.height + ((end.height - start.height) * amount);
  70866. return new Size(w, h);
  70867. };
  70868. return Size;
  70869. }());
  70870. /**
  70871. * Class used to store quaternion data
  70872. * @see https://en.wikipedia.org/wiki/Quaternion
  70873. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70874. */
  70875. var Quaternion = /** @class */ (function () {
  70876. /**
  70877. * Creates a new Quaternion from the given floats
  70878. * @param x defines the first component (0 by default)
  70879. * @param y defines the second component (0 by default)
  70880. * @param z defines the third component (0 by default)
  70881. * @param w defines the fourth component (1.0 by default)
  70882. */
  70883. function Quaternion(
  70884. /** defines the first component (0 by default) */
  70885. x,
  70886. /** defines the second component (0 by default) */
  70887. y,
  70888. /** defines the third component (0 by default) */
  70889. z,
  70890. /** defines the fourth component (1.0 by default) */
  70891. w) {
  70892. if (x === void 0) { x = 0.0; }
  70893. if (y === void 0) { y = 0.0; }
  70894. if (z === void 0) { z = 0.0; }
  70895. if (w === void 0) { w = 1.0; }
  70896. this.x = x;
  70897. this.y = y;
  70898. this.z = z;
  70899. this.w = w;
  70900. }
  70901. /**
  70902. * Gets a string representation for the current quaternion
  70903. * @returns a string with the Quaternion coordinates
  70904. */
  70905. Quaternion.prototype.toString = function () {
  70906. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70907. };
  70908. /**
  70909. * Gets the class name of the quaternion
  70910. * @returns the string "Quaternion"
  70911. */
  70912. Quaternion.prototype.getClassName = function () {
  70913. return "Quaternion";
  70914. };
  70915. /**
  70916. * Gets a hash code for this quaternion
  70917. * @returns the quaternion hash code
  70918. */
  70919. Quaternion.prototype.getHashCode = function () {
  70920. var hash = this.x || 0;
  70921. hash = (hash * 397) ^ (this.y || 0);
  70922. hash = (hash * 397) ^ (this.z || 0);
  70923. hash = (hash * 397) ^ (this.w || 0);
  70924. return hash;
  70925. };
  70926. /**
  70927. * Copy the quaternion to an array
  70928. * @returns a new array populated with 4 elements from the quaternion coordinates
  70929. */
  70930. Quaternion.prototype.asArray = function () {
  70931. return [this.x, this.y, this.z, this.w];
  70932. };
  70933. /**
  70934. * Check if two quaternions are equals
  70935. * @param otherQuaternion defines the second operand
  70936. * @return true if the current quaternion and the given one coordinates are strictly equals
  70937. */
  70938. Quaternion.prototype.equals = function (otherQuaternion) {
  70939. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  70940. };
  70941. /**
  70942. * Clone the current quaternion
  70943. * @returns a new quaternion copied from the current one
  70944. */
  70945. Quaternion.prototype.clone = function () {
  70946. return new Quaternion(this.x, this.y, this.z, this.w);
  70947. };
  70948. /**
  70949. * Copy a quaternion to the current one
  70950. * @param other defines the other quaternion
  70951. * @returns the updated current quaternion
  70952. */
  70953. Quaternion.prototype.copyFrom = function (other) {
  70954. this.x = other.x;
  70955. this.y = other.y;
  70956. this.z = other.z;
  70957. this.w = other.w;
  70958. return this;
  70959. };
  70960. /**
  70961. * Updates the current quaternion with the given float coordinates
  70962. * @param x defines the x coordinate
  70963. * @param y defines the y coordinate
  70964. * @param z defines the z coordinate
  70965. * @param w defines the w coordinate
  70966. * @returns the updated current quaternion
  70967. */
  70968. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  70969. this.x = x;
  70970. this.y = y;
  70971. this.z = z;
  70972. this.w = w;
  70973. return this;
  70974. };
  70975. /**
  70976. * Updates the current quaternion from the given float coordinates
  70977. * @param x defines the x coordinate
  70978. * @param y defines the y coordinate
  70979. * @param z defines the z coordinate
  70980. * @param w defines the w coordinate
  70981. * @returns the updated current quaternion
  70982. */
  70983. Quaternion.prototype.set = function (x, y, z, w) {
  70984. return this.copyFromFloats(x, y, z, w);
  70985. };
  70986. /**
  70987. * Adds two quaternions
  70988. * @param other defines the second operand
  70989. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70990. */
  70991. Quaternion.prototype.add = function (other) {
  70992. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  70993. };
  70994. /**
  70995. * Add a quaternion to the current one
  70996. * @param other defines the quaternion to add
  70997. * @returns the current quaternion
  70998. */
  70999. Quaternion.prototype.addInPlace = function (other) {
  71000. this.x += other.x;
  71001. this.y += other.y;
  71002. this.z += other.z;
  71003. this.w += other.w;
  71004. return this;
  71005. };
  71006. /**
  71007. * Subtract two quaternions
  71008. * @param other defines the second operand
  71009. * @returns a new quaternion as the subtraction result of the given one from the current one
  71010. */
  71011. Quaternion.prototype.subtract = function (other) {
  71012. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  71013. };
  71014. /**
  71015. * Multiplies the current quaternion by a scale factor
  71016. * @param value defines the scale factor
  71017. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71018. */
  71019. Quaternion.prototype.scale = function (value) {
  71020. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  71021. };
  71022. /**
  71023. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71024. * @param scale defines the scale factor
  71025. * @param result defines the Quaternion object where to store the result
  71026. * @returns the unmodified current quaternion
  71027. */
  71028. Quaternion.prototype.scaleToRef = function (scale, result) {
  71029. result.x = this.x * scale;
  71030. result.y = this.y * scale;
  71031. result.z = this.z * scale;
  71032. result.w = this.w * scale;
  71033. return this;
  71034. };
  71035. /**
  71036. * Multiplies in place the current quaternion by a scale factor
  71037. * @param value defines the scale factor
  71038. * @returns the current modified quaternion
  71039. */
  71040. Quaternion.prototype.scaleInPlace = function (value) {
  71041. this.x *= value;
  71042. this.y *= value;
  71043. this.z *= value;
  71044. this.w *= value;
  71045. return this;
  71046. };
  71047. /**
  71048. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71049. * @param scale defines the scale factor
  71050. * @param result defines the Quaternion object where to store the result
  71051. * @returns the unmodified current quaternion
  71052. */
  71053. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  71054. result.x += this.x * scale;
  71055. result.y += this.y * scale;
  71056. result.z += this.z * scale;
  71057. result.w += this.w * scale;
  71058. return this;
  71059. };
  71060. /**
  71061. * Multiplies two quaternions
  71062. * @param q1 defines the second operand
  71063. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71064. */
  71065. Quaternion.prototype.multiply = function (q1) {
  71066. var result = new Quaternion(0, 0, 0, 1.0);
  71067. this.multiplyToRef(q1, result);
  71068. return result;
  71069. };
  71070. /**
  71071. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71072. * @param q1 defines the second operand
  71073. * @param result defines the target quaternion
  71074. * @returns the current quaternion
  71075. */
  71076. Quaternion.prototype.multiplyToRef = function (q1, result) {
  71077. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  71078. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  71079. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  71080. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  71081. result.copyFromFloats(x, y, z, w);
  71082. return this;
  71083. };
  71084. /**
  71085. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71086. * @param q1 defines the second operand
  71087. * @returns the currentupdated quaternion
  71088. */
  71089. Quaternion.prototype.multiplyInPlace = function (q1) {
  71090. this.multiplyToRef(q1, this);
  71091. return this;
  71092. };
  71093. /**
  71094. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71095. * @param ref defines the target quaternion
  71096. * @returns the current quaternion
  71097. */
  71098. Quaternion.prototype.conjugateToRef = function (ref) {
  71099. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  71100. return this;
  71101. };
  71102. /**
  71103. * Conjugates in place (1-q) the current quaternion
  71104. * @returns the current updated quaternion
  71105. */
  71106. Quaternion.prototype.conjugateInPlace = function () {
  71107. this.x *= -1;
  71108. this.y *= -1;
  71109. this.z *= -1;
  71110. return this;
  71111. };
  71112. /**
  71113. * Conjugates in place (1-q) the current quaternion
  71114. * @returns a new quaternion
  71115. */
  71116. Quaternion.prototype.conjugate = function () {
  71117. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  71118. return result;
  71119. };
  71120. /**
  71121. * Gets length of current quaternion
  71122. * @returns the quaternion length (float)
  71123. */
  71124. Quaternion.prototype.length = function () {
  71125. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  71126. };
  71127. /**
  71128. * Normalize in place the current quaternion
  71129. * @returns the current updated quaternion
  71130. */
  71131. Quaternion.prototype.normalize = function () {
  71132. var length = 1.0 / this.length();
  71133. this.x *= length;
  71134. this.y *= length;
  71135. this.z *= length;
  71136. this.w *= length;
  71137. return this;
  71138. };
  71139. /**
  71140. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71141. * @param order is a reserved parameter and is ignore for now
  71142. * @returns a new Vector3 containing the Euler angles
  71143. */
  71144. Quaternion.prototype.toEulerAngles = function (order) {
  71145. if (order === void 0) { order = "YZX"; }
  71146. var result = Vector3.Zero();
  71147. this.toEulerAnglesToRef(result);
  71148. return result;
  71149. };
  71150. /**
  71151. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71152. * @param result defines the vector which will be filled with the Euler angles
  71153. * @param order is a reserved parameter and is ignore for now
  71154. * @returns the current unchanged quaternion
  71155. */
  71156. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  71157. var qz = this.z;
  71158. var qx = this.x;
  71159. var qy = this.y;
  71160. var qw = this.w;
  71161. var sqw = qw * qw;
  71162. var sqz = qz * qz;
  71163. var sqx = qx * qx;
  71164. var sqy = qy * qy;
  71165. var zAxisY = qy * qz - qx * qw;
  71166. var limit = .4999999;
  71167. if (zAxisY < -limit) {
  71168. result.y = 2 * Math.atan2(qy, qw);
  71169. result.x = Math.PI / 2;
  71170. result.z = 0;
  71171. }
  71172. else if (zAxisY > limit) {
  71173. result.y = 2 * Math.atan2(qy, qw);
  71174. result.x = -Math.PI / 2;
  71175. result.z = 0;
  71176. }
  71177. else {
  71178. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  71179. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  71180. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  71181. }
  71182. return this;
  71183. };
  71184. /**
  71185. * Updates the given rotation matrix with the current quaternion values
  71186. * @param result defines the target matrix
  71187. * @returns the current unchanged quaternion
  71188. */
  71189. Quaternion.prototype.toRotationMatrix = function (result) {
  71190. Matrix.FromQuaternionToRef(this, result);
  71191. return this;
  71192. };
  71193. /**
  71194. * Updates the current quaternion from the given rotation matrix values
  71195. * @param matrix defines the source matrix
  71196. * @returns the current updated quaternion
  71197. */
  71198. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  71199. Quaternion.FromRotationMatrixToRef(matrix, this);
  71200. return this;
  71201. };
  71202. // Statics
  71203. /**
  71204. * Creates a new quaternion from a rotation matrix
  71205. * @param matrix defines the source matrix
  71206. * @returns a new quaternion created from the given rotation matrix values
  71207. */
  71208. Quaternion.FromRotationMatrix = function (matrix) {
  71209. var result = new Quaternion();
  71210. Quaternion.FromRotationMatrixToRef(matrix, result);
  71211. return result;
  71212. };
  71213. /**
  71214. * Updates the given quaternion with the given rotation matrix values
  71215. * @param matrix defines the source matrix
  71216. * @param result defines the target quaternion
  71217. */
  71218. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  71219. var data = matrix.m;
  71220. var m11 = data[0], m12 = data[4], m13 = data[8];
  71221. var m21 = data[1], m22 = data[5], m23 = data[9];
  71222. var m31 = data[2], m32 = data[6], m33 = data[10];
  71223. var trace = m11 + m22 + m33;
  71224. var s;
  71225. if (trace > 0) {
  71226. s = 0.5 / Math.sqrt(trace + 1.0);
  71227. result.w = 0.25 / s;
  71228. result.x = (m32 - m23) * s;
  71229. result.y = (m13 - m31) * s;
  71230. result.z = (m21 - m12) * s;
  71231. }
  71232. else if (m11 > m22 && m11 > m33) {
  71233. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  71234. result.w = (m32 - m23) / s;
  71235. result.x = 0.25 * s;
  71236. result.y = (m12 + m21) / s;
  71237. result.z = (m13 + m31) / s;
  71238. }
  71239. else if (m22 > m33) {
  71240. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  71241. result.w = (m13 - m31) / s;
  71242. result.x = (m12 + m21) / s;
  71243. result.y = 0.25 * s;
  71244. result.z = (m23 + m32) / s;
  71245. }
  71246. else {
  71247. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  71248. result.w = (m21 - m12) / s;
  71249. result.x = (m13 + m31) / s;
  71250. result.y = (m23 + m32) / s;
  71251. result.z = 0.25 * s;
  71252. }
  71253. };
  71254. /**
  71255. * Returns the dot product (float) between the quaternions "left" and "right"
  71256. * @param left defines the left operand
  71257. * @param right defines the right operand
  71258. * @returns the dot product
  71259. */
  71260. Quaternion.Dot = function (left, right) {
  71261. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  71262. };
  71263. /**
  71264. * Checks if the two quaternions are close to each other
  71265. * @param quat0 defines the first quaternion to check
  71266. * @param quat1 defines the second quaternion to check
  71267. * @returns true if the two quaternions are close to each other
  71268. */
  71269. Quaternion.AreClose = function (quat0, quat1) {
  71270. var dot = Quaternion.Dot(quat0, quat1);
  71271. return dot >= 0;
  71272. };
  71273. /**
  71274. * Creates an empty quaternion
  71275. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71276. */
  71277. Quaternion.Zero = function () {
  71278. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  71279. };
  71280. /**
  71281. * Inverse a given quaternion
  71282. * @param q defines the source quaternion
  71283. * @returns a new quaternion as the inverted current quaternion
  71284. */
  71285. Quaternion.Inverse = function (q) {
  71286. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  71287. };
  71288. /**
  71289. * Inverse a given quaternion
  71290. * @param q defines the source quaternion
  71291. * @param result the quaternion the result will be stored in
  71292. * @returns the result quaternion
  71293. */
  71294. Quaternion.InverseToRef = function (q, result) {
  71295. result.set(-q.x, -q.y, -q.z, q.w);
  71296. return result;
  71297. };
  71298. /**
  71299. * Creates an identity quaternion
  71300. * @returns the identity quaternion
  71301. */
  71302. Quaternion.Identity = function () {
  71303. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  71304. };
  71305. /**
  71306. * Gets a boolean indicating if the given quaternion is identity
  71307. * @param quaternion defines the quaternion to check
  71308. * @returns true if the quaternion is identity
  71309. */
  71310. Quaternion.IsIdentity = function (quaternion) {
  71311. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  71312. };
  71313. /**
  71314. * Creates a quaternion from a rotation around an axis
  71315. * @param axis defines the axis to use
  71316. * @param angle defines the angle to use
  71317. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71318. */
  71319. Quaternion.RotationAxis = function (axis, angle) {
  71320. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  71321. };
  71322. /**
  71323. * Creates a rotation around an axis and stores it into the given quaternion
  71324. * @param axis defines the axis to use
  71325. * @param angle defines the angle to use
  71326. * @param result defines the target quaternion
  71327. * @returns the target quaternion
  71328. */
  71329. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  71330. var sin = Math.sin(angle / 2);
  71331. axis.normalize();
  71332. result.w = Math.cos(angle / 2);
  71333. result.x = axis.x * sin;
  71334. result.y = axis.y * sin;
  71335. result.z = axis.z * sin;
  71336. return result;
  71337. };
  71338. /**
  71339. * Creates a new quaternion from data stored into an array
  71340. * @param array defines the data source
  71341. * @param offset defines the offset in the source array where the data starts
  71342. * @returns a new quaternion
  71343. */
  71344. Quaternion.FromArray = function (array, offset) {
  71345. if (!offset) {
  71346. offset = 0;
  71347. }
  71348. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71349. };
  71350. /**
  71351. * Create a quaternion from Euler rotation angles
  71352. * @param x Pitch
  71353. * @param y Yaw
  71354. * @param z Roll
  71355. * @returns the new Quaternion
  71356. */
  71357. Quaternion.FromEulerAngles = function (x, y, z) {
  71358. var q = new Quaternion();
  71359. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  71360. return q;
  71361. };
  71362. /**
  71363. * Updates a quaternion from Euler rotation angles
  71364. * @param x Pitch
  71365. * @param y Yaw
  71366. * @param z Roll
  71367. * @param result the quaternion to store the result
  71368. * @returns the updated quaternion
  71369. */
  71370. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  71371. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  71372. return result;
  71373. };
  71374. /**
  71375. * Create a quaternion from Euler rotation vector
  71376. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71377. * @returns the new Quaternion
  71378. */
  71379. Quaternion.FromEulerVector = function (vec) {
  71380. var q = new Quaternion();
  71381. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  71382. return q;
  71383. };
  71384. /**
  71385. * Updates a quaternion from Euler rotation vector
  71386. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71387. * @param result the quaternion to store the result
  71388. * @returns the updated quaternion
  71389. */
  71390. Quaternion.FromEulerVectorToRef = function (vec, result) {
  71391. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  71392. return result;
  71393. };
  71394. /**
  71395. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71396. * @param yaw defines the rotation around Y axis
  71397. * @param pitch defines the rotation around X axis
  71398. * @param roll defines the rotation around Z axis
  71399. * @returns the new quaternion
  71400. */
  71401. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71402. var q = new Quaternion();
  71403. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  71404. return q;
  71405. };
  71406. /**
  71407. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71408. * @param yaw defines the rotation around Y axis
  71409. * @param pitch defines the rotation around X axis
  71410. * @param roll defines the rotation around Z axis
  71411. * @param result defines the target quaternion
  71412. */
  71413. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71414. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  71415. var halfRoll = roll * 0.5;
  71416. var halfPitch = pitch * 0.5;
  71417. var halfYaw = yaw * 0.5;
  71418. var sinRoll = Math.sin(halfRoll);
  71419. var cosRoll = Math.cos(halfRoll);
  71420. var sinPitch = Math.sin(halfPitch);
  71421. var cosPitch = Math.cos(halfPitch);
  71422. var sinYaw = Math.sin(halfYaw);
  71423. var cosYaw = Math.cos(halfYaw);
  71424. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  71425. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  71426. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  71427. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  71428. };
  71429. /**
  71430. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71431. * @param alpha defines the rotation around first axis
  71432. * @param beta defines the rotation around second axis
  71433. * @param gamma defines the rotation around third axis
  71434. * @returns the new quaternion
  71435. */
  71436. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  71437. var result = new Quaternion();
  71438. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  71439. return result;
  71440. };
  71441. /**
  71442. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71443. * @param alpha defines the rotation around first axis
  71444. * @param beta defines the rotation around second axis
  71445. * @param gamma defines the rotation around third axis
  71446. * @param result defines the target quaternion
  71447. */
  71448. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  71449. // Produces a quaternion from Euler angles in the z-x-z orientation
  71450. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  71451. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  71452. var halfBeta = beta * 0.5;
  71453. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71454. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71455. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71456. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71457. };
  71458. /**
  71459. * 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)
  71460. * @param axis1 defines the first axis
  71461. * @param axis2 defines the second axis
  71462. * @param axis3 defines the third axis
  71463. * @returns the new quaternion
  71464. */
  71465. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  71466. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  71467. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71468. return quat;
  71469. };
  71470. /**
  71471. * 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
  71472. * @param axis1 defines the first axis
  71473. * @param axis2 defines the second axis
  71474. * @param axis3 defines the third axis
  71475. * @param ref defines the target quaternion
  71476. */
  71477. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71478. var rotMat = MathTmp.Matrix[0];
  71479. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  71480. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  71481. };
  71482. /**
  71483. * Interpolates between two quaternions
  71484. * @param left defines first quaternion
  71485. * @param right defines second quaternion
  71486. * @param amount defines the gradient to use
  71487. * @returns the new interpolated quaternion
  71488. */
  71489. Quaternion.Slerp = function (left, right, amount) {
  71490. var result = Quaternion.Identity();
  71491. Quaternion.SlerpToRef(left, right, amount, result);
  71492. return result;
  71493. };
  71494. /**
  71495. * Interpolates between two quaternions and stores it into a target quaternion
  71496. * @param left defines first quaternion
  71497. * @param right defines second quaternion
  71498. * @param amount defines the gradient to use
  71499. * @param result defines the target quaternion
  71500. */
  71501. Quaternion.SlerpToRef = function (left, right, amount, result) {
  71502. var num2;
  71503. var num3;
  71504. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  71505. var flag = false;
  71506. if (num4 < 0) {
  71507. flag = true;
  71508. num4 = -num4;
  71509. }
  71510. if (num4 > 0.999999) {
  71511. num3 = 1 - amount;
  71512. num2 = flag ? -amount : amount;
  71513. }
  71514. else {
  71515. var num5 = Math.acos(num4);
  71516. var num6 = (1.0 / Math.sin(num5));
  71517. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  71518. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  71519. }
  71520. result.x = (num3 * left.x) + (num2 * right.x);
  71521. result.y = (num3 * left.y) + (num2 * right.y);
  71522. result.z = (num3 * left.z) + (num2 * right.z);
  71523. result.w = (num3 * left.w) + (num2 * right.w);
  71524. };
  71525. /**
  71526. * Interpolate between two quaternions using Hermite interpolation
  71527. * @param value1 defines first quaternion
  71528. * @param tangent1 defines the incoming tangent
  71529. * @param value2 defines second quaternion
  71530. * @param tangent2 defines the outgoing tangent
  71531. * @param amount defines the target quaternion
  71532. * @returns the new interpolated quaternion
  71533. */
  71534. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71535. var squared = amount * amount;
  71536. var cubed = amount * squared;
  71537. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71538. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71539. var part3 = (cubed - (2.0 * squared)) + amount;
  71540. var part4 = cubed - squared;
  71541. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71542. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71543. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71544. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  71545. return new Quaternion(x, y, z, w);
  71546. };
  71547. return Quaternion;
  71548. }());
  71549. /**
  71550. * Class used to store matrix data (4x4)
  71551. */
  71552. var Matrix = /** @class */ (function () {
  71553. /**
  71554. * Creates an empty matrix (filled with zeros)
  71555. */
  71556. function Matrix() {
  71557. this._isIdentity = false;
  71558. this._isIdentityDirty = true;
  71559. this._isIdentity3x2 = true;
  71560. this._isIdentity3x2Dirty = true;
  71561. this._m = new Float32Array(16);
  71562. this._updateIdentityStatus(false);
  71563. }
  71564. Object.defineProperty(Matrix.prototype, "m", {
  71565. /**
  71566. * Gets the internal data of the matrix
  71567. */
  71568. get: function () { return this._m; },
  71569. enumerable: true,
  71570. configurable: true
  71571. });
  71572. /** @hidden */
  71573. Matrix.prototype._markAsUpdated = function () {
  71574. this.updateFlag = Matrix._updateFlagSeed++;
  71575. this._isIdentity = false;
  71576. this._isIdentity3x2 = false;
  71577. this._isIdentityDirty = true;
  71578. this._isIdentity3x2Dirty = true;
  71579. };
  71580. /** @hidden */
  71581. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71582. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71583. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71584. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71585. this.updateFlag = Matrix._updateFlagSeed++;
  71586. this._isIdentity = isIdentity;
  71587. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71588. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71589. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71590. };
  71591. // Properties
  71592. /**
  71593. * Check if the current matrix is identity
  71594. * @returns true is the matrix is the identity matrix
  71595. */
  71596. Matrix.prototype.isIdentity = function () {
  71597. if (this._isIdentityDirty) {
  71598. this._isIdentityDirty = false;
  71599. var m = this._m;
  71600. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71601. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71602. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71603. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71604. }
  71605. return this._isIdentity;
  71606. };
  71607. /**
  71608. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71609. * @returns true is the matrix is the identity matrix
  71610. */
  71611. Matrix.prototype.isIdentityAs3x2 = function () {
  71612. if (this._isIdentity3x2Dirty) {
  71613. this._isIdentity3x2Dirty = false;
  71614. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71615. this._isIdentity3x2 = false;
  71616. }
  71617. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71618. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71619. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71620. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71621. this._isIdentity3x2 = false;
  71622. }
  71623. else {
  71624. this._isIdentity3x2 = true;
  71625. }
  71626. }
  71627. return this._isIdentity3x2;
  71628. };
  71629. /**
  71630. * Gets the determinant of the matrix
  71631. * @returns the matrix determinant
  71632. */
  71633. Matrix.prototype.determinant = function () {
  71634. if (this._isIdentity === true) {
  71635. return 1;
  71636. }
  71637. var m = this._m;
  71638. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71639. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71640. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71641. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71642. // https://en.wikipedia.org/wiki/Laplace_expansion
  71643. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71644. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71645. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71646. // where
  71647. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71648. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71649. //
  71650. // Here we do that for the 1st row.
  71651. var det_22_33 = m22 * m33 - m32 * m23;
  71652. var det_21_33 = m21 * m33 - m31 * m23;
  71653. var det_21_32 = m21 * m32 - m31 * m22;
  71654. var det_20_33 = m20 * m33 - m30 * m23;
  71655. var det_20_32 = m20 * m32 - m22 * m30;
  71656. var det_20_31 = m20 * m31 - m30 * m21;
  71657. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71658. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71659. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71660. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71661. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71662. };
  71663. // Methods
  71664. /**
  71665. * Returns the matrix as a Float32Array
  71666. * @returns the matrix underlying array
  71667. */
  71668. Matrix.prototype.toArray = function () {
  71669. return this._m;
  71670. };
  71671. /**
  71672. * Returns the matrix as a Float32Array
  71673. * @returns the matrix underlying array.
  71674. */
  71675. Matrix.prototype.asArray = function () {
  71676. return this._m;
  71677. };
  71678. /**
  71679. * Inverts the current matrix in place
  71680. * @returns the current inverted matrix
  71681. */
  71682. Matrix.prototype.invert = function () {
  71683. this.invertToRef(this);
  71684. return this;
  71685. };
  71686. /**
  71687. * Sets all the matrix elements to zero
  71688. * @returns the current matrix
  71689. */
  71690. Matrix.prototype.reset = function () {
  71691. 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);
  71692. this._updateIdentityStatus(false);
  71693. return this;
  71694. };
  71695. /**
  71696. * Adds the current matrix with a second one
  71697. * @param other defines the matrix to add
  71698. * @returns a new matrix as the addition of the current matrix and the given one
  71699. */
  71700. Matrix.prototype.add = function (other) {
  71701. var result = new Matrix();
  71702. this.addToRef(other, result);
  71703. return result;
  71704. };
  71705. /**
  71706. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71707. * @param other defines the matrix to add
  71708. * @param result defines the target matrix
  71709. * @returns the current matrix
  71710. */
  71711. Matrix.prototype.addToRef = function (other, result) {
  71712. var m = this._m;
  71713. var resultM = result._m;
  71714. var otherM = other.m;
  71715. for (var index = 0; index < 16; index++) {
  71716. resultM[index] = m[index] + otherM[index];
  71717. }
  71718. result._markAsUpdated();
  71719. return this;
  71720. };
  71721. /**
  71722. * Adds in place the given matrix to the current matrix
  71723. * @param other defines the second operand
  71724. * @returns the current updated matrix
  71725. */
  71726. Matrix.prototype.addToSelf = function (other) {
  71727. var m = this._m;
  71728. var otherM = other.m;
  71729. for (var index = 0; index < 16; index++) {
  71730. m[index] += otherM[index];
  71731. }
  71732. this._markAsUpdated();
  71733. return this;
  71734. };
  71735. /**
  71736. * Sets the given matrix to the current inverted Matrix
  71737. * @param other defines the target matrix
  71738. * @returns the unmodified current matrix
  71739. */
  71740. Matrix.prototype.invertToRef = function (other) {
  71741. if (this._isIdentity === true) {
  71742. Matrix.IdentityToRef(other);
  71743. return this;
  71744. }
  71745. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  71746. var m = this._m;
  71747. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71748. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71749. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71750. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71751. var det_22_33 = m22 * m33 - m32 * m23;
  71752. var det_21_33 = m21 * m33 - m31 * m23;
  71753. var det_21_32 = m21 * m32 - m31 * m22;
  71754. var det_20_33 = m20 * m33 - m30 * m23;
  71755. var det_20_32 = m20 * m32 - m22 * m30;
  71756. var det_20_31 = m20 * m31 - m30 * m21;
  71757. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71758. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71759. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71760. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71761. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71762. if (det === 0) {
  71763. // not invertible
  71764. other.copyFrom(this);
  71765. return this;
  71766. }
  71767. var detInv = 1 / det;
  71768. var det_12_33 = m12 * m33 - m32 * m13;
  71769. var det_11_33 = m11 * m33 - m31 * m13;
  71770. var det_11_32 = m11 * m32 - m31 * m12;
  71771. var det_10_33 = m10 * m33 - m30 * m13;
  71772. var det_10_32 = m10 * m32 - m30 * m12;
  71773. var det_10_31 = m10 * m31 - m30 * m11;
  71774. var det_12_23 = m12 * m23 - m22 * m13;
  71775. var det_11_23 = m11 * m23 - m21 * m13;
  71776. var det_11_22 = m11 * m22 - m21 * m12;
  71777. var det_10_23 = m10 * m23 - m20 * m13;
  71778. var det_10_22 = m10 * m22 - m20 * m12;
  71779. var det_10_21 = m10 * m21 - m20 * m11;
  71780. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  71781. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  71782. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  71783. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  71784. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  71785. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  71786. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  71787. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  71788. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  71789. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  71790. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  71791. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  71792. 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);
  71793. return this;
  71794. };
  71795. /**
  71796. * add a value at the specified position in the current Matrix
  71797. * @param index the index of the value within the matrix. between 0 and 15.
  71798. * @param value the value to be added
  71799. * @returns the current updated matrix
  71800. */
  71801. Matrix.prototype.addAtIndex = function (index, value) {
  71802. this._m[index] += value;
  71803. this._markAsUpdated();
  71804. return this;
  71805. };
  71806. /**
  71807. * mutiply the specified position in the current Matrix by a value
  71808. * @param index the index of the value within the matrix. between 0 and 15.
  71809. * @param value the value to be added
  71810. * @returns the current updated matrix
  71811. */
  71812. Matrix.prototype.multiplyAtIndex = function (index, value) {
  71813. this._m[index] *= value;
  71814. this._markAsUpdated();
  71815. return this;
  71816. };
  71817. /**
  71818. * Inserts the translation vector (using 3 floats) in the current matrix
  71819. * @param x defines the 1st component of the translation
  71820. * @param y defines the 2nd component of the translation
  71821. * @param z defines the 3rd component of the translation
  71822. * @returns the current updated matrix
  71823. */
  71824. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  71825. this._m[12] = x;
  71826. this._m[13] = y;
  71827. this._m[14] = z;
  71828. this._markAsUpdated();
  71829. return this;
  71830. };
  71831. /**
  71832. * Inserts the translation vector in the current matrix
  71833. * @param vector3 defines the translation to insert
  71834. * @returns the current updated matrix
  71835. */
  71836. Matrix.prototype.setTranslation = function (vector3) {
  71837. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  71838. };
  71839. /**
  71840. * Gets the translation value of the current matrix
  71841. * @returns a new Vector3 as the extracted translation from the matrix
  71842. */
  71843. Matrix.prototype.getTranslation = function () {
  71844. return new Vector3(this._m[12], this._m[13], this._m[14]);
  71845. };
  71846. /**
  71847. * Fill a Vector3 with the extracted translation from the matrix
  71848. * @param result defines the Vector3 where to store the translation
  71849. * @returns the current matrix
  71850. */
  71851. Matrix.prototype.getTranslationToRef = function (result) {
  71852. result.x = this._m[12];
  71853. result.y = this._m[13];
  71854. result.z = this._m[14];
  71855. return this;
  71856. };
  71857. /**
  71858. * Remove rotation and scaling part from the matrix
  71859. * @returns the updated matrix
  71860. */
  71861. Matrix.prototype.removeRotationAndScaling = function () {
  71862. var m = this.m;
  71863. 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);
  71864. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  71865. return this;
  71866. };
  71867. /**
  71868. * Multiply two matrices
  71869. * @param other defines the second operand
  71870. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71871. */
  71872. Matrix.prototype.multiply = function (other) {
  71873. var result = new Matrix();
  71874. this.multiplyToRef(other, result);
  71875. return result;
  71876. };
  71877. /**
  71878. * Copy the current matrix from the given one
  71879. * @param other defines the source matrix
  71880. * @returns the current updated matrix
  71881. */
  71882. Matrix.prototype.copyFrom = function (other) {
  71883. other.copyToArray(this._m);
  71884. var o = other;
  71885. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  71886. return this;
  71887. };
  71888. /**
  71889. * Populates the given array from the starting index with the current matrix values
  71890. * @param array defines the target array
  71891. * @param offset defines the offset in the target array where to start storing values
  71892. * @returns the current matrix
  71893. */
  71894. Matrix.prototype.copyToArray = function (array, offset) {
  71895. if (offset === void 0) { offset = 0; }
  71896. for (var index = 0; index < 16; index++) {
  71897. array[offset + index] = this._m[index];
  71898. }
  71899. return this;
  71900. };
  71901. /**
  71902. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71903. * @param other defines the second operand
  71904. * @param result defines the matrix where to store the multiplication
  71905. * @returns the current matrix
  71906. */
  71907. Matrix.prototype.multiplyToRef = function (other, result) {
  71908. if (this._isIdentity) {
  71909. result.copyFrom(other);
  71910. return this;
  71911. }
  71912. if (other._isIdentity) {
  71913. result.copyFrom(this);
  71914. return this;
  71915. }
  71916. this.multiplyToArray(other, result._m, 0);
  71917. result._markAsUpdated();
  71918. return this;
  71919. };
  71920. /**
  71921. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71922. * @param other defines the second operand
  71923. * @param result defines the array where to store the multiplication
  71924. * @param offset defines the offset in the target array where to start storing values
  71925. * @returns the current matrix
  71926. */
  71927. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  71928. var m = this._m;
  71929. var otherM = other.m;
  71930. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  71931. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  71932. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  71933. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  71934. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  71935. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  71936. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  71937. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  71938. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  71939. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  71940. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  71941. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  71942. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  71943. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  71944. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  71945. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  71946. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  71947. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  71948. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  71949. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  71950. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  71951. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  71952. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  71953. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  71954. return this;
  71955. };
  71956. /**
  71957. * Check equality between this matrix and a second one
  71958. * @param value defines the second matrix to compare
  71959. * @returns true is the current matrix and the given one values are strictly equal
  71960. */
  71961. Matrix.prototype.equals = function (value) {
  71962. var other = value;
  71963. if (!other) {
  71964. return false;
  71965. }
  71966. if (this._isIdentity || other._isIdentity) {
  71967. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  71968. return this._isIdentity && other._isIdentity;
  71969. }
  71970. }
  71971. var m = this.m;
  71972. var om = other.m;
  71973. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  71974. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  71975. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  71976. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  71977. };
  71978. /**
  71979. * Clone the current matrix
  71980. * @returns a new matrix from the current matrix
  71981. */
  71982. Matrix.prototype.clone = function () {
  71983. var matrix = new Matrix();
  71984. matrix.copyFrom(this);
  71985. return matrix;
  71986. };
  71987. /**
  71988. * Returns the name of the current matrix class
  71989. * @returns the string "Matrix"
  71990. */
  71991. Matrix.prototype.getClassName = function () {
  71992. return "Matrix";
  71993. };
  71994. /**
  71995. * Gets the hash code of the current matrix
  71996. * @returns the hash code
  71997. */
  71998. Matrix.prototype.getHashCode = function () {
  71999. var hash = this._m[0] || 0;
  72000. for (var i = 1; i < 16; i++) {
  72001. hash = (hash * 397) ^ (this._m[i] || 0);
  72002. }
  72003. return hash;
  72004. };
  72005. /**
  72006. * Decomposes the current Matrix into a translation, rotation and scaling components
  72007. * @param scale defines the scale vector3 given as a reference to update
  72008. * @param rotation defines the rotation quaternion given as a reference to update
  72009. * @param translation defines the translation vector3 given as a reference to update
  72010. * @returns true if operation was successful
  72011. */
  72012. Matrix.prototype.decompose = function (scale, rotation, translation) {
  72013. if (this._isIdentity) {
  72014. if (translation) {
  72015. translation.setAll(0);
  72016. }
  72017. if (scale) {
  72018. scale.setAll(1);
  72019. }
  72020. if (rotation) {
  72021. rotation.copyFromFloats(0, 0, 0, 1);
  72022. }
  72023. return true;
  72024. }
  72025. var m = this._m;
  72026. if (translation) {
  72027. translation.copyFromFloats(m[12], m[13], m[14]);
  72028. }
  72029. scale = scale || MathTmp.Vector3[0];
  72030. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  72031. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  72032. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  72033. if (this.determinant() <= 0) {
  72034. scale.y *= -1;
  72035. }
  72036. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  72037. if (rotation) {
  72038. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  72039. }
  72040. return false;
  72041. }
  72042. if (rotation) {
  72043. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72044. 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]);
  72045. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  72046. }
  72047. return true;
  72048. };
  72049. /**
  72050. * Gets specific row of the matrix
  72051. * @param index defines the number of the row to get
  72052. * @returns the index-th row of the current matrix as a new Vector4
  72053. */
  72054. Matrix.prototype.getRow = function (index) {
  72055. if (index < 0 || index > 3) {
  72056. return null;
  72057. }
  72058. var i = index * 4;
  72059. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  72060. };
  72061. /**
  72062. * Sets the index-th row of the current matrix to the vector4 values
  72063. * @param index defines the number of the row to set
  72064. * @param row defines the target vector4
  72065. * @returns the updated current matrix
  72066. */
  72067. Matrix.prototype.setRow = function (index, row) {
  72068. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  72069. };
  72070. /**
  72071. * Compute the transpose of the matrix
  72072. * @returns the new transposed matrix
  72073. */
  72074. Matrix.prototype.transpose = function () {
  72075. return Matrix.Transpose(this);
  72076. };
  72077. /**
  72078. * Compute the transpose of the matrix and store it in a given matrix
  72079. * @param result defines the target matrix
  72080. * @returns the current matrix
  72081. */
  72082. Matrix.prototype.transposeToRef = function (result) {
  72083. Matrix.TransposeToRef(this, result);
  72084. return this;
  72085. };
  72086. /**
  72087. * Sets the index-th row of the current matrix with the given 4 x float values
  72088. * @param index defines the row index
  72089. * @param x defines the x component to set
  72090. * @param y defines the y component to set
  72091. * @param z defines the z component to set
  72092. * @param w defines the w component to set
  72093. * @returns the updated current matrix
  72094. */
  72095. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  72096. if (index < 0 || index > 3) {
  72097. return this;
  72098. }
  72099. var i = index * 4;
  72100. this._m[i + 0] = x;
  72101. this._m[i + 1] = y;
  72102. this._m[i + 2] = z;
  72103. this._m[i + 3] = w;
  72104. this._markAsUpdated();
  72105. return this;
  72106. };
  72107. /**
  72108. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72109. * @param scale defines the scale factor
  72110. * @returns a new matrix
  72111. */
  72112. Matrix.prototype.scale = function (scale) {
  72113. var result = new Matrix();
  72114. this.scaleToRef(scale, result);
  72115. return result;
  72116. };
  72117. /**
  72118. * Scale the current matrix values by a factor to a given result matrix
  72119. * @param scale defines the scale factor
  72120. * @param result defines the matrix to store the result
  72121. * @returns the current matrix
  72122. */
  72123. Matrix.prototype.scaleToRef = function (scale, result) {
  72124. for (var index = 0; index < 16; index++) {
  72125. result._m[index] = this._m[index] * scale;
  72126. }
  72127. result._markAsUpdated();
  72128. return this;
  72129. };
  72130. /**
  72131. * Scale the current matrix values by a factor and add the result to a given matrix
  72132. * @param scale defines the scale factor
  72133. * @param result defines the Matrix to store the result
  72134. * @returns the current matrix
  72135. */
  72136. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  72137. for (var index = 0; index < 16; index++) {
  72138. result._m[index] += this._m[index] * scale;
  72139. }
  72140. result._markAsUpdated();
  72141. return this;
  72142. };
  72143. /**
  72144. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72145. * @param ref matrix to store the result
  72146. */
  72147. Matrix.prototype.toNormalMatrix = function (ref) {
  72148. var tmp = MathTmp.Matrix[0];
  72149. this.invertToRef(tmp);
  72150. tmp.transposeToRef(ref);
  72151. var m = ref._m;
  72152. 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);
  72153. };
  72154. /**
  72155. * Gets only rotation part of the current matrix
  72156. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72157. */
  72158. Matrix.prototype.getRotationMatrix = function () {
  72159. var result = new Matrix();
  72160. this.getRotationMatrixToRef(result);
  72161. return result;
  72162. };
  72163. /**
  72164. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72165. * @param result defines the target matrix to store data to
  72166. * @returns the current matrix
  72167. */
  72168. Matrix.prototype.getRotationMatrixToRef = function (result) {
  72169. var scale = MathTmp.Vector3[0];
  72170. if (!this.decompose(scale)) {
  72171. Matrix.IdentityToRef(result);
  72172. return this;
  72173. }
  72174. var m = this._m;
  72175. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72176. 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);
  72177. return this;
  72178. };
  72179. /**
  72180. * Toggles model matrix from being right handed to left handed in place and vice versa
  72181. */
  72182. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  72183. var m = this._m;
  72184. m[2] *= -1;
  72185. m[6] *= -1;
  72186. m[8] *= -1;
  72187. m[9] *= -1;
  72188. m[14] *= -1;
  72189. this._markAsUpdated();
  72190. };
  72191. /**
  72192. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72193. */
  72194. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  72195. var m = this._m;
  72196. m[8] *= -1;
  72197. m[9] *= -1;
  72198. m[10] *= -1;
  72199. m[11] *= -1;
  72200. this._markAsUpdated();
  72201. };
  72202. // Statics
  72203. /**
  72204. * Creates a matrix from an array
  72205. * @param array defines the source array
  72206. * @param offset defines an offset in the source array
  72207. * @returns a new Matrix set from the starting index of the given array
  72208. */
  72209. Matrix.FromArray = function (array, offset) {
  72210. if (offset === void 0) { offset = 0; }
  72211. var result = new Matrix();
  72212. Matrix.FromArrayToRef(array, offset, result);
  72213. return result;
  72214. };
  72215. /**
  72216. * Copy the content of an array into a given matrix
  72217. * @param array defines the source array
  72218. * @param offset defines an offset in the source array
  72219. * @param result defines the target matrix
  72220. */
  72221. Matrix.FromArrayToRef = function (array, offset, result) {
  72222. for (var index = 0; index < 16; index++) {
  72223. result._m[index] = array[index + offset];
  72224. }
  72225. result._markAsUpdated();
  72226. };
  72227. /**
  72228. * Stores an array into a matrix after having multiplied each component by a given factor
  72229. * @param array defines the source array
  72230. * @param offset defines the offset in the source array
  72231. * @param scale defines the scaling factor
  72232. * @param result defines the target matrix
  72233. */
  72234. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  72235. for (var index = 0; index < 16; index++) {
  72236. result._m[index] = array[index + offset] * scale;
  72237. }
  72238. result._markAsUpdated();
  72239. };
  72240. Object.defineProperty(Matrix, "IdentityReadOnly", {
  72241. /**
  72242. * Gets an identity matrix that must not be updated
  72243. */
  72244. get: function () {
  72245. return Matrix._identityReadOnly;
  72246. },
  72247. enumerable: true,
  72248. configurable: true
  72249. });
  72250. /**
  72251. * Stores a list of values (16) inside a given matrix
  72252. * @param initialM11 defines 1st value of 1st row
  72253. * @param initialM12 defines 2nd value of 1st row
  72254. * @param initialM13 defines 3rd value of 1st row
  72255. * @param initialM14 defines 4th value of 1st row
  72256. * @param initialM21 defines 1st value of 2nd row
  72257. * @param initialM22 defines 2nd value of 2nd row
  72258. * @param initialM23 defines 3rd value of 2nd row
  72259. * @param initialM24 defines 4th value of 2nd row
  72260. * @param initialM31 defines 1st value of 3rd row
  72261. * @param initialM32 defines 2nd value of 3rd row
  72262. * @param initialM33 defines 3rd value of 3rd row
  72263. * @param initialM34 defines 4th value of 3rd row
  72264. * @param initialM41 defines 1st value of 4th row
  72265. * @param initialM42 defines 2nd value of 4th row
  72266. * @param initialM43 defines 3rd value of 4th row
  72267. * @param initialM44 defines 4th value of 4th row
  72268. * @param result defines the target matrix
  72269. */
  72270. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  72271. var m = result._m;
  72272. m[0] = initialM11;
  72273. m[1] = initialM12;
  72274. m[2] = initialM13;
  72275. m[3] = initialM14;
  72276. m[4] = initialM21;
  72277. m[5] = initialM22;
  72278. m[6] = initialM23;
  72279. m[7] = initialM24;
  72280. m[8] = initialM31;
  72281. m[9] = initialM32;
  72282. m[10] = initialM33;
  72283. m[11] = initialM34;
  72284. m[12] = initialM41;
  72285. m[13] = initialM42;
  72286. m[14] = initialM43;
  72287. m[15] = initialM44;
  72288. result._markAsUpdated();
  72289. };
  72290. /**
  72291. * Creates new matrix from a list of values (16)
  72292. * @param initialM11 defines 1st value of 1st row
  72293. * @param initialM12 defines 2nd value of 1st row
  72294. * @param initialM13 defines 3rd value of 1st row
  72295. * @param initialM14 defines 4th value of 1st row
  72296. * @param initialM21 defines 1st value of 2nd row
  72297. * @param initialM22 defines 2nd value of 2nd row
  72298. * @param initialM23 defines 3rd value of 2nd row
  72299. * @param initialM24 defines 4th value of 2nd row
  72300. * @param initialM31 defines 1st value of 3rd row
  72301. * @param initialM32 defines 2nd value of 3rd row
  72302. * @param initialM33 defines 3rd value of 3rd row
  72303. * @param initialM34 defines 4th value of 3rd row
  72304. * @param initialM41 defines 1st value of 4th row
  72305. * @param initialM42 defines 2nd value of 4th row
  72306. * @param initialM43 defines 3rd value of 4th row
  72307. * @param initialM44 defines 4th value of 4th row
  72308. * @returns the new matrix
  72309. */
  72310. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  72311. var result = new Matrix();
  72312. var m = result._m;
  72313. m[0] = initialM11;
  72314. m[1] = initialM12;
  72315. m[2] = initialM13;
  72316. m[3] = initialM14;
  72317. m[4] = initialM21;
  72318. m[5] = initialM22;
  72319. m[6] = initialM23;
  72320. m[7] = initialM24;
  72321. m[8] = initialM31;
  72322. m[9] = initialM32;
  72323. m[10] = initialM33;
  72324. m[11] = initialM34;
  72325. m[12] = initialM41;
  72326. m[13] = initialM42;
  72327. m[14] = initialM43;
  72328. m[15] = initialM44;
  72329. result._markAsUpdated();
  72330. return result;
  72331. };
  72332. /**
  72333. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72334. * @param scale defines the scale vector3
  72335. * @param rotation defines the rotation quaternion
  72336. * @param translation defines the translation vector3
  72337. * @returns a new matrix
  72338. */
  72339. Matrix.Compose = function (scale, rotation, translation) {
  72340. var result = new Matrix();
  72341. Matrix.ComposeToRef(scale, rotation, translation, result);
  72342. return result;
  72343. };
  72344. /**
  72345. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72346. * @param scale defines the scale vector3
  72347. * @param rotation defines the rotation quaternion
  72348. * @param translation defines the translation vector3
  72349. * @param result defines the target matrix
  72350. */
  72351. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  72352. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  72353. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  72354. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  72355. result.setTranslation(translation);
  72356. };
  72357. /**
  72358. * Creates a new identity matrix
  72359. * @returns a new identity matrix
  72360. */
  72361. Matrix.Identity = function () {
  72362. 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);
  72363. identity._updateIdentityStatus(true);
  72364. return identity;
  72365. };
  72366. /**
  72367. * Creates a new identity matrix and stores the result in a given matrix
  72368. * @param result defines the target matrix
  72369. */
  72370. Matrix.IdentityToRef = function (result) {
  72371. 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);
  72372. result._updateIdentityStatus(true);
  72373. };
  72374. /**
  72375. * Creates a new zero matrix
  72376. * @returns a new zero matrix
  72377. */
  72378. Matrix.Zero = function () {
  72379. 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);
  72380. zero._updateIdentityStatus(false);
  72381. return zero;
  72382. };
  72383. /**
  72384. * Creates a new rotation matrix for "angle" radians around the X axis
  72385. * @param angle defines the angle (in radians) to use
  72386. * @return the new matrix
  72387. */
  72388. Matrix.RotationX = function (angle) {
  72389. var result = new Matrix();
  72390. Matrix.RotationXToRef(angle, result);
  72391. return result;
  72392. };
  72393. /**
  72394. * Creates a new matrix as the invert of a given matrix
  72395. * @param source defines the source matrix
  72396. * @returns the new matrix
  72397. */
  72398. Matrix.Invert = function (source) {
  72399. var result = new Matrix();
  72400. source.invertToRef(result);
  72401. return result;
  72402. };
  72403. /**
  72404. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72405. * @param angle defines the angle (in radians) to use
  72406. * @param result defines the target matrix
  72407. */
  72408. Matrix.RotationXToRef = function (angle, result) {
  72409. var s = Math.sin(angle);
  72410. var c = Math.cos(angle);
  72411. 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);
  72412. result._updateIdentityStatus(c === 1 && s === 0);
  72413. };
  72414. /**
  72415. * Creates a new rotation matrix for "angle" radians around the Y axis
  72416. * @param angle defines the angle (in radians) to use
  72417. * @return the new matrix
  72418. */
  72419. Matrix.RotationY = function (angle) {
  72420. var result = new Matrix();
  72421. Matrix.RotationYToRef(angle, result);
  72422. return result;
  72423. };
  72424. /**
  72425. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72426. * @param angle defines the angle (in radians) to use
  72427. * @param result defines the target matrix
  72428. */
  72429. Matrix.RotationYToRef = function (angle, result) {
  72430. var s = Math.sin(angle);
  72431. var c = Math.cos(angle);
  72432. 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);
  72433. result._updateIdentityStatus(c === 1 && s === 0);
  72434. };
  72435. /**
  72436. * Creates a new rotation matrix for "angle" radians around the Z axis
  72437. * @param angle defines the angle (in radians) to use
  72438. * @return the new matrix
  72439. */
  72440. Matrix.RotationZ = function (angle) {
  72441. var result = new Matrix();
  72442. Matrix.RotationZToRef(angle, result);
  72443. return result;
  72444. };
  72445. /**
  72446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72447. * @param angle defines the angle (in radians) to use
  72448. * @param result defines the target matrix
  72449. */
  72450. Matrix.RotationZToRef = function (angle, result) {
  72451. var s = Math.sin(angle);
  72452. var c = Math.cos(angle);
  72453. 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);
  72454. result._updateIdentityStatus(c === 1 && s === 0);
  72455. };
  72456. /**
  72457. * Creates a new rotation matrix for "angle" radians around the given axis
  72458. * @param axis defines the axis to use
  72459. * @param angle defines the angle (in radians) to use
  72460. * @return the new matrix
  72461. */
  72462. Matrix.RotationAxis = function (axis, angle) {
  72463. var result = new Matrix();
  72464. Matrix.RotationAxisToRef(axis, angle, result);
  72465. return result;
  72466. };
  72467. /**
  72468. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72469. * @param axis defines the axis to use
  72470. * @param angle defines the angle (in radians) to use
  72471. * @param result defines the target matrix
  72472. */
  72473. Matrix.RotationAxisToRef = function (axis, angle, result) {
  72474. var s = Math.sin(-angle);
  72475. var c = Math.cos(-angle);
  72476. var c1 = 1 - c;
  72477. axis.normalize();
  72478. var m = result._m;
  72479. m[0] = (axis.x * axis.x) * c1 + c;
  72480. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  72481. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  72482. m[3] = 0.0;
  72483. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  72484. m[5] = (axis.y * axis.y) * c1 + c;
  72485. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  72486. m[7] = 0.0;
  72487. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  72488. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  72489. m[10] = (axis.z * axis.z) * c1 + c;
  72490. m[11] = 0.0;
  72491. m[12] = 0.0;
  72492. m[13] = 0.0;
  72493. m[14] = 0.0;
  72494. m[15] = 1.0;
  72495. result._markAsUpdated();
  72496. };
  72497. /**
  72498. * Creates a rotation matrix
  72499. * @param yaw defines the yaw angle in radians (Y axis)
  72500. * @param pitch defines the pitch angle in radians (X axis)
  72501. * @param roll defines the roll angle in radians (X axis)
  72502. * @returns the new rotation matrix
  72503. */
  72504. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72505. var result = new Matrix();
  72506. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  72507. return result;
  72508. };
  72509. /**
  72510. * Creates a rotation matrix and stores it in a given matrix
  72511. * @param yaw defines the yaw angle in radians (Y axis)
  72512. * @param pitch defines the pitch angle in radians (X axis)
  72513. * @param roll defines the roll angle in radians (X axis)
  72514. * @param result defines the target matrix
  72515. */
  72516. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72517. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  72518. MathTmp.Quaternion[0].toRotationMatrix(result);
  72519. };
  72520. /**
  72521. * Creates a scaling matrix
  72522. * @param x defines the scale factor on X axis
  72523. * @param y defines the scale factor on Y axis
  72524. * @param z defines the scale factor on Z axis
  72525. * @returns the new matrix
  72526. */
  72527. Matrix.Scaling = function (x, y, z) {
  72528. var result = new Matrix();
  72529. Matrix.ScalingToRef(x, y, z, result);
  72530. return result;
  72531. };
  72532. /**
  72533. * Creates a scaling matrix and stores it in a given matrix
  72534. * @param x defines the scale factor on X axis
  72535. * @param y defines the scale factor on Y axis
  72536. * @param z defines the scale factor on Z axis
  72537. * @param result defines the target matrix
  72538. */
  72539. Matrix.ScalingToRef = function (x, y, z, result) {
  72540. 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);
  72541. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  72542. };
  72543. /**
  72544. * Creates a translation matrix
  72545. * @param x defines the translation on X axis
  72546. * @param y defines the translation on Y axis
  72547. * @param z defines the translationon Z axis
  72548. * @returns the new matrix
  72549. */
  72550. Matrix.Translation = function (x, y, z) {
  72551. var result = new Matrix();
  72552. Matrix.TranslationToRef(x, y, z, result);
  72553. return result;
  72554. };
  72555. /**
  72556. * Creates a translation matrix and stores it in a given matrix
  72557. * @param x defines the translation on X axis
  72558. * @param y defines the translation on Y axis
  72559. * @param z defines the translationon Z axis
  72560. * @param result defines the target matrix
  72561. */
  72562. Matrix.TranslationToRef = function (x, y, z, result) {
  72563. 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);
  72564. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72565. };
  72566. /**
  72567. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72568. * @param startValue defines the start value
  72569. * @param endValue defines the end value
  72570. * @param gradient defines the gradient factor
  72571. * @returns the new matrix
  72572. */
  72573. Matrix.Lerp = function (startValue, endValue, gradient) {
  72574. var result = new Matrix();
  72575. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72576. return result;
  72577. };
  72578. /**
  72579. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72580. * @param startValue defines the start value
  72581. * @param endValue defines the end value
  72582. * @param gradient defines the gradient factor
  72583. * @param result defines the Matrix object where to store data
  72584. */
  72585. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72586. var resultM = result._m;
  72587. var startM = startValue.m;
  72588. var endM = endValue.m;
  72589. for (var index = 0; index < 16; index++) {
  72590. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72591. }
  72592. result._markAsUpdated();
  72593. };
  72594. /**
  72595. * Builds a new matrix whose values are computed by:
  72596. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72597. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72598. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72599. * @param startValue defines the first matrix
  72600. * @param endValue defines the second matrix
  72601. * @param gradient defines the gradient between the two matrices
  72602. * @returns the new matrix
  72603. */
  72604. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72605. var result = new Matrix();
  72606. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72607. return result;
  72608. };
  72609. /**
  72610. * Update a matrix to values which are computed by:
  72611. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72612. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72613. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72614. * @param startValue defines the first matrix
  72615. * @param endValue defines the second matrix
  72616. * @param gradient defines the gradient between the two matrices
  72617. * @param result defines the target matrix
  72618. */
  72619. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72620. var startScale = MathTmp.Vector3[0];
  72621. var startRotation = MathTmp.Quaternion[0];
  72622. var startTranslation = MathTmp.Vector3[1];
  72623. startValue.decompose(startScale, startRotation, startTranslation);
  72624. var endScale = MathTmp.Vector3[2];
  72625. var endRotation = MathTmp.Quaternion[1];
  72626. var endTranslation = MathTmp.Vector3[3];
  72627. endValue.decompose(endScale, endRotation, endTranslation);
  72628. var resultScale = MathTmp.Vector3[4];
  72629. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72630. var resultRotation = MathTmp.Quaternion[2];
  72631. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72632. var resultTranslation = MathTmp.Vector3[5];
  72633. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72634. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72635. };
  72636. /**
  72637. * 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"
  72638. * This function works in left handed mode
  72639. * @param eye defines the final position of the entity
  72640. * @param target defines where the entity should look at
  72641. * @param up defines the up vector for the entity
  72642. * @returns the new matrix
  72643. */
  72644. Matrix.LookAtLH = function (eye, target, up) {
  72645. var result = new Matrix();
  72646. Matrix.LookAtLHToRef(eye, target, up, result);
  72647. return result;
  72648. };
  72649. /**
  72650. * 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".
  72651. * This function works in left handed mode
  72652. * @param eye defines the final position of the entity
  72653. * @param target defines where the entity should look at
  72654. * @param up defines the up vector for the entity
  72655. * @param result defines the target matrix
  72656. */
  72657. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72658. var xAxis = MathTmp.Vector3[0];
  72659. var yAxis = MathTmp.Vector3[1];
  72660. var zAxis = MathTmp.Vector3[2];
  72661. // Z axis
  72662. target.subtractToRef(eye, zAxis);
  72663. zAxis.normalize();
  72664. // X axis
  72665. Vector3.CrossToRef(up, zAxis, xAxis);
  72666. var xSquareLength = xAxis.lengthSquared();
  72667. if (xSquareLength === 0) {
  72668. xAxis.x = 1.0;
  72669. }
  72670. else {
  72671. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72672. }
  72673. // Y axis
  72674. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72675. yAxis.normalize();
  72676. // Eye angles
  72677. var ex = -Vector3.Dot(xAxis, eye);
  72678. var ey = -Vector3.Dot(yAxis, eye);
  72679. var ez = -Vector3.Dot(zAxis, eye);
  72680. 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);
  72681. };
  72682. /**
  72683. * 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"
  72684. * This function works in right handed mode
  72685. * @param eye defines the final position of the entity
  72686. * @param target defines where the entity should look at
  72687. * @param up defines the up vector for the entity
  72688. * @returns the new matrix
  72689. */
  72690. Matrix.LookAtRH = function (eye, target, up) {
  72691. var result = new Matrix();
  72692. Matrix.LookAtRHToRef(eye, target, up, result);
  72693. return result;
  72694. };
  72695. /**
  72696. * 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".
  72697. * This function works in right handed mode
  72698. * @param eye defines the final position of the entity
  72699. * @param target defines where the entity should look at
  72700. * @param up defines the up vector for the entity
  72701. * @param result defines the target matrix
  72702. */
  72703. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  72704. var xAxis = MathTmp.Vector3[0];
  72705. var yAxis = MathTmp.Vector3[1];
  72706. var zAxis = MathTmp.Vector3[2];
  72707. // Z axis
  72708. eye.subtractToRef(target, zAxis);
  72709. zAxis.normalize();
  72710. // X axis
  72711. Vector3.CrossToRef(up, zAxis, xAxis);
  72712. var xSquareLength = xAxis.lengthSquared();
  72713. if (xSquareLength === 0) {
  72714. xAxis.x = 1.0;
  72715. }
  72716. else {
  72717. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72718. }
  72719. // Y axis
  72720. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72721. yAxis.normalize();
  72722. // Eye angles
  72723. var ex = -Vector3.Dot(xAxis, eye);
  72724. var ey = -Vector3.Dot(yAxis, eye);
  72725. var ez = -Vector3.Dot(zAxis, eye);
  72726. 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);
  72727. };
  72728. /**
  72729. * Create a left-handed orthographic projection matrix
  72730. * @param width defines the viewport width
  72731. * @param height defines the viewport height
  72732. * @param znear defines the near clip plane
  72733. * @param zfar defines the far clip plane
  72734. * @returns a new matrix as a left-handed orthographic projection matrix
  72735. */
  72736. Matrix.OrthoLH = function (width, height, znear, zfar) {
  72737. var matrix = new Matrix();
  72738. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  72739. return matrix;
  72740. };
  72741. /**
  72742. * Store a left-handed orthographic projection to a given matrix
  72743. * @param width defines the viewport width
  72744. * @param height defines the viewport height
  72745. * @param znear defines the near clip plane
  72746. * @param zfar defines the far clip plane
  72747. * @param result defines the target matrix
  72748. */
  72749. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  72750. var n = znear;
  72751. var f = zfar;
  72752. var a = 2.0 / width;
  72753. var b = 2.0 / height;
  72754. var c = 2.0 / (f - n);
  72755. var d = -(f + n) / (f - n);
  72756. 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);
  72757. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  72758. };
  72759. /**
  72760. * Create a left-handed orthographic projection matrix
  72761. * @param left defines the viewport left coordinate
  72762. * @param right defines the viewport right coordinate
  72763. * @param bottom defines the viewport bottom coordinate
  72764. * @param top defines the viewport top coordinate
  72765. * @param znear defines the near clip plane
  72766. * @param zfar defines the far clip plane
  72767. * @returns a new matrix as a left-handed orthographic projection matrix
  72768. */
  72769. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  72770. var matrix = new Matrix();
  72771. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  72772. return matrix;
  72773. };
  72774. /**
  72775. * Stores a left-handed orthographic projection into a given matrix
  72776. * @param left defines the viewport left coordinate
  72777. * @param right defines the viewport right coordinate
  72778. * @param bottom defines the viewport bottom coordinate
  72779. * @param top defines the viewport top coordinate
  72780. * @param znear defines the near clip plane
  72781. * @param zfar defines the far clip plane
  72782. * @param result defines the target matrix
  72783. */
  72784. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72785. var n = znear;
  72786. var f = zfar;
  72787. var a = 2.0 / (right - left);
  72788. var b = 2.0 / (top - bottom);
  72789. var c = 2.0 / (f - n);
  72790. var d = -(f + n) / (f - n);
  72791. var i0 = (left + right) / (left - right);
  72792. var i1 = (top + bottom) / (bottom - top);
  72793. 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);
  72794. result._markAsUpdated();
  72795. };
  72796. /**
  72797. * Creates a right-handed orthographic projection matrix
  72798. * @param left defines the viewport left coordinate
  72799. * @param right defines the viewport right coordinate
  72800. * @param bottom defines the viewport bottom coordinate
  72801. * @param top defines the viewport top coordinate
  72802. * @param znear defines the near clip plane
  72803. * @param zfar defines the far clip plane
  72804. * @returns a new matrix as a right-handed orthographic projection matrix
  72805. */
  72806. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  72807. var matrix = new Matrix();
  72808. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  72809. return matrix;
  72810. };
  72811. /**
  72812. * Stores a right-handed orthographic projection into a given matrix
  72813. * @param left defines the viewport left coordinate
  72814. * @param right defines the viewport right coordinate
  72815. * @param bottom defines the viewport bottom coordinate
  72816. * @param top defines the viewport top coordinate
  72817. * @param znear defines the near clip plane
  72818. * @param zfar defines the far clip plane
  72819. * @param result defines the target matrix
  72820. */
  72821. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72822. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  72823. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  72824. };
  72825. /**
  72826. * Creates a left-handed perspective projection matrix
  72827. * @param width defines the viewport width
  72828. * @param height defines the viewport height
  72829. * @param znear defines the near clip plane
  72830. * @param zfar defines the far clip plane
  72831. * @returns a new matrix as a left-handed perspective projection matrix
  72832. */
  72833. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  72834. var matrix = new Matrix();
  72835. var n = znear;
  72836. var f = zfar;
  72837. var a = 2.0 * n / width;
  72838. var b = 2.0 * n / height;
  72839. var c = (f + n) / (f - n);
  72840. var d = -2.0 * f * n / (f - n);
  72841. 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);
  72842. matrix._updateIdentityStatus(false);
  72843. return matrix;
  72844. };
  72845. /**
  72846. * Creates a left-handed perspective projection matrix
  72847. * @param fov defines the horizontal field of view
  72848. * @param aspect defines the aspect ratio
  72849. * @param znear defines the near clip plane
  72850. * @param zfar defines the far clip plane
  72851. * @returns a new matrix as a left-handed perspective projection matrix
  72852. */
  72853. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  72854. var matrix = new Matrix();
  72855. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  72856. return matrix;
  72857. };
  72858. /**
  72859. * Stores a left-handed perspective projection into a given matrix
  72860. * @param fov defines the horizontal field of view
  72861. * @param aspect defines the aspect ratio
  72862. * @param znear defines the near clip plane
  72863. * @param zfar defines the far clip plane
  72864. * @param result defines the target matrix
  72865. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72866. */
  72867. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72868. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72869. var n = znear;
  72870. var f = zfar;
  72871. var t = 1.0 / (Math.tan(fov * 0.5));
  72872. var a = isVerticalFovFixed ? (t / aspect) : t;
  72873. var b = isVerticalFovFixed ? t : (t * aspect);
  72874. var c = (f + n) / (f - n);
  72875. var d = -2.0 * f * n / (f - n);
  72876. 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);
  72877. result._updateIdentityStatus(false);
  72878. };
  72879. /**
  72880. * Creates a right-handed perspective projection matrix
  72881. * @param fov defines the horizontal field of view
  72882. * @param aspect defines the aspect ratio
  72883. * @param znear defines the near clip plane
  72884. * @param zfar defines the far clip plane
  72885. * @returns a new matrix as a right-handed perspective projection matrix
  72886. */
  72887. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  72888. var matrix = new Matrix();
  72889. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  72890. return matrix;
  72891. };
  72892. /**
  72893. * Stores a right-handed perspective projection into a given matrix
  72894. * @param fov defines the horizontal field of view
  72895. * @param aspect defines the aspect ratio
  72896. * @param znear defines the near clip plane
  72897. * @param zfar defines the far clip plane
  72898. * @param result defines the target matrix
  72899. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72900. */
  72901. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72902. //alternatively this could be expressed as:
  72903. // m = PerspectiveFovLHToRef
  72904. // m[10] *= -1.0;
  72905. // m[11] *= -1.0;
  72906. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72907. var n = znear;
  72908. var f = zfar;
  72909. var t = 1.0 / (Math.tan(fov * 0.5));
  72910. var a = isVerticalFovFixed ? (t / aspect) : t;
  72911. var b = isVerticalFovFixed ? t : (t * aspect);
  72912. var c = -(f + n) / (f - n);
  72913. var d = -2 * f * n / (f - n);
  72914. 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);
  72915. result._updateIdentityStatus(false);
  72916. };
  72917. /**
  72918. * Stores a perspective projection for WebVR info a given matrix
  72919. * @param fov defines the field of view
  72920. * @param znear defines the near clip plane
  72921. * @param zfar defines the far clip plane
  72922. * @param result defines the target matrix
  72923. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72924. */
  72925. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  72926. if (rightHanded === void 0) { rightHanded = false; }
  72927. var rightHandedFactor = rightHanded ? -1 : 1;
  72928. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  72929. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  72930. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  72931. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  72932. var xScale = 2.0 / (leftTan + rightTan);
  72933. var yScale = 2.0 / (upTan + downTan);
  72934. var m = result._m;
  72935. m[0] = xScale;
  72936. m[1] = m[2] = m[3] = m[4] = 0.0;
  72937. m[5] = yScale;
  72938. m[6] = m[7] = 0.0;
  72939. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  72940. m[9] = -((upTan - downTan) * yScale * 0.5);
  72941. m[10] = -zfar / (znear - zfar);
  72942. m[11] = 1.0 * rightHandedFactor;
  72943. m[12] = m[13] = m[15] = 0.0;
  72944. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  72945. result._markAsUpdated();
  72946. };
  72947. /**
  72948. * Computes a complete transformation matrix
  72949. * @param viewport defines the viewport to use
  72950. * @param world defines the world matrix
  72951. * @param view defines the view matrix
  72952. * @param projection defines the projection matrix
  72953. * @param zmin defines the near clip plane
  72954. * @param zmax defines the far clip plane
  72955. * @returns the transformation matrix
  72956. */
  72957. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  72958. var cw = viewport.width;
  72959. var ch = viewport.height;
  72960. var cx = viewport.x;
  72961. var cy = viewport.y;
  72962. 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);
  72963. var matrix = MathTmp.Matrix[0];
  72964. world.multiplyToRef(view, matrix);
  72965. matrix.multiplyToRef(projection, matrix);
  72966. return matrix.multiply(viewportMatrix);
  72967. };
  72968. /**
  72969. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72970. * @param matrix defines the matrix to use
  72971. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72972. */
  72973. Matrix.GetAsMatrix2x2 = function (matrix) {
  72974. var m = matrix.m;
  72975. return new Float32Array([m[0], m[1], m[4], m[5]]);
  72976. };
  72977. /**
  72978. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72979. * @param matrix defines the matrix to use
  72980. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72981. */
  72982. Matrix.GetAsMatrix3x3 = function (matrix) {
  72983. var m = matrix.m;
  72984. return new Float32Array([
  72985. m[0], m[1], m[2],
  72986. m[4], m[5], m[6],
  72987. m[8], m[9], m[10]
  72988. ]);
  72989. };
  72990. /**
  72991. * Compute the transpose of a given matrix
  72992. * @param matrix defines the matrix to transpose
  72993. * @returns the new matrix
  72994. */
  72995. Matrix.Transpose = function (matrix) {
  72996. var result = new Matrix();
  72997. Matrix.TransposeToRef(matrix, result);
  72998. return result;
  72999. };
  73000. /**
  73001. * Compute the transpose of a matrix and store it in a target matrix
  73002. * @param matrix defines the matrix to transpose
  73003. * @param result defines the target matrix
  73004. */
  73005. Matrix.TransposeToRef = function (matrix, result) {
  73006. var rm = result._m;
  73007. var mm = matrix.m;
  73008. rm[0] = mm[0];
  73009. rm[1] = mm[4];
  73010. rm[2] = mm[8];
  73011. rm[3] = mm[12];
  73012. rm[4] = mm[1];
  73013. rm[5] = mm[5];
  73014. rm[6] = mm[9];
  73015. rm[7] = mm[13];
  73016. rm[8] = mm[2];
  73017. rm[9] = mm[6];
  73018. rm[10] = mm[10];
  73019. rm[11] = mm[14];
  73020. rm[12] = mm[3];
  73021. rm[13] = mm[7];
  73022. rm[14] = mm[11];
  73023. rm[15] = mm[15];
  73024. // identity-ness does not change when transposing
  73025. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  73026. };
  73027. /**
  73028. * Computes a reflection matrix from a plane
  73029. * @param plane defines the reflection plane
  73030. * @returns a new matrix
  73031. */
  73032. Matrix.Reflection = function (plane) {
  73033. var matrix = new Matrix();
  73034. Matrix.ReflectionToRef(plane, matrix);
  73035. return matrix;
  73036. };
  73037. /**
  73038. * Computes a reflection matrix from a plane
  73039. * @param plane defines the reflection plane
  73040. * @param result defines the target matrix
  73041. */
  73042. Matrix.ReflectionToRef = function (plane, result) {
  73043. plane.normalize();
  73044. var x = plane.normal.x;
  73045. var y = plane.normal.y;
  73046. var z = plane.normal.z;
  73047. var temp = -2 * x;
  73048. var temp2 = -2 * y;
  73049. var temp3 = -2 * z;
  73050. 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);
  73051. };
  73052. /**
  73053. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73054. * @param xaxis defines the value of the 1st axis
  73055. * @param yaxis defines the value of the 2nd axis
  73056. * @param zaxis defines the value of the 3rd axis
  73057. * @param result defines the target matrix
  73058. */
  73059. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  73060. 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);
  73061. };
  73062. /**
  73063. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73064. * @param quat defines the quaternion to use
  73065. * @param result defines the target matrix
  73066. */
  73067. Matrix.FromQuaternionToRef = function (quat, result) {
  73068. var xx = quat.x * quat.x;
  73069. var yy = quat.y * quat.y;
  73070. var zz = quat.z * quat.z;
  73071. var xy = quat.x * quat.y;
  73072. var zw = quat.z * quat.w;
  73073. var zx = quat.z * quat.x;
  73074. var yw = quat.y * quat.w;
  73075. var yz = quat.y * quat.z;
  73076. var xw = quat.x * quat.w;
  73077. result._m[0] = 1.0 - (2.0 * (yy + zz));
  73078. result._m[1] = 2.0 * (xy + zw);
  73079. result._m[2] = 2.0 * (zx - yw);
  73080. result._m[3] = 0.0;
  73081. result._m[4] = 2.0 * (xy - zw);
  73082. result._m[5] = 1.0 - (2.0 * (zz + xx));
  73083. result._m[6] = 2.0 * (yz + xw);
  73084. result._m[7] = 0.0;
  73085. result._m[8] = 2.0 * (zx + yw);
  73086. result._m[9] = 2.0 * (yz - xw);
  73087. result._m[10] = 1.0 - (2.0 * (yy + xx));
  73088. result._m[11] = 0.0;
  73089. result._m[12] = 0.0;
  73090. result._m[13] = 0.0;
  73091. result._m[14] = 0.0;
  73092. result._m[15] = 1.0;
  73093. result._markAsUpdated();
  73094. };
  73095. Matrix._updateFlagSeed = 0;
  73096. Matrix._identityReadOnly = Matrix.Identity();
  73097. return Matrix;
  73098. }());
  73099. /**
  73100. * Represens a plane by the equation ax + by + cz + d = 0
  73101. */
  73102. var Plane = /** @class */ (function () {
  73103. /**
  73104. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73105. * @param a a component of the plane
  73106. * @param b b component of the plane
  73107. * @param c c component of the plane
  73108. * @param d d component of the plane
  73109. */
  73110. function Plane(a, b, c, d) {
  73111. this.normal = new Vector3(a, b, c);
  73112. this.d = d;
  73113. }
  73114. /**
  73115. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73116. */
  73117. Plane.prototype.asArray = function () {
  73118. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  73119. };
  73120. // Methods
  73121. /**
  73122. * @returns a new plane copied from the current Plane.
  73123. */
  73124. Plane.prototype.clone = function () {
  73125. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  73126. };
  73127. /**
  73128. * @returns the string "Plane".
  73129. */
  73130. Plane.prototype.getClassName = function () {
  73131. return "Plane";
  73132. };
  73133. /**
  73134. * @returns the Plane hash code.
  73135. */
  73136. Plane.prototype.getHashCode = function () {
  73137. var hash = this.normal.getHashCode();
  73138. hash = (hash * 397) ^ (this.d || 0);
  73139. return hash;
  73140. };
  73141. /**
  73142. * Normalize the current Plane in place.
  73143. * @returns the updated Plane.
  73144. */
  73145. Plane.prototype.normalize = function () {
  73146. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  73147. var magnitude = 0.0;
  73148. if (norm !== 0) {
  73149. magnitude = 1.0 / norm;
  73150. }
  73151. this.normal.x *= magnitude;
  73152. this.normal.y *= magnitude;
  73153. this.normal.z *= magnitude;
  73154. this.d *= magnitude;
  73155. return this;
  73156. };
  73157. /**
  73158. * Applies a transformation the plane and returns the result
  73159. * @param transformation the transformation matrix to be applied to the plane
  73160. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73161. */
  73162. Plane.prototype.transform = function (transformation) {
  73163. var transposedMatrix = MathTmp.Matrix[0];
  73164. Matrix.TransposeToRef(transformation, transposedMatrix);
  73165. var m = transposedMatrix.m;
  73166. var x = this.normal.x;
  73167. var y = this.normal.y;
  73168. var z = this.normal.z;
  73169. var d = this.d;
  73170. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  73171. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  73172. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  73173. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  73174. return new Plane(normalX, normalY, normalZ, finalD);
  73175. };
  73176. /**
  73177. * Calcualtte the dot product between the point and the plane normal
  73178. * @param point point to calculate the dot product with
  73179. * @returns the dot product (float) of the point coordinates and the plane normal.
  73180. */
  73181. Plane.prototype.dotCoordinate = function (point) {
  73182. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  73183. };
  73184. /**
  73185. * Updates the current Plane from the plane defined by the three given points.
  73186. * @param point1 one of the points used to contruct the plane
  73187. * @param point2 one of the points used to contruct the plane
  73188. * @param point3 one of the points used to contruct the plane
  73189. * @returns the updated Plane.
  73190. */
  73191. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  73192. var x1 = point2.x - point1.x;
  73193. var y1 = point2.y - point1.y;
  73194. var z1 = point2.z - point1.z;
  73195. var x2 = point3.x - point1.x;
  73196. var y2 = point3.y - point1.y;
  73197. var z2 = point3.z - point1.z;
  73198. var yz = (y1 * z2) - (z1 * y2);
  73199. var xz = (z1 * x2) - (x1 * z2);
  73200. var xy = (x1 * y2) - (y1 * x2);
  73201. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  73202. var invPyth;
  73203. if (pyth !== 0) {
  73204. invPyth = 1.0 / pyth;
  73205. }
  73206. else {
  73207. invPyth = 0.0;
  73208. }
  73209. this.normal.x = yz * invPyth;
  73210. this.normal.y = xz * invPyth;
  73211. this.normal.z = xy * invPyth;
  73212. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  73213. return this;
  73214. };
  73215. /**
  73216. * Checks if the plane is facing a given direction
  73217. * @param direction the direction to check if the plane is facing
  73218. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73219. * @returns True is the vector "direction" is the same side than the plane normal.
  73220. */
  73221. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  73222. var dot = Vector3.Dot(this.normal, direction);
  73223. return (dot <= epsilon);
  73224. };
  73225. /**
  73226. * Calculates the distance to a point
  73227. * @param point point to calculate distance to
  73228. * @returns the signed distance (float) from the given point to the Plane.
  73229. */
  73230. Plane.prototype.signedDistanceTo = function (point) {
  73231. return Vector3.Dot(point, this.normal) + this.d;
  73232. };
  73233. // Statics
  73234. /**
  73235. * Creates a plane from an array
  73236. * @param array the array to create a plane from
  73237. * @returns a new Plane from the given array.
  73238. */
  73239. Plane.FromArray = function (array) {
  73240. return new Plane(array[0], array[1], array[2], array[3]);
  73241. };
  73242. /**
  73243. * Creates a plane from three points
  73244. * @param point1 point used to create the plane
  73245. * @param point2 point used to create the plane
  73246. * @param point3 point used to create the plane
  73247. * @returns a new Plane defined by the three given points.
  73248. */
  73249. Plane.FromPoints = function (point1, point2, point3) {
  73250. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73251. result.copyFromPoints(point1, point2, point3);
  73252. return result;
  73253. };
  73254. /**
  73255. * Creates a plane from an origin point and a normal
  73256. * @param origin origin of the plane to be constructed
  73257. * @param normal normal of the plane to be constructed
  73258. * @returns a new Plane the normal vector to this plane at the given origin point.
  73259. * Note : the vector "normal" is updated because normalized.
  73260. */
  73261. Plane.FromPositionAndNormal = function (origin, normal) {
  73262. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73263. normal.normalize();
  73264. result.normal = normal;
  73265. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73266. return result;
  73267. };
  73268. /**
  73269. * Calculates the distance from a plane and a point
  73270. * @param origin origin of the plane to be constructed
  73271. * @param normal normal of the plane to be constructed
  73272. * @param point point to calculate distance to
  73273. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73274. */
  73275. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  73276. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73277. return Vector3.Dot(point, normal) + d;
  73278. };
  73279. return Plane;
  73280. }());
  73281. /**
  73282. * Class used to represent a viewport on screen
  73283. */
  73284. var Viewport = /** @class */ (function () {
  73285. /**
  73286. * Creates a Viewport object located at (x, y) and sized (width, height)
  73287. * @param x defines viewport left coordinate
  73288. * @param y defines viewport top coordinate
  73289. * @param width defines the viewport width
  73290. * @param height defines the viewport height
  73291. */
  73292. function Viewport(
  73293. /** viewport left coordinate */
  73294. x,
  73295. /** viewport top coordinate */
  73296. y,
  73297. /**viewport width */
  73298. width,
  73299. /** viewport height */
  73300. height) {
  73301. this.x = x;
  73302. this.y = y;
  73303. this.width = width;
  73304. this.height = height;
  73305. }
  73306. /**
  73307. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73308. * @param renderWidth defines the rendering width
  73309. * @param renderHeight defines the rendering height
  73310. * @returns a new Viewport
  73311. */
  73312. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  73313. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  73314. };
  73315. /**
  73316. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73317. * @param renderWidth defines the rendering width
  73318. * @param renderHeight defines the rendering height
  73319. * @param ref defines the target viewport
  73320. * @returns the current viewport
  73321. */
  73322. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  73323. ref.x = this.x * renderWidth;
  73324. ref.y = this.y * renderHeight;
  73325. ref.width = this.width * renderWidth;
  73326. ref.height = this.height * renderHeight;
  73327. return this;
  73328. };
  73329. /**
  73330. * Returns a new Viewport copied from the current one
  73331. * @returns a new Viewport
  73332. */
  73333. Viewport.prototype.clone = function () {
  73334. return new Viewport(this.x, this.y, this.width, this.height);
  73335. };
  73336. return Viewport;
  73337. }());
  73338. /**
  73339. * Reprasents a camera frustum
  73340. */
  73341. var Frustum = /** @class */ (function () {
  73342. function Frustum() {
  73343. }
  73344. /**
  73345. * Gets the planes representing the frustum
  73346. * @param transform matrix to be applied to the returned planes
  73347. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  73348. */
  73349. Frustum.GetPlanes = function (transform) {
  73350. var frustumPlanes = [];
  73351. for (var index = 0; index < 6; index++) {
  73352. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  73353. }
  73354. Frustum.GetPlanesToRef(transform, frustumPlanes);
  73355. return frustumPlanes;
  73356. };
  73357. /**
  73358. * Gets the near frustum plane transformed by the transform matrix
  73359. * @param transform transformation matrix to be applied to the resulting frustum plane
  73360. * @param frustumPlane the resuling frustum plane
  73361. */
  73362. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  73363. var m = transform.m;
  73364. frustumPlane.normal.x = m[3] + m[2];
  73365. frustumPlane.normal.y = m[7] + m[6];
  73366. frustumPlane.normal.z = m[11] + m[10];
  73367. frustumPlane.d = m[15] + m[14];
  73368. frustumPlane.normalize();
  73369. };
  73370. /**
  73371. * Gets the far frustum plane transformed by the transform matrix
  73372. * @param transform transformation matrix to be applied to the resulting frustum plane
  73373. * @param frustumPlane the resuling frustum plane
  73374. */
  73375. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  73376. var m = transform.m;
  73377. frustumPlane.normal.x = m[3] - m[2];
  73378. frustumPlane.normal.y = m[7] - m[6];
  73379. frustumPlane.normal.z = m[11] - m[10];
  73380. frustumPlane.d = m[15] - m[14];
  73381. frustumPlane.normalize();
  73382. };
  73383. /**
  73384. * Gets the left frustum plane transformed by the transform matrix
  73385. * @param transform transformation matrix to be applied to the resulting frustum plane
  73386. * @param frustumPlane the resuling frustum plane
  73387. */
  73388. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  73389. var m = transform.m;
  73390. frustumPlane.normal.x = m[3] + m[0];
  73391. frustumPlane.normal.y = m[7] + m[4];
  73392. frustumPlane.normal.z = m[11] + m[8];
  73393. frustumPlane.d = m[15] + m[12];
  73394. frustumPlane.normalize();
  73395. };
  73396. /**
  73397. * Gets the right frustum plane transformed by the transform matrix
  73398. * @param transform transformation matrix to be applied to the resulting frustum plane
  73399. * @param frustumPlane the resuling frustum plane
  73400. */
  73401. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  73402. var m = transform.m;
  73403. frustumPlane.normal.x = m[3] - m[0];
  73404. frustumPlane.normal.y = m[7] - m[4];
  73405. frustumPlane.normal.z = m[11] - m[8];
  73406. frustumPlane.d = m[15] - m[12];
  73407. frustumPlane.normalize();
  73408. };
  73409. /**
  73410. * Gets the top frustum plane transformed by the transform matrix
  73411. * @param transform transformation matrix to be applied to the resulting frustum plane
  73412. * @param frustumPlane the resuling frustum plane
  73413. */
  73414. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  73415. var m = transform.m;
  73416. frustumPlane.normal.x = m[3] - m[1];
  73417. frustumPlane.normal.y = m[7] - m[5];
  73418. frustumPlane.normal.z = m[11] - m[9];
  73419. frustumPlane.d = m[15] - m[13];
  73420. frustumPlane.normalize();
  73421. };
  73422. /**
  73423. * Gets the bottom frustum plane transformed by the transform matrix
  73424. * @param transform transformation matrix to be applied to the resulting frustum plane
  73425. * @param frustumPlane the resuling frustum plane
  73426. */
  73427. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  73428. var m = transform.m;
  73429. frustumPlane.normal.x = m[3] + m[1];
  73430. frustumPlane.normal.y = m[7] + m[5];
  73431. frustumPlane.normal.z = m[11] + m[9];
  73432. frustumPlane.d = m[15] + m[13];
  73433. frustumPlane.normalize();
  73434. };
  73435. /**
  73436. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  73437. * @param transform transformation matrix to be applied to the resulting frustum planes
  73438. * @param frustumPlanes the resuling frustum planes
  73439. */
  73440. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  73441. // Near
  73442. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  73443. // Far
  73444. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  73445. // Left
  73446. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  73447. // Right
  73448. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  73449. // Top
  73450. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  73451. // Bottom
  73452. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  73453. };
  73454. return Frustum;
  73455. }());
  73456. /** Defines supported spaces */
  73457. var Space;
  73458. (function (Space) {
  73459. /** Local (object) space */
  73460. Space[Space["LOCAL"] = 0] = "LOCAL";
  73461. /** World space */
  73462. Space[Space["WORLD"] = 1] = "WORLD";
  73463. /** Bone space */
  73464. Space[Space["BONE"] = 2] = "BONE";
  73465. })(Space || (Space = {}));
  73466. /** Defines the 3 main axes */
  73467. var Axis = /** @class */ (function () {
  73468. function Axis() {
  73469. }
  73470. /** X axis */
  73471. Axis.X = new Vector3(1.0, 0.0, 0.0);
  73472. /** Y axis */
  73473. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  73474. /** Z axis */
  73475. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  73476. return Axis;
  73477. }());
  73478. /** Class used to represent a Bezier curve */
  73479. var BezierCurve = /** @class */ (function () {
  73480. function BezierCurve() {
  73481. }
  73482. /**
  73483. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73484. * @param t defines the time
  73485. * @param x1 defines the left coordinate on X axis
  73486. * @param y1 defines the left coordinate on Y axis
  73487. * @param x2 defines the right coordinate on X axis
  73488. * @param y2 defines the right coordinate on Y axis
  73489. * @returns the interpolated value
  73490. */
  73491. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  73492. // Extract X (which is equal to time here)
  73493. var f0 = 1 - 3 * x2 + 3 * x1;
  73494. var f1 = 3 * x2 - 6 * x1;
  73495. var f2 = 3 * x1;
  73496. var refinedT = t;
  73497. for (var i = 0; i < 5; i++) {
  73498. var refinedT2 = refinedT * refinedT;
  73499. var refinedT3 = refinedT2 * refinedT;
  73500. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  73501. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  73502. refinedT -= (x - t) * slope;
  73503. refinedT = Math.min(1, Math.max(0, refinedT));
  73504. }
  73505. // Resolve cubic bezier for the given x
  73506. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  73507. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  73508. Math.pow(refinedT, 3);
  73509. };
  73510. return BezierCurve;
  73511. }());
  73512. /**
  73513. * Defines potential orientation for back face culling
  73514. */
  73515. var Orientation;
  73516. (function (Orientation) {
  73517. /**
  73518. * Clockwise
  73519. */
  73520. Orientation[Orientation["CW"] = 0] = "CW";
  73521. /** Counter clockwise */
  73522. Orientation[Orientation["CCW"] = 1] = "CCW";
  73523. })(Orientation || (Orientation = {}));
  73524. /**
  73525. * Defines angle representation
  73526. */
  73527. var Angle = /** @class */ (function () {
  73528. /**
  73529. * Creates an Angle object of "radians" radians (float).
  73530. * @param radians the angle in radians
  73531. */
  73532. function Angle(radians) {
  73533. this._radians = radians;
  73534. if (this._radians < 0.0) {
  73535. this._radians += (2.0 * Math.PI);
  73536. }
  73537. }
  73538. /**
  73539. * Get value in degrees
  73540. * @returns the Angle value in degrees (float)
  73541. */
  73542. Angle.prototype.degrees = function () {
  73543. return this._radians * 180.0 / Math.PI;
  73544. };
  73545. /**
  73546. * Get value in radians
  73547. * @returns the Angle value in radians (float)
  73548. */
  73549. Angle.prototype.radians = function () {
  73550. return this._radians;
  73551. };
  73552. /**
  73553. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73554. * @param a defines first vector
  73555. * @param b defines second vector
  73556. * @returns a new Angle
  73557. */
  73558. Angle.BetweenTwoPoints = function (a, b) {
  73559. var delta = b.subtract(a);
  73560. var theta = Math.atan2(delta.y, delta.x);
  73561. return new Angle(theta);
  73562. };
  73563. /**
  73564. * Gets a new Angle object from the given float in radians
  73565. * @param radians defines the angle value in radians
  73566. * @returns a new Angle
  73567. */
  73568. Angle.FromRadians = function (radians) {
  73569. return new Angle(radians);
  73570. };
  73571. /**
  73572. * Gets a new Angle object from the given float in degrees
  73573. * @param degrees defines the angle value in degrees
  73574. * @returns a new Angle
  73575. */
  73576. Angle.FromDegrees = function (degrees) {
  73577. return new Angle(degrees * Math.PI / 180.0);
  73578. };
  73579. return Angle;
  73580. }());
  73581. /**
  73582. * This represents an arc in a 2d space.
  73583. */
  73584. var Arc2 = /** @class */ (function () {
  73585. /**
  73586. * Creates an Arc object from the three given points : start, middle and end.
  73587. * @param startPoint Defines the start point of the arc
  73588. * @param midPoint Defines the midlle point of the arc
  73589. * @param endPoint Defines the end point of the arc
  73590. */
  73591. function Arc2(
  73592. /** Defines the start point of the arc */
  73593. startPoint,
  73594. /** Defines the mid point of the arc */
  73595. midPoint,
  73596. /** Defines the end point of the arc */
  73597. endPoint) {
  73598. this.startPoint = startPoint;
  73599. this.midPoint = midPoint;
  73600. this.endPoint = endPoint;
  73601. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73602. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73603. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73604. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73605. 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);
  73606. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73607. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73608. var a1 = this.startAngle.degrees();
  73609. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73610. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73611. // angles correction
  73612. if (a2 - a1 > +180.0) {
  73613. a2 -= 360.0;
  73614. }
  73615. if (a2 - a1 < -180.0) {
  73616. a2 += 360.0;
  73617. }
  73618. if (a3 - a2 > +180.0) {
  73619. a3 -= 360.0;
  73620. }
  73621. if (a3 - a2 < -180.0) {
  73622. a3 += 360.0;
  73623. }
  73624. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73625. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73626. }
  73627. return Arc2;
  73628. }());
  73629. /**
  73630. * Represents a 2D path made up of multiple 2D points
  73631. */
  73632. var Path2 = /** @class */ (function () {
  73633. /**
  73634. * Creates a Path2 object from the starting 2D coordinates x and y.
  73635. * @param x the starting points x value
  73636. * @param y the starting points y value
  73637. */
  73638. function Path2(x, y) {
  73639. this._points = new Array();
  73640. this._length = 0.0;
  73641. /**
  73642. * If the path start and end point are the same
  73643. */
  73644. this.closed = false;
  73645. this._points.push(new Vector2(x, y));
  73646. }
  73647. /**
  73648. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73649. * @param x the added points x value
  73650. * @param y the added points y value
  73651. * @returns the updated Path2.
  73652. */
  73653. Path2.prototype.addLineTo = function (x, y) {
  73654. if (this.closed) {
  73655. return this;
  73656. }
  73657. var newPoint = new Vector2(x, y);
  73658. var previousPoint = this._points[this._points.length - 1];
  73659. this._points.push(newPoint);
  73660. this._length += newPoint.subtract(previousPoint).length();
  73661. return this;
  73662. };
  73663. /**
  73664. * 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.
  73665. * @param midX middle point x value
  73666. * @param midY middle point y value
  73667. * @param endX end point x value
  73668. * @param endY end point y value
  73669. * @param numberOfSegments (default: 36)
  73670. * @returns the updated Path2.
  73671. */
  73672. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73673. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73674. if (this.closed) {
  73675. return this;
  73676. }
  73677. var startPoint = this._points[this._points.length - 1];
  73678. var midPoint = new Vector2(midX, midY);
  73679. var endPoint = new Vector2(endX, endY);
  73680. var arc = new Arc2(startPoint, midPoint, endPoint);
  73681. var increment = arc.angle.radians() / numberOfSegments;
  73682. if (arc.orientation === Orientation.CW) {
  73683. increment *= -1;
  73684. }
  73685. var currentAngle = arc.startAngle.radians() + increment;
  73686. for (var i = 0; i < numberOfSegments; i++) {
  73687. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73688. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73689. this.addLineTo(x, y);
  73690. currentAngle += increment;
  73691. }
  73692. return this;
  73693. };
  73694. /**
  73695. * Closes the Path2.
  73696. * @returns the Path2.
  73697. */
  73698. Path2.prototype.close = function () {
  73699. this.closed = true;
  73700. return this;
  73701. };
  73702. /**
  73703. * Gets the sum of the distance between each sequential point in the path
  73704. * @returns the Path2 total length (float).
  73705. */
  73706. Path2.prototype.length = function () {
  73707. var result = this._length;
  73708. if (!this.closed) {
  73709. var lastPoint = this._points[this._points.length - 1];
  73710. var firstPoint = this._points[0];
  73711. result += (firstPoint.subtract(lastPoint).length());
  73712. }
  73713. return result;
  73714. };
  73715. /**
  73716. * Gets the points which construct the path
  73717. * @returns the Path2 internal array of points.
  73718. */
  73719. Path2.prototype.getPoints = function () {
  73720. return this._points;
  73721. };
  73722. /**
  73723. * Retreives the point at the distance aways from the starting point
  73724. * @param normalizedLengthPosition the length along the path to retreive the point from
  73725. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73726. */
  73727. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  73728. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  73729. return Vector2.Zero();
  73730. }
  73731. var lengthPosition = normalizedLengthPosition * this.length();
  73732. var previousOffset = 0;
  73733. for (var i = 0; i < this._points.length; i++) {
  73734. var j = (i + 1) % this._points.length;
  73735. var a = this._points[i];
  73736. var b = this._points[j];
  73737. var bToA = b.subtract(a);
  73738. var nextOffset = (bToA.length() + previousOffset);
  73739. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  73740. var dir = bToA.normalize();
  73741. var localOffset = lengthPosition - previousOffset;
  73742. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  73743. }
  73744. previousOffset = nextOffset;
  73745. }
  73746. return Vector2.Zero();
  73747. };
  73748. /**
  73749. * Creates a new path starting from an x and y position
  73750. * @param x starting x value
  73751. * @param y starting y value
  73752. * @returns a new Path2 starting at the coordinates (x, y).
  73753. */
  73754. Path2.StartingAt = function (x, y) {
  73755. return new Path2(x, y);
  73756. };
  73757. return Path2;
  73758. }());
  73759. /**
  73760. * Represents a 3D path made up of multiple 3D points
  73761. */
  73762. var Path3D = /** @class */ (function () {
  73763. /**
  73764. * new Path3D(path, normal, raw)
  73765. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73766. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73767. * @param path an array of Vector3, the curve axis of the Path3D
  73768. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73769. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73770. */
  73771. function Path3D(
  73772. /**
  73773. * an array of Vector3, the curve axis of the Path3D
  73774. */
  73775. path, firstNormal, raw) {
  73776. if (firstNormal === void 0) { firstNormal = null; }
  73777. this.path = path;
  73778. this._curve = new Array();
  73779. this._distances = new Array();
  73780. this._tangents = new Array();
  73781. this._normals = new Array();
  73782. this._binormals = new Array();
  73783. for (var p = 0; p < path.length; p++) {
  73784. this._curve[p] = path[p].clone(); // hard copy
  73785. }
  73786. this._raw = raw || false;
  73787. this._compute(firstNormal);
  73788. }
  73789. /**
  73790. * Returns the Path3D array of successive Vector3 designing its curve.
  73791. * @returns the Path3D array of successive Vector3 designing its curve.
  73792. */
  73793. Path3D.prototype.getCurve = function () {
  73794. return this._curve;
  73795. };
  73796. /**
  73797. * Returns an array populated with tangent vectors on each Path3D curve point.
  73798. * @returns an array populated with tangent vectors on each Path3D curve point.
  73799. */
  73800. Path3D.prototype.getTangents = function () {
  73801. return this._tangents;
  73802. };
  73803. /**
  73804. * Returns an array populated with normal vectors on each Path3D curve point.
  73805. * @returns an array populated with normal vectors on each Path3D curve point.
  73806. */
  73807. Path3D.prototype.getNormals = function () {
  73808. return this._normals;
  73809. };
  73810. /**
  73811. * Returns an array populated with binormal vectors on each Path3D curve point.
  73812. * @returns an array populated with binormal vectors on each Path3D curve point.
  73813. */
  73814. Path3D.prototype.getBinormals = function () {
  73815. return this._binormals;
  73816. };
  73817. /**
  73818. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73819. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73820. */
  73821. Path3D.prototype.getDistances = function () {
  73822. return this._distances;
  73823. };
  73824. /**
  73825. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73826. * @param path path which all values are copied into the curves points
  73827. * @param firstNormal which should be projected onto the curve
  73828. * @returns the same object updated.
  73829. */
  73830. Path3D.prototype.update = function (path, firstNormal) {
  73831. if (firstNormal === void 0) { firstNormal = null; }
  73832. for (var p = 0; p < path.length; p++) {
  73833. this._curve[p].x = path[p].x;
  73834. this._curve[p].y = path[p].y;
  73835. this._curve[p].z = path[p].z;
  73836. }
  73837. this._compute(firstNormal);
  73838. return this;
  73839. };
  73840. // private function compute() : computes tangents, normals and binormals
  73841. Path3D.prototype._compute = function (firstNormal) {
  73842. var l = this._curve.length;
  73843. // first and last tangents
  73844. this._tangents[0] = this._getFirstNonNullVector(0);
  73845. if (!this._raw) {
  73846. this._tangents[0].normalize();
  73847. }
  73848. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  73849. if (!this._raw) {
  73850. this._tangents[l - 1].normalize();
  73851. }
  73852. // normals and binormals at first point : arbitrary vector with _normalVector()
  73853. var tg0 = this._tangents[0];
  73854. var pp0 = this._normalVector(tg0, firstNormal);
  73855. this._normals[0] = pp0;
  73856. if (!this._raw) {
  73857. this._normals[0].normalize();
  73858. }
  73859. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  73860. if (!this._raw) {
  73861. this._binormals[0].normalize();
  73862. }
  73863. this._distances[0] = 0.0;
  73864. // normals and binormals : next points
  73865. var prev; // previous vector (segment)
  73866. var cur; // current vector (segment)
  73867. var curTang; // current tangent
  73868. // previous normal
  73869. var prevBinor; // previous binormal
  73870. for (var i = 1; i < l; i++) {
  73871. // tangents
  73872. prev = this._getLastNonNullVector(i);
  73873. if (i < l - 1) {
  73874. cur = this._getFirstNonNullVector(i);
  73875. this._tangents[i] = prev.add(cur);
  73876. this._tangents[i].normalize();
  73877. }
  73878. this._distances[i] = this._distances[i - 1] + prev.length();
  73879. // normals and binormals
  73880. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  73881. curTang = this._tangents[i];
  73882. prevBinor = this._binormals[i - 1];
  73883. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  73884. if (!this._raw) {
  73885. this._normals[i].normalize();
  73886. }
  73887. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  73888. if (!this._raw) {
  73889. this._binormals[i].normalize();
  73890. }
  73891. }
  73892. };
  73893. // private function getFirstNonNullVector(index)
  73894. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  73895. Path3D.prototype._getFirstNonNullVector = function (index) {
  73896. var i = 1;
  73897. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  73898. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  73899. i++;
  73900. nNVector = this._curve[index + i].subtract(this._curve[index]);
  73901. }
  73902. return nNVector;
  73903. };
  73904. // private function getLastNonNullVector(index)
  73905. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  73906. Path3D.prototype._getLastNonNullVector = function (index) {
  73907. var i = 1;
  73908. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  73909. while (nLVector.length() === 0 && index > i + 1) {
  73910. i++;
  73911. nLVector = this._curve[index].subtract(this._curve[index - i]);
  73912. }
  73913. return nLVector;
  73914. };
  73915. // private function normalVector(v0, vt, va) :
  73916. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  73917. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  73918. Path3D.prototype._normalVector = function (vt, va) {
  73919. var normal0;
  73920. var tgl = vt.length();
  73921. if (tgl === 0.0) {
  73922. tgl = 1.0;
  73923. }
  73924. if (va === undefined || va === null) {
  73925. var point;
  73926. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  73927. point = new Vector3(0.0, -1.0, 0.0);
  73928. }
  73929. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  73930. point = new Vector3(1.0, 0.0, 0.0);
  73931. }
  73932. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  73933. point = new Vector3(0.0, 0.0, 1.0);
  73934. }
  73935. else {
  73936. point = Vector3.Zero();
  73937. }
  73938. normal0 = Vector3.Cross(vt, point);
  73939. }
  73940. else {
  73941. normal0 = Vector3.Cross(vt, va);
  73942. Vector3.CrossToRef(normal0, vt, normal0);
  73943. }
  73944. normal0.normalize();
  73945. return normal0;
  73946. };
  73947. return Path3D;
  73948. }());
  73949. /**
  73950. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73951. * A Curve3 is designed from a series of successive Vector3.
  73952. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73953. */
  73954. var Curve3 = /** @class */ (function () {
  73955. /**
  73956. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73957. * A Curve3 is designed from a series of successive Vector3.
  73958. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73959. * @param points points which make up the curve
  73960. */
  73961. function Curve3(points) {
  73962. this._length = 0.0;
  73963. this._points = points;
  73964. this._length = this._computeLength(points);
  73965. }
  73966. /**
  73967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73969. * @param v1 (Vector3) the control point
  73970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73971. * @param nbPoints (integer) the wanted number of points in the curve
  73972. * @returns the created Curve3
  73973. */
  73974. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  73975. nbPoints = nbPoints > 2 ? nbPoints : 3;
  73976. var bez = new Array();
  73977. var equation = function (t, val0, val1, val2) {
  73978. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  73979. return res;
  73980. };
  73981. for (var i = 0; i <= nbPoints; i++) {
  73982. 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)));
  73983. }
  73984. return new Curve3(bez);
  73985. };
  73986. /**
  73987. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73988. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73989. * @param v1 (Vector3) the first control point
  73990. * @param v2 (Vector3) the second control point
  73991. * @param v3 (Vector3) the end point of the Cubic Bezier
  73992. * @param nbPoints (integer) the wanted number of points in the curve
  73993. * @returns the created Curve3
  73994. */
  73995. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  73996. nbPoints = nbPoints > 3 ? nbPoints : 4;
  73997. var bez = new Array();
  73998. var equation = function (t, val0, val1, val2, val3) {
  73999. 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;
  74000. return res;
  74001. };
  74002. for (var i = 0; i <= nbPoints; i++) {
  74003. 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)));
  74004. }
  74005. return new Curve3(bez);
  74006. };
  74007. /**
  74008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74009. * @param p1 (Vector3) the origin point of the Hermite Spline
  74010. * @param t1 (Vector3) the tangent vector at the origin point
  74011. * @param p2 (Vector3) the end point of the Hermite Spline
  74012. * @param t2 (Vector3) the tangent vector at the end point
  74013. * @param nbPoints (integer) the wanted number of points in the curve
  74014. * @returns the created Curve3
  74015. */
  74016. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  74017. var hermite = new Array();
  74018. var step = 1.0 / nbPoints;
  74019. for (var i = 0; i <= nbPoints; i++) {
  74020. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  74021. }
  74022. return new Curve3(hermite);
  74023. };
  74024. /**
  74025. * Returns a Curve3 object along a CatmullRom Spline curve :
  74026. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74027. * @param nbPoints (integer) the wanted number of points between each curve control points
  74028. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74029. * @returns the created Curve3
  74030. */
  74031. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  74032. var catmullRom = new Array();
  74033. var step = 1.0 / nbPoints;
  74034. var amount = 0.0;
  74035. if (closed) {
  74036. var pointsCount = points.length;
  74037. for (var i = 0; i < pointsCount; i++) {
  74038. amount = 0;
  74039. for (var c = 0; c < nbPoints; c++) {
  74040. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  74041. amount += step;
  74042. }
  74043. }
  74044. catmullRom.push(catmullRom[0]);
  74045. }
  74046. else {
  74047. var totalPoints = new Array();
  74048. totalPoints.push(points[0].clone());
  74049. Array.prototype.push.apply(totalPoints, points);
  74050. totalPoints.push(points[points.length - 1].clone());
  74051. for (var i = 0; i < totalPoints.length - 3; i++) {
  74052. amount = 0;
  74053. for (var c = 0; c < nbPoints; c++) {
  74054. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74055. amount += step;
  74056. }
  74057. }
  74058. i--;
  74059. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74060. }
  74061. return new Curve3(catmullRom);
  74062. };
  74063. /**
  74064. * @returns the Curve3 stored array of successive Vector3
  74065. */
  74066. Curve3.prototype.getPoints = function () {
  74067. return this._points;
  74068. };
  74069. /**
  74070. * @returns the computed length (float) of the curve.
  74071. */
  74072. Curve3.prototype.length = function () {
  74073. return this._length;
  74074. };
  74075. /**
  74076. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74077. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74078. * curveA and curveB keep unchanged.
  74079. * @param curve the curve to continue from this curve
  74080. * @returns the newly constructed curve
  74081. */
  74082. Curve3.prototype.continue = function (curve) {
  74083. var lastPoint = this._points[this._points.length - 1];
  74084. var continuedPoints = this._points.slice();
  74085. var curvePoints = curve.getPoints();
  74086. for (var i = 1; i < curvePoints.length; i++) {
  74087. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  74088. }
  74089. var continuedCurve = new Curve3(continuedPoints);
  74090. return continuedCurve;
  74091. };
  74092. Curve3.prototype._computeLength = function (path) {
  74093. var l = 0;
  74094. for (var i = 1; i < path.length; i++) {
  74095. l += (path[i].subtract(path[i - 1])).length();
  74096. }
  74097. return l;
  74098. };
  74099. return Curve3;
  74100. }());
  74101. // Vertex formats
  74102. /**
  74103. * Contains position and normal vectors for a vertex
  74104. */
  74105. var PositionNormalVertex = /** @class */ (function () {
  74106. /**
  74107. * Creates a PositionNormalVertex
  74108. * @param position the position of the vertex (defaut: 0,0,0)
  74109. * @param normal the normal of the vertex (defaut: 0,1,0)
  74110. */
  74111. function PositionNormalVertex(
  74112. /** the position of the vertex (defaut: 0,0,0) */
  74113. position,
  74114. /** the normal of the vertex (defaut: 0,1,0) */
  74115. normal) {
  74116. if (position === void 0) { position = Vector3.Zero(); }
  74117. if (normal === void 0) { normal = Vector3.Up(); }
  74118. this.position = position;
  74119. this.normal = normal;
  74120. }
  74121. /**
  74122. * Clones the PositionNormalVertex
  74123. * @returns the cloned PositionNormalVertex
  74124. */
  74125. PositionNormalVertex.prototype.clone = function () {
  74126. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  74127. };
  74128. return PositionNormalVertex;
  74129. }());
  74130. /**
  74131. * Contains position, normal and uv vectors for a vertex
  74132. */
  74133. var PositionNormalTextureVertex = /** @class */ (function () {
  74134. /**
  74135. * Creates a PositionNormalTextureVertex
  74136. * @param position the position of the vertex (defaut: 0,0,0)
  74137. * @param normal the normal of the vertex (defaut: 0,1,0)
  74138. * @param uv the uv of the vertex (default: 0,0)
  74139. */
  74140. function PositionNormalTextureVertex(
  74141. /** the position of the vertex (defaut: 0,0,0) */
  74142. position,
  74143. /** the normal of the vertex (defaut: 0,1,0) */
  74144. normal,
  74145. /** the uv of the vertex (default: 0,0) */
  74146. uv) {
  74147. if (position === void 0) { position = Vector3.Zero(); }
  74148. if (normal === void 0) { normal = Vector3.Up(); }
  74149. if (uv === void 0) { uv = Vector2.Zero(); }
  74150. this.position = position;
  74151. this.normal = normal;
  74152. this.uv = uv;
  74153. }
  74154. /**
  74155. * Clones the PositionNormalTextureVertex
  74156. * @returns the cloned PositionNormalTextureVertex
  74157. */
  74158. PositionNormalTextureVertex.prototype.clone = function () {
  74159. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  74160. };
  74161. return PositionNormalTextureVertex;
  74162. }());
  74163. // Temporary pre-allocated objects for engine internal use
  74164. // usage in any internal function :
  74165. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  74166. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  74167. /**
  74168. * @hidden
  74169. */
  74170. var Tmp = /** @class */ (function () {
  74171. function Tmp() {
  74172. }
  74173. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  74174. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  74175. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  74176. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  74177. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  74178. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  74179. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  74180. return Tmp;
  74181. }());
  74182. /**
  74183. * @hidden
  74184. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  74185. */
  74186. var MathTmp = /** @class */ (function () {
  74187. function MathTmp() {
  74188. }
  74189. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  74190. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  74191. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  74192. return MathTmp;
  74193. }());
  74194. /***/ }),
  74195. /***/ "./Maths/sphericalPolynomial.ts":
  74196. /*!**************************************!*\
  74197. !*** ./Maths/sphericalPolynomial.ts ***!
  74198. \**************************************/
  74199. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  74200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74201. "use strict";
  74202. __webpack_require__.r(__webpack_exports__);
  74203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  74204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  74205. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74206. /**
  74207. * Class representing spherical polynomial coefficients to the 3rd degree
  74208. */
  74209. var SphericalPolynomial = /** @class */ (function () {
  74210. function SphericalPolynomial() {
  74211. /**
  74212. * The x coefficients of the spherical polynomial
  74213. */
  74214. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74215. /**
  74216. * The y coefficients of the spherical polynomial
  74217. */
  74218. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74219. /**
  74220. * The z coefficients of the spherical polynomial
  74221. */
  74222. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74223. /**
  74224. * The xx coefficients of the spherical polynomial
  74225. */
  74226. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74227. /**
  74228. * The yy coefficients of the spherical polynomial
  74229. */
  74230. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74231. /**
  74232. * The zz coefficients of the spherical polynomial
  74233. */
  74234. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74235. /**
  74236. * The xy coefficients of the spherical polynomial
  74237. */
  74238. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74239. /**
  74240. * The yz coefficients of the spherical polynomial
  74241. */
  74242. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74243. /**
  74244. * The zx coefficients of the spherical polynomial
  74245. */
  74246. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74247. }
  74248. /**
  74249. * Adds an ambient color to the spherical polynomial
  74250. * @param color the color to add
  74251. */
  74252. SphericalPolynomial.prototype.addAmbient = function (color) {
  74253. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74254. this.xx = this.xx.add(colorVector);
  74255. this.yy = this.yy.add(colorVector);
  74256. this.zz = this.zz.add(colorVector);
  74257. };
  74258. /**
  74259. * Scales the spherical polynomial by the given amount
  74260. * @param scale the amount to scale
  74261. */
  74262. SphericalPolynomial.prototype.scale = function (scale) {
  74263. this.x = this.x.scale(scale);
  74264. this.y = this.y.scale(scale);
  74265. this.z = this.z.scale(scale);
  74266. this.xx = this.xx.scale(scale);
  74267. this.yy = this.yy.scale(scale);
  74268. this.zz = this.zz.scale(scale);
  74269. this.yz = this.yz.scale(scale);
  74270. this.zx = this.zx.scale(scale);
  74271. this.xy = this.xy.scale(scale);
  74272. };
  74273. /**
  74274. * Gets the spherical polynomial from harmonics
  74275. * @param harmonics the spherical harmonics
  74276. * @returns the spherical polynomial
  74277. */
  74278. SphericalPolynomial.FromHarmonics = function (harmonics) {
  74279. var result = new SphericalPolynomial();
  74280. result.x = harmonics.l11.scale(1.02333);
  74281. result.y = harmonics.l1_1.scale(1.02333);
  74282. result.z = harmonics.l10.scale(1.02333);
  74283. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  74284. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  74285. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  74286. result.yz = harmonics.l2_1.scale(0.858086);
  74287. result.zx = harmonics.l21.scale(0.858086);
  74288. result.xy = harmonics.l2_2.scale(0.858086);
  74289. result.scale(1.0 / Math.PI);
  74290. return result;
  74291. };
  74292. /**
  74293. * Constructs a spherical polynomial from an array.
  74294. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  74295. * @returns the spherical polynomial
  74296. */
  74297. SphericalPolynomial.FromArray = function (data) {
  74298. var sp = new SphericalPolynomial();
  74299. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  74300. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  74301. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  74302. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  74303. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  74304. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  74305. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  74306. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  74307. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  74308. return sp;
  74309. };
  74310. return SphericalPolynomial;
  74311. }());
  74312. /**
  74313. * Class representing spherical harmonics coefficients to the 3rd degree
  74314. */
  74315. var SphericalHarmonics = /** @class */ (function () {
  74316. function SphericalHarmonics() {
  74317. /**
  74318. * The l0,0 coefficients of the spherical harmonics
  74319. */
  74320. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74321. /**
  74322. * The l1,-1 coefficients of the spherical harmonics
  74323. */
  74324. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74325. /**
  74326. * The l1,0 coefficients of the spherical harmonics
  74327. */
  74328. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74329. /**
  74330. * The l1,1 coefficients of the spherical harmonics
  74331. */
  74332. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74333. /**
  74334. * The l2,-2 coefficients of the spherical harmonics
  74335. */
  74336. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74337. /**
  74338. * The l2,-1 coefficients of the spherical harmonics
  74339. */
  74340. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74341. /**
  74342. * The l2,0 coefficients of the spherical harmonics
  74343. */
  74344. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74345. /**
  74346. * The l2,1 coefficients of the spherical harmonics
  74347. */
  74348. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74349. /**
  74350. * The l2,2 coefficients of the spherical harmonics
  74351. */
  74352. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74353. }
  74354. /**
  74355. * Adds a light to the spherical harmonics
  74356. * @param direction the direction of the light
  74357. * @param color the color of the light
  74358. * @param deltaSolidAngle the delta solid angle of the light
  74359. */
  74360. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  74361. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74362. var c = colorVector.scale(deltaSolidAngle);
  74363. this.l00 = this.l00.add(c.scale(0.282095));
  74364. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  74365. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  74366. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  74367. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  74368. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  74369. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  74370. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  74371. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  74372. };
  74373. /**
  74374. * Scales the spherical harmonics by the given amount
  74375. * @param scale the amount to scale
  74376. */
  74377. SphericalHarmonics.prototype.scale = function (scale) {
  74378. this.l00 = this.l00.scale(scale);
  74379. this.l1_1 = this.l1_1.scale(scale);
  74380. this.l10 = this.l10.scale(scale);
  74381. this.l11 = this.l11.scale(scale);
  74382. this.l2_2 = this.l2_2.scale(scale);
  74383. this.l2_1 = this.l2_1.scale(scale);
  74384. this.l20 = this.l20.scale(scale);
  74385. this.l21 = this.l21.scale(scale);
  74386. this.lL22 = this.lL22.scale(scale);
  74387. };
  74388. /**
  74389. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  74390. *
  74391. * ```
  74392. * E_lm = A_l * L_lm
  74393. * ```
  74394. *
  74395. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  74396. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  74397. * the scaling factors are given in equation 9.
  74398. */
  74399. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  74400. // Constant (Band 0)
  74401. this.l00 = this.l00.scale(3.141593);
  74402. // Linear (Band 1)
  74403. this.l1_1 = this.l1_1.scale(2.094395);
  74404. this.l10 = this.l10.scale(2.094395);
  74405. this.l11 = this.l11.scale(2.094395);
  74406. // Quadratic (Band 2)
  74407. this.l2_2 = this.l2_2.scale(0.785398);
  74408. this.l2_1 = this.l2_1.scale(0.785398);
  74409. this.l20 = this.l20.scale(0.785398);
  74410. this.l21 = this.l21.scale(0.785398);
  74411. this.lL22 = this.lL22.scale(0.785398);
  74412. };
  74413. /**
  74414. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  74415. *
  74416. * ```
  74417. * L = (1/pi) * E * rho
  74418. * ```
  74419. *
  74420. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  74421. */
  74422. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  74423. this.scale(1.0 / Math.PI);
  74424. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  74425. // (The pixel shader must apply albedo after texture fetches, etc).
  74426. };
  74427. /**
  74428. * Gets the spherical harmonics from polynomial
  74429. * @param polynomial the spherical polynomial
  74430. * @returns the spherical harmonics
  74431. */
  74432. SphericalHarmonics.FromPolynomial = function (polynomial) {
  74433. var result = new SphericalHarmonics();
  74434. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  74435. result.l1_1 = polynomial.y.scale(0.977204);
  74436. result.l10 = polynomial.z.scale(0.977204);
  74437. result.l11 = polynomial.x.scale(0.977204);
  74438. result.l2_2 = polynomial.xy.scale(1.16538);
  74439. result.l2_1 = polynomial.yz.scale(1.16538);
  74440. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  74441. result.l21 = polynomial.zx.scale(1.16538);
  74442. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  74443. result.scale(Math.PI);
  74444. return result;
  74445. };
  74446. /**
  74447. * Constructs a spherical harmonics from an array.
  74448. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  74449. * @returns the spherical harmonics
  74450. */
  74451. SphericalHarmonics.FromArray = function (data) {
  74452. var sh = new SphericalHarmonics();
  74453. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  74454. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  74455. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  74456. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  74457. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  74458. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  74459. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  74460. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  74461. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  74462. return sh;
  74463. };
  74464. return SphericalHarmonics;
  74465. }());
  74466. /***/ }),
  74467. /***/ "./Meshes/Builders/boxBuilder.ts":
  74468. /*!***************************************!*\
  74469. !*** ./Meshes/Builders/boxBuilder.ts ***!
  74470. \***************************************/
  74471. /*! exports provided: BoxBuilder */
  74472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74473. "use strict";
  74474. __webpack_require__.r(__webpack_exports__);
  74475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  74476. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74477. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74478. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74479. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  74480. var normalsSource = [
  74481. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  74482. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  74483. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  74484. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  74485. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  74486. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  74487. ];
  74488. var indices = [];
  74489. var positions = [];
  74490. var normals = [];
  74491. var uvs = [];
  74492. var width = options.width || options.size || 1;
  74493. var height = options.height || options.size || 1;
  74494. var depth = options.depth || options.size || 1;
  74495. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74496. var faceUV = options.faceUV || new Array(6);
  74497. var faceColors = options.faceColors;
  74498. var colors = [];
  74499. // default face colors and UV if undefined
  74500. for (var f = 0; f < 6; f++) {
  74501. if (faceUV[f] === undefined) {
  74502. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74503. }
  74504. if (faceColors && faceColors[f] === undefined) {
  74505. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74506. }
  74507. }
  74508. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  74509. // Create each face in turn.
  74510. for (var index = 0; index < normalsSource.length; index++) {
  74511. var normal = normalsSource[index];
  74512. // Get two vectors perpendicular to the face normal and to each other.
  74513. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  74514. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  74515. // Six indices (two triangles) per face.
  74516. var verticesLength = positions.length / 3;
  74517. indices.push(verticesLength);
  74518. indices.push(verticesLength + 1);
  74519. indices.push(verticesLength + 2);
  74520. indices.push(verticesLength);
  74521. indices.push(verticesLength + 2);
  74522. indices.push(verticesLength + 3);
  74523. // Four vertices per face.
  74524. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  74525. positions.push(vertex.x, vertex.y, vertex.z);
  74526. normals.push(normal.x, normal.y, normal.z);
  74527. uvs.push(faceUV[index].z, faceUV[index].w);
  74528. if (faceColors) {
  74529. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74530. }
  74531. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  74532. positions.push(vertex.x, vertex.y, vertex.z);
  74533. normals.push(normal.x, normal.y, normal.z);
  74534. uvs.push(faceUV[index].x, faceUV[index].w);
  74535. if (faceColors) {
  74536. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74537. }
  74538. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  74539. positions.push(vertex.x, vertex.y, vertex.z);
  74540. normals.push(normal.x, normal.y, normal.z);
  74541. uvs.push(faceUV[index].x, faceUV[index].y);
  74542. if (faceColors) {
  74543. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74544. }
  74545. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  74546. positions.push(vertex.x, vertex.y, vertex.z);
  74547. normals.push(normal.x, normal.y, normal.z);
  74548. uvs.push(faceUV[index].z, faceUV[index].y);
  74549. if (faceColors) {
  74550. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74551. }
  74552. }
  74553. // sides
  74554. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  74555. // Result
  74556. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  74557. vertexData.indices = indices;
  74558. vertexData.positions = positions;
  74559. vertexData.normals = normals;
  74560. vertexData.uvs = uvs;
  74561. if (faceColors) {
  74562. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  74563. vertexData.colors = totalColors;
  74564. }
  74565. return vertexData;
  74566. };
  74567. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  74568. if (scene === void 0) { scene = null; }
  74569. var options = {
  74570. size: size,
  74571. sideOrientation: sideOrientation,
  74572. updatable: updatable
  74573. };
  74574. return BoxBuilder.CreateBox(name, options, scene);
  74575. };
  74576. /**
  74577. * Class containing static functions to help procedurally build meshes
  74578. */
  74579. var BoxBuilder = /** @class */ (function () {
  74580. function BoxBuilder() {
  74581. }
  74582. /**
  74583. * Creates a box mesh
  74584. * * The parameter `size` sets the size (float) of each box side (default 1)
  74585. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  74586. * * 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)
  74587. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74589. * * 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
  74590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74591. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74592. * @param name defines the name of the mesh
  74593. * @param options defines the options used to create the mesh
  74594. * @param scene defines the hosting scene
  74595. * @returns the box mesh
  74596. */
  74597. BoxBuilder.CreateBox = function (name, options, scene) {
  74598. if (scene === void 0) { scene = null; }
  74599. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  74600. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  74601. box._originalBuilderSideOrientation = options.sideOrientation;
  74602. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  74603. vertexData.applyToMesh(box, options.updatable);
  74604. return box;
  74605. };
  74606. return BoxBuilder;
  74607. }());
  74608. /***/ }),
  74609. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  74610. /*!********************************************!*\
  74611. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  74612. \********************************************/
  74613. /*! exports provided: CylinderBuilder */
  74614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74615. "use strict";
  74616. __webpack_require__.r(__webpack_exports__);
  74617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  74618. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74619. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74620. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74621. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  74622. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  74623. var height = options.height || 2;
  74624. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  74625. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  74626. var tessellation = options.tessellation || 24;
  74627. var subdivisions = options.subdivisions || 1;
  74628. var hasRings = options.hasRings ? true : false;
  74629. var enclose = options.enclose ? true : false;
  74630. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  74631. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74632. var faceUV = options.faceUV || new Array(3);
  74633. var faceColors = options.faceColors;
  74634. // default face colors and UV if undefined
  74635. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  74636. var ringNb = (hasRings) ? subdivisions : 1;
  74637. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  74638. var f;
  74639. for (f = 0; f < surfaceNb; f++) {
  74640. if (faceColors && faceColors[f] === undefined) {
  74641. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74642. }
  74643. }
  74644. for (f = 0; f < surfaceNb; f++) {
  74645. if (faceUV && faceUV[f] === undefined) {
  74646. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74647. }
  74648. }
  74649. var indices = new Array();
  74650. var positions = new Array();
  74651. var normals = new Array();
  74652. var uvs = new Array();
  74653. var colors = new Array();
  74654. var angle_step = Math.PI * 2 * arc / tessellation;
  74655. var angle;
  74656. var h;
  74657. var radius;
  74658. var tan = (diameterBottom - diameterTop) / 2 / height;
  74659. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74660. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74661. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74662. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74663. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74664. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  74665. // positions, normals, uvs
  74666. var i;
  74667. var j;
  74668. var r;
  74669. var ringIdx = 1;
  74670. var s = 1; // surface index
  74671. var cs = 0;
  74672. var v = 0;
  74673. for (i = 0; i <= subdivisions; i++) {
  74674. h = i / subdivisions;
  74675. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  74676. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  74677. for (r = 0; r < ringIdx; r++) {
  74678. if (hasRings) {
  74679. s += r;
  74680. }
  74681. if (enclose) {
  74682. s += 2 * r;
  74683. }
  74684. for (j = 0; j <= tessellation; j++) {
  74685. angle = j * angle_step;
  74686. // position
  74687. ringVertex.x = Math.cos(-angle) * radius;
  74688. ringVertex.y = -height / 2 + h * height;
  74689. ringVertex.z = Math.sin(-angle) * radius;
  74690. // normal
  74691. if (diameterTop === 0 && i === subdivisions) {
  74692. // if no top cap, reuse former normals
  74693. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  74694. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  74695. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  74696. }
  74697. else {
  74698. ringNormal.x = ringVertex.x;
  74699. ringNormal.z = ringVertex.z;
  74700. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  74701. ringNormal.normalize();
  74702. }
  74703. // keep first ring vertex values for enclose
  74704. if (j === 0) {
  74705. ringFirstVertex.copyFrom(ringVertex);
  74706. ringFirstNormal.copyFrom(ringNormal);
  74707. }
  74708. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  74709. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  74710. if (hasRings) {
  74711. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  74712. }
  74713. else {
  74714. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  74715. }
  74716. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  74717. if (faceColors) {
  74718. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  74719. }
  74720. }
  74721. // if enclose, add four vertices and their dedicated normals
  74722. if (arc !== 1 && enclose) {
  74723. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  74724. positions.push(0, ringVertex.y, 0);
  74725. positions.push(0, ringVertex.y, 0);
  74726. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  74727. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  74728. quadNormal.normalize();
  74729. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  74730. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  74731. quadNormal.normalize();
  74732. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  74733. if (hasRings) {
  74734. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  74735. }
  74736. else {
  74737. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  74738. }
  74739. uvs.push(faceUV[s + 1].x, v);
  74740. uvs.push(faceUV[s + 1].z, v);
  74741. if (hasRings) {
  74742. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  74743. }
  74744. else {
  74745. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  74746. }
  74747. uvs.push(faceUV[s + 2].x, v);
  74748. uvs.push(faceUV[s + 2].z, v);
  74749. if (faceColors) {
  74750. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  74751. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  74752. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  74753. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  74754. }
  74755. }
  74756. if (cs !== s) {
  74757. cs = s;
  74758. }
  74759. }
  74760. }
  74761. // indices
  74762. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  74763. var s;
  74764. i = 0;
  74765. for (s = 0; s < subdivisions; s++) {
  74766. var i0 = 0;
  74767. var i1 = 0;
  74768. var i2 = 0;
  74769. var i3 = 0;
  74770. for (j = 0; j < tessellation; j++) {
  74771. i0 = i * (e + 1) + j;
  74772. i1 = (i + 1) * (e + 1) + j;
  74773. i2 = i * (e + 1) + (j + 1);
  74774. i3 = (i + 1) * (e + 1) + (j + 1);
  74775. indices.push(i0, i1, i2);
  74776. indices.push(i3, i2, i1);
  74777. }
  74778. if (arc !== 1 && enclose) { // if enclose, add two quads
  74779. indices.push(i0 + 2, i1 + 2, i2 + 2);
  74780. indices.push(i3 + 2, i2 + 2, i1 + 2);
  74781. indices.push(i0 + 4, i1 + 4, i2 + 4);
  74782. indices.push(i3 + 4, i2 + 4, i1 + 4);
  74783. }
  74784. i = (hasRings) ? (i + 2) : (i + 1);
  74785. }
  74786. // Caps
  74787. var createCylinderCap = function (isTop) {
  74788. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  74789. if (radius === 0) {
  74790. return;
  74791. }
  74792. // Cap positions, normals & uvs
  74793. var angle;
  74794. var circleVector;
  74795. var i;
  74796. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  74797. var c = null;
  74798. if (faceColors) {
  74799. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  74800. }
  74801. // cap center
  74802. var vbase = positions.length / 3;
  74803. var offset = isTop ? height / 2 : -height / 2;
  74804. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  74805. positions.push(center.x, center.y, center.z);
  74806. normals.push(0, isTop ? 1 : -1, 0);
  74807. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  74808. if (c) {
  74809. colors.push(c.r, c.g, c.b, c.a);
  74810. }
  74811. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  74812. for (i = 0; i <= tessellation; i++) {
  74813. angle = Math.PI * 2 * i * arc / tessellation;
  74814. var cos = Math.cos(-angle);
  74815. var sin = Math.sin(-angle);
  74816. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  74817. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  74818. positions.push(circleVector.x, circleVector.y, circleVector.z);
  74819. normals.push(0, isTop ? 1 : -1, 0);
  74820. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  74821. if (c) {
  74822. colors.push(c.r, c.g, c.b, c.a);
  74823. }
  74824. }
  74825. // Cap indices
  74826. for (i = 0; i < tessellation; i++) {
  74827. if (!isTop) {
  74828. indices.push(vbase);
  74829. indices.push(vbase + (i + 1));
  74830. indices.push(vbase + (i + 2));
  74831. }
  74832. else {
  74833. indices.push(vbase);
  74834. indices.push(vbase + (i + 2));
  74835. indices.push(vbase + (i + 1));
  74836. }
  74837. }
  74838. };
  74839. // add caps to geometry
  74840. createCylinderCap(false);
  74841. createCylinderCap(true);
  74842. // Sides
  74843. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  74844. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  74845. vertexData.indices = indices;
  74846. vertexData.positions = positions;
  74847. vertexData.normals = normals;
  74848. vertexData.uvs = uvs;
  74849. if (faceColors) {
  74850. vertexData.colors = colors;
  74851. }
  74852. return vertexData;
  74853. };
  74854. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  74855. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  74856. if (scene !== undefined) {
  74857. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  74858. updatable = scene;
  74859. }
  74860. scene = subdivisions;
  74861. subdivisions = 1;
  74862. }
  74863. var options = {
  74864. height: height,
  74865. diameterTop: diameterTop,
  74866. diameterBottom: diameterBottom,
  74867. tessellation: tessellation,
  74868. subdivisions: subdivisions,
  74869. sideOrientation: sideOrientation,
  74870. updatable: updatable
  74871. };
  74872. return CylinderBuilder.CreateCylinder(name, options, scene);
  74873. };
  74874. /**
  74875. * Class containing static functions to help procedurally build meshes
  74876. */
  74877. var CylinderBuilder = /** @class */ (function () {
  74878. function CylinderBuilder() {
  74879. }
  74880. /**
  74881. * Creates a cylinder or a cone mesh
  74882. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  74883. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  74884. * * 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.
  74885. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  74886. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  74887. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  74888. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  74889. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  74890. * * 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).
  74891. * * 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
  74892. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  74893. * * 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
  74894. * * 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.
  74895. * * If `enclose` is false, a ring surface is one element.
  74896. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  74897. * * 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
  74898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74899. * * 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
  74900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74901. * @param name defines the name of the mesh
  74902. * @param options defines the options used to create the mesh
  74903. * @param scene defines the hosting scene
  74904. * @returns the cylinder mesh
  74905. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  74906. */
  74907. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  74908. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  74909. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  74910. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  74911. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  74912. vertexData.applyToMesh(cylinder, options.updatable);
  74913. return cylinder;
  74914. };
  74915. return CylinderBuilder;
  74916. }());
  74917. /***/ }),
  74918. /***/ "./Meshes/Builders/decalBuilder.ts":
  74919. /*!*****************************************!*\
  74920. !*** ./Meshes/Builders/decalBuilder.ts ***!
  74921. \*****************************************/
  74922. /*! exports provided: DecalBuilder */
  74923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74924. "use strict";
  74925. __webpack_require__.r(__webpack_exports__);
  74926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  74927. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74928. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74929. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  74930. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74931. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  74932. var options = {
  74933. position: position,
  74934. normal: normal,
  74935. size: size,
  74936. angle: angle
  74937. };
  74938. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  74939. };
  74940. /**
  74941. * Class containing static functions to help procedurally build meshes
  74942. */
  74943. var DecalBuilder = /** @class */ (function () {
  74944. function DecalBuilder() {
  74945. }
  74946. /**
  74947. * Creates a decal mesh.
  74948. * 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
  74949. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74950. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74951. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74952. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74953. * @param name defines the name of the mesh
  74954. * @param sourceMesh defines the mesh where the decal must be applied
  74955. * @param options defines the options used to create the mesh
  74956. * @param scene defines the hosting scene
  74957. * @returns the decal mesh
  74958. * @see https://doc.babylonjs.com/how_to/decals
  74959. */
  74960. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  74961. var indices = sourceMesh.getIndices();
  74962. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  74963. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  74964. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74965. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  74966. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  74967. var angle = options.angle || 0;
  74968. // Getting correct rotation
  74969. if (!normal) {
  74970. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  74971. var camera = sourceMesh.getScene().activeCamera;
  74972. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  74973. normal = camera.globalPosition.subtract(cameraWorldTarget);
  74974. }
  74975. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  74976. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  74977. var pitch = Math.atan2(normal.y, len);
  74978. // Matrix
  74979. 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));
  74980. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  74981. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  74982. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  74983. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  74984. vertexData.indices = [];
  74985. vertexData.positions = [];
  74986. vertexData.normals = [];
  74987. vertexData.uvs = [];
  74988. var currentVertexDataIndex = 0;
  74989. var extractDecalVector3 = function (indexId) {
  74990. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  74991. if (!indices || !positions || !normals) {
  74992. return result;
  74993. }
  74994. var vertexId = indices[indexId];
  74995. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  74996. // Send vector to decal local world
  74997. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  74998. // Get normal
  74999. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  75000. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  75001. return result;
  75002. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  75003. var clip = function (vertices, axis) {
  75004. if (vertices.length === 0) {
  75005. return vertices;
  75006. }
  75007. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  75008. var clipVertices = function (v0, v1) {
  75009. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  75010. 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));
  75011. };
  75012. var result = new Array();
  75013. for (var index = 0; index < vertices.length; index += 3) {
  75014. var v1Out;
  75015. var v2Out;
  75016. var v3Out;
  75017. var total = 0;
  75018. var nV1 = null;
  75019. var nV2 = null;
  75020. var nV3 = null;
  75021. var nV4 = null;
  75022. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  75023. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  75024. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  75025. v1Out = d1 > 0;
  75026. v2Out = d2 > 0;
  75027. v3Out = d3 > 0;
  75028. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  75029. switch (total) {
  75030. case 0:
  75031. result.push(vertices[index]);
  75032. result.push(vertices[index + 1]);
  75033. result.push(vertices[index + 2]);
  75034. break;
  75035. case 1:
  75036. if (v1Out) {
  75037. nV1 = vertices[index + 1];
  75038. nV2 = vertices[index + 2];
  75039. nV3 = clipVertices(vertices[index], nV1);
  75040. nV4 = clipVertices(vertices[index], nV2);
  75041. }
  75042. if (v2Out) {
  75043. nV1 = vertices[index];
  75044. nV2 = vertices[index + 2];
  75045. nV3 = clipVertices(vertices[index + 1], nV1);
  75046. nV4 = clipVertices(vertices[index + 1], nV2);
  75047. result.push(nV3);
  75048. result.push(nV2.clone());
  75049. result.push(nV1.clone());
  75050. result.push(nV2.clone());
  75051. result.push(nV3.clone());
  75052. result.push(nV4);
  75053. break;
  75054. }
  75055. if (v3Out) {
  75056. nV1 = vertices[index];
  75057. nV2 = vertices[index + 1];
  75058. nV3 = clipVertices(vertices[index + 2], nV1);
  75059. nV4 = clipVertices(vertices[index + 2], nV2);
  75060. }
  75061. if (nV1 && nV2 && nV3 && nV4) {
  75062. result.push(nV1.clone());
  75063. result.push(nV2.clone());
  75064. result.push(nV3);
  75065. result.push(nV4);
  75066. result.push(nV3.clone());
  75067. result.push(nV2.clone());
  75068. }
  75069. break;
  75070. case 2:
  75071. if (!v1Out) {
  75072. nV1 = vertices[index].clone();
  75073. nV2 = clipVertices(nV1, vertices[index + 1]);
  75074. nV3 = clipVertices(nV1, vertices[index + 2]);
  75075. result.push(nV1);
  75076. result.push(nV2);
  75077. result.push(nV3);
  75078. }
  75079. if (!v2Out) {
  75080. nV1 = vertices[index + 1].clone();
  75081. nV2 = clipVertices(nV1, vertices[index + 2]);
  75082. nV3 = clipVertices(nV1, vertices[index]);
  75083. result.push(nV1);
  75084. result.push(nV2);
  75085. result.push(nV3);
  75086. }
  75087. if (!v3Out) {
  75088. nV1 = vertices[index + 2].clone();
  75089. nV2 = clipVertices(nV1, vertices[index]);
  75090. nV3 = clipVertices(nV1, vertices[index + 1]);
  75091. result.push(nV1);
  75092. result.push(nV2);
  75093. result.push(nV3);
  75094. }
  75095. break;
  75096. case 3:
  75097. break;
  75098. }
  75099. }
  75100. return result;
  75101. };
  75102. for (var index = 0; index < indices.length; index += 3) {
  75103. var faceVertices = new Array();
  75104. faceVertices.push(extractDecalVector3(index));
  75105. faceVertices.push(extractDecalVector3(index + 1));
  75106. faceVertices.push(extractDecalVector3(index + 2));
  75107. // Clip
  75108. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  75109. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  75110. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  75111. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  75112. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  75113. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  75114. if (faceVertices.length === 0) {
  75115. continue;
  75116. }
  75117. // Add UVs and get back to world
  75118. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  75119. var vertex = faceVertices[vIndex];
  75120. //TODO check for Int32Array | Uint32Array | Uint16Array
  75121. vertexData.indices.push(currentVertexDataIndex);
  75122. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  75123. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  75124. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  75125. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  75126. currentVertexDataIndex++;
  75127. }
  75128. }
  75129. // Return mesh
  75130. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  75131. vertexData.applyToMesh(decal);
  75132. decal.position = position.clone();
  75133. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  75134. return decal;
  75135. };
  75136. return DecalBuilder;
  75137. }());
  75138. /***/ }),
  75139. /***/ "./Meshes/Builders/discBuilder.ts":
  75140. /*!****************************************!*\
  75141. !*** ./Meshes/Builders/discBuilder.ts ***!
  75142. \****************************************/
  75143. /*! exports provided: DiscBuilder */
  75144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75145. "use strict";
  75146. __webpack_require__.r(__webpack_exports__);
  75147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  75148. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75149. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75150. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  75151. var positions = new Array();
  75152. var indices = new Array();
  75153. var normals = new Array();
  75154. var uvs = new Array();
  75155. var radius = options.radius || 0.5;
  75156. var tessellation = options.tessellation || 64;
  75157. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75158. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  75159. // positions and uvs
  75160. positions.push(0, 0, 0); // disc center first
  75161. uvs.push(0.5, 0.5);
  75162. var theta = Math.PI * 2 * arc;
  75163. var step = theta / tessellation;
  75164. for (var a = 0; a < theta; a += step) {
  75165. var x = Math.cos(a);
  75166. var y = Math.sin(a);
  75167. var u = (x + 1) / 2;
  75168. var v = (1 - y) / 2;
  75169. positions.push(radius * x, radius * y, 0);
  75170. uvs.push(u, v);
  75171. }
  75172. if (arc === 1) {
  75173. positions.push(positions[3], positions[4], positions[5]); // close the circle
  75174. uvs.push(uvs[2], uvs[3]);
  75175. }
  75176. //indices
  75177. var vertexNb = positions.length / 3;
  75178. for (var i = 1; i < vertexNb - 1; i++) {
  75179. indices.push(i + 1, 0, i);
  75180. }
  75181. // result
  75182. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  75183. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75184. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  75185. vertexData.indices = indices;
  75186. vertexData.positions = positions;
  75187. vertexData.normals = normals;
  75188. vertexData.uvs = uvs;
  75189. return vertexData;
  75190. };
  75191. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  75192. if (scene === void 0) { scene = null; }
  75193. var options = {
  75194. radius: radius,
  75195. tessellation: tessellation,
  75196. sideOrientation: sideOrientation,
  75197. updatable: updatable
  75198. };
  75199. return DiscBuilder.CreateDisc(name, options, scene);
  75200. };
  75201. /**
  75202. * Class containing static functions to help procedurally build meshes
  75203. */
  75204. var DiscBuilder = /** @class */ (function () {
  75205. function DiscBuilder() {
  75206. }
  75207. /**
  75208. * Creates a plane polygonal mesh. By default, this is a disc
  75209. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  75210. * * 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
  75211. * * 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
  75212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75213. * * 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
  75214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75215. * @param name defines the name of the mesh
  75216. * @param options defines the options used to create the mesh
  75217. * @param scene defines the hosting scene
  75218. * @returns the plane polygonal mesh
  75219. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  75220. */
  75221. DiscBuilder.CreateDisc = function (name, options, scene) {
  75222. if (scene === void 0) { scene = null; }
  75223. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  75224. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75225. disc._originalBuilderSideOrientation = options.sideOrientation;
  75226. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  75227. vertexData.applyToMesh(disc, options.updatable);
  75228. return disc;
  75229. };
  75230. return DiscBuilder;
  75231. }());
  75232. /***/ }),
  75233. /***/ "./Meshes/Builders/groundBuilder.ts":
  75234. /*!******************************************!*\
  75235. !*** ./Meshes/Builders/groundBuilder.ts ***!
  75236. \******************************************/
  75237. /*! exports provided: GroundBuilder */
  75238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75239. "use strict";
  75240. __webpack_require__.r(__webpack_exports__);
  75241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  75242. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75243. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75244. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75245. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  75246. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  75247. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  75248. var indices = [];
  75249. var positions = [];
  75250. var normals = [];
  75251. var uvs = [];
  75252. var row, col;
  75253. var width = options.width || 1;
  75254. var height = options.height || 1;
  75255. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75256. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75257. for (row = 0; row <= subdivisionsY; row++) {
  75258. for (col = 0; col <= subdivisionsX; col++) {
  75259. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  75260. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75261. positions.push(position.x, position.y, position.z);
  75262. normals.push(normal.x, normal.y, normal.z);
  75263. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  75264. }
  75265. }
  75266. for (row = 0; row < subdivisionsY; row++) {
  75267. for (col = 0; col < subdivisionsX; col++) {
  75268. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75269. indices.push(col + 1 + row * (subdivisionsX + 1));
  75270. indices.push(col + row * (subdivisionsX + 1));
  75271. indices.push(col + (row + 1) * (subdivisionsX + 1));
  75272. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75273. indices.push(col + row * (subdivisionsX + 1));
  75274. }
  75275. }
  75276. // Result
  75277. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75278. vertexData.indices = indices;
  75279. vertexData.positions = positions;
  75280. vertexData.normals = normals;
  75281. vertexData.uvs = uvs;
  75282. return vertexData;
  75283. };
  75284. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  75285. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  75286. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  75287. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  75288. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  75289. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  75290. var precision = options.precision || { w: 1, h: 1 };
  75291. var indices = new Array();
  75292. var positions = new Array();
  75293. var normals = new Array();
  75294. var uvs = new Array();
  75295. var row, col, tileRow, tileCol;
  75296. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  75297. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  75298. precision.w = (precision.w < 1) ? 1 : precision.w;
  75299. precision.h = (precision.h < 1) ? 1 : precision.h;
  75300. var tileSize = {
  75301. 'w': (xmax - xmin) / subdivisions.w,
  75302. 'h': (zmax - zmin) / subdivisions.h
  75303. };
  75304. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  75305. // Indices
  75306. var base = positions.length / 3;
  75307. var rowLength = precision.w + 1;
  75308. for (row = 0; row < precision.h; row++) {
  75309. for (col = 0; col < precision.w; col++) {
  75310. var square = [
  75311. base + col + row * rowLength,
  75312. base + (col + 1) + row * rowLength,
  75313. base + (col + 1) + (row + 1) * rowLength,
  75314. base + col + (row + 1) * rowLength
  75315. ];
  75316. indices.push(square[1]);
  75317. indices.push(square[2]);
  75318. indices.push(square[3]);
  75319. indices.push(square[0]);
  75320. indices.push(square[1]);
  75321. indices.push(square[3]);
  75322. }
  75323. }
  75324. // Position, normals and uvs
  75325. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75326. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75327. for (row = 0; row <= precision.h; row++) {
  75328. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  75329. for (col = 0; col <= precision.w; col++) {
  75330. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  75331. position.y = 0;
  75332. positions.push(position.x, position.y, position.z);
  75333. normals.push(normal.x, normal.y, normal.z);
  75334. uvs.push(col / precision.w, row / precision.h);
  75335. }
  75336. }
  75337. }
  75338. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  75339. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  75340. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  75341. }
  75342. }
  75343. // Result
  75344. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75345. vertexData.indices = indices;
  75346. vertexData.positions = positions;
  75347. vertexData.normals = normals;
  75348. vertexData.uvs = uvs;
  75349. return vertexData;
  75350. };
  75351. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  75352. var indices = [];
  75353. var positions = [];
  75354. var normals = [];
  75355. var uvs = [];
  75356. var row, col;
  75357. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75358. var alphaFilter = options.alphaFilter || 0.0;
  75359. // Vertices
  75360. for (row = 0; row <= options.subdivisions; row++) {
  75361. for (col = 0; col <= options.subdivisions; col++) {
  75362. 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));
  75363. // Compute height
  75364. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  75365. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  75366. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  75367. var r = options.buffer[pos] / 255.0;
  75368. var g = options.buffer[pos + 1] / 255.0;
  75369. var b = options.buffer[pos + 2] / 255.0;
  75370. var a = options.buffer[pos + 3] / 255.0;
  75371. var gradient = r * filter.r + g * filter.g + b * filter.b;
  75372. // If our alpha channel is not within our filter then we will assign a 'special' height
  75373. // Then when building the indices, we will ignore any vertex that is using the special height
  75374. if (a >= alphaFilter) {
  75375. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  75376. }
  75377. else {
  75378. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  75379. }
  75380. // Add vertex
  75381. positions.push(position.x, position.y, position.z);
  75382. normals.push(0, 0, 0);
  75383. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  75384. }
  75385. }
  75386. // Indices
  75387. for (row = 0; row < options.subdivisions; row++) {
  75388. for (col = 0; col < options.subdivisions; col++) {
  75389. // Calculate Indices
  75390. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  75391. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  75392. var idx3 = (col + row * (options.subdivisions + 1));
  75393. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  75394. // Check that all indices are visible (based on our special height)
  75395. // Only display the vertex if all Indices are visible
  75396. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  75397. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  75398. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  75399. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  75400. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  75401. indices.push(idx1);
  75402. indices.push(idx2);
  75403. indices.push(idx3);
  75404. }
  75405. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  75406. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  75407. indices.push(idx4);
  75408. indices.push(idx1);
  75409. indices.push(idx3);
  75410. }
  75411. }
  75412. }
  75413. // Normals
  75414. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  75415. // Result
  75416. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75417. vertexData.indices = indices;
  75418. vertexData.positions = positions;
  75419. vertexData.normals = normals;
  75420. vertexData.uvs = uvs;
  75421. return vertexData;
  75422. };
  75423. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  75424. var options = {
  75425. width: width,
  75426. height: height,
  75427. subdivisions: subdivisions,
  75428. updatable: updatable
  75429. };
  75430. return GroundBuilder.CreateGround(name, options, scene);
  75431. };
  75432. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  75433. var options = {
  75434. xmin: xmin,
  75435. zmin: zmin,
  75436. xmax: xmax,
  75437. zmax: zmax,
  75438. subdivisions: subdivisions,
  75439. precision: precision,
  75440. updatable: updatable
  75441. };
  75442. return GroundBuilder.CreateTiledGround(name, options, scene);
  75443. };
  75444. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  75445. var options = {
  75446. width: width,
  75447. height: height,
  75448. subdivisions: subdivisions,
  75449. minHeight: minHeight,
  75450. maxHeight: maxHeight,
  75451. updatable: updatable,
  75452. onReady: onReady,
  75453. alphaFilter: alphaFilter
  75454. };
  75455. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  75456. };
  75457. /**
  75458. * Class containing static functions to help procedurally build meshes
  75459. */
  75460. var GroundBuilder = /** @class */ (function () {
  75461. function GroundBuilder() {
  75462. }
  75463. /**
  75464. * Creates a ground mesh
  75465. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  75466. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  75467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75468. * @param name defines the name of the mesh
  75469. * @param options defines the options used to create the mesh
  75470. * @param scene defines the hosting scene
  75471. * @returns the ground mesh
  75472. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  75473. */
  75474. GroundBuilder.CreateGround = function (name, options, scene) {
  75475. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75476. ground._setReady(false);
  75477. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75478. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75479. ground._width = options.width || 1;
  75480. ground._height = options.height || 1;
  75481. ground._maxX = ground._width / 2;
  75482. ground._maxZ = ground._height / 2;
  75483. ground._minX = -ground._maxX;
  75484. ground._minZ = -ground._maxZ;
  75485. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  75486. vertexData.applyToMesh(ground, options.updatable);
  75487. ground._setReady(true);
  75488. return ground;
  75489. };
  75490. /**
  75491. * Creates a tiled ground mesh
  75492. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  75493. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  75494. * * 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
  75495. * * 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
  75496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75497. * @param name defines the name of the mesh
  75498. * @param options defines the options used to create the mesh
  75499. * @param scene defines the hosting scene
  75500. * @returns the tiled ground mesh
  75501. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  75502. */
  75503. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  75504. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75505. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  75506. vertexData.applyToMesh(tiledGround, options.updatable);
  75507. return tiledGround;
  75508. };
  75509. /**
  75510. * Creates a ground mesh from a height map
  75511. * * The parameter `url` sets the URL of the height map image resource.
  75512. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  75513. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  75514. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  75515. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  75516. * * 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.
  75517. * * 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).
  75518. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75520. * @param name defines the name of the mesh
  75521. * @param url defines the url to the height map
  75522. * @param options defines the options used to create the mesh
  75523. * @param scene defines the hosting scene
  75524. * @returns the ground mesh
  75525. * @see https://doc.babylonjs.com/babylon101/height_map
  75526. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  75527. */
  75528. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  75529. var width = options.width || 10.0;
  75530. var height = options.height || 10.0;
  75531. var subdivisions = options.subdivisions || 1 | 0;
  75532. var minHeight = options.minHeight || 0.0;
  75533. var maxHeight = options.maxHeight || 1.0;
  75534. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75535. var alphaFilter = options.alphaFilter || 0.0;
  75536. var updatable = options.updatable;
  75537. var onReady = options.onReady;
  75538. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75539. ground._subdivisionsX = subdivisions;
  75540. ground._subdivisionsY = subdivisions;
  75541. ground._width = width;
  75542. ground._height = height;
  75543. ground._maxX = ground._width / 2.0;
  75544. ground._maxZ = ground._height / 2.0;
  75545. ground._minX = -ground._maxX;
  75546. ground._minZ = -ground._maxZ;
  75547. ground._setReady(false);
  75548. var onload = function (img) {
  75549. // Getting height map data
  75550. var canvas = document.createElement("canvas");
  75551. var context = canvas.getContext("2d");
  75552. if (!context) {
  75553. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  75554. }
  75555. if (scene.isDisposed) {
  75556. return;
  75557. }
  75558. var bufferWidth = img.width;
  75559. var bufferHeight = img.height;
  75560. canvas.width = bufferWidth;
  75561. canvas.height = bufferHeight;
  75562. context.drawImage(img, 0, 0);
  75563. // Create VertexData from map data
  75564. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  75565. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  75566. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  75567. width: width, height: height,
  75568. subdivisions: subdivisions,
  75569. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  75570. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  75571. alphaFilter: alphaFilter
  75572. });
  75573. vertexData.applyToMesh(ground, updatable);
  75574. //execute ready callback, if set
  75575. if (onReady) {
  75576. onReady(ground);
  75577. }
  75578. ground._setReady(true);
  75579. };
  75580. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  75581. return ground;
  75582. };
  75583. return GroundBuilder;
  75584. }());
  75585. /***/ }),
  75586. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  75587. /*!*********************************************!*\
  75588. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  75589. \*********************************************/
  75590. /*! exports provided: IcoSphereBuilder */
  75591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75592. "use strict";
  75593. __webpack_require__.r(__webpack_exports__);
  75594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  75595. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75596. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75597. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75598. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  75599. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75600. var radius = options.radius || 1;
  75601. var flat = (options.flat === undefined) ? true : options.flat;
  75602. var subdivisions = options.subdivisions || 4;
  75603. var radiusX = options.radiusX || radius;
  75604. var radiusY = options.radiusY || radius;
  75605. var radiusZ = options.radiusZ || radius;
  75606. var t = (1 + Math.sqrt(5)) / 2;
  75607. // 12 vertex x,y,z
  75608. var ico_vertices = [
  75609. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  75610. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  75611. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  75612. ];
  75613. // index of 3 vertex makes a face of icopshere
  75614. var ico_indices = [
  75615. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  75616. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  75617. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  75618. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  75619. ];
  75620. // vertex for uv have aliased position, not for UV
  75621. var vertices_unalias_id = [
  75622. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  75623. // vertex alias
  75624. 0,
  75625. 2,
  75626. 3,
  75627. 3,
  75628. 3,
  75629. 4,
  75630. 7,
  75631. 8,
  75632. 9,
  75633. 9,
  75634. 10,
  75635. 11 // 23: B + 12
  75636. ];
  75637. // uv as integer step (not pixels !)
  75638. var ico_vertexuv = [
  75639. 5, 1, 3, 1, 6, 4, 0, 0,
  75640. 5, 3, 4, 2, 2, 2, 4, 0,
  75641. 2, 0, 1, 1, 6, 0, 6, 2,
  75642. // vertex alias (for same vertex on different faces)
  75643. 0, 4,
  75644. 3, 3,
  75645. 4, 4,
  75646. 3, 1,
  75647. 4, 2,
  75648. 4, 4,
  75649. 0, 2,
  75650. 1, 1,
  75651. 2, 2,
  75652. 3, 3,
  75653. 1, 3,
  75654. 2, 4 // 23: B + 12
  75655. ];
  75656. // Vertices[0, 1, ...9, A, B] : position on UV plane
  75657. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  75658. // First island of uv mapping
  75659. // v = 4h 3+ 2
  75660. // v = 3h 9+ 4
  75661. // v = 2h 9+ 5 B
  75662. // v = 1h 9 1 0
  75663. // v = 0h 3 8 7 A
  75664. // u = 0 1 2 3 4 5 6 *a
  75665. // Second island of uv mapping
  75666. // v = 4h 0+ B+ 4+
  75667. // v = 3h A+ 2+
  75668. // v = 2h 7+ 6 3+
  75669. // v = 1h 8+ 3+
  75670. // v = 0h
  75671. // u = 0 1 2 3 4 5 6 *a
  75672. // Face layout on texture UV mapping
  75673. // ============
  75674. // \ 4 /\ 16 / ======
  75675. // \ / \ / /\ 11 /
  75676. // \/ 7 \/ / \ /
  75677. // ======= / 10 \/
  75678. // /\ 17 /\ =======
  75679. // / \ / \ \ 15 /\
  75680. // / 8 \/ 12 \ \ / \
  75681. // ============ \/ 6 \
  75682. // \ 18 /\ ============
  75683. // \ / \ \ 5 /\ 0 /
  75684. // \/ 13 \ \ / \ /
  75685. // ======= \/ 1 \/
  75686. // =============
  75687. // /\ 19 /\ 2 /\
  75688. // / \ / \ / \
  75689. // / 14 \/ 9 \/ 3 \
  75690. // ===================
  75691. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  75692. var ustep = 138 / 1024;
  75693. var vstep = 239 / 1024;
  75694. var uoffset = 60 / 1024;
  75695. var voffset = 26 / 1024;
  75696. // Second island should have margin, not to touch the first island
  75697. // avoid any borderline artefact in pixel rounding
  75698. var island_u_offset = -40 / 1024;
  75699. var island_v_offset = +20 / 1024;
  75700. // face is either island 0 or 1 :
  75701. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  75702. var island = [
  75703. 0, 0, 0, 0, 1,
  75704. 0, 0, 1, 1, 0,
  75705. 0, 0, 1, 1, 0,
  75706. 0, 1, 1, 1, 0 // 15 - 19
  75707. ];
  75708. var indices = new Array();
  75709. var positions = new Array();
  75710. var normals = new Array();
  75711. var uvs = new Array();
  75712. var current_indice = 0;
  75713. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  75714. var face_vertex_pos = new Array(3);
  75715. var face_vertex_uv = new Array(3);
  75716. var v012;
  75717. for (v012 = 0; v012 < 3; v012++) {
  75718. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75719. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  75720. }
  75721. // create all with normals
  75722. for (var face = 0; face < 20; face++) {
  75723. // 3 vertex per face
  75724. for (v012 = 0; v012 < 3; v012++) {
  75725. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  75726. var v_id = ico_indices[3 * face + v012];
  75727. // vertex have 3D position (x,y,z)
  75728. 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]);
  75729. // Normalize to get normal, then scale to radius
  75730. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  75731. // uv Coordinates from vertex ID
  75732. 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);
  75733. }
  75734. // Subdivide the face (interpolate pos, norm, uv)
  75735. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  75736. // - norm is linear interpolation of vertex corner normal
  75737. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  75738. // - uv is linear interpolation
  75739. //
  75740. // Topology is as below for sub-divide by 2
  75741. // vertex shown as v0,v1,v2
  75742. // interp index is i1 to progress in range [v0,v1[
  75743. // interp index is i2 to progress in range [v0,v2[
  75744. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  75745. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  75746. //
  75747. //
  75748. // i2 v2
  75749. // ^ ^
  75750. // / / \
  75751. // / / \
  75752. // / / \
  75753. // / / (0,1) \
  75754. // / #---------\
  75755. // / / \ (0,0)'/ \
  75756. // / / \ / \
  75757. // / / \ / \
  75758. // / / (0,0) \ / (1,0) \
  75759. // / #---------#---------\
  75760. // v0 v1
  75761. //
  75762. // --------------------> i1
  75763. //
  75764. // interp of (i1,i2):
  75765. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  75766. // along i1 : lerp(x0,x1, i1/(S-i2))
  75767. //
  75768. // centroid of triangle is needed to get help normal computation
  75769. // (c1,c2) are used for centroid location
  75770. var interp_vertex = function (i1, i2, c1, c2) {
  75771. // vertex is interpolated from
  75772. // - face_vertex_pos[0..2]
  75773. // - face_vertex_uv[0..2]
  75774. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  75775. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  75776. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  75777. pos_interp.normalize();
  75778. var vertex_normal;
  75779. if (flat) {
  75780. // in flat mode, recalculate normal as face centroid normal
  75781. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  75782. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  75783. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  75784. }
  75785. else {
  75786. // in smooth mode, recalculate normal from each single vertex position
  75787. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  75788. }
  75789. // Vertex normal need correction due to X,Y,Z radius scaling
  75790. vertex_normal.x /= radiusX;
  75791. vertex_normal.y /= radiusY;
  75792. vertex_normal.z /= radiusZ;
  75793. vertex_normal.normalize();
  75794. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  75795. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  75796. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  75797. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  75798. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  75799. uvs.push(uv_interp.x, uv_interp.y);
  75800. // push each vertex has member of a face
  75801. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  75802. indices.push(current_indice);
  75803. current_indice++;
  75804. };
  75805. for (var i2 = 0; i2 < subdivisions; i2++) {
  75806. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  75807. // face : (i1,i2) for /\ :
  75808. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  75809. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  75810. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  75811. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  75812. if (i1 + i2 + 1 < subdivisions) {
  75813. // face : (i1,i2)' for \/ :
  75814. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  75815. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  75816. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  75817. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  75818. }
  75819. }
  75820. }
  75821. }
  75822. // Sides
  75823. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75824. // Result
  75825. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75826. vertexData.indices = indices;
  75827. vertexData.positions = positions;
  75828. vertexData.normals = normals;
  75829. vertexData.uvs = uvs;
  75830. return vertexData;
  75831. };
  75832. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  75833. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  75834. };
  75835. /**
  75836. * Class containing static functions to help procedurally build meshes
  75837. */
  75838. var IcoSphereBuilder = /** @class */ (function () {
  75839. function IcoSphereBuilder() {
  75840. }
  75841. /**
  75842. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  75843. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  75844. * * 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`)
  75845. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  75846. * * 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
  75847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75848. * * 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
  75849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75850. * @param name defines the name of the mesh
  75851. * @param options defines the options used to create the mesh
  75852. * @param scene defines the hosting scene
  75853. * @returns the icosahedron mesh
  75854. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  75855. */
  75856. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  75857. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75858. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75859. sphere._originalBuilderSideOrientation = options.sideOrientation;
  75860. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  75861. vertexData.applyToMesh(sphere, options.updatable);
  75862. return sphere;
  75863. };
  75864. return IcoSphereBuilder;
  75865. }());
  75866. /***/ }),
  75867. /***/ "./Meshes/Builders/index.ts":
  75868. /*!**********************************!*\
  75869. !*** ./Meshes/Builders/index.ts ***!
  75870. \**********************************/
  75871. /*! exports provided: BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  75872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75873. "use strict";
  75874. __webpack_require__.r(__webpack_exports__);
  75875. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  75876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  75877. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  75878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  75879. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  75880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  75881. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  75882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  75883. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  75884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  75885. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  75886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  75887. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  75888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  75889. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  75890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  75891. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  75892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  75893. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  75894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  75895. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  75896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  75897. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  75898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  75899. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  75900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  75901. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  75902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  75903. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  75904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  75905. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  75906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  75907. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  75908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  75909. /***/ }),
  75910. /***/ "./Meshes/Builders/latheBuilder.ts":
  75911. /*!*****************************************!*\
  75912. !*** ./Meshes/Builders/latheBuilder.ts ***!
  75913. \*****************************************/
  75914. /*! exports provided: LatheBuilder */
  75915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75916. "use strict";
  75917. __webpack_require__.r(__webpack_exports__);
  75918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  75919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75920. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75921. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  75922. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  75923. var options = {
  75924. shape: shape,
  75925. radius: radius,
  75926. tessellation: tessellation,
  75927. sideOrientation: sideOrientation,
  75928. updatable: updatable
  75929. };
  75930. return LatheBuilder.CreateLathe(name, options, scene);
  75931. };
  75932. /**
  75933. * Class containing static functions to help procedurally build meshes
  75934. */
  75935. var LatheBuilder = /** @class */ (function () {
  75936. function LatheBuilder() {
  75937. }
  75938. /**
  75939. * Creates lathe mesh.
  75940. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  75941. * * 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
  75942. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  75943. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  75944. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  75945. * * 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
  75946. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  75947. * * 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
  75948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75949. * * 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
  75950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  75951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75952. * @param name defines the name of the mesh
  75953. * @param options defines the options used to create the mesh
  75954. * @param scene defines the hosting scene
  75955. * @returns the lathe mesh
  75956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  75957. */
  75958. LatheBuilder.CreateLathe = function (name, options, scene) {
  75959. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  75960. var closed = (options.closed === undefined) ? true : options.closed;
  75961. var shape = options.shape;
  75962. var radius = options.radius || 1;
  75963. var tessellation = options.tessellation || 64;
  75964. var clip = options.clip || 0;
  75965. var updatable = options.updatable;
  75966. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75967. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  75968. var pi2 = Math.PI * 2;
  75969. var paths = new Array();
  75970. var invertUV = options.invertUV || false;
  75971. var i = 0;
  75972. var p = 0;
  75973. var step = pi2 / tessellation * arc;
  75974. var rotated;
  75975. var path = new Array();
  75976. for (i = 0; i <= tessellation - clip; i++) {
  75977. var path = [];
  75978. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  75979. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  75980. 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));
  75981. }
  75982. for (p = 0; p < shape.length; p++) {
  75983. 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);
  75984. path.push(rotated);
  75985. }
  75986. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  75987. 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));
  75988. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  75989. }
  75990. paths.push(path);
  75991. }
  75992. // lathe ribbon
  75993. 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);
  75994. return lathe;
  75995. };
  75996. return LatheBuilder;
  75997. }());
  75998. /***/ }),
  75999. /***/ "./Meshes/Builders/linesBuilder.ts":
  76000. /*!*****************************************!*\
  76001. !*** ./Meshes/Builders/linesBuilder.ts ***!
  76002. \*****************************************/
  76003. /*! exports provided: LinesBuilder */
  76004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76005. "use strict";
  76006. __webpack_require__.r(__webpack_exports__);
  76007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  76008. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76009. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76010. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76011. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  76012. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76013. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  76014. var indices = [];
  76015. var positions = [];
  76016. var lines = options.lines;
  76017. var colors = options.colors;
  76018. var vertexColors = [];
  76019. var idx = 0;
  76020. for (var l = 0; l < lines.length; l++) {
  76021. var points = lines[l];
  76022. for (var index = 0; index < points.length; index++) {
  76023. positions.push(points[index].x, points[index].y, points[index].z);
  76024. if (colors) {
  76025. var color = colors[l];
  76026. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  76027. }
  76028. if (index > 0) {
  76029. indices.push(idx - 1);
  76030. indices.push(idx);
  76031. }
  76032. idx++;
  76033. }
  76034. }
  76035. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76036. vertexData.indices = indices;
  76037. vertexData.positions = positions;
  76038. if (colors) {
  76039. vertexData.colors = vertexColors;
  76040. }
  76041. return vertexData;
  76042. };
  76043. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  76044. var dashSize = options.dashSize || 3;
  76045. var gapSize = options.gapSize || 1;
  76046. var dashNb = options.dashNb || 200;
  76047. var points = options.points;
  76048. var positions = new Array();
  76049. var indices = new Array();
  76050. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76051. var lg = 0;
  76052. var nb = 0;
  76053. var shft = 0;
  76054. var dashshft = 0;
  76055. var curshft = 0;
  76056. var idx = 0;
  76057. var i = 0;
  76058. for (i = 0; i < points.length - 1; i++) {
  76059. points[i + 1].subtractToRef(points[i], curvect);
  76060. lg += curvect.length();
  76061. }
  76062. shft = lg / dashNb;
  76063. dashshft = dashSize * shft / (dashSize + gapSize);
  76064. for (i = 0; i < points.length - 1; i++) {
  76065. points[i + 1].subtractToRef(points[i], curvect);
  76066. nb = Math.floor(curvect.length() / shft);
  76067. curvect.normalize();
  76068. for (var j = 0; j < nb; j++) {
  76069. curshft = shft * j;
  76070. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  76071. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  76072. indices.push(idx, idx + 1);
  76073. idx += 2;
  76074. }
  76075. }
  76076. // Result
  76077. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76078. vertexData.positions = positions;
  76079. vertexData.indices = indices;
  76080. return vertexData;
  76081. };
  76082. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  76083. if (scene === void 0) { scene = null; }
  76084. if (updatable === void 0) { updatable = false; }
  76085. if (instance === void 0) { instance = null; }
  76086. var options = {
  76087. points: points,
  76088. updatable: updatable,
  76089. instance: instance
  76090. };
  76091. return LinesBuilder.CreateLines(name, options, scene);
  76092. };
  76093. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  76094. if (scene === void 0) { scene = null; }
  76095. var options = {
  76096. points: points,
  76097. dashSize: dashSize,
  76098. gapSize: gapSize,
  76099. dashNb: dashNb,
  76100. updatable: updatable,
  76101. instance: instance
  76102. };
  76103. return LinesBuilder.CreateDashedLines(name, options, scene);
  76104. };
  76105. /**
  76106. * Class containing static functions to help procedurally build meshes
  76107. */
  76108. var LinesBuilder = /** @class */ (function () {
  76109. function LinesBuilder() {
  76110. }
  76111. /**
  76112. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  76113. * * 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
  76114. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  76115. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  76116. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  76117. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  76118. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  76119. * * 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
  76120. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  76121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  76123. * @param name defines the name of the new line system
  76124. * @param options defines the options used to create the line system
  76125. * @param scene defines the hosting scene
  76126. * @returns a new line system mesh
  76127. */
  76128. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  76129. var instance = options.instance;
  76130. var lines = options.lines;
  76131. var colors = options.colors;
  76132. if (instance) { // lines update
  76133. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76134. var vertexColor;
  76135. var lineColors;
  76136. if (colors) {
  76137. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  76138. }
  76139. var i = 0;
  76140. var c = 0;
  76141. for (var l = 0; l < lines.length; l++) {
  76142. var points = lines[l];
  76143. for (var p = 0; p < points.length; p++) {
  76144. positions[i] = points[p].x;
  76145. positions[i + 1] = points[p].y;
  76146. positions[i + 2] = points[p].z;
  76147. if (colors && vertexColor) {
  76148. lineColors = colors[l];
  76149. vertexColor[c] = lineColors[p].r;
  76150. vertexColor[c + 1] = lineColors[p].g;
  76151. vertexColor[c + 2] = lineColors[p].b;
  76152. vertexColor[c + 3] = lineColors[p].a;
  76153. c += 4;
  76154. }
  76155. i += 3;
  76156. }
  76157. }
  76158. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  76159. if (colors && vertexColor) {
  76160. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  76161. }
  76162. return instance;
  76163. }
  76164. // line system creation
  76165. var useVertexColor = (colors) ? true : false;
  76166. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  76167. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  76168. vertexData.applyToMesh(lineSystem, options.updatable);
  76169. return lineSystem;
  76170. };
  76171. /**
  76172. * Creates a line mesh
  76173. * 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
  76174. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76175. * * The parameter `points` is an array successive Vector3
  76176. * * 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
  76177. * * The optional parameter `colors` is an array of successive Color4, one per line point
  76178. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  76179. * * When updating an instance, remember that only point positions can change, not the number of points
  76180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  76182. * @param name defines the name of the new line system
  76183. * @param options defines the options used to create the line system
  76184. * @param scene defines the hosting scene
  76185. * @returns a new line mesh
  76186. */
  76187. LinesBuilder.CreateLines = function (name, options, scene) {
  76188. if (scene === void 0) { scene = null; }
  76189. var colors = (options.colors) ? [options.colors] : null;
  76190. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  76191. return lines;
  76192. };
  76193. /**
  76194. * Creates a dashed line mesh
  76195. * * 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
  76196. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76197. * * The parameter `points` is an array successive Vector3
  76198. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  76199. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  76200. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76201. * * 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
  76202. * * When updating an instance, remember that only point positions can change, not the number of points
  76203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76204. * @param name defines the name of the mesh
  76205. * @param options defines the options used to create the mesh
  76206. * @param scene defines the hosting scene
  76207. * @returns the dashed line mesh
  76208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  76209. */
  76210. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  76211. if (scene === void 0) { scene = null; }
  76212. var points = options.points;
  76213. var instance = options.instance;
  76214. var gapSize = options.gapSize || 1;
  76215. var dashSize = options.dashSize || 3;
  76216. if (instance) { // dashed lines update
  76217. var positionFunction = function (positions) {
  76218. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76219. var nbSeg = positions.length / 6;
  76220. var lg = 0;
  76221. var nb = 0;
  76222. var shft = 0;
  76223. var dashshft = 0;
  76224. var curshft = 0;
  76225. var p = 0;
  76226. var i = 0;
  76227. var j = 0;
  76228. for (i = 0; i < points.length - 1; i++) {
  76229. points[i + 1].subtractToRef(points[i], curvect);
  76230. lg += curvect.length();
  76231. }
  76232. shft = lg / nbSeg;
  76233. var dashSize = instance._creationDataStorage.dashSize;
  76234. var gapSize = instance._creationDataStorage.gapSize;
  76235. dashshft = dashSize * shft / (dashSize + gapSize);
  76236. for (i = 0; i < points.length - 1; i++) {
  76237. points[i + 1].subtractToRef(points[i], curvect);
  76238. nb = Math.floor(curvect.length() / shft);
  76239. curvect.normalize();
  76240. j = 0;
  76241. while (j < nb && p < positions.length) {
  76242. curshft = shft * j;
  76243. positions[p] = points[i].x + curshft * curvect.x;
  76244. positions[p + 1] = points[i].y + curshft * curvect.y;
  76245. positions[p + 2] = points[i].z + curshft * curvect.z;
  76246. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  76247. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  76248. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  76249. p += 6;
  76250. j++;
  76251. }
  76252. }
  76253. while (p < positions.length) {
  76254. positions[p] = points[i].x;
  76255. positions[p + 1] = points[i].y;
  76256. positions[p + 2] = points[i].z;
  76257. p += 3;
  76258. }
  76259. };
  76260. instance.updateMeshPositions(positionFunction, false);
  76261. return instance;
  76262. }
  76263. // dashed lines creation
  76264. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  76265. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  76266. vertexData.applyToMesh(dashedLines, options.updatable);
  76267. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  76268. dashedLines._creationDataStorage.dashSize = dashSize;
  76269. dashedLines._creationDataStorage.gapSize = gapSize;
  76270. return dashedLines;
  76271. };
  76272. return LinesBuilder;
  76273. }());
  76274. /***/ }),
  76275. /***/ "./Meshes/Builders/planeBuilder.ts":
  76276. /*!*****************************************!*\
  76277. !*** ./Meshes/Builders/planeBuilder.ts ***!
  76278. \*****************************************/
  76279. /*! exports provided: PlaneBuilder */
  76280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76281. "use strict";
  76282. __webpack_require__.r(__webpack_exports__);
  76283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  76284. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76285. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76286. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  76287. var indices = [];
  76288. var positions = [];
  76289. var normals = [];
  76290. var uvs = [];
  76291. var width = options.width || options.size || 1;
  76292. var height = options.height || options.size || 1;
  76293. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  76294. // Vertices
  76295. var halfWidth = width / 2.0;
  76296. var halfHeight = height / 2.0;
  76297. positions.push(-halfWidth, -halfHeight, 0);
  76298. normals.push(0, 0, -1.0);
  76299. uvs.push(0.0, 0.0);
  76300. positions.push(halfWidth, -halfHeight, 0);
  76301. normals.push(0, 0, -1.0);
  76302. uvs.push(1.0, 0.0);
  76303. positions.push(halfWidth, halfHeight, 0);
  76304. normals.push(0, 0, -1.0);
  76305. uvs.push(1.0, 1.0);
  76306. positions.push(-halfWidth, halfHeight, 0);
  76307. normals.push(0, 0, -1.0);
  76308. uvs.push(0.0, 1.0);
  76309. // Indices
  76310. indices.push(0);
  76311. indices.push(1);
  76312. indices.push(2);
  76313. indices.push(0);
  76314. indices.push(2);
  76315. indices.push(3);
  76316. // Sides
  76317. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76318. // Result
  76319. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  76320. vertexData.indices = indices;
  76321. vertexData.positions = positions;
  76322. vertexData.normals = normals;
  76323. vertexData.uvs = uvs;
  76324. return vertexData;
  76325. };
  76326. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  76327. var options = {
  76328. size: size,
  76329. width: size,
  76330. height: size,
  76331. sideOrientation: sideOrientation,
  76332. updatable: updatable
  76333. };
  76334. return PlaneBuilder.CreatePlane(name, options, scene);
  76335. };
  76336. /**
  76337. * Class containing static functions to help procedurally build meshes
  76338. */
  76339. var PlaneBuilder = /** @class */ (function () {
  76340. function PlaneBuilder() {
  76341. }
  76342. /**
  76343. * Creates a plane mesh
  76344. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  76345. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  76346. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  76347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76348. * * 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
  76349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76350. * @param name defines the name of the mesh
  76351. * @param options defines the options used to create the mesh
  76352. * @param scene defines the hosting scene
  76353. * @returns the plane mesh
  76354. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  76355. */
  76356. PlaneBuilder.CreatePlane = function (name, options, scene) {
  76357. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  76358. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76359. plane._originalBuilderSideOrientation = options.sideOrientation;
  76360. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  76361. vertexData.applyToMesh(plane, options.updatable);
  76362. if (options.sourcePlane) {
  76363. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  76364. plane.setDirection(options.sourcePlane.normal.scale(-1));
  76365. }
  76366. return plane;
  76367. };
  76368. return PlaneBuilder;
  76369. }());
  76370. /***/ }),
  76371. /***/ "./Meshes/Builders/polygonBuilder.ts":
  76372. /*!*******************************************!*\
  76373. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  76374. \*******************************************/
  76375. /*! exports provided: PolygonBuilder */
  76376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76377. "use strict";
  76378. __webpack_require__.r(__webpack_exports__);
  76379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  76380. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76381. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76382. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76383. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  76384. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76385. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  76386. var faceUV = fUV || new Array(3);
  76387. var faceColors = fColors;
  76388. var colors = [];
  76389. // default face colors and UV if undefined
  76390. for (var f = 0; f < 3; f++) {
  76391. if (faceUV[f] === undefined) {
  76392. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76393. }
  76394. if (faceColors && faceColors[f] === undefined) {
  76395. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76396. }
  76397. }
  76398. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76399. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  76400. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  76401. var indices = polygon.getIndices();
  76402. // set face colours and textures
  76403. var idx = 0;
  76404. var face = 0;
  76405. for (var index = 0; index < normals.length; index += 3) {
  76406. //Edge Face no. 1
  76407. if (Math.abs(normals[index + 1]) < 0.001) {
  76408. face = 1;
  76409. }
  76410. //Top Face no. 0
  76411. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  76412. face = 0;
  76413. }
  76414. //Bottom Face no. 2
  76415. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  76416. face = 2;
  76417. }
  76418. idx = index / 3;
  76419. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  76420. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  76421. if (faceColors) {
  76422. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  76423. }
  76424. }
  76425. // sides
  76426. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  76427. // Result
  76428. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76429. vertexData.indices = indices;
  76430. vertexData.positions = positions;
  76431. vertexData.normals = normals;
  76432. vertexData.uvs = uvs;
  76433. if (faceColors) {
  76434. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76435. vertexData.colors = totalColors;
  76436. }
  76437. return vertexData;
  76438. };
  76439. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  76440. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76441. var options = {
  76442. shape: shape,
  76443. holes: holes,
  76444. updatable: updatable,
  76445. sideOrientation: sideOrientation
  76446. };
  76447. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76448. };
  76449. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  76450. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76451. var options = {
  76452. shape: shape,
  76453. holes: holes,
  76454. depth: depth,
  76455. updatable: updatable,
  76456. sideOrientation: sideOrientation
  76457. };
  76458. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  76459. };
  76460. /**
  76461. * Class containing static functions to help procedurally build meshes
  76462. */
  76463. var PolygonBuilder = /** @class */ (function () {
  76464. function PolygonBuilder() {
  76465. }
  76466. /**
  76467. * Creates a polygon mesh
  76468. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  76469. * * 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
  76470. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76472. * * 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)
  76473. * * Remember you can only change the shape positions, not their number when updating a polygon
  76474. * @param name defines the name of the mesh
  76475. * @param options defines the options used to create the mesh
  76476. * @param scene defines the hosting scene
  76477. * @param earcutInjection can be used to inject your own earcut reference
  76478. * @returns the polygon mesh
  76479. */
  76480. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  76481. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76482. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76483. var shape = options.shape;
  76484. var holes = options.holes || [];
  76485. var depth = options.depth || 0;
  76486. var contours = [];
  76487. var hole = [];
  76488. for (var i = 0; i < shape.length; i++) {
  76489. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  76490. }
  76491. var epsilon = 0.00000001;
  76492. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  76493. contours.pop();
  76494. }
  76495. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  76496. for (var hNb = 0; hNb < holes.length; hNb++) {
  76497. hole = [];
  76498. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  76499. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  76500. }
  76501. polygonTriangulation.addHole(hole);
  76502. }
  76503. var polygon = polygonTriangulation.build(options.updatable, depth);
  76504. polygon._originalBuilderSideOrientation = options.sideOrientation;
  76505. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  76506. vertexData.applyToMesh(polygon, options.updatable);
  76507. return polygon;
  76508. };
  76509. /**
  76510. * Creates an extruded polygon mesh, with depth in the Y direction.
  76511. * * 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)
  76512. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76513. * @param name defines the name of the mesh
  76514. * @param options defines the options used to create the mesh
  76515. * @param scene defines the hosting scene
  76516. * @param earcutInjection can be used to inject your own earcut reference
  76517. * @returns the polygon mesh
  76518. */
  76519. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  76520. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76521. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76522. };
  76523. return PolygonBuilder;
  76524. }());
  76525. /***/ }),
  76526. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  76527. /*!**********************************************!*\
  76528. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  76529. \**********************************************/
  76530. /*! exports provided: PolyhedronBuilder */
  76531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76532. "use strict";
  76533. __webpack_require__.r(__webpack_exports__);
  76534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  76535. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76536. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76537. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76538. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  76539. // provided polyhedron types :
  76540. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  76541. // 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)
  76542. var polyhedra = [];
  76543. 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]] };
  76544. 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]] };
  76545. polyhedra[2] = {
  76546. 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]],
  76547. 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]]
  76548. };
  76549. polyhedra[3] = {
  76550. 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]],
  76551. 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]]
  76552. };
  76553. polyhedra[4] = {
  76554. 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]],
  76555. 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]]
  76556. };
  76557. 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]] };
  76558. 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]] };
  76559. 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]] };
  76560. 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]] };
  76561. 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]] };
  76562. 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]] };
  76563. 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]] };
  76564. 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]] };
  76565. 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]] };
  76566. polyhedra[14] = {
  76567. 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]],
  76568. 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]]
  76569. };
  76570. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  76571. var size = options.size;
  76572. var sizeX = options.sizeX || size || 1;
  76573. var sizeY = options.sizeY || size || 1;
  76574. var sizeZ = options.sizeZ || size || 1;
  76575. var data = options.custom || polyhedra[type];
  76576. var nbfaces = data.face.length;
  76577. var faceUV = options.faceUV || new Array(nbfaces);
  76578. var faceColors = options.faceColors;
  76579. var flat = (options.flat === undefined) ? true : options.flat;
  76580. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76581. var positions = new Array();
  76582. var indices = new Array();
  76583. var normals = new Array();
  76584. var uvs = new Array();
  76585. var colors = new Array();
  76586. var index = 0;
  76587. var faceIdx = 0; // face cursor in the array "indexes"
  76588. var indexes = new Array();
  76589. var i = 0;
  76590. var f = 0;
  76591. var u, v, ang, x, y, tmp;
  76592. // default face colors and UV if undefined
  76593. if (flat) {
  76594. for (f = 0; f < nbfaces; f++) {
  76595. if (faceColors && faceColors[f] === undefined) {
  76596. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76597. }
  76598. if (faceUV && faceUV[f] === undefined) {
  76599. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76600. }
  76601. }
  76602. }
  76603. if (!flat) {
  76604. for (i = 0; i < data.vertex.length; i++) {
  76605. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  76606. uvs.push(0, 0);
  76607. }
  76608. for (f = 0; f < nbfaces; f++) {
  76609. for (i = 0; i < data.face[f].length - 2; i++) {
  76610. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  76611. }
  76612. }
  76613. }
  76614. else {
  76615. for (f = 0; f < nbfaces; f++) {
  76616. var fl = data.face[f].length; // number of vertices of the current face
  76617. ang = 2 * Math.PI / fl;
  76618. x = 0.5 * Math.tan(ang / 2);
  76619. y = 0.5;
  76620. // positions, uvs, colors
  76621. for (i = 0; i < fl; i++) {
  76622. // positions
  76623. 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);
  76624. indexes.push(index);
  76625. index++;
  76626. // uvs
  76627. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  76628. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  76629. uvs.push(u, v);
  76630. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  76631. y = x * Math.sin(ang) + y * Math.cos(ang);
  76632. x = tmp;
  76633. // colors
  76634. if (faceColors) {
  76635. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  76636. }
  76637. }
  76638. // indices from indexes
  76639. for (i = 0; i < fl - 2; i++) {
  76640. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  76641. }
  76642. faceIdx += fl;
  76643. }
  76644. }
  76645. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  76646. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76647. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76648. vertexData.positions = positions;
  76649. vertexData.indices = indices;
  76650. vertexData.normals = normals;
  76651. vertexData.uvs = uvs;
  76652. if (faceColors && flat) {
  76653. vertexData.colors = colors;
  76654. }
  76655. return vertexData;
  76656. };
  76657. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  76658. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  76659. };
  76660. /**
  76661. * Class containing static functions to help procedurally build meshes
  76662. */
  76663. var PolyhedronBuilder = /** @class */ (function () {
  76664. function PolyhedronBuilder() {
  76665. }
  76666. /**
  76667. * Creates a polyhedron mesh
  76668. * * 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
  76669. * * The parameter `size` (positive float, default 1) sets the polygon size
  76670. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76671. * * 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`
  76672. * * 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
  76673. * * 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)`)
  76674. * * 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
  76675. * * 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
  76676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76677. * * 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
  76678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76679. * @param name defines the name of the mesh
  76680. * @param options defines the options used to create the mesh
  76681. * @param scene defines the hosting scene
  76682. * @returns the polyhedron mesh
  76683. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  76684. */
  76685. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  76686. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76687. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76688. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  76689. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  76690. vertexData.applyToMesh(polyhedron, options.updatable);
  76691. return polyhedron;
  76692. };
  76693. return PolyhedronBuilder;
  76694. }());
  76695. /***/ }),
  76696. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  76697. /*!******************************************!*\
  76698. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  76699. \******************************************/
  76700. /*! exports provided: RibbonBuilder */
  76701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76702. "use strict";
  76703. __webpack_require__.r(__webpack_exports__);
  76704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  76705. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76706. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76707. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  76708. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76709. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  76710. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  76711. var pathArray = options.pathArray;
  76712. var closeArray = options.closeArray || false;
  76713. var closePath = options.closePath || false;
  76714. var invertUV = options.invertUV || false;
  76715. var defaultOffset = Math.floor(pathArray[0].length / 2);
  76716. var offset = options.offset || defaultOffset;
  76717. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  76718. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  76719. var customUV = options.uvs;
  76720. var customColors = options.colors;
  76721. var positions = [];
  76722. var indices = [];
  76723. var normals = [];
  76724. var uvs = [];
  76725. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  76726. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  76727. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  76728. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  76729. var minlg; // minimal length among all paths from pathArray
  76730. var lg = []; // array of path lengths : nb of vertex per path
  76731. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  76732. var p; // path iterator
  76733. var i; // point iterator
  76734. var j; // point iterator
  76735. // if single path in pathArray
  76736. if (pathArray.length < 2) {
  76737. var ar1 = [];
  76738. var ar2 = [];
  76739. for (i = 0; i < pathArray[0].length - offset; i++) {
  76740. ar1.push(pathArray[0][i]);
  76741. ar2.push(pathArray[0][i + offset]);
  76742. }
  76743. pathArray = [ar1, ar2];
  76744. }
  76745. // positions and horizontal distances (u)
  76746. var idc = 0;
  76747. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  76748. var path;
  76749. var l;
  76750. minlg = pathArray[0].length;
  76751. var vectlg;
  76752. var dist;
  76753. for (p = 0; p < pathArray.length; p++) {
  76754. uTotalDistance[p] = 0;
  76755. us[p] = [0];
  76756. path = pathArray[p];
  76757. l = path.length;
  76758. minlg = (minlg < l) ? minlg : l;
  76759. j = 0;
  76760. while (j < l) {
  76761. positions.push(path[j].x, path[j].y, path[j].z);
  76762. if (j > 0) {
  76763. vectlg = path[j].subtract(path[j - 1]).length();
  76764. dist = vectlg + uTotalDistance[p];
  76765. us[p].push(dist);
  76766. uTotalDistance[p] = dist;
  76767. }
  76768. j++;
  76769. }
  76770. if (closePath) { // an extra hidden vertex is added in the "positions" array
  76771. j--;
  76772. positions.push(path[0].x, path[0].y, path[0].z);
  76773. vectlg = path[j].subtract(path[0]).length();
  76774. dist = vectlg + uTotalDistance[p];
  76775. us[p].push(dist);
  76776. uTotalDistance[p] = dist;
  76777. }
  76778. lg[p] = l + closePathCorr;
  76779. idx[p] = idc;
  76780. idc += (l + closePathCorr);
  76781. }
  76782. // vertical distances (v)
  76783. var path1;
  76784. var path2;
  76785. var vertex1 = null;
  76786. var vertex2 = null;
  76787. for (i = 0; i < minlg + closePathCorr; i++) {
  76788. vTotalDistance[i] = 0;
  76789. vs[i] = [0];
  76790. for (p = 0; p < pathArray.length - 1; p++) {
  76791. path1 = pathArray[p];
  76792. path2 = pathArray[p + 1];
  76793. if (i === minlg) { // closePath
  76794. vertex1 = path1[0];
  76795. vertex2 = path2[0];
  76796. }
  76797. else {
  76798. vertex1 = path1[i];
  76799. vertex2 = path2[i];
  76800. }
  76801. vectlg = vertex2.subtract(vertex1).length();
  76802. dist = vectlg + vTotalDistance[i];
  76803. vs[i].push(dist);
  76804. vTotalDistance[i] = dist;
  76805. }
  76806. if (closeArray && vertex2 && vertex1) {
  76807. path1 = pathArray[p];
  76808. path2 = pathArray[0];
  76809. if (i === minlg) { // closePath
  76810. vertex2 = path2[0];
  76811. }
  76812. vectlg = vertex2.subtract(vertex1).length();
  76813. dist = vectlg + vTotalDistance[i];
  76814. vTotalDistance[i] = dist;
  76815. }
  76816. }
  76817. // uvs
  76818. var u;
  76819. var v;
  76820. if (customUV) {
  76821. for (p = 0; p < customUV.length; p++) {
  76822. uvs.push(customUV[p].x, customUV[p].y);
  76823. }
  76824. }
  76825. else {
  76826. for (p = 0; p < pathArray.length; p++) {
  76827. for (i = 0; i < minlg + closePathCorr; i++) {
  76828. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  76829. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  76830. if (invertUV) {
  76831. uvs.push(v, u);
  76832. }
  76833. else {
  76834. uvs.push(u, v);
  76835. }
  76836. }
  76837. }
  76838. }
  76839. // indices
  76840. p = 0; // path index
  76841. var pi = 0; // positions array index
  76842. var l1 = lg[p] - 1; // path1 length
  76843. var l2 = lg[p + 1] - 1; // path2 length
  76844. var min = (l1 < l2) ? l1 : l2; // current path stop index
  76845. var shft = idx[1] - idx[0]; // shift
  76846. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  76847. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  76848. // 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
  76849. indices.push(pi, pi + shft, pi + 1);
  76850. indices.push(pi + shft + 1, pi + 1, pi + shft);
  76851. pi += 1;
  76852. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  76853. p++;
  76854. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  76855. shft = idx[0] - idx[p];
  76856. l1 = lg[p] - 1;
  76857. l2 = lg[0] - 1;
  76858. }
  76859. else {
  76860. shft = idx[p + 1] - idx[p];
  76861. l1 = lg[p] - 1;
  76862. l2 = lg[p + 1] - 1;
  76863. }
  76864. pi = idx[p];
  76865. min = (l1 < l2) ? l1 + pi : l2 + pi;
  76866. }
  76867. }
  76868. // normals
  76869. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  76870. if (closePath) { // update both the first and last vertex normals to their average value
  76871. var indexFirst = 0;
  76872. var indexLast = 0;
  76873. for (p = 0; p < pathArray.length; p++) {
  76874. indexFirst = idx[p] * 3;
  76875. if (p + 1 < pathArray.length) {
  76876. indexLast = (idx[p + 1] - 1) * 3;
  76877. }
  76878. else {
  76879. indexLast = normals.length - 3;
  76880. }
  76881. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  76882. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  76883. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  76884. normals[indexLast] = normals[indexFirst];
  76885. normals[indexLast + 1] = normals[indexFirst + 1];
  76886. normals[indexLast + 2] = normals[indexFirst + 2];
  76887. }
  76888. }
  76889. // sides
  76890. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76891. // Colors
  76892. var colors = null;
  76893. if (customColors) {
  76894. colors = new Float32Array(customColors.length * 4);
  76895. for (var c = 0; c < customColors.length; c++) {
  76896. colors[c * 4] = customColors[c].r;
  76897. colors[c * 4 + 1] = customColors[c].g;
  76898. colors[c * 4 + 2] = customColors[c].b;
  76899. colors[c * 4 + 3] = customColors[c].a;
  76900. }
  76901. }
  76902. // Result
  76903. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  76904. var positions32 = new Float32Array(positions);
  76905. var normals32 = new Float32Array(normals);
  76906. var uvs32 = new Float32Array(uvs);
  76907. vertexData.indices = indices;
  76908. vertexData.positions = positions32;
  76909. vertexData.normals = normals32;
  76910. vertexData.uvs = uvs32;
  76911. if (colors) {
  76912. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  76913. }
  76914. if (closePath) {
  76915. vertexData._idx = idx;
  76916. }
  76917. return vertexData;
  76918. };
  76919. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  76920. if (closeArray === void 0) { closeArray = false; }
  76921. if (updatable === void 0) { updatable = false; }
  76922. return RibbonBuilder.CreateRibbon(name, {
  76923. pathArray: pathArray,
  76924. closeArray: closeArray,
  76925. closePath: closePath,
  76926. offset: offset,
  76927. updatable: updatable,
  76928. sideOrientation: sideOrientation,
  76929. instance: instance
  76930. }, scene);
  76931. };
  76932. /**
  76933. * Class containing static functions to help procedurally build meshes
  76934. */
  76935. var RibbonBuilder = /** @class */ (function () {
  76936. function RibbonBuilder() {
  76937. }
  76938. /**
  76939. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  76940. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  76941. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  76942. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  76943. * * 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
  76944. * * 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
  76945. * * 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
  76946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76947. * * 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
  76948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  76949. * * 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
  76950. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  76951. * * 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
  76952. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  76953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76954. * @param name defines the name of the mesh
  76955. * @param options defines the options used to create the mesh
  76956. * @param scene defines the hosting scene
  76957. * @returns the ribbon mesh
  76958. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  76959. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  76960. */
  76961. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  76962. if (scene === void 0) { scene = null; }
  76963. var pathArray = options.pathArray;
  76964. var closeArray = options.closeArray;
  76965. var closePath = options.closePath;
  76966. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76967. var instance = options.instance;
  76968. var updatable = options.updatable;
  76969. if (instance) { // existing ribbon instance update
  76970. // positionFunction : ribbon case
  76971. // only pathArray and sideOrientation parameters are taken into account for positions update
  76972. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  76973. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  76974. var positionFunction = function (positions) {
  76975. var minlg = pathArray[0].length;
  76976. var mesh = instance;
  76977. var i = 0;
  76978. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  76979. for (var si = 1; si <= ns; ++si) {
  76980. for (var p = 0; p < pathArray.length; ++p) {
  76981. var path = pathArray[p];
  76982. var l = path.length;
  76983. minlg = (minlg < l) ? minlg : l;
  76984. for (var j = 0; j < minlg; ++j) {
  76985. var pathPoint = path[j];
  76986. positions[i] = pathPoint.x;
  76987. positions[i + 1] = pathPoint.y;
  76988. positions[i + 2] = pathPoint.z;
  76989. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  76990. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  76991. i += 3;
  76992. }
  76993. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  76994. var pathPoint = path[0];
  76995. positions[i] = pathPoint.x;
  76996. positions[i + 1] = pathPoint.y;
  76997. positions[i + 2] = pathPoint.z;
  76998. i += 3;
  76999. }
  77000. }
  77001. }
  77002. };
  77003. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77004. positionFunction(positions);
  77005. if (instance._boundingInfo) {
  77006. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  77007. }
  77008. else {
  77009. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  77010. }
  77011. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  77012. if (options.colors) {
  77013. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77014. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  77015. var color = options.colors[c];
  77016. colors[colorIndex] = color.r;
  77017. colors[colorIndex + 1] = color.g;
  77018. colors[colorIndex + 2] = color.b;
  77019. colors[colorIndex + 3] = color.a;
  77020. }
  77021. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  77022. }
  77023. if (options.uvs) {
  77024. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  77025. for (var i = 0; i < options.uvs.length; i++) {
  77026. uvs[i * 2] = options.uvs[i].x;
  77027. uvs[i * 2 + 1] = options.uvs[i].y;
  77028. }
  77029. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  77030. }
  77031. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  77032. var indices = instance.getIndices();
  77033. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77034. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  77035. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  77036. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  77037. var indexFirst = 0;
  77038. var indexLast = 0;
  77039. for (var p = 0; p < pathArray.length; p++) {
  77040. indexFirst = instance._creationDataStorage.idx[p] * 3;
  77041. if (p + 1 < pathArray.length) {
  77042. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  77043. }
  77044. else {
  77045. indexLast = normals.length - 3;
  77046. }
  77047. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77048. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77049. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77050. normals[indexLast] = normals[indexFirst];
  77051. normals[indexLast + 1] = normals[indexFirst + 1];
  77052. normals[indexLast + 2] = normals[indexFirst + 2];
  77053. }
  77054. }
  77055. if (!(instance.areNormalsFrozen)) {
  77056. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  77057. }
  77058. }
  77059. return instance;
  77060. }
  77061. else { // new ribbon creation
  77062. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77063. ribbon._originalBuilderSideOrientation = sideOrientation;
  77064. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77065. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  77066. if (closePath) {
  77067. ribbon._creationDataStorage.idx = vertexData._idx;
  77068. }
  77069. ribbon._creationDataStorage.closePath = closePath;
  77070. ribbon._creationDataStorage.closeArray = closeArray;
  77071. vertexData.applyToMesh(ribbon, updatable);
  77072. return ribbon;
  77073. }
  77074. };
  77075. return RibbonBuilder;
  77076. }());
  77077. /***/ }),
  77078. /***/ "./Meshes/Builders/shapeBuilder.ts":
  77079. /*!*****************************************!*\
  77080. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  77081. \*****************************************/
  77082. /*! exports provided: ShapeBuilder */
  77083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77084. "use strict";
  77085. __webpack_require__.r(__webpack_exports__);
  77086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  77087. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77088. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77089. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77090. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  77091. if (scene === void 0) { scene = null; }
  77092. var options = {
  77093. shape: shape,
  77094. path: path,
  77095. scale: scale,
  77096. rotation: rotation,
  77097. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77098. sideOrientation: sideOrientation,
  77099. instance: instance,
  77100. updatable: updatable
  77101. };
  77102. return ShapeBuilder.ExtrudeShape(name, options, scene);
  77103. };
  77104. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  77105. var options = {
  77106. shape: shape,
  77107. path: path,
  77108. scaleFunction: scaleFunction,
  77109. rotationFunction: rotationFunction,
  77110. ribbonCloseArray: ribbonCloseArray,
  77111. ribbonClosePath: ribbonClosePath,
  77112. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77113. sideOrientation: sideOrientation,
  77114. instance: instance,
  77115. updatable: updatable
  77116. };
  77117. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  77118. };
  77119. /**
  77120. * Class containing static functions to help procedurally build meshes
  77121. */
  77122. var ShapeBuilder = /** @class */ (function () {
  77123. function ShapeBuilder() {
  77124. }
  77125. /**
  77126. * 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.
  77127. * * 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.
  77128. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77129. * * 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.
  77130. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  77131. * * 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
  77132. * * 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
  77133. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  77134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77135. * * 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
  77136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  77137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77138. * @param name defines the name of the mesh
  77139. * @param options defines the options used to create the mesh
  77140. * @param scene defines the hosting scene
  77141. * @returns the extruded shape mesh
  77142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77144. */
  77145. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  77146. if (scene === void 0) { scene = null; }
  77147. var path = options.path;
  77148. var shape = options.shape;
  77149. var scale = options.scale || 1;
  77150. var rotation = options.rotation || 0;
  77151. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77152. var updatable = options.updatable;
  77153. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77154. var instance = options.instance || null;
  77155. var invertUV = options.invertUV || false;
  77156. 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);
  77157. };
  77158. /**
  77159. * Creates an custom extruded shape mesh.
  77160. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  77161. * * 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.
  77162. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77163. * * 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
  77164. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  77165. * * 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
  77166. * * It must returns a float value that will be the scale value applied to the shape on each path point
  77167. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77168. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  77169. * * 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
  77170. * * 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
  77171. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  77172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77173. * * 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
  77174. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77176. * @param name defines the name of the mesh
  77177. * @param options defines the options used to create the mesh
  77178. * @param scene defines the hosting scene
  77179. * @returns the custom extruded shape mesh
  77180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  77181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77183. */
  77184. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  77185. var path = options.path;
  77186. var shape = options.shape;
  77187. var scaleFunction = options.scaleFunction || (function () { return 1; });
  77188. var rotationFunction = options.rotationFunction || (function () { return 0; });
  77189. var ribbonCloseArray = options.ribbonCloseArray || false;
  77190. var ribbonClosePath = options.ribbonClosePath || false;
  77191. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77192. var updatable = options.updatable;
  77193. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77194. var instance = options.instance;
  77195. var invertUV = options.invertUV || false;
  77196. 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);
  77197. };
  77198. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  77199. // extrusion geometry
  77200. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  77201. var tangents = path3D.getTangents();
  77202. var normals = path3D.getNormals();
  77203. var binormals = path3D.getBinormals();
  77204. var distances = path3D.getDistances();
  77205. var angle = 0;
  77206. var returnScale = function () { return scale !== null ? scale : 1; };
  77207. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  77208. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  77209. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  77210. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77211. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77212. for (var i = 0; i < curve.length; i++) {
  77213. var shapePath = new Array();
  77214. var angleStep = rotate(i, distances[i]);
  77215. var scaleRatio = scl(i, distances[i]);
  77216. for (var p = 0; p < shape.length; p++) {
  77217. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  77218. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  77219. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77220. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  77221. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  77222. shapePath[p] = rotated;
  77223. }
  77224. shapePaths[index] = shapePath;
  77225. angle += angleStep;
  77226. index++;
  77227. }
  77228. // cap
  77229. var capPath = function (shapePath) {
  77230. var pointCap = Array();
  77231. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77232. var i;
  77233. for (i = 0; i < shapePath.length; i++) {
  77234. barycenter.addInPlace(shapePath[i]);
  77235. }
  77236. barycenter.scaleInPlace(1.0 / shapePath.length);
  77237. for (i = 0; i < shapePath.length; i++) {
  77238. pointCap.push(barycenter);
  77239. }
  77240. return pointCap;
  77241. };
  77242. switch (cap) {
  77243. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77244. break;
  77245. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77246. shapePaths[0] = capPath(shapePaths[2]);
  77247. shapePaths[1] = shapePaths[2];
  77248. break;
  77249. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77250. shapePaths[index] = shapePaths[index - 1];
  77251. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77252. break;
  77253. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77254. shapePaths[0] = capPath(shapePaths[2]);
  77255. shapePaths[1] = shapePaths[2];
  77256. shapePaths[index] = shapePaths[index - 1];
  77257. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77258. break;
  77259. default:
  77260. break;
  77261. }
  77262. return shapePaths;
  77263. };
  77264. var path3D;
  77265. var pathArray;
  77266. if (instance) { // instance update
  77267. var storage = instance._creationDataStorage;
  77268. path3D = storage.path3D.update(curve);
  77269. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  77270. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  77271. return instance;
  77272. }
  77273. // extruded shape creation
  77274. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  77275. var newShapePaths = new Array();
  77276. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77277. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  77278. 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);
  77279. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  77280. extrudedGeneric._creationDataStorage.path3D = path3D;
  77281. extrudedGeneric._creationDataStorage.cap = cap;
  77282. return extrudedGeneric;
  77283. };
  77284. return ShapeBuilder;
  77285. }());
  77286. /***/ }),
  77287. /***/ "./Meshes/Builders/sphereBuilder.ts":
  77288. /*!******************************************!*\
  77289. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  77290. \******************************************/
  77291. /*! exports provided: SphereBuilder */
  77292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77293. "use strict";
  77294. __webpack_require__.r(__webpack_exports__);
  77295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  77296. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77297. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77298. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77299. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  77300. var segments = options.segments || 32;
  77301. var diameterX = options.diameterX || options.diameter || 1;
  77302. var diameterY = options.diameterY || options.diameter || 1;
  77303. var diameterZ = options.diameterZ || options.diameter || 1;
  77304. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77305. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  77306. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77307. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  77308. var totalZRotationSteps = 2 + segments;
  77309. var totalYRotationSteps = 2 * totalZRotationSteps;
  77310. var indices = [];
  77311. var positions = [];
  77312. var normals = [];
  77313. var uvs = [];
  77314. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  77315. var normalizedZ = zRotationStep / totalZRotationSteps;
  77316. var angleZ = normalizedZ * Math.PI * slice;
  77317. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  77318. var normalizedY = yRotationStep / totalYRotationSteps;
  77319. var angleY = normalizedY * Math.PI * 2 * arc;
  77320. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  77321. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  77322. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  77323. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  77324. var vertex = complete.multiply(radius);
  77325. var normal = complete.divide(radius).normalize();
  77326. positions.push(vertex.x, vertex.y, vertex.z);
  77327. normals.push(normal.x, normal.y, normal.z);
  77328. uvs.push(normalizedY, normalizedZ);
  77329. }
  77330. if (zRotationStep > 0) {
  77331. var verticesCount = positions.length / 3;
  77332. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  77333. indices.push((firstIndex));
  77334. indices.push((firstIndex + 1));
  77335. indices.push(firstIndex + totalYRotationSteps + 1);
  77336. indices.push((firstIndex + totalYRotationSteps + 1));
  77337. indices.push((firstIndex + 1));
  77338. indices.push((firstIndex + totalYRotationSteps + 2));
  77339. }
  77340. }
  77341. }
  77342. // Sides
  77343. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77344. // Result
  77345. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77346. vertexData.indices = indices;
  77347. vertexData.positions = positions;
  77348. vertexData.normals = normals;
  77349. vertexData.uvs = uvs;
  77350. return vertexData;
  77351. };
  77352. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  77353. var options = {
  77354. segments: segments,
  77355. diameterX: diameter,
  77356. diameterY: diameter,
  77357. diameterZ: diameter,
  77358. sideOrientation: sideOrientation,
  77359. updatable: updatable
  77360. };
  77361. return SphereBuilder.CreateSphere(name, options, scene);
  77362. };
  77363. /**
  77364. * Class containing static functions to help procedurally build meshes
  77365. */
  77366. var SphereBuilder = /** @class */ (function () {
  77367. function SphereBuilder() {
  77368. }
  77369. /**
  77370. * Creates a sphere mesh
  77371. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  77372. * * 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`)
  77373. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  77374. * * 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
  77375. * * 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)
  77376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77377. * * 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
  77378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77379. * @param name defines the name of the mesh
  77380. * @param options defines the options used to create the mesh
  77381. * @param scene defines the hosting scene
  77382. * @returns the sphere mesh
  77383. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  77384. */
  77385. SphereBuilder.CreateSphere = function (name, options, scene) {
  77386. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77387. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77388. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77389. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  77390. vertexData.applyToMesh(sphere, options.updatable);
  77391. return sphere;
  77392. };
  77393. return SphereBuilder;
  77394. }());
  77395. /***/ }),
  77396. /***/ "./Meshes/Builders/torusBuilder.ts":
  77397. /*!*****************************************!*\
  77398. !*** ./Meshes/Builders/torusBuilder.ts ***!
  77399. \*****************************************/
  77400. /*! exports provided: TorusBuilder */
  77401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77402. "use strict";
  77403. __webpack_require__.r(__webpack_exports__);
  77404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  77405. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77406. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77407. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77408. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  77409. var indices = [];
  77410. var positions = [];
  77411. var normals = [];
  77412. var uvs = [];
  77413. var diameter = options.diameter || 1;
  77414. var thickness = options.thickness || 0.5;
  77415. var tessellation = options.tessellation || 16;
  77416. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77417. var stride = tessellation + 1;
  77418. for (var i = 0; i <= tessellation; i++) {
  77419. var u = i / tessellation;
  77420. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  77421. 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));
  77422. for (var j = 0; j <= tessellation; j++) {
  77423. var v = 1 - j / tessellation;
  77424. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  77425. var dx = Math.cos(innerAngle);
  77426. var dy = Math.sin(innerAngle);
  77427. // Create a vertex.
  77428. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  77429. var position = normal.scale(thickness / 2);
  77430. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  77431. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  77432. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  77433. positions.push(position.x, position.y, position.z);
  77434. normals.push(normal.x, normal.y, normal.z);
  77435. uvs.push(textureCoordinate.x, textureCoordinate.y);
  77436. // And create indices for two triangles.
  77437. var nextI = (i + 1) % stride;
  77438. var nextJ = (j + 1) % stride;
  77439. indices.push(i * stride + j);
  77440. indices.push(i * stride + nextJ);
  77441. indices.push(nextI * stride + j);
  77442. indices.push(i * stride + nextJ);
  77443. indices.push(nextI * stride + nextJ);
  77444. indices.push(nextI * stride + j);
  77445. }
  77446. }
  77447. // Sides
  77448. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77449. // Result
  77450. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77451. vertexData.indices = indices;
  77452. vertexData.positions = positions;
  77453. vertexData.normals = normals;
  77454. vertexData.uvs = uvs;
  77455. return vertexData;
  77456. };
  77457. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  77458. var options = {
  77459. diameter: diameter,
  77460. thickness: thickness,
  77461. tessellation: tessellation,
  77462. sideOrientation: sideOrientation,
  77463. updatable: updatable
  77464. };
  77465. return TorusBuilder.CreateTorus(name, options, scene);
  77466. };
  77467. /**
  77468. * Class containing static functions to help procedurally build meshes
  77469. */
  77470. var TorusBuilder = /** @class */ (function () {
  77471. function TorusBuilder() {
  77472. }
  77473. /**
  77474. * Creates a torus mesh
  77475. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  77476. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  77477. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  77478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77479. * * 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
  77480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77481. * @param name defines the name of the mesh
  77482. * @param options defines the options used to create the mesh
  77483. * @param scene defines the hosting scene
  77484. * @returns the torus mesh
  77485. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  77486. */
  77487. TorusBuilder.CreateTorus = function (name, options, scene) {
  77488. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77489. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77490. torus._originalBuilderSideOrientation = options.sideOrientation;
  77491. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  77492. vertexData.applyToMesh(torus, options.updatable);
  77493. return torus;
  77494. };
  77495. return TorusBuilder;
  77496. }());
  77497. /***/ }),
  77498. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  77499. /*!*********************************************!*\
  77500. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  77501. \*********************************************/
  77502. /*! exports provided: TorusKnotBuilder */
  77503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77504. "use strict";
  77505. __webpack_require__.r(__webpack_exports__);
  77506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  77507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77508. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77509. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77510. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  77511. var indices = new Array();
  77512. var positions = new Array();
  77513. var normals = new Array();
  77514. var uvs = new Array();
  77515. var radius = options.radius || 2;
  77516. var tube = options.tube || 0.5;
  77517. var radialSegments = options.radialSegments || 32;
  77518. var tubularSegments = options.tubularSegments || 32;
  77519. var p = options.p || 2;
  77520. var q = options.q || 3;
  77521. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77522. // Helper
  77523. var getPos = function (angle) {
  77524. var cu = Math.cos(angle);
  77525. var su = Math.sin(angle);
  77526. var quOverP = q / p * angle;
  77527. var cs = Math.cos(quOverP);
  77528. var tx = radius * (2 + cs) * 0.5 * cu;
  77529. var ty = radius * (2 + cs) * su * 0.5;
  77530. var tz = radius * Math.sin(quOverP) * 0.5;
  77531. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  77532. };
  77533. // Vertices
  77534. var i;
  77535. var j;
  77536. for (i = 0; i <= radialSegments; i++) {
  77537. var modI = i % radialSegments;
  77538. var u = modI / radialSegments * 2 * p * Math.PI;
  77539. var p1 = getPos(u);
  77540. var p2 = getPos(u + 0.01);
  77541. var tang = p2.subtract(p1);
  77542. var n = p2.add(p1);
  77543. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  77544. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  77545. bitan.normalize();
  77546. n.normalize();
  77547. for (j = 0; j < tubularSegments; j++) {
  77548. var modJ = j % tubularSegments;
  77549. var v = modJ / tubularSegments * 2 * Math.PI;
  77550. var cx = -tube * Math.cos(v);
  77551. var cy = tube * Math.sin(v);
  77552. positions.push(p1.x + cx * n.x + cy * bitan.x);
  77553. positions.push(p1.y + cx * n.y + cy * bitan.y);
  77554. positions.push(p1.z + cx * n.z + cy * bitan.z);
  77555. uvs.push(i / radialSegments);
  77556. uvs.push(j / tubularSegments);
  77557. }
  77558. }
  77559. for (i = 0; i < radialSegments; i++) {
  77560. for (j = 0; j < tubularSegments; j++) {
  77561. var jNext = (j + 1) % tubularSegments;
  77562. var a = i * tubularSegments + j;
  77563. var b = (i + 1) * tubularSegments + j;
  77564. var c = (i + 1) * tubularSegments + jNext;
  77565. var d = i * tubularSegments + jNext;
  77566. indices.push(d);
  77567. indices.push(b);
  77568. indices.push(a);
  77569. indices.push(d);
  77570. indices.push(c);
  77571. indices.push(b);
  77572. }
  77573. }
  77574. // Normals
  77575. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77576. // Sides
  77577. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77578. // Result
  77579. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77580. vertexData.indices = indices;
  77581. vertexData.positions = positions;
  77582. vertexData.normals = normals;
  77583. vertexData.uvs = uvs;
  77584. return vertexData;
  77585. };
  77586. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  77587. var options = {
  77588. radius: radius,
  77589. tube: tube,
  77590. radialSegments: radialSegments,
  77591. tubularSegments: tubularSegments,
  77592. p: p,
  77593. q: q,
  77594. sideOrientation: sideOrientation,
  77595. updatable: updatable
  77596. };
  77597. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  77598. };
  77599. /**
  77600. * Class containing static functions to help procedurally build meshes
  77601. */
  77602. var TorusKnotBuilder = /** @class */ (function () {
  77603. function TorusKnotBuilder() {
  77604. }
  77605. /**
  77606. * Creates a torus knot mesh
  77607. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  77608. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  77609. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  77610. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  77611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77612. * * 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
  77613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77614. * @param name defines the name of the mesh
  77615. * @param options defines the options used to create the mesh
  77616. * @param scene defines the hosting scene
  77617. * @returns the torus knot mesh
  77618. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  77619. */
  77620. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  77621. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77622. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77623. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  77624. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  77625. vertexData.applyToMesh(torusKnot, options.updatable);
  77626. return torusKnot;
  77627. };
  77628. return TorusKnotBuilder;
  77629. }());
  77630. /***/ }),
  77631. /***/ "./Meshes/Builders/tubeBuilder.ts":
  77632. /*!****************************************!*\
  77633. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  77634. \****************************************/
  77635. /*! exports provided: TubeBuilder */
  77636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77637. "use strict";
  77638. __webpack_require__.r(__webpack_exports__);
  77639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  77640. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77641. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77642. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77643. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  77644. var options = {
  77645. path: path,
  77646. radius: radius,
  77647. tessellation: tessellation,
  77648. radiusFunction: radiusFunction,
  77649. arc: 1,
  77650. cap: cap,
  77651. updatable: updatable,
  77652. sideOrientation: sideOrientation,
  77653. instance: instance
  77654. };
  77655. return TubeBuilder.CreateTube(name, options, scene);
  77656. };
  77657. /**
  77658. * Class containing static functions to help procedurally build meshes
  77659. */
  77660. var TubeBuilder = /** @class */ (function () {
  77661. function TubeBuilder() {
  77662. }
  77663. /**
  77664. * Creates a tube mesh.
  77665. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77666. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  77667. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  77668. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  77669. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  77670. * * 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)
  77671. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  77672. * * 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
  77673. * * 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
  77674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77675. * * 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
  77676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77678. * @param name defines the name of the mesh
  77679. * @param options defines the options used to create the mesh
  77680. * @param scene defines the hosting scene
  77681. * @returns the tube mesh
  77682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77683. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  77684. */
  77685. TubeBuilder.CreateTube = function (name, options, scene) {
  77686. var path = options.path;
  77687. var instance = options.instance;
  77688. var radius = 1.0;
  77689. if (options.radius !== undefined) {
  77690. radius = options.radius;
  77691. }
  77692. else if (instance) {
  77693. radius = instance._creationDataStorage.radius;
  77694. }
  77695. var tessellation = options.tessellation || 64 | 0;
  77696. var radiusFunction = options.radiusFunction || null;
  77697. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77698. var invertUV = options.invertUV || false;
  77699. var updatable = options.updatable;
  77700. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77701. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  77702. // tube geometry
  77703. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  77704. var tangents = path3D.getTangents();
  77705. var normals = path3D.getNormals();
  77706. var distances = path3D.getDistances();
  77707. var pi2 = Math.PI * 2;
  77708. var step = pi2 / tessellation * arc;
  77709. var returnRadius = function () { return radius; };
  77710. var radiusFunctionFinal = radiusFunction || returnRadius;
  77711. var circlePath;
  77712. var rad;
  77713. var normal;
  77714. var rotated;
  77715. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77716. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77717. for (var i = 0; i < path.length; i++) {
  77718. rad = radiusFunctionFinal(i, distances[i]); // current radius
  77719. circlePath = Array(); // current circle array
  77720. normal = normals[i]; // current normal
  77721. for (var t = 0; t < tessellation; t++) {
  77722. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  77723. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77724. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  77725. rotated.scaleInPlace(rad).addInPlace(path[i]);
  77726. circlePath[t] = rotated;
  77727. }
  77728. circlePaths[index] = circlePath;
  77729. index++;
  77730. }
  77731. // cap
  77732. var capPath = function (nbPoints, pathIndex) {
  77733. var pointCap = Array();
  77734. for (var i = 0; i < nbPoints; i++) {
  77735. pointCap.push(path[pathIndex]);
  77736. }
  77737. return pointCap;
  77738. };
  77739. switch (cap) {
  77740. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77741. break;
  77742. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77743. circlePaths[0] = capPath(tessellation, 0);
  77744. circlePaths[1] = circlePaths[2].slice(0);
  77745. break;
  77746. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77747. circlePaths[index] = circlePaths[index - 1].slice(0);
  77748. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  77749. break;
  77750. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77751. circlePaths[0] = capPath(tessellation, 0);
  77752. circlePaths[1] = circlePaths[2].slice(0);
  77753. circlePaths[index] = circlePaths[index - 1].slice(0);
  77754. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  77755. break;
  77756. default:
  77757. break;
  77758. }
  77759. return circlePaths;
  77760. };
  77761. var path3D;
  77762. var pathArray;
  77763. if (instance) { // tube update
  77764. var storage = instance._creationDataStorage;
  77765. var arc = options.arc || storage.arc;
  77766. path3D = storage.path3D.update(path);
  77767. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  77768. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  77769. // Update mode, no need to recreate the storage.
  77770. storage.path3D = path3D;
  77771. storage.pathArray = pathArray;
  77772. storage.arc = arc;
  77773. storage.radius = radius;
  77774. return instance;
  77775. }
  77776. // tube creation
  77777. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  77778. var newPathArray = new Array();
  77779. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77780. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  77781. 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);
  77782. tube._creationDataStorage.pathArray = pathArray;
  77783. tube._creationDataStorage.path3D = path3D;
  77784. tube._creationDataStorage.tessellation = tessellation;
  77785. tube._creationDataStorage.cap = cap;
  77786. tube._creationDataStorage.arc = options.arc;
  77787. tube._creationDataStorage.radius = radius;
  77788. return tube;
  77789. };
  77790. return TubeBuilder;
  77791. }());
  77792. /***/ }),
  77793. /***/ "./Meshes/Compression/dracoCompression.ts":
  77794. /*!************************************************!*\
  77795. !*** ./Meshes/Compression/dracoCompression.ts ***!
  77796. \************************************************/
  77797. /*! exports provided: DracoCompression */
  77798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77799. "use strict";
  77800. __webpack_require__.r(__webpack_exports__);
  77801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  77802. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  77803. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77804. /**
  77805. * Draco compression (https://google.github.io/draco/)
  77806. *
  77807. * This class wraps the Draco module.
  77808. *
  77809. * **Encoder**
  77810. *
  77811. * The encoder is not currently implemented.
  77812. *
  77813. * **Decoder**
  77814. *
  77815. * 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.
  77816. *
  77817. * To update the configuration, use the following code:
  77818. * ```javascript
  77819. * DracoCompression.Configuration = {
  77820. * decoder: {
  77821. * wasmUrl: "<url to the WebAssembly library>",
  77822. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  77823. * fallbackUrl: "<url to the fallback JavaScript library>",
  77824. * }
  77825. * };
  77826. * ```
  77827. *
  77828. * 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.
  77829. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  77830. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  77831. *
  77832. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  77833. * ```javascript
  77834. * var dracoCompression = new DracoCompression();
  77835. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  77836. * [VertexBuffer.PositionKind]: 0
  77837. * });
  77838. * ```
  77839. *
  77840. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  77841. */
  77842. var DracoCompression = /** @class */ (function () {
  77843. /**
  77844. * Constructor
  77845. */
  77846. function DracoCompression() {
  77847. }
  77848. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  77849. /**
  77850. * Returns true if the decoder is available.
  77851. */
  77852. get: function () {
  77853. if (typeof DracoDecoderModule !== "undefined") {
  77854. return true;
  77855. }
  77856. var decoder = DracoCompression.Configuration.decoder;
  77857. if (decoder) {
  77858. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  77859. return true;
  77860. }
  77861. if (decoder.fallbackUrl) {
  77862. return true;
  77863. }
  77864. }
  77865. return false;
  77866. },
  77867. enumerable: true,
  77868. configurable: true
  77869. });
  77870. /**
  77871. * Stop all async operations and release resources.
  77872. */
  77873. DracoCompression.prototype.dispose = function () {
  77874. };
  77875. /**
  77876. * Decode Draco compressed mesh data to vertex data.
  77877. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  77878. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  77879. * @returns A promise that resolves with the decoded vertex data
  77880. */
  77881. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  77882. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  77883. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  77884. var module = wrappedModule.module;
  77885. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  77886. var buffer = new module.DecoderBuffer();
  77887. buffer.Init(dataView, dataView.byteLength);
  77888. var decoder = new module.Decoder();
  77889. var geometry;
  77890. var status;
  77891. try {
  77892. var type = decoder.GetEncodedGeometryType(buffer);
  77893. switch (type) {
  77894. case module.TRIANGULAR_MESH:
  77895. geometry = new module.Mesh();
  77896. status = decoder.DecodeBufferToMesh(buffer, geometry);
  77897. break;
  77898. case module.POINT_CLOUD:
  77899. geometry = new module.PointCloud();
  77900. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  77901. break;
  77902. default:
  77903. throw new Error("Invalid geometry type " + type);
  77904. }
  77905. if (!status.ok() || !geometry.ptr) {
  77906. throw new Error(status.error_msg());
  77907. }
  77908. var numPoints = geometry.num_points();
  77909. if (type === module.TRIANGULAR_MESH) {
  77910. var numFaces = geometry.num_faces();
  77911. var faceIndices = new module.DracoInt32Array();
  77912. try {
  77913. var indices = new Uint32Array(numFaces * 3);
  77914. for (var i = 0; i < numFaces; i++) {
  77915. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  77916. var offset = i * 3;
  77917. indices[offset + 0] = faceIndices.GetValue(0);
  77918. indices[offset + 1] = faceIndices.GetValue(1);
  77919. indices[offset + 2] = faceIndices.GetValue(2);
  77920. }
  77921. vertexData.indices = indices;
  77922. }
  77923. finally {
  77924. module.destroy(faceIndices);
  77925. }
  77926. }
  77927. for (var kind in attributes) {
  77928. var uniqueId = attributes[kind];
  77929. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  77930. var dracoData = new module.DracoFloat32Array();
  77931. try {
  77932. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  77933. var babylonData = new Float32Array(numPoints * attribute.num_components());
  77934. for (var i = 0; i < babylonData.length; i++) {
  77935. babylonData[i] = dracoData.GetValue(i);
  77936. }
  77937. vertexData.set(babylonData, kind);
  77938. }
  77939. finally {
  77940. module.destroy(dracoData);
  77941. }
  77942. }
  77943. }
  77944. finally {
  77945. if (geometry) {
  77946. module.destroy(geometry);
  77947. }
  77948. module.destroy(decoder);
  77949. module.destroy(buffer);
  77950. }
  77951. return vertexData;
  77952. });
  77953. };
  77954. DracoCompression._GetDecoderModule = function () {
  77955. if (!DracoCompression._DecoderModulePromise) {
  77956. var promise = null;
  77957. var config_1 = {};
  77958. if (typeof DracoDecoderModule !== "undefined") {
  77959. promise = Promise.resolve();
  77960. }
  77961. else {
  77962. var decoder = DracoCompression.Configuration.decoder;
  77963. if (decoder) {
  77964. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  77965. promise = Promise.all([
  77966. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  77967. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  77968. config_1.wasmBinary = data;
  77969. })
  77970. ]);
  77971. }
  77972. else if (decoder.fallbackUrl) {
  77973. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  77974. }
  77975. }
  77976. }
  77977. if (!promise) {
  77978. throw new Error("Draco decoder module is not available");
  77979. }
  77980. DracoCompression._DecoderModulePromise = promise.then(function () {
  77981. return new Promise(function (resolve) {
  77982. config_1.onModuleLoaded = function (decoderModule) {
  77983. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  77984. resolve({ module: decoderModule });
  77985. };
  77986. DracoDecoderModule(config_1);
  77987. });
  77988. });
  77989. }
  77990. return DracoCompression._DecoderModulePromise;
  77991. };
  77992. DracoCompression._LoadScriptAsync = function (url) {
  77993. return new Promise(function (resolve, reject) {
  77994. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  77995. resolve();
  77996. }, function (message) {
  77997. reject(new Error(message));
  77998. });
  77999. });
  78000. };
  78001. DracoCompression._LoadFileAsync = function (url) {
  78002. return new Promise(function (resolve, reject) {
  78003. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  78004. resolve(data);
  78005. }, undefined, undefined, true, function (request, exception) {
  78006. reject(exception);
  78007. });
  78008. });
  78009. };
  78010. /**
  78011. * The configuration. Defaults to the following urls:
  78012. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  78013. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  78014. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78015. */
  78016. DracoCompression.Configuration = {
  78017. decoder: {
  78018. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  78019. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  78020. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78021. }
  78022. };
  78023. return DracoCompression;
  78024. }());
  78025. /***/ }),
  78026. /***/ "./Meshes/Compression/index.ts":
  78027. /*!*************************************!*\
  78028. !*** ./Meshes/Compression/index.ts ***!
  78029. \*************************************/
  78030. /*! exports provided: DracoCompression */
  78031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78032. "use strict";
  78033. __webpack_require__.r(__webpack_exports__);
  78034. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  78035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  78036. /***/ }),
  78037. /***/ "./Meshes/abstractMesh.ts":
  78038. /*!********************************!*\
  78039. !*** ./Meshes/abstractMesh.ts ***!
  78040. \********************************/
  78041. /*! exports provided: AbstractMesh */
  78042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78043. "use strict";
  78044. __webpack_require__.r(__webpack_exports__);
  78045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  78046. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78047. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  78048. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  78049. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78050. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  78051. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78052. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78053. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  78054. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  78055. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78056. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78057. /** @hidden */
  78058. var _FacetDataStorage = /** @class */ (function () {
  78059. function _FacetDataStorage() {
  78060. this.facetNb = 0; // facet number
  78061. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  78062. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  78063. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  78064. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  78065. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  78066. this.subDiv = {
  78067. max: 1,
  78068. X: 1,
  78069. Y: 1,
  78070. Z: 1
  78071. };
  78072. this.facetDepthSort = false; // is the facet depth sort to be computed
  78073. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  78074. }
  78075. return _FacetDataStorage;
  78076. }());
  78077. /**
  78078. * Class used to store all common mesh properties
  78079. */
  78080. var AbstractMesh = /** @class */ (function (_super) {
  78081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  78082. // Constructor
  78083. /**
  78084. * Creates a new AbstractMesh
  78085. * @param name defines the name of the mesh
  78086. * @param scene defines the hosting scene
  78087. */
  78088. function AbstractMesh(name, scene) {
  78089. if (scene === void 0) { scene = null; }
  78090. var _this = _super.call(this, name, scene, false) || this;
  78091. _this._facetData = new _FacetDataStorage();
  78092. /**
  78093. * The culling strategy to use to check whether the mesh must be rendered or not.
  78094. * This value can be changed at any time and will be used on the next render mesh selection.
  78095. * The possible values are :
  78096. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78097. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78098. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78099. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78100. * Please read each static variable documentation to get details about the culling process.
  78101. * */
  78102. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  78103. // Events
  78104. /**
  78105. * An event triggered when this mesh collides with another one
  78106. */
  78107. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78108. /**
  78109. * An event triggered when the collision's position changes
  78110. */
  78111. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78112. /**
  78113. * An event triggered when material is changed
  78114. */
  78115. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78116. // Properties
  78117. /**
  78118. * Gets or sets the orientation for POV movement & rotation
  78119. */
  78120. _this.definedFacingForward = true;
  78121. _this._visibility = 1.0;
  78122. /** Gets or sets the alpha index used to sort transparent meshes
  78123. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78124. */
  78125. _this.alphaIndex = Number.MAX_VALUE;
  78126. /**
  78127. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78128. */
  78129. _this.isVisible = true;
  78130. /**
  78131. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78132. */
  78133. _this.isPickable = true;
  78134. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  78135. _this.showSubMeshesBoundingBox = false;
  78136. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  78137. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  78138. */
  78139. _this.isBlocker = false;
  78140. /**
  78141. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  78142. */
  78143. _this.enablePointerMoveEvents = false;
  78144. /**
  78145. * Specifies the rendering group id for this mesh (0 by default)
  78146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78147. */
  78148. _this.renderingGroupId = 0;
  78149. _this._receiveShadows = false;
  78150. /** Defines color to use when rendering outline */
  78151. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78152. /** Define width to use when rendering outline */
  78153. _this.outlineWidth = 0.02;
  78154. /** Defines color to use when rendering overlay */
  78155. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78156. /** Defines alpha to use when rendering overlay */
  78157. _this.overlayAlpha = 0.5;
  78158. _this._hasVertexAlpha = false;
  78159. _this._useVertexColors = true;
  78160. _this._computeBonesUsingShaders = true;
  78161. _this._numBoneInfluencers = 4;
  78162. _this._applyFog = true;
  78163. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  78164. _this.useOctreeForRenderingSelection = true;
  78165. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  78166. _this.useOctreeForPicking = true;
  78167. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  78168. _this.useOctreeForCollisions = true;
  78169. _this._layerMask = 0x0FFFFFFF;
  78170. /**
  78171. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  78172. */
  78173. _this.alwaysSelectAsActiveMesh = false;
  78174. /**
  78175. * Gets or sets the current action manager
  78176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78177. */
  78178. _this.actionManager = null;
  78179. // Collisions
  78180. _this._checkCollisions = false;
  78181. _this._collisionMask = -1;
  78182. _this._collisionGroup = -1;
  78183. /**
  78184. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  78185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78186. */
  78187. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  78188. /**
  78189. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  78190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78191. */
  78192. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78193. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78194. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78195. // Edges
  78196. /**
  78197. * Defines edge width used when edgesRenderer is enabled
  78198. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78199. */
  78200. _this.edgesWidth = 1;
  78201. /**
  78202. * Defines edge color used when edgesRenderer is enabled
  78203. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78204. */
  78205. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  78206. /** @hidden */
  78207. _this._renderId = 0;
  78208. /** @hidden */
  78209. _this._intersectionsInProgress = new Array();
  78210. /** @hidden */
  78211. _this._unIndexed = false;
  78212. /** @hidden */
  78213. _this._lightSources = new Array();
  78214. /**
  78215. * An event triggered when the mesh is rebuilt.
  78216. */
  78217. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78218. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  78219. if (collidedMesh === void 0) { collidedMesh = null; }
  78220. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  78221. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  78222. _this.position.addInPlace(_this._diffPositionForCollisions);
  78223. }
  78224. if (collidedMesh) {
  78225. _this.onCollideObservable.notifyObservers(collidedMesh);
  78226. }
  78227. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  78228. };
  78229. _this.getScene().addMesh(_this);
  78230. _this._resyncLightSources();
  78231. return _this;
  78232. }
  78233. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  78234. /**
  78235. * No billboard
  78236. */
  78237. get: function () {
  78238. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  78239. },
  78240. enumerable: true,
  78241. configurable: true
  78242. });
  78243. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  78244. /** Billboard on X axis */
  78245. get: function () {
  78246. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  78247. },
  78248. enumerable: true,
  78249. configurable: true
  78250. });
  78251. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  78252. /** Billboard on Y axis */
  78253. get: function () {
  78254. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  78255. },
  78256. enumerable: true,
  78257. configurable: true
  78258. });
  78259. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  78260. /** Billboard on Z axis */
  78261. get: function () {
  78262. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  78263. },
  78264. enumerable: true,
  78265. configurable: true
  78266. });
  78267. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  78268. /** Billboard on all axes */
  78269. get: function () {
  78270. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  78271. },
  78272. enumerable: true,
  78273. configurable: true
  78274. });
  78275. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  78276. /**
  78277. * Gets the number of facets in the mesh
  78278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78279. */
  78280. get: function () {
  78281. return this._facetData.facetNb;
  78282. },
  78283. enumerable: true,
  78284. configurable: true
  78285. });
  78286. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  78287. /**
  78288. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78290. */
  78291. get: function () {
  78292. return this._facetData.partitioningSubdivisions;
  78293. },
  78294. set: function (nb) {
  78295. this._facetData.partitioningSubdivisions = nb;
  78296. },
  78297. enumerable: true,
  78298. configurable: true
  78299. });
  78300. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  78301. /**
  78302. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78303. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78305. */
  78306. get: function () {
  78307. return this._facetData.partitioningBBoxRatio;
  78308. },
  78309. set: function (ratio) {
  78310. this._facetData.partitioningBBoxRatio = ratio;
  78311. },
  78312. enumerable: true,
  78313. configurable: true
  78314. });
  78315. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  78316. /**
  78317. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78318. * Works only for updatable meshes.
  78319. * Doesn't work with multi-materials
  78320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78321. */
  78322. get: function () {
  78323. return this._facetData.facetDepthSort;
  78324. },
  78325. set: function (sort) {
  78326. this._facetData.facetDepthSort = sort;
  78327. },
  78328. enumerable: true,
  78329. configurable: true
  78330. });
  78331. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  78332. /**
  78333. * The location (Vector3) where the facet depth sort must be computed from.
  78334. * By default, the active camera position.
  78335. * Used only when facet depth sort is enabled
  78336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78337. */
  78338. get: function () {
  78339. return this._facetData.facetDepthSortFrom;
  78340. },
  78341. set: function (location) {
  78342. this._facetData.facetDepthSortFrom = location;
  78343. },
  78344. enumerable: true,
  78345. configurable: true
  78346. });
  78347. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  78348. /**
  78349. * gets a boolean indicating if facetData is enabled
  78350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78351. */
  78352. get: function () {
  78353. return this._facetData.facetDataEnabled;
  78354. },
  78355. enumerable: true,
  78356. configurable: true
  78357. });
  78358. /** @hidden */
  78359. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  78360. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  78361. return false;
  78362. }
  78363. this._markSubMeshesAsMiscDirty();
  78364. return true;
  78365. };
  78366. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  78367. /** Set a function to call when this mesh collides with another one */
  78368. set: function (callback) {
  78369. if (this._onCollideObserver) {
  78370. this.onCollideObservable.remove(this._onCollideObserver);
  78371. }
  78372. this._onCollideObserver = this.onCollideObservable.add(callback);
  78373. },
  78374. enumerable: true,
  78375. configurable: true
  78376. });
  78377. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  78378. /** Set a function to call when the collision's position changes */
  78379. set: function (callback) {
  78380. if (this._onCollisionPositionChangeObserver) {
  78381. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  78382. }
  78383. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  78384. },
  78385. enumerable: true,
  78386. configurable: true
  78387. });
  78388. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  78389. /**
  78390. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78391. */
  78392. get: function () {
  78393. return this._visibility;
  78394. },
  78395. /**
  78396. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78397. */
  78398. set: function (value) {
  78399. if (this._visibility === value) {
  78400. return;
  78401. }
  78402. this._visibility = value;
  78403. this._markSubMeshesAsMiscDirty();
  78404. },
  78405. enumerable: true,
  78406. configurable: true
  78407. });
  78408. Object.defineProperty(AbstractMesh.prototype, "material", {
  78409. /** Gets or sets current material */
  78410. get: function () {
  78411. return this._material;
  78412. },
  78413. set: function (value) {
  78414. if (this._material === value) {
  78415. return;
  78416. }
  78417. // remove from material mesh map id needed
  78418. if (this._material && this._material.meshMap) {
  78419. this._material.meshMap[this.uniqueId] = undefined;
  78420. }
  78421. this._material = value;
  78422. if (value && value.meshMap) {
  78423. value.meshMap[this.uniqueId] = this;
  78424. }
  78425. if (this.onMaterialChangedObservable.hasObservers) {
  78426. this.onMaterialChangedObservable.notifyObservers(this);
  78427. }
  78428. if (!this.subMeshes) {
  78429. return;
  78430. }
  78431. this._unBindEffect();
  78432. },
  78433. enumerable: true,
  78434. configurable: true
  78435. });
  78436. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  78437. /**
  78438. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  78439. * @see http://doc.babylonjs.com/babylon101/shadows
  78440. */
  78441. get: function () {
  78442. return this._receiveShadows;
  78443. },
  78444. set: function (value) {
  78445. if (this._receiveShadows === value) {
  78446. return;
  78447. }
  78448. this._receiveShadows = value;
  78449. this._markSubMeshesAsLightDirty();
  78450. },
  78451. enumerable: true,
  78452. configurable: true
  78453. });
  78454. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  78455. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  78456. get: function () {
  78457. return this._hasVertexAlpha;
  78458. },
  78459. set: function (value) {
  78460. if (this._hasVertexAlpha === value) {
  78461. return;
  78462. }
  78463. this._hasVertexAlpha = value;
  78464. this._markSubMeshesAsAttributesDirty();
  78465. this._markSubMeshesAsMiscDirty();
  78466. },
  78467. enumerable: true,
  78468. configurable: true
  78469. });
  78470. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  78471. /** 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) */
  78472. get: function () {
  78473. return this._useVertexColors;
  78474. },
  78475. set: function (value) {
  78476. if (this._useVertexColors === value) {
  78477. return;
  78478. }
  78479. this._useVertexColors = value;
  78480. this._markSubMeshesAsAttributesDirty();
  78481. },
  78482. enumerable: true,
  78483. configurable: true
  78484. });
  78485. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  78486. /**
  78487. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  78488. */
  78489. get: function () {
  78490. return this._computeBonesUsingShaders;
  78491. },
  78492. set: function (value) {
  78493. if (this._computeBonesUsingShaders === value) {
  78494. return;
  78495. }
  78496. this._computeBonesUsingShaders = value;
  78497. this._markSubMeshesAsAttributesDirty();
  78498. },
  78499. enumerable: true,
  78500. configurable: true
  78501. });
  78502. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  78503. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  78504. get: function () {
  78505. return this._numBoneInfluencers;
  78506. },
  78507. set: function (value) {
  78508. if (this._numBoneInfluencers === value) {
  78509. return;
  78510. }
  78511. this._numBoneInfluencers = value;
  78512. this._markSubMeshesAsAttributesDirty();
  78513. },
  78514. enumerable: true,
  78515. configurable: true
  78516. });
  78517. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  78518. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  78519. get: function () {
  78520. return this._applyFog;
  78521. },
  78522. set: function (value) {
  78523. if (this._applyFog === value) {
  78524. return;
  78525. }
  78526. this._applyFog = value;
  78527. this._markSubMeshesAsMiscDirty();
  78528. },
  78529. enumerable: true,
  78530. configurable: true
  78531. });
  78532. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  78533. /**
  78534. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  78535. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  78536. */
  78537. get: function () {
  78538. return this._layerMask;
  78539. },
  78540. set: function (value) {
  78541. if (value === this._layerMask) {
  78542. return;
  78543. }
  78544. this._layerMask = value;
  78545. this._resyncLightSources();
  78546. },
  78547. enumerable: true,
  78548. configurable: true
  78549. });
  78550. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  78551. /**
  78552. * Gets or sets a collision mask used to mask collisions (default is -1).
  78553. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78554. */
  78555. get: function () {
  78556. return this._collisionMask;
  78557. },
  78558. set: function (mask) {
  78559. this._collisionMask = !isNaN(mask) ? mask : -1;
  78560. },
  78561. enumerable: true,
  78562. configurable: true
  78563. });
  78564. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  78565. /**
  78566. * Gets or sets the current collision group mask (-1 by default).
  78567. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78568. */
  78569. get: function () {
  78570. return this._collisionGroup;
  78571. },
  78572. set: function (mask) {
  78573. this._collisionGroup = !isNaN(mask) ? mask : -1;
  78574. },
  78575. enumerable: true,
  78576. configurable: true
  78577. });
  78578. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  78579. /** @hidden */
  78580. get: function () {
  78581. return null;
  78582. },
  78583. enumerable: true,
  78584. configurable: true
  78585. });
  78586. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  78587. get: function () {
  78588. return this._skeleton;
  78589. },
  78590. /**
  78591. * Gets or sets a skeleton to apply skining transformations
  78592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78593. */
  78594. set: function (value) {
  78595. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  78596. this._skeleton._unregisterMeshWithPoseMatrix(this);
  78597. }
  78598. if (value && value.needInitialSkinMatrix) {
  78599. value._registerMeshWithPoseMatrix(this);
  78600. }
  78601. this._skeleton = value;
  78602. if (!this._skeleton) {
  78603. this._bonesTransformMatrices = null;
  78604. }
  78605. this._markSubMeshesAsAttributesDirty();
  78606. },
  78607. enumerable: true,
  78608. configurable: true
  78609. });
  78610. /**
  78611. * Returns the string "AbstractMesh"
  78612. * @returns "AbstractMesh"
  78613. */
  78614. AbstractMesh.prototype.getClassName = function () {
  78615. return "AbstractMesh";
  78616. };
  78617. /**
  78618. * Gets a string representation of the current mesh
  78619. * @param fullDetails defines a boolean indicating if full details must be included
  78620. * @returns a string representation of the current mesh
  78621. */
  78622. AbstractMesh.prototype.toString = function (fullDetails) {
  78623. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  78624. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  78625. if (this._skeleton) {
  78626. ret += ", skeleton: " + this._skeleton.name;
  78627. }
  78628. if (fullDetails) {
  78629. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  78630. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  78631. }
  78632. return ret;
  78633. };
  78634. /** @hidden */
  78635. AbstractMesh.prototype._rebuild = function () {
  78636. this.onRebuildObservable.notifyObservers(this);
  78637. if (this._occlusionQuery) {
  78638. this._occlusionQuery = null;
  78639. }
  78640. if (!this.subMeshes) {
  78641. return;
  78642. }
  78643. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78644. var subMesh = _a[_i];
  78645. subMesh._rebuild();
  78646. }
  78647. };
  78648. /** @hidden */
  78649. AbstractMesh.prototype._resyncLightSources = function () {
  78650. this._lightSources.length = 0;
  78651. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  78652. var light = _a[_i];
  78653. if (!light.isEnabled()) {
  78654. continue;
  78655. }
  78656. if (light.canAffectMesh(this)) {
  78657. this._lightSources.push(light);
  78658. }
  78659. }
  78660. this._markSubMeshesAsLightDirty();
  78661. };
  78662. /** @hidden */
  78663. AbstractMesh.prototype._resyncLighSource = function (light) {
  78664. var isIn = light.isEnabled() && light.canAffectMesh(this);
  78665. var index = this._lightSources.indexOf(light);
  78666. if (index === -1) {
  78667. if (!isIn) {
  78668. return;
  78669. }
  78670. this._lightSources.push(light);
  78671. }
  78672. else {
  78673. if (isIn) {
  78674. return;
  78675. }
  78676. this._lightSources.splice(index, 1);
  78677. }
  78678. this._markSubMeshesAsLightDirty();
  78679. };
  78680. /** @hidden */
  78681. AbstractMesh.prototype._unBindEffect = function () {
  78682. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78683. var subMesh = _a[_i];
  78684. subMesh.setEffect(null);
  78685. }
  78686. };
  78687. /** @hidden */
  78688. AbstractMesh.prototype._removeLightSource = function (light) {
  78689. var index = this._lightSources.indexOf(light);
  78690. if (index === -1) {
  78691. return;
  78692. }
  78693. this._lightSources.splice(index, 1);
  78694. this._markSubMeshesAsLightDirty();
  78695. };
  78696. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  78697. if (!this.subMeshes) {
  78698. return;
  78699. }
  78700. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78701. var subMesh = _a[_i];
  78702. if (subMesh._materialDefines) {
  78703. func(subMesh._materialDefines);
  78704. }
  78705. }
  78706. };
  78707. /** @hidden */
  78708. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  78709. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  78710. };
  78711. /** @hidden */
  78712. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  78713. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  78714. };
  78715. /** @hidden */
  78716. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  78717. if (!this.subMeshes) {
  78718. return;
  78719. }
  78720. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78721. var subMesh = _a[_i];
  78722. var material = subMesh.getMaterial();
  78723. if (material) {
  78724. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  78725. }
  78726. }
  78727. };
  78728. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  78729. /**
  78730. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  78731. */
  78732. get: function () {
  78733. return this._scaling;
  78734. },
  78735. set: function (newScaling) {
  78736. this._scaling = newScaling;
  78737. if (this.physicsImpostor) {
  78738. this.physicsImpostor.forceUpdate();
  78739. }
  78740. },
  78741. enumerable: true,
  78742. configurable: true
  78743. });
  78744. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  78745. // Methods
  78746. /**
  78747. * Returns true if the mesh is blocked. Implemented by child classes
  78748. */
  78749. get: function () {
  78750. return false;
  78751. },
  78752. enumerable: true,
  78753. configurable: true
  78754. });
  78755. /**
  78756. * Returns the mesh itself by default. Implemented by child classes
  78757. * @param camera defines the camera to use to pick the right LOD level
  78758. * @returns the currentAbstractMesh
  78759. */
  78760. AbstractMesh.prototype.getLOD = function (camera) {
  78761. return this;
  78762. };
  78763. /**
  78764. * Returns 0 by default. Implemented by child classes
  78765. * @returns an integer
  78766. */
  78767. AbstractMesh.prototype.getTotalVertices = function () {
  78768. return 0;
  78769. };
  78770. /**
  78771. * Returns a positive integer : the total number of indices in this mesh geometry.
  78772. * @returns the numner of indices or zero if the mesh has no geometry.
  78773. */
  78774. AbstractMesh.prototype.getTotalIndices = function () {
  78775. return 0;
  78776. };
  78777. /**
  78778. * Returns null by default. Implemented by child classes
  78779. * @returns null
  78780. */
  78781. AbstractMesh.prototype.getIndices = function () {
  78782. return null;
  78783. };
  78784. /**
  78785. * Returns the array of the requested vertex data kind. Implemented by child classes
  78786. * @param kind defines the vertex data kind to use
  78787. * @returns null
  78788. */
  78789. AbstractMesh.prototype.getVerticesData = function (kind) {
  78790. return null;
  78791. };
  78792. /**
  78793. * Sets the vertex data of the mesh geometry for the requested `kind`.
  78794. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  78795. * Note that a new underlying VertexBuffer object is created each call.
  78796. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  78797. * @param kind defines vertex data kind:
  78798. * * VertexBuffer.PositionKind
  78799. * * VertexBuffer.UVKind
  78800. * * VertexBuffer.UV2Kind
  78801. * * VertexBuffer.UV3Kind
  78802. * * VertexBuffer.UV4Kind
  78803. * * VertexBuffer.UV5Kind
  78804. * * VertexBuffer.UV6Kind
  78805. * * VertexBuffer.ColorKind
  78806. * * VertexBuffer.MatricesIndicesKind
  78807. * * VertexBuffer.MatricesIndicesExtraKind
  78808. * * VertexBuffer.MatricesWeightsKind
  78809. * * VertexBuffer.MatricesWeightsExtraKind
  78810. * @param data defines the data source
  78811. * @param updatable defines if the data must be flagged as updatable (or static)
  78812. * @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
  78813. * @returns the current mesh
  78814. */
  78815. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  78816. return this;
  78817. };
  78818. /**
  78819. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  78820. * If the mesh has no geometry, it is simply returned as it is.
  78821. * @param kind defines vertex data kind:
  78822. * * VertexBuffer.PositionKind
  78823. * * VertexBuffer.UVKind
  78824. * * VertexBuffer.UV2Kind
  78825. * * VertexBuffer.UV3Kind
  78826. * * VertexBuffer.UV4Kind
  78827. * * VertexBuffer.UV5Kind
  78828. * * VertexBuffer.UV6Kind
  78829. * * VertexBuffer.ColorKind
  78830. * * VertexBuffer.MatricesIndicesKind
  78831. * * VertexBuffer.MatricesIndicesExtraKind
  78832. * * VertexBuffer.MatricesWeightsKind
  78833. * * VertexBuffer.MatricesWeightsExtraKind
  78834. * @param data defines the data source
  78835. * @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
  78836. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  78837. * @returns the current mesh
  78838. */
  78839. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  78840. return this;
  78841. };
  78842. /**
  78843. * Sets the mesh indices,
  78844. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  78845. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  78846. * @param totalVertices Defines the total number of vertices
  78847. * @returns the current mesh
  78848. */
  78849. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  78850. return this;
  78851. };
  78852. /**
  78853. * Gets a boolean indicating if specific vertex data is present
  78854. * @param kind defines the vertex data kind to use
  78855. * @returns true is data kind is present
  78856. */
  78857. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  78858. return false;
  78859. };
  78860. /**
  78861. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  78862. * @returns a BoundingInfo
  78863. */
  78864. AbstractMesh.prototype.getBoundingInfo = function () {
  78865. if (this._masterMesh) {
  78866. return this._masterMesh.getBoundingInfo();
  78867. }
  78868. if (!this._boundingInfo) {
  78869. // this._boundingInfo is being created here
  78870. this._updateBoundingInfo();
  78871. }
  78872. // cannot be null.
  78873. return this._boundingInfo;
  78874. };
  78875. /**
  78876. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78877. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  78878. * @returns the current mesh
  78879. */
  78880. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  78881. if (includeDescendants === void 0) { includeDescendants = true; }
  78882. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  78883. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  78884. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  78885. if (maxDimension === 0) {
  78886. return this;
  78887. }
  78888. var scale = 1 / maxDimension;
  78889. this.scaling.scaleInPlace(scale);
  78890. return this;
  78891. };
  78892. /**
  78893. * Overwrite the current bounding info
  78894. * @param boundingInfo defines the new bounding info
  78895. * @returns the current mesh
  78896. */
  78897. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  78898. this._boundingInfo = boundingInfo;
  78899. return this;
  78900. };
  78901. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  78902. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  78903. get: function () {
  78904. 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));
  78905. },
  78906. enumerable: true,
  78907. configurable: true
  78908. });
  78909. /** @hidden */
  78910. AbstractMesh.prototype._preActivate = function () {
  78911. };
  78912. /** @hidden */
  78913. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  78914. };
  78915. /** @hidden */
  78916. AbstractMesh.prototype._activate = function (renderId) {
  78917. this._renderId = renderId;
  78918. };
  78919. /**
  78920. * Gets the current world matrix
  78921. * @returns a Matrix
  78922. */
  78923. AbstractMesh.prototype.getWorldMatrix = function () {
  78924. if (this._masterMesh) {
  78925. return this._masterMesh.getWorldMatrix();
  78926. }
  78927. return _super.prototype.getWorldMatrix.call(this);
  78928. };
  78929. /** @hidden */
  78930. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  78931. if (this._masterMesh) {
  78932. return this._masterMesh._getWorldMatrixDeterminant();
  78933. }
  78934. return _super.prototype._getWorldMatrixDeterminant.call(this);
  78935. };
  78936. // ================================== Point of View Movement =================================
  78937. /**
  78938. * Perform relative position change from the point of view of behind the front of the mesh.
  78939. * This is performed taking into account the meshes current rotation, so you do not have to care.
  78940. * Supports definition of mesh facing forward or backward
  78941. * @param amountRight defines the distance on the right axis
  78942. * @param amountUp defines the distance on the up axis
  78943. * @param amountForward defines the distance on the forward axis
  78944. * @returns the current mesh
  78945. */
  78946. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  78947. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  78948. return this;
  78949. };
  78950. /**
  78951. * Calculate relative position change from the point of view of behind the front of the mesh.
  78952. * This is performed taking into account the meshes current rotation, so you do not have to care.
  78953. * Supports definition of mesh facing forward or backward
  78954. * @param amountRight defines the distance on the right axis
  78955. * @param amountUp defines the distance on the up axis
  78956. * @param amountForward defines the distance on the forward axis
  78957. * @returns the new displacement vector
  78958. */
  78959. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  78960. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  78961. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  78962. rotQuaternion.toRotationMatrix(rotMatrix);
  78963. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  78964. var defForwardMult = this.definedFacingForward ? -1 : 1;
  78965. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  78966. return translationDelta;
  78967. };
  78968. // ================================== Point of View Rotation =================================
  78969. /**
  78970. * Perform relative rotation change from the point of view of behind the front of the mesh.
  78971. * Supports definition of mesh facing forward or backward
  78972. * @param flipBack defines the flip
  78973. * @param twirlClockwise defines the twirl
  78974. * @param tiltRight defines the tilt
  78975. * @returns the current mesh
  78976. */
  78977. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  78978. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  78979. return this;
  78980. };
  78981. /**
  78982. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  78983. * Supports definition of mesh facing forward or backward.
  78984. * @param flipBack defines the flip
  78985. * @param twirlClockwise defines the twirl
  78986. * @param tiltRight defines the tilt
  78987. * @returns the new rotation vector
  78988. */
  78989. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  78990. var defForwardMult = this.definedFacingForward ? 1 : -1;
  78991. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  78992. };
  78993. /**
  78994. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  78995. * @param includeDescendants Include bounding info from descendants as well (true by default)
  78996. * @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
  78997. * @returns the new bounding vectors
  78998. */
  78999. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  79000. if (includeDescendants === void 0) { includeDescendants = true; }
  79001. if (predicate === void 0) { predicate = null; }
  79002. // Ensures that all world matrix will be recomputed.
  79003. this.getScene().incrementRenderId();
  79004. this.computeWorldMatrix(true);
  79005. var min;
  79006. var max;
  79007. var boundingInfo = this.getBoundingInfo();
  79008. if (!this.subMeshes) {
  79009. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  79010. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  79011. }
  79012. else {
  79013. min = boundingInfo.boundingBox.minimumWorld;
  79014. max = boundingInfo.boundingBox.maximumWorld;
  79015. }
  79016. if (includeDescendants) {
  79017. var descendants = this.getDescendants(false);
  79018. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  79019. var descendant = descendants_1[_i];
  79020. var childMesh = descendant;
  79021. childMesh.computeWorldMatrix(true);
  79022. // Filters meshes based on custom predicate function.
  79023. if (predicate && !predicate(childMesh)) {
  79024. continue;
  79025. }
  79026. //make sure we have the needed params to get mix and max
  79027. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  79028. continue;
  79029. }
  79030. var childBoundingInfo = childMesh.getBoundingInfo();
  79031. var boundingBox = childBoundingInfo.boundingBox;
  79032. var minBox = boundingBox.minimumWorld;
  79033. var maxBox = boundingBox.maximumWorld;
  79034. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  79035. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  79036. }
  79037. }
  79038. return {
  79039. min: min,
  79040. max: max
  79041. };
  79042. };
  79043. /**
  79044. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79045. * This means the mesh underlying bounding box and sphere are recomputed.
  79046. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79047. * @returns the current mesh
  79048. */
  79049. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79050. if (applySkeleton === void 0) { applySkeleton = false; }
  79051. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79052. return this;
  79053. }
  79054. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  79055. return this;
  79056. };
  79057. /** @hidden */
  79058. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  79059. if (data) {
  79060. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  79061. if (this._boundingInfo) {
  79062. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  79063. }
  79064. else {
  79065. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  79066. }
  79067. }
  79068. if (this.subMeshes) {
  79069. for (var index = 0; index < this.subMeshes.length; index++) {
  79070. this.subMeshes[index].refreshBoundingInfo();
  79071. }
  79072. }
  79073. this._updateBoundingInfo();
  79074. };
  79075. /** @hidden */
  79076. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  79077. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79078. if (data && applySkeleton && this.skeleton) {
  79079. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  79080. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  79081. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  79082. if (matricesWeightsData && matricesIndicesData) {
  79083. var needExtras = this.numBoneInfluencers > 4;
  79084. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  79085. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  79086. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  79087. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79088. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79089. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79090. var matWeightIdx = 0;
  79091. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  79092. finalMatrix.reset();
  79093. var inf;
  79094. var weight;
  79095. for (inf = 0; inf < 4; inf++) {
  79096. weight = matricesWeightsData[matWeightIdx + inf];
  79097. if (weight > 0) {
  79098. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79099. finalMatrix.addToSelf(tempMatrix);
  79100. }
  79101. }
  79102. if (needExtras) {
  79103. for (inf = 0; inf < 4; inf++) {
  79104. weight = matricesWeightsExtraData[matWeightIdx + inf];
  79105. if (weight > 0) {
  79106. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79107. finalMatrix.addToSelf(tempMatrix);
  79108. }
  79109. }
  79110. }
  79111. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  79112. tempVector.toArray(data, index);
  79113. }
  79114. }
  79115. }
  79116. return data;
  79117. };
  79118. /** @hidden */
  79119. AbstractMesh.prototype._updateBoundingInfo = function () {
  79120. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  79121. if (this._boundingInfo) {
  79122. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  79123. }
  79124. else {
  79125. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  79126. }
  79127. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  79128. return this;
  79129. };
  79130. /** @hidden */
  79131. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  79132. if (!this.subMeshes) {
  79133. return this;
  79134. }
  79135. var count = this.subMeshes.length;
  79136. for (var subIndex = 0; subIndex < count; subIndex++) {
  79137. var subMesh = this.subMeshes[subIndex];
  79138. if (count > 1 || !subMesh.IsGlobal) {
  79139. subMesh.updateBoundingInfo(matrix);
  79140. }
  79141. }
  79142. return this;
  79143. };
  79144. /** @hidden */
  79145. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  79146. // Bounding info
  79147. this._updateBoundingInfo();
  79148. };
  79149. /**
  79150. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79151. * A mesh is in the frustum if its bounding box intersects the frustum
  79152. * @param frustumPlanes defines the frustum to test
  79153. * @returns true if the mesh is in the frustum planes
  79154. */
  79155. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  79156. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  79157. };
  79158. /**
  79159. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79160. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79161. * @param frustumPlanes defines the frustum to test
  79162. * @returns true if the mesh is completely in the frustum planes
  79163. */
  79164. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  79165. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  79166. };
  79167. /**
  79168. * True if the mesh intersects another mesh or a SolidParticle object
  79169. * @param mesh defines a target mesh or SolidParticle to test
  79170. * @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)
  79171. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79172. * @returns true if there is an intersection
  79173. */
  79174. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  79175. if (precise === void 0) { precise = false; }
  79176. if (!this._boundingInfo || !mesh._boundingInfo) {
  79177. return false;
  79178. }
  79179. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  79180. return true;
  79181. }
  79182. if (includeDescendants) {
  79183. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  79184. var child = _a[_i];
  79185. if (child.intersectsMesh(mesh, precise, true)) {
  79186. return true;
  79187. }
  79188. }
  79189. }
  79190. return false;
  79191. };
  79192. /**
  79193. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79194. * @param point defines the point to test
  79195. * @returns true if there is an intersection
  79196. */
  79197. AbstractMesh.prototype.intersectsPoint = function (point) {
  79198. if (!this._boundingInfo) {
  79199. return false;
  79200. }
  79201. return this._boundingInfo.intersectsPoint(point);
  79202. };
  79203. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  79204. // Collisions
  79205. /**
  79206. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79208. */
  79209. get: function () {
  79210. return this._checkCollisions;
  79211. },
  79212. set: function (collisionEnabled) {
  79213. this._checkCollisions = collisionEnabled;
  79214. },
  79215. enumerable: true,
  79216. configurable: true
  79217. });
  79218. Object.defineProperty(AbstractMesh.prototype, "collider", {
  79219. /**
  79220. * Gets Collider object used to compute collisions (not physics)
  79221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79222. */
  79223. get: function () {
  79224. return this._collider;
  79225. },
  79226. enumerable: true,
  79227. configurable: true
  79228. });
  79229. /**
  79230. * Move the mesh using collision engine
  79231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79232. * @param displacement defines the requested displacement vector
  79233. * @returns the current mesh
  79234. */
  79235. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  79236. var globalPosition = this.getAbsolutePosition();
  79237. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  79238. var coordinator = this.getScene().collisionCoordinator;
  79239. if (!this._collider) {
  79240. this._collider = coordinator.createCollider();
  79241. }
  79242. this._collider._radius = this.ellipsoid;
  79243. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  79244. return this;
  79245. };
  79246. // Collisions
  79247. /** @hidden */
  79248. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  79249. this._generatePointsArray();
  79250. if (!this._positions) {
  79251. return this;
  79252. }
  79253. // Transformation
  79254. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  79255. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  79256. subMesh._lastColliderWorldVertices = [];
  79257. subMesh._trianglePlanes = [];
  79258. var start = subMesh.verticesStart;
  79259. var end = (subMesh.verticesStart + subMesh.verticesCount);
  79260. for (var i = start; i < end; i++) {
  79261. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  79262. }
  79263. }
  79264. // Collide
  79265. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  79266. if (collider.collisionFound) {
  79267. collider.collidedMesh = this;
  79268. }
  79269. return this;
  79270. };
  79271. /** @hidden */
  79272. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  79273. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  79274. var len = subMeshes.length;
  79275. for (var index = 0; index < len; index++) {
  79276. var subMesh = subMeshes.data[index];
  79277. // Bounding test
  79278. if (len > 1 && !subMesh._checkCollision(collider)) {
  79279. continue;
  79280. }
  79281. this._collideForSubMesh(subMesh, transformMatrix, collider);
  79282. }
  79283. return this;
  79284. };
  79285. /** @hidden */
  79286. AbstractMesh.prototype._checkCollision = function (collider) {
  79287. // Bounding box test
  79288. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  79289. return this;
  79290. }
  79291. // Transformation matrix
  79292. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79293. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79294. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  79295. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  79296. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  79297. return this;
  79298. };
  79299. // Picking
  79300. /** @hidden */
  79301. AbstractMesh.prototype._generatePointsArray = function () {
  79302. return false;
  79303. };
  79304. /**
  79305. * Checks if the passed Ray intersects with the mesh
  79306. * @param ray defines the ray to use
  79307. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79308. * @returns the picking info
  79309. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79310. */
  79311. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  79312. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  79313. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  79314. var boundingInfo = this._boundingInfo;
  79315. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  79316. return pickingInfo;
  79317. }
  79318. if (!this._generatePointsArray()) {
  79319. return pickingInfo;
  79320. }
  79321. var intersectInfo = null;
  79322. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  79323. var len = subMeshes.length;
  79324. for (var index = 0; index < len; index++) {
  79325. var subMesh = subMeshes.data[index];
  79326. // Bounding test
  79327. if (len > 1 && !subMesh.canIntersects(ray)) {
  79328. continue;
  79329. }
  79330. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  79331. if (currentIntersectInfo) {
  79332. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  79333. intersectInfo = currentIntersectInfo;
  79334. intersectInfo.subMeshId = index;
  79335. if (fastCheck) {
  79336. break;
  79337. }
  79338. }
  79339. }
  79340. }
  79341. if (intersectInfo) {
  79342. // Get picked point
  79343. var world = this.getWorldMatrix();
  79344. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79345. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  79346. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  79347. ray.direction.scaleToRef(intersectInfo.distance, direction);
  79348. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  79349. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  79350. // Return result
  79351. pickingInfo.hit = true;
  79352. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  79353. pickingInfo.pickedPoint = pickedPoint;
  79354. pickingInfo.pickedMesh = this;
  79355. pickingInfo.bu = intersectInfo.bu || 0;
  79356. pickingInfo.bv = intersectInfo.bv || 0;
  79357. pickingInfo.faceId = intersectInfo.faceId;
  79358. pickingInfo.subMeshId = intersectInfo.subMeshId;
  79359. return pickingInfo;
  79360. }
  79361. return pickingInfo;
  79362. };
  79363. /**
  79364. * Clones the current mesh
  79365. * @param name defines the mesh name
  79366. * @param newParent defines the new mesh parent
  79367. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79368. * @returns the new mesh
  79369. */
  79370. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79371. return null;
  79372. };
  79373. /**
  79374. * Disposes all the submeshes of the current meshnp
  79375. * @returns the current mesh
  79376. */
  79377. AbstractMesh.prototype.releaseSubMeshes = function () {
  79378. if (this.subMeshes) {
  79379. while (this.subMeshes.length) {
  79380. this.subMeshes[0].dispose();
  79381. }
  79382. }
  79383. else {
  79384. this.subMeshes = new Array();
  79385. }
  79386. return this;
  79387. };
  79388. /**
  79389. * Releases resources associated with this abstract mesh.
  79390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79392. */
  79393. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  79394. var _this = this;
  79395. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  79396. var index;
  79397. // Smart Array Retainers.
  79398. this.getScene().freeActiveMeshes();
  79399. this.getScene().freeRenderingGroups();
  79400. // Action manager
  79401. if (this.actionManager !== undefined && this.actionManager !== null) {
  79402. this.actionManager.dispose();
  79403. this.actionManager = null;
  79404. }
  79405. // Skeleton
  79406. this._skeleton = null;
  79407. // Intersections in progress
  79408. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  79409. var other = this._intersectionsInProgress[index];
  79410. var pos = other._intersectionsInProgress.indexOf(this);
  79411. other._intersectionsInProgress.splice(pos, 1);
  79412. }
  79413. this._intersectionsInProgress = [];
  79414. // Lights
  79415. var lights = this.getScene().lights;
  79416. lights.forEach(function (light) {
  79417. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  79418. if (meshIndex !== -1) {
  79419. light.includedOnlyMeshes.splice(meshIndex, 1);
  79420. }
  79421. meshIndex = light.excludedMeshes.indexOf(_this);
  79422. if (meshIndex !== -1) {
  79423. light.excludedMeshes.splice(meshIndex, 1);
  79424. }
  79425. // Shadow generators
  79426. var generator = light.getShadowGenerator();
  79427. if (generator) {
  79428. var shadowMap = generator.getShadowMap();
  79429. if (shadowMap && shadowMap.renderList) {
  79430. meshIndex = shadowMap.renderList.indexOf(_this);
  79431. if (meshIndex !== -1) {
  79432. shadowMap.renderList.splice(meshIndex, 1);
  79433. }
  79434. }
  79435. }
  79436. });
  79437. // SubMeshes
  79438. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  79439. this.releaseSubMeshes();
  79440. }
  79441. // Query
  79442. var engine = this.getScene().getEngine();
  79443. if (this._occlusionQuery) {
  79444. this.isOcclusionQueryInProgress = false;
  79445. engine.deleteQuery(this._occlusionQuery);
  79446. this._occlusionQuery = null;
  79447. }
  79448. // Engine
  79449. engine.wipeCaches();
  79450. // Remove from scene
  79451. this.getScene().removeMesh(this);
  79452. if (disposeMaterialAndTextures) {
  79453. if (this.material) {
  79454. this.material.dispose(false, true);
  79455. }
  79456. }
  79457. if (!doNotRecurse) {
  79458. // Particles
  79459. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  79460. if (this.getScene().particleSystems[index].emitter === this) {
  79461. this.getScene().particleSystems[index].dispose();
  79462. index--;
  79463. }
  79464. }
  79465. }
  79466. // facet data
  79467. if (this._facetData.facetDataEnabled) {
  79468. this.disableFacetData();
  79469. }
  79470. this.onAfterWorldMatrixUpdateObservable.clear();
  79471. this.onCollideObservable.clear();
  79472. this.onCollisionPositionChangeObservable.clear();
  79473. this.onRebuildObservable.clear();
  79474. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  79475. };
  79476. /**
  79477. * Adds the passed mesh as a child to the current mesh
  79478. * @param mesh defines the child mesh
  79479. * @returns the current mesh
  79480. */
  79481. AbstractMesh.prototype.addChild = function (mesh) {
  79482. mesh.setParent(this);
  79483. return this;
  79484. };
  79485. /**
  79486. * Removes the passed mesh from the current mesh children list
  79487. * @param mesh defines the child mesh
  79488. * @returns the current mesh
  79489. */
  79490. AbstractMesh.prototype.removeChild = function (mesh) {
  79491. mesh.setParent(null);
  79492. return this;
  79493. };
  79494. // Facet data
  79495. /** @hidden */
  79496. AbstractMesh.prototype._initFacetData = function () {
  79497. var data = this._facetData;
  79498. if (!data.facetNormals) {
  79499. data.facetNormals = new Array();
  79500. }
  79501. if (!data.facetPositions) {
  79502. data.facetPositions = new Array();
  79503. }
  79504. if (!data.facetPartitioning) {
  79505. data.facetPartitioning = new Array();
  79506. }
  79507. data.facetNb = (this.getIndices().length / 3) | 0;
  79508. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  79509. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  79510. for (var f = 0; f < data.facetNb; f++) {
  79511. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79512. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79513. }
  79514. data.facetDataEnabled = true;
  79515. return this;
  79516. };
  79517. /**
  79518. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79519. * This method can be called within the render loop.
  79520. * 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
  79521. * @returns the current mesh
  79522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79523. */
  79524. AbstractMesh.prototype.updateFacetData = function () {
  79525. var data = this._facetData;
  79526. if (!data.facetDataEnabled) {
  79527. this._initFacetData();
  79528. }
  79529. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79530. var indices = this.getIndices();
  79531. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  79532. var bInfo = this.getBoundingInfo();
  79533. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  79534. // init arrays, matrix and sort function on first call
  79535. data.facetDepthSortEnabled = true;
  79536. if (indices instanceof Uint16Array) {
  79537. data.depthSortedIndices = new Uint16Array(indices);
  79538. }
  79539. else if (indices instanceof Uint32Array) {
  79540. data.depthSortedIndices = new Uint32Array(indices);
  79541. }
  79542. else {
  79543. var needs32bits = false;
  79544. for (var i = 0; i < indices.length; i++) {
  79545. if (indices[i] > 65535) {
  79546. needs32bits = true;
  79547. break;
  79548. }
  79549. }
  79550. if (needs32bits) {
  79551. data.depthSortedIndices = new Uint32Array(indices);
  79552. }
  79553. else {
  79554. data.depthSortedIndices = new Uint16Array(indices);
  79555. }
  79556. }
  79557. data.facetDepthSortFunction = function (f1, f2) {
  79558. return (f2.sqDistance - f1.sqDistance);
  79559. };
  79560. if (!data.facetDepthSortFrom) {
  79561. var camera = this.getScene().activeCamera;
  79562. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79563. }
  79564. data.depthSortedFacets = [];
  79565. for (var f = 0; f < data.facetNb; f++) {
  79566. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  79567. data.depthSortedFacets.push(depthSortedFacet);
  79568. }
  79569. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  79570. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79571. }
  79572. 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"];
  79573. 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"];
  79574. 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"];
  79575. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  79576. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  79577. data.subDiv.max = data.partitioningSubdivisions;
  79578. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  79579. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  79580. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  79581. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  79582. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  79583. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  79584. // set the parameters for ComputeNormals()
  79585. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  79586. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  79587. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  79588. data.facetParameters.bInfo = bInfo;
  79589. data.facetParameters.bbSize = data.bbSize;
  79590. data.facetParameters.subDiv = data.subDiv;
  79591. data.facetParameters.ratio = this.partitioningBBoxRatio;
  79592. data.facetParameters.depthSort = data.facetDepthSort;
  79593. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79594. this.computeWorldMatrix(true);
  79595. this._worldMatrix.invertToRef(data.invertedMatrix);
  79596. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  79597. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  79598. }
  79599. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  79600. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  79601. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79602. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  79603. var l = (data.depthSortedIndices.length / 3) | 0;
  79604. for (var f = 0; f < l; f++) {
  79605. var sind = data.depthSortedFacets[f].ind;
  79606. data.depthSortedIndices[f * 3] = indices[sind];
  79607. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  79608. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  79609. }
  79610. this.updateIndices(data.depthSortedIndices);
  79611. }
  79612. return this;
  79613. };
  79614. /**
  79615. * Returns the facetLocalNormals array.
  79616. * The normals are expressed in the mesh local spac
  79617. * @returns an array of Vector3
  79618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79619. */
  79620. AbstractMesh.prototype.getFacetLocalNormals = function () {
  79621. if (!this._facetData.facetNormals) {
  79622. this.updateFacetData();
  79623. }
  79624. return this._facetData.facetNormals;
  79625. };
  79626. /**
  79627. * Returns the facetLocalPositions array.
  79628. * The facet positions are expressed in the mesh local space
  79629. * @returns an array of Vector3
  79630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79631. */
  79632. AbstractMesh.prototype.getFacetLocalPositions = function () {
  79633. if (!this._facetData.facetPositions) {
  79634. this.updateFacetData();
  79635. }
  79636. return this._facetData.facetPositions;
  79637. };
  79638. /**
  79639. * Returns the facetLocalPartioning array
  79640. * @returns an array of array of numbers
  79641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79642. */
  79643. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  79644. if (!this._facetData.facetPartitioning) {
  79645. this.updateFacetData();
  79646. }
  79647. return this._facetData.facetPartitioning;
  79648. };
  79649. /**
  79650. * Returns the i-th facet position in the world system.
  79651. * This method allocates a new Vector3 per call
  79652. * @param i defines the facet index
  79653. * @returns a new Vector3
  79654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79655. */
  79656. AbstractMesh.prototype.getFacetPosition = function (i) {
  79657. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79658. this.getFacetPositionToRef(i, pos);
  79659. return pos;
  79660. };
  79661. /**
  79662. * Sets the reference Vector3 with the i-th facet position in the world system
  79663. * @param i defines the facet index
  79664. * @param ref defines the target vector
  79665. * @returns the current mesh
  79666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79667. */
  79668. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  79669. var localPos = (this.getFacetLocalPositions())[i];
  79670. var world = this.getWorldMatrix();
  79671. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  79672. return this;
  79673. };
  79674. /**
  79675. * Returns the i-th facet normal in the world system.
  79676. * This method allocates a new Vector3 per call
  79677. * @param i defines the facet index
  79678. * @returns a new Vector3
  79679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79680. */
  79681. AbstractMesh.prototype.getFacetNormal = function (i) {
  79682. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79683. this.getFacetNormalToRef(i, norm);
  79684. return norm;
  79685. };
  79686. /**
  79687. * Sets the reference Vector3 with the i-th facet normal in the world system
  79688. * @param i defines the facet index
  79689. * @param ref defines the target vector
  79690. * @returns the current mesh
  79691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79692. */
  79693. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  79694. var localNorm = (this.getFacetLocalNormals())[i];
  79695. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  79696. return this;
  79697. };
  79698. /**
  79699. * 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)
  79700. * @param x defines x coordinate
  79701. * @param y defines y coordinate
  79702. * @param z defines z coordinate
  79703. * @returns the array of facet indexes
  79704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79705. */
  79706. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  79707. var bInfo = this.getBoundingInfo();
  79708. var data = this._facetData;
  79709. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  79710. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  79711. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  79712. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  79713. return null;
  79714. }
  79715. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  79716. };
  79717. /**
  79718. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79719. * @param projected sets as the (x,y,z) world projection on the facet
  79720. * @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
  79721. * @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
  79722. * @param x defines x coordinate
  79723. * @param y defines y coordinate
  79724. * @param z defines z coordinate
  79725. * @returns the face index if found (or null instead)
  79726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79727. */
  79728. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  79729. if (checkFace === void 0) { checkFace = false; }
  79730. if (facing === void 0) { facing = true; }
  79731. var world = this.getWorldMatrix();
  79732. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  79733. world.invertToRef(invMat);
  79734. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  79735. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  79736. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  79737. if (projected) {
  79738. // tranform the local computed projected vector to world coordinates
  79739. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  79740. }
  79741. return closest;
  79742. };
  79743. /**
  79744. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79745. * @param projected sets as the (x,y,z) local projection on the facet
  79746. * @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
  79747. * @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
  79748. * @param x defines x coordinate
  79749. * @param y defines y coordinate
  79750. * @param z defines z coordinate
  79751. * @returns the face index if found (or null instead)
  79752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79753. */
  79754. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  79755. if (checkFace === void 0) { checkFace = false; }
  79756. if (facing === void 0) { facing = true; }
  79757. var closest = null;
  79758. var tmpx = 0.0;
  79759. var tmpy = 0.0;
  79760. var tmpz = 0.0;
  79761. var d = 0.0; // tmp dot facet normal * facet position
  79762. var t0 = 0.0;
  79763. var projx = 0.0;
  79764. var projy = 0.0;
  79765. var projz = 0.0;
  79766. // Get all the facets in the same partitioning block than (x, y, z)
  79767. var facetPositions = this.getFacetLocalPositions();
  79768. var facetNormals = this.getFacetLocalNormals();
  79769. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  79770. if (!facetsInBlock) {
  79771. return null;
  79772. }
  79773. // Get the closest facet to (x, y, z)
  79774. var shortest = Number.MAX_VALUE; // init distance vars
  79775. var tmpDistance = shortest;
  79776. var fib; // current facet in the block
  79777. var norm; // current facet normal
  79778. var p0; // current facet barycenter position
  79779. // loop on all the facets in the current partitioning block
  79780. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  79781. fib = facetsInBlock[idx];
  79782. norm = facetNormals[fib];
  79783. p0 = facetPositions[fib];
  79784. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  79785. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  79786. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  79787. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  79788. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  79789. projx = x + norm.x * t0;
  79790. projy = y + norm.y * t0;
  79791. projz = z + norm.z * t0;
  79792. tmpx = projx - x;
  79793. tmpy = projy - y;
  79794. tmpz = projz - z;
  79795. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  79796. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  79797. shortest = tmpDistance;
  79798. closest = fib;
  79799. if (projected) {
  79800. projected.x = projx;
  79801. projected.y = projy;
  79802. projected.z = projz;
  79803. }
  79804. }
  79805. }
  79806. }
  79807. return closest;
  79808. };
  79809. /**
  79810. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79811. * @returns the parameters
  79812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79813. */
  79814. AbstractMesh.prototype.getFacetDataParameters = function () {
  79815. return this._facetData.facetParameters;
  79816. };
  79817. /**
  79818. * Disables the feature FacetData and frees the related memory
  79819. * @returns the current mesh
  79820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79821. */
  79822. AbstractMesh.prototype.disableFacetData = function () {
  79823. if (this._facetData.facetDataEnabled) {
  79824. this._facetData.facetDataEnabled = false;
  79825. this._facetData.facetPositions = new Array();
  79826. this._facetData.facetNormals = new Array();
  79827. this._facetData.facetPartitioning = new Array();
  79828. this._facetData.facetParameters = null;
  79829. this._facetData.depthSortedIndices = new Uint32Array(0);
  79830. }
  79831. return this;
  79832. };
  79833. /**
  79834. * Updates the AbstractMesh indices array
  79835. * @param indices defines the data source
  79836. * @returns the current mesh
  79837. */
  79838. AbstractMesh.prototype.updateIndices = function (indices) {
  79839. return this;
  79840. };
  79841. /**
  79842. * Creates new normals data for the mesh
  79843. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  79844. * @returns the current mesh
  79845. */
  79846. AbstractMesh.prototype.createNormals = function (updatable) {
  79847. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79848. var indices = this.getIndices();
  79849. var normals;
  79850. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  79851. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  79852. }
  79853. else {
  79854. normals = [];
  79855. }
  79856. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  79857. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  79858. return this;
  79859. };
  79860. /**
  79861. * Align the mesh with a normal
  79862. * @param normal defines the normal to use
  79863. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  79864. * @returns the current mesh
  79865. */
  79866. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  79867. if (!upDirection) {
  79868. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  79869. }
  79870. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79871. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  79872. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  79873. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  79874. if (this.rotationQuaternion) {
  79875. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  79876. }
  79877. else {
  79878. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  79879. }
  79880. return this;
  79881. };
  79882. /** @hidden */
  79883. AbstractMesh.prototype._checkOcclusionQuery = function () {
  79884. return false;
  79885. };
  79886. /** No occlusion */
  79887. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  79888. /** Occlusion set to optimisitic */
  79889. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  79890. /** Occlusion set to strict */
  79891. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  79892. /** Use an accurante occlusion algorithm */
  79893. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  79894. /** Use a conservative occlusion algorithm */
  79895. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  79896. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79897. * Test order :
  79898. * Is the bounding sphere outside the frustum ?
  79899. * If not, are the bounding box vertices outside the frustum ?
  79900. * It not, then the cullable object is in the frustum.
  79901. */
  79902. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  79903. /** Culling strategy : Bounding Sphere Only.
  79904. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79905. * It's also less accurate than the standard because some not visible objects can still be selected.
  79906. * Test : is the bounding sphere outside the frustum ?
  79907. * If not, then the cullable object is in the frustum.
  79908. */
  79909. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  79910. /** Culling strategy : Optimistic Inclusion.
  79911. * This in an inclusion test first, then the standard exclusion test.
  79912. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79913. * 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.
  79914. * Anyway, it's as accurate as the standard strategy.
  79915. * Test :
  79916. * Is the cullable object bounding sphere center in the frustum ?
  79917. * If not, apply the default culling strategy.
  79918. */
  79919. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  79920. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79921. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79922. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79923. * 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.
  79924. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79925. * Test :
  79926. * Is the cullable object bounding sphere center in the frustum ?
  79927. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79928. */
  79929. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  79930. return AbstractMesh;
  79931. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  79932. /***/ }),
  79933. /***/ "./Meshes/buffer.ts":
  79934. /*!**************************!*\
  79935. !*** ./Meshes/buffer.ts ***!
  79936. \**************************/
  79937. /*! exports provided: Buffer, VertexBuffer */
  79938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79939. "use strict";
  79940. __webpack_require__.r(__webpack_exports__);
  79941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  79942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  79943. /**
  79944. * Class used to store data that will be store in GPU memory
  79945. */
  79946. var Buffer = /** @class */ (function () {
  79947. /**
  79948. * Constructor
  79949. * @param engine the engine
  79950. * @param data the data to use for this buffer
  79951. * @param updatable whether the data is updatable
  79952. * @param stride the stride (optional)
  79953. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79954. * @param instanced whether the buffer is instanced (optional)
  79955. * @param useBytes set to true if the stride in in bytes (optional)
  79956. */
  79957. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  79958. if (stride === void 0) { stride = 0; }
  79959. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  79960. if (instanced === void 0) { instanced = false; }
  79961. if (useBytes === void 0) { useBytes = false; }
  79962. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  79963. this._engine = engine.getScene().getEngine();
  79964. }
  79965. else {
  79966. this._engine = engine;
  79967. }
  79968. this._updatable = updatable;
  79969. this._instanced = instanced;
  79970. this._data = data;
  79971. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  79972. if (!postponeInternalCreation) { // by default
  79973. this.create();
  79974. }
  79975. }
  79976. /**
  79977. * Create a new VertexBuffer based on the current buffer
  79978. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79979. * @param offset defines offset in the buffer (0 by default)
  79980. * @param size defines the size in floats of attributes (position is 3 for instance)
  79981. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79982. * @param instanced defines if the vertex buffer contains indexed data
  79983. * @param useBytes defines if the offset and stride are in bytes
  79984. * @returns the new vertex buffer
  79985. */
  79986. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  79987. if (useBytes === void 0) { useBytes = false; }
  79988. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  79989. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  79990. // a lot of these parameters are ignored as they are overriden by the buffer
  79991. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  79992. };
  79993. // Properties
  79994. /**
  79995. * Gets a boolean indicating if the Buffer is updatable?
  79996. * @returns true if the buffer is updatable
  79997. */
  79998. Buffer.prototype.isUpdatable = function () {
  79999. return this._updatable;
  80000. };
  80001. /**
  80002. * Gets current buffer's data
  80003. * @returns a DataArray or null
  80004. */
  80005. Buffer.prototype.getData = function () {
  80006. return this._data;
  80007. };
  80008. /**
  80009. * Gets underlying native buffer
  80010. * @returns underlying native buffer
  80011. */
  80012. Buffer.prototype.getBuffer = function () {
  80013. return this._buffer;
  80014. };
  80015. /**
  80016. * Gets the stride in float32 units (i.e. byte stride / 4).
  80017. * May not be an integer if the byte stride is not divisible by 4.
  80018. * DEPRECATED. Use byteStride instead.
  80019. * @returns the stride in float32 units
  80020. */
  80021. Buffer.prototype.getStrideSize = function () {
  80022. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  80023. };
  80024. // Methods
  80025. /**
  80026. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80027. * @param data defines the data to store
  80028. */
  80029. Buffer.prototype.create = function (data) {
  80030. if (data === void 0) { data = null; }
  80031. if (!data && this._buffer) {
  80032. return; // nothing to do
  80033. }
  80034. data = data || this._data;
  80035. if (!data) {
  80036. return;
  80037. }
  80038. if (!this._buffer) { // create buffer
  80039. if (this._updatable) {
  80040. this._buffer = this._engine.createDynamicVertexBuffer(data);
  80041. this._data = data;
  80042. }
  80043. else {
  80044. this._buffer = this._engine.createVertexBuffer(data);
  80045. }
  80046. }
  80047. else if (this._updatable) { // update buffer
  80048. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  80049. this._data = data;
  80050. }
  80051. };
  80052. /** @hidden */
  80053. Buffer.prototype._rebuild = function () {
  80054. this._buffer = null;
  80055. this.create(this._data);
  80056. };
  80057. /**
  80058. * Update current buffer data
  80059. * @param data defines the data to store
  80060. */
  80061. Buffer.prototype.update = function (data) {
  80062. this.create(data);
  80063. };
  80064. /**
  80065. * Updates the data directly.
  80066. * @param data the new data
  80067. * @param offset the new offset
  80068. * @param vertexCount the vertex count (optional)
  80069. * @param useBytes set to true if the offset is in bytes
  80070. */
  80071. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  80072. if (useBytes === void 0) { useBytes = false; }
  80073. if (!this._buffer) {
  80074. return;
  80075. }
  80076. if (this._updatable) { // update buffer
  80077. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  80078. this._data = null;
  80079. }
  80080. };
  80081. /**
  80082. * Release all resources
  80083. */
  80084. Buffer.prototype.dispose = function () {
  80085. if (!this._buffer) {
  80086. return;
  80087. }
  80088. if (this._engine._releaseBuffer(this._buffer)) {
  80089. this._buffer = null;
  80090. }
  80091. };
  80092. return Buffer;
  80093. }());
  80094. /**
  80095. * Specialized buffer used to store vertex data
  80096. */
  80097. var VertexBuffer = /** @class */ (function () {
  80098. /**
  80099. * Constructor
  80100. * @param engine the engine
  80101. * @param data the data to use for this vertex buffer
  80102. * @param kind the vertex buffer kind
  80103. * @param updatable whether the data is updatable
  80104. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80105. * @param stride the stride (optional)
  80106. * @param instanced whether the buffer is instanced (optional)
  80107. * @param offset the offset of the data (optional)
  80108. * @param size the number of components (optional)
  80109. * @param type the type of the component (optional)
  80110. * @param normalized whether the data contains normalized data (optional)
  80111. * @param useBytes set to true if stride and offset are in bytes (optional)
  80112. */
  80113. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  80114. if (normalized === void 0) { normalized = false; }
  80115. if (useBytes === void 0) { useBytes = false; }
  80116. if (data instanceof Buffer) {
  80117. this._buffer = data;
  80118. this._ownsBuffer = false;
  80119. }
  80120. else {
  80121. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  80122. this._ownsBuffer = true;
  80123. }
  80124. this._kind = kind;
  80125. if (type == undefined) {
  80126. var data_1 = this.getData();
  80127. this.type = VertexBuffer.FLOAT;
  80128. if (data_1 instanceof Int8Array) {
  80129. this.type = VertexBuffer.BYTE;
  80130. }
  80131. else if (data_1 instanceof Uint8Array) {
  80132. this.type = VertexBuffer.UNSIGNED_BYTE;
  80133. }
  80134. else if (data_1 instanceof Int16Array) {
  80135. this.type = VertexBuffer.SHORT;
  80136. }
  80137. else if (data_1 instanceof Uint16Array) {
  80138. this.type = VertexBuffer.UNSIGNED_SHORT;
  80139. }
  80140. else if (data_1 instanceof Int32Array) {
  80141. this.type = VertexBuffer.INT;
  80142. }
  80143. else if (data_1 instanceof Uint32Array) {
  80144. this.type = VertexBuffer.UNSIGNED_INT;
  80145. }
  80146. }
  80147. else {
  80148. this.type = type;
  80149. }
  80150. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  80151. if (useBytes) {
  80152. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  80153. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  80154. this.byteOffset = offset || 0;
  80155. }
  80156. else {
  80157. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  80158. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  80159. this.byteOffset = (offset || 0) * typeByteLength;
  80160. }
  80161. this.normalized = normalized;
  80162. this._instanced = instanced !== undefined ? instanced : false;
  80163. this._instanceDivisor = instanced ? 1 : 0;
  80164. }
  80165. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  80166. /**
  80167. * Gets or sets the instance divisor when in instanced mode
  80168. */
  80169. get: function () {
  80170. return this._instanceDivisor;
  80171. },
  80172. set: function (value) {
  80173. this._instanceDivisor = value;
  80174. if (value == 0) {
  80175. this._instanced = false;
  80176. }
  80177. else {
  80178. this._instanced = true;
  80179. }
  80180. },
  80181. enumerable: true,
  80182. configurable: true
  80183. });
  80184. /** @hidden */
  80185. VertexBuffer.prototype._rebuild = function () {
  80186. if (!this._buffer) {
  80187. return;
  80188. }
  80189. this._buffer._rebuild();
  80190. };
  80191. /**
  80192. * Returns the kind of the VertexBuffer (string)
  80193. * @returns a string
  80194. */
  80195. VertexBuffer.prototype.getKind = function () {
  80196. return this._kind;
  80197. };
  80198. // Properties
  80199. /**
  80200. * Gets a boolean indicating if the VertexBuffer is updatable?
  80201. * @returns true if the buffer is updatable
  80202. */
  80203. VertexBuffer.prototype.isUpdatable = function () {
  80204. return this._buffer.isUpdatable();
  80205. };
  80206. /**
  80207. * Gets current buffer's data
  80208. * @returns a DataArray or null
  80209. */
  80210. VertexBuffer.prototype.getData = function () {
  80211. return this._buffer.getData();
  80212. };
  80213. /**
  80214. * Gets underlying native buffer
  80215. * @returns underlying native buffer
  80216. */
  80217. VertexBuffer.prototype.getBuffer = function () {
  80218. return this._buffer.getBuffer();
  80219. };
  80220. /**
  80221. * Gets the stride in float32 units (i.e. byte stride / 4).
  80222. * May not be an integer if the byte stride is not divisible by 4.
  80223. * DEPRECATED. Use byteStride instead.
  80224. * @returns the stride in float32 units
  80225. */
  80226. VertexBuffer.prototype.getStrideSize = function () {
  80227. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  80228. };
  80229. /**
  80230. * Returns the offset as a multiple of the type byte length.
  80231. * DEPRECATED. Use byteOffset instead.
  80232. * @returns the offset in bytes
  80233. */
  80234. VertexBuffer.prototype.getOffset = function () {
  80235. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  80236. };
  80237. /**
  80238. * Returns the number of components per vertex attribute (integer)
  80239. * @returns the size in float
  80240. */
  80241. VertexBuffer.prototype.getSize = function () {
  80242. return this._size;
  80243. };
  80244. /**
  80245. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80246. * @returns true if this buffer is instanced
  80247. */
  80248. VertexBuffer.prototype.getIsInstanced = function () {
  80249. return this._instanced;
  80250. };
  80251. /**
  80252. * Returns the instancing divisor, zero for non-instanced (integer).
  80253. * @returns a number
  80254. */
  80255. VertexBuffer.prototype.getInstanceDivisor = function () {
  80256. return this._instanceDivisor;
  80257. };
  80258. // Methods
  80259. /**
  80260. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80261. * @param data defines the data to store
  80262. */
  80263. VertexBuffer.prototype.create = function (data) {
  80264. this._buffer.create(data);
  80265. };
  80266. /**
  80267. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80268. * This function will create a new buffer if the current one is not updatable
  80269. * @param data defines the data to store
  80270. */
  80271. VertexBuffer.prototype.update = function (data) {
  80272. this._buffer.update(data);
  80273. };
  80274. /**
  80275. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80276. * Returns the directly updated WebGLBuffer.
  80277. * @param data the new data
  80278. * @param offset the new offset
  80279. * @param useBytes set to true if the offset is in bytes
  80280. */
  80281. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  80282. if (useBytes === void 0) { useBytes = false; }
  80283. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  80284. };
  80285. /**
  80286. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80287. */
  80288. VertexBuffer.prototype.dispose = function () {
  80289. if (this._ownsBuffer) {
  80290. this._buffer.dispose();
  80291. }
  80292. };
  80293. /**
  80294. * Enumerates each value of this vertex buffer as numbers.
  80295. * @param count the number of values to enumerate
  80296. * @param callback the callback function called for each value
  80297. */
  80298. VertexBuffer.prototype.forEach = function (count, callback) {
  80299. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  80300. };
  80301. /**
  80302. * Deduces the stride given a kind.
  80303. * @param kind The kind string to deduce
  80304. * @returns The deduced stride
  80305. */
  80306. VertexBuffer.DeduceStride = function (kind) {
  80307. switch (kind) {
  80308. case VertexBuffer.UVKind:
  80309. case VertexBuffer.UV2Kind:
  80310. case VertexBuffer.UV3Kind:
  80311. case VertexBuffer.UV4Kind:
  80312. case VertexBuffer.UV5Kind:
  80313. case VertexBuffer.UV6Kind:
  80314. return 2;
  80315. case VertexBuffer.NormalKind:
  80316. case VertexBuffer.PositionKind:
  80317. return 3;
  80318. case VertexBuffer.ColorKind:
  80319. case VertexBuffer.MatricesIndicesKind:
  80320. case VertexBuffer.MatricesIndicesExtraKind:
  80321. case VertexBuffer.MatricesWeightsKind:
  80322. case VertexBuffer.MatricesWeightsExtraKind:
  80323. case VertexBuffer.TangentKind:
  80324. return 4;
  80325. default:
  80326. throw new Error("Invalid kind '" + kind + "'");
  80327. }
  80328. };
  80329. /**
  80330. * Gets the byte length of the given type.
  80331. * @param type the type
  80332. * @returns the number of bytes
  80333. */
  80334. VertexBuffer.GetTypeByteLength = function (type) {
  80335. switch (type) {
  80336. case VertexBuffer.BYTE:
  80337. case VertexBuffer.UNSIGNED_BYTE:
  80338. return 1;
  80339. case VertexBuffer.SHORT:
  80340. case VertexBuffer.UNSIGNED_SHORT:
  80341. return 2;
  80342. case VertexBuffer.INT:
  80343. case VertexBuffer.FLOAT:
  80344. return 4;
  80345. default:
  80346. throw new Error("Invalid type '" + type + "'");
  80347. }
  80348. };
  80349. /**
  80350. * Enumerates each value of the given parameters as numbers.
  80351. * @param data the data to enumerate
  80352. * @param byteOffset the byte offset of the data
  80353. * @param byteStride the byte stride of the data
  80354. * @param componentCount the number of components per element
  80355. * @param componentType the type of the component
  80356. * @param count the total number of components
  80357. * @param normalized whether the data is normalized
  80358. * @param callback the callback function called for each value
  80359. */
  80360. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  80361. if (data instanceof Array) {
  80362. var offset = byteOffset / 4;
  80363. var stride = byteStride / 4;
  80364. for (var index = 0; index < count; index += componentCount) {
  80365. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80366. callback(data[offset + componentIndex], index + componentIndex);
  80367. }
  80368. offset += stride;
  80369. }
  80370. }
  80371. else {
  80372. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  80373. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  80374. for (var index = 0; index < count; index += componentCount) {
  80375. var componentByteOffset = byteOffset;
  80376. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80377. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  80378. callback(value, index + componentIndex);
  80379. componentByteOffset += componentByteLength;
  80380. }
  80381. byteOffset += byteStride;
  80382. }
  80383. }
  80384. };
  80385. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  80386. switch (type) {
  80387. case VertexBuffer.BYTE: {
  80388. var value = dataView.getInt8(byteOffset);
  80389. if (normalized) {
  80390. value = Math.max(value / 127, -1);
  80391. }
  80392. return value;
  80393. }
  80394. case VertexBuffer.UNSIGNED_BYTE: {
  80395. var value = dataView.getUint8(byteOffset);
  80396. if (normalized) {
  80397. value = value / 255;
  80398. }
  80399. return value;
  80400. }
  80401. case VertexBuffer.SHORT: {
  80402. var value = dataView.getInt16(byteOffset, true);
  80403. if (normalized) {
  80404. value = Math.max(value / 16383, -1);
  80405. }
  80406. return value;
  80407. }
  80408. case VertexBuffer.UNSIGNED_SHORT: {
  80409. var value = dataView.getUint16(byteOffset, true);
  80410. if (normalized) {
  80411. value = value / 65535;
  80412. }
  80413. return value;
  80414. }
  80415. case VertexBuffer.FLOAT: {
  80416. return dataView.getFloat32(byteOffset, true);
  80417. }
  80418. default: {
  80419. throw new Error("Invalid component type " + type);
  80420. }
  80421. }
  80422. };
  80423. /**
  80424. * The byte type.
  80425. */
  80426. VertexBuffer.BYTE = 5120;
  80427. /**
  80428. * The unsigned byte type.
  80429. */
  80430. VertexBuffer.UNSIGNED_BYTE = 5121;
  80431. /**
  80432. * The short type.
  80433. */
  80434. VertexBuffer.SHORT = 5122;
  80435. /**
  80436. * The unsigned short type.
  80437. */
  80438. VertexBuffer.UNSIGNED_SHORT = 5123;
  80439. /**
  80440. * The integer type.
  80441. */
  80442. VertexBuffer.INT = 5124;
  80443. /**
  80444. * The unsigned integer type.
  80445. */
  80446. VertexBuffer.UNSIGNED_INT = 5125;
  80447. /**
  80448. * The float type.
  80449. */
  80450. VertexBuffer.FLOAT = 5126;
  80451. // Enums
  80452. /**
  80453. * Positions
  80454. */
  80455. VertexBuffer.PositionKind = "position";
  80456. /**
  80457. * Normals
  80458. */
  80459. VertexBuffer.NormalKind = "normal";
  80460. /**
  80461. * Tangents
  80462. */
  80463. VertexBuffer.TangentKind = "tangent";
  80464. /**
  80465. * Texture coordinates
  80466. */
  80467. VertexBuffer.UVKind = "uv";
  80468. /**
  80469. * Texture coordinates 2
  80470. */
  80471. VertexBuffer.UV2Kind = "uv2";
  80472. /**
  80473. * Texture coordinates 3
  80474. */
  80475. VertexBuffer.UV3Kind = "uv3";
  80476. /**
  80477. * Texture coordinates 4
  80478. */
  80479. VertexBuffer.UV4Kind = "uv4";
  80480. /**
  80481. * Texture coordinates 5
  80482. */
  80483. VertexBuffer.UV5Kind = "uv5";
  80484. /**
  80485. * Texture coordinates 6
  80486. */
  80487. VertexBuffer.UV6Kind = "uv6";
  80488. /**
  80489. * Colors
  80490. */
  80491. VertexBuffer.ColorKind = "color";
  80492. /**
  80493. * Matrix indices (for bones)
  80494. */
  80495. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  80496. /**
  80497. * Matrix weights (for bones)
  80498. */
  80499. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  80500. /**
  80501. * Additional matrix indices (for bones)
  80502. */
  80503. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  80504. /**
  80505. * Additional matrix weights (for bones)
  80506. */
  80507. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  80508. return VertexBuffer;
  80509. }());
  80510. /***/ }),
  80511. /***/ "./Meshes/csg.ts":
  80512. /*!***********************!*\
  80513. !*** ./Meshes/csg.ts ***!
  80514. \***********************/
  80515. /*! exports provided: CSG */
  80516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80517. "use strict";
  80518. __webpack_require__.r(__webpack_exports__);
  80519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  80520. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80521. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80522. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  80523. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80524. /**
  80525. * Unique ID when we import meshes from Babylon to CSG
  80526. */
  80527. var currentCSGMeshId = 0;
  80528. /**
  80529. * Represents a vertex of a polygon. Use your own vertex class instead of this
  80530. * one to provide additional features like texture coordinates and vertex
  80531. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  80532. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  80533. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  80534. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  80535. * is not used anywhere else.
  80536. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  80537. */
  80538. var Vertex = /** @class */ (function () {
  80539. /**
  80540. * Initializes the vertex
  80541. * @param pos The position of the vertex
  80542. * @param normal The normal of the vertex
  80543. * @param uv The texture coordinate of the vertex
  80544. */
  80545. function Vertex(
  80546. /**
  80547. * The position of the vertex
  80548. */
  80549. pos,
  80550. /**
  80551. * The normal of the vertex
  80552. */
  80553. normal,
  80554. /**
  80555. * The texture coordinate of the vertex
  80556. */
  80557. uv) {
  80558. this.pos = pos;
  80559. this.normal = normal;
  80560. this.uv = uv;
  80561. }
  80562. /**
  80563. * Make a clone, or deep copy, of the vertex
  80564. * @returns A new Vertex
  80565. */
  80566. Vertex.prototype.clone = function () {
  80567. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  80568. };
  80569. /**
  80570. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  80571. * orientation of a polygon is flipped.
  80572. */
  80573. Vertex.prototype.flip = function () {
  80574. this.normal = this.normal.scale(-1);
  80575. };
  80576. /**
  80577. * Create a new vertex between this vertex and `other` by linearly
  80578. * interpolating all properties using a parameter of `t`. Subclasses should
  80579. * override this to interpolate additional properties.
  80580. * @param other the vertex to interpolate against
  80581. * @param t The factor used to linearly interpolate between the vertices
  80582. */
  80583. Vertex.prototype.interpolate = function (other, t) {
  80584. 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));
  80585. };
  80586. return Vertex;
  80587. }());
  80588. /**
  80589. * Represents a plane in 3D space.
  80590. */
  80591. var Plane = /** @class */ (function () {
  80592. /**
  80593. * Initializes the plane
  80594. * @param normal The normal for the plane
  80595. * @param w
  80596. */
  80597. function Plane(normal, w) {
  80598. this.normal = normal;
  80599. this.w = w;
  80600. }
  80601. /**
  80602. * Construct a plane from three points
  80603. * @param a Point a
  80604. * @param b Point b
  80605. * @param c Point c
  80606. */
  80607. Plane.FromPoints = function (a, b, c) {
  80608. var v0 = c.subtract(a);
  80609. var v1 = b.subtract(a);
  80610. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  80611. return null;
  80612. }
  80613. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  80614. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  80615. };
  80616. /**
  80617. * Clone, or make a deep copy of the plane
  80618. * @returns a new Plane
  80619. */
  80620. Plane.prototype.clone = function () {
  80621. return new Plane(this.normal.clone(), this.w);
  80622. };
  80623. /**
  80624. * Flip the face of the plane
  80625. */
  80626. Plane.prototype.flip = function () {
  80627. this.normal.scaleInPlace(-1);
  80628. this.w = -this.w;
  80629. };
  80630. /**
  80631. * Split `polygon` by this plane if needed, then put the polygon or polygon
  80632. * fragments in the appropriate lists. Coplanar polygons go into either
  80633. `* coplanarFront` or `coplanarBack` depending on their orientation with
  80634. * respect to this plane. Polygons in front or in back of this plane go into
  80635. * either `front` or `back`
  80636. * @param polygon The polygon to be split
  80637. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  80638. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  80639. * @param front Will contain the polygons in front of the plane
  80640. * @param back Will contain the polygons begind the plane
  80641. */
  80642. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  80643. var COPLANAR = 0;
  80644. var FRONT = 1;
  80645. var BACK = 2;
  80646. var SPANNING = 3;
  80647. // Classify each point as well as the entire polygon into one of the above
  80648. // four classes.
  80649. var polygonType = 0;
  80650. var types = [];
  80651. var i;
  80652. var t;
  80653. for (i = 0; i < polygon.vertices.length; i++) {
  80654. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  80655. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  80656. polygonType |= type;
  80657. types.push(type);
  80658. }
  80659. // Put the polygon in the correct list, splitting it when necessary
  80660. switch (polygonType) {
  80661. case COPLANAR:
  80662. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  80663. break;
  80664. case FRONT:
  80665. front.push(polygon);
  80666. break;
  80667. case BACK:
  80668. back.push(polygon);
  80669. break;
  80670. case SPANNING:
  80671. var f = [], b = [];
  80672. for (i = 0; i < polygon.vertices.length; i++) {
  80673. var j = (i + 1) % polygon.vertices.length;
  80674. var ti = types[i], tj = types[j];
  80675. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  80676. if (ti !== BACK) {
  80677. f.push(vi);
  80678. }
  80679. if (ti !== FRONT) {
  80680. b.push(ti !== BACK ? vi.clone() : vi);
  80681. }
  80682. if ((ti | tj) === SPANNING) {
  80683. 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));
  80684. var v = vi.interpolate(vj, t);
  80685. f.push(v);
  80686. b.push(v.clone());
  80687. }
  80688. }
  80689. var poly;
  80690. if (f.length >= 3) {
  80691. poly = new Polygon(f, polygon.shared);
  80692. if (poly.plane) {
  80693. front.push(poly);
  80694. }
  80695. }
  80696. if (b.length >= 3) {
  80697. poly = new Polygon(b, polygon.shared);
  80698. if (poly.plane) {
  80699. back.push(poly);
  80700. }
  80701. }
  80702. break;
  80703. }
  80704. };
  80705. /**
  80706. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  80707. * point is on the plane
  80708. */
  80709. Plane.EPSILON = 1e-5;
  80710. return Plane;
  80711. }());
  80712. /**
  80713. * Represents a convex polygon. The vertices used to initialize a polygon must
  80714. * be coplanar and form a convex loop.
  80715. *
  80716. * Each convex polygon has a `shared` property, which is shared between all
  80717. * polygons that are clones of each other or were split from the same polygon.
  80718. * This can be used to define per-polygon properties (such as surface color)
  80719. */
  80720. var Polygon = /** @class */ (function () {
  80721. /**
  80722. * Initializes the polygon
  80723. * @param vertices The vertices of the polygon
  80724. * @param shared The properties shared across all polygons
  80725. */
  80726. function Polygon(vertices, shared) {
  80727. this.vertices = vertices;
  80728. this.shared = shared;
  80729. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  80730. }
  80731. /**
  80732. * Clones, or makes a deep copy, or the polygon
  80733. */
  80734. Polygon.prototype.clone = function () {
  80735. var vertices = this.vertices.map(function (v) { return v.clone(); });
  80736. return new Polygon(vertices, this.shared);
  80737. };
  80738. /**
  80739. * Flips the faces of the polygon
  80740. */
  80741. Polygon.prototype.flip = function () {
  80742. this.vertices.reverse().map(function (v) { v.flip(); });
  80743. this.plane.flip();
  80744. };
  80745. return Polygon;
  80746. }());
  80747. /**
  80748. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  80749. * by picking a polygon to split along. That polygon (and all other coplanar
  80750. * polygons) are added directly to that node and the other polygons are added to
  80751. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  80752. * no distinction between internal and leaf nodes
  80753. */
  80754. var Node = /** @class */ (function () {
  80755. /**
  80756. * Initializes the node
  80757. * @param polygons A collection of polygons held in the node
  80758. */
  80759. function Node(polygons) {
  80760. this.plane = null;
  80761. this.front = null;
  80762. this.back = null;
  80763. this.polygons = new Array();
  80764. if (polygons) {
  80765. this.build(polygons);
  80766. }
  80767. }
  80768. /**
  80769. * Clones, or makes a deep copy, of the node
  80770. * @returns The cloned node
  80771. */
  80772. Node.prototype.clone = function () {
  80773. var node = new Node();
  80774. node.plane = this.plane && this.plane.clone();
  80775. node.front = this.front && this.front.clone();
  80776. node.back = this.back && this.back.clone();
  80777. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  80778. return node;
  80779. };
  80780. /**
  80781. * Convert solid space to empty space and empty space to solid space
  80782. */
  80783. Node.prototype.invert = function () {
  80784. for (var i = 0; i < this.polygons.length; i++) {
  80785. this.polygons[i].flip();
  80786. }
  80787. if (this.plane) {
  80788. this.plane.flip();
  80789. }
  80790. if (this.front) {
  80791. this.front.invert();
  80792. }
  80793. if (this.back) {
  80794. this.back.invert();
  80795. }
  80796. var temp = this.front;
  80797. this.front = this.back;
  80798. this.back = temp;
  80799. };
  80800. /**
  80801. * Recursively remove all polygons in `polygons` that are inside this BSP
  80802. * tree.
  80803. * @param polygons Polygons to remove from the BSP
  80804. * @returns Polygons clipped from the BSP
  80805. */
  80806. Node.prototype.clipPolygons = function (polygons) {
  80807. if (!this.plane) {
  80808. return polygons.slice();
  80809. }
  80810. var front = new Array(), back = new Array();
  80811. for (var i = 0; i < polygons.length; i++) {
  80812. this.plane.splitPolygon(polygons[i], front, back, front, back);
  80813. }
  80814. if (this.front) {
  80815. front = this.front.clipPolygons(front);
  80816. }
  80817. if (this.back) {
  80818. back = this.back.clipPolygons(back);
  80819. }
  80820. else {
  80821. back = [];
  80822. }
  80823. return front.concat(back);
  80824. };
  80825. /**
  80826. * Remove all polygons in this BSP tree that are inside the other BSP tree
  80827. * `bsp`.
  80828. * @param bsp BSP containing polygons to remove from this BSP
  80829. */
  80830. Node.prototype.clipTo = function (bsp) {
  80831. this.polygons = bsp.clipPolygons(this.polygons);
  80832. if (this.front) {
  80833. this.front.clipTo(bsp);
  80834. }
  80835. if (this.back) {
  80836. this.back.clipTo(bsp);
  80837. }
  80838. };
  80839. /**
  80840. * Return a list of all polygons in this BSP tree
  80841. * @returns List of all polygons in this BSP tree
  80842. */
  80843. Node.prototype.allPolygons = function () {
  80844. var polygons = this.polygons.slice();
  80845. if (this.front) {
  80846. polygons = polygons.concat(this.front.allPolygons());
  80847. }
  80848. if (this.back) {
  80849. polygons = polygons.concat(this.back.allPolygons());
  80850. }
  80851. return polygons;
  80852. };
  80853. /**
  80854. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  80855. * new polygons are filtered down to the bottom of the tree and become new
  80856. * nodes there. Each set of polygons is partitioned using the first polygon
  80857. * (no heuristic is used to pick a good split)
  80858. * @param polygons Polygons used to construct the BSP tree
  80859. */
  80860. Node.prototype.build = function (polygons) {
  80861. if (!polygons.length) {
  80862. return;
  80863. }
  80864. if (!this.plane) {
  80865. this.plane = polygons[0].plane.clone();
  80866. }
  80867. var front = new Array(), back = new Array();
  80868. for (var i = 0; i < polygons.length; i++) {
  80869. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  80870. }
  80871. if (front.length) {
  80872. if (!this.front) {
  80873. this.front = new Node();
  80874. }
  80875. this.front.build(front);
  80876. }
  80877. if (back.length) {
  80878. if (!this.back) {
  80879. this.back = new Node();
  80880. }
  80881. this.back.build(back);
  80882. }
  80883. };
  80884. return Node;
  80885. }());
  80886. /**
  80887. * Class for building Constructive Solid Geometry
  80888. */
  80889. var CSG = /** @class */ (function () {
  80890. function CSG() {
  80891. this.polygons = new Array();
  80892. }
  80893. /**
  80894. * Convert the Mesh to CSG
  80895. * @param mesh The Mesh to convert to CSG
  80896. * @returns A new CSG from the Mesh
  80897. */
  80898. CSG.FromMesh = function (mesh) {
  80899. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  80900. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  80901. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  80902. mesh.computeWorldMatrix(true);
  80903. matrix = mesh.getWorldMatrix();
  80904. meshPosition = mesh.position.clone();
  80905. meshRotation = mesh.rotation.clone();
  80906. if (mesh.rotationQuaternion) {
  80907. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  80908. }
  80909. meshScaling = mesh.scaling.clone();
  80910. }
  80911. else {
  80912. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  80913. }
  80914. 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);
  80915. var subMeshes = mesh.subMeshes;
  80916. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  80917. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  80918. vertices = [];
  80919. for (var j = 0; j < 3; j++) {
  80920. 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]);
  80921. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  80922. 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]);
  80923. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  80924. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  80925. vertex = new Vertex(position, normal, uv);
  80926. vertices.push(vertex);
  80927. }
  80928. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  80929. // To handle the case of degenerated triangle
  80930. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  80931. if (polygon.plane) {
  80932. polygons.push(polygon);
  80933. }
  80934. }
  80935. }
  80936. var csg = CSG.FromPolygons(polygons);
  80937. csg.matrix = matrix;
  80938. csg.position = meshPosition;
  80939. csg.rotation = meshRotation;
  80940. csg.scaling = meshScaling;
  80941. csg.rotationQuaternion = meshRotationQuaternion;
  80942. currentCSGMeshId++;
  80943. return csg;
  80944. };
  80945. /**
  80946. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  80947. * @param polygons Polygons used to construct a CSG solid
  80948. */
  80949. CSG.FromPolygons = function (polygons) {
  80950. var csg = new CSG();
  80951. csg.polygons = polygons;
  80952. return csg;
  80953. };
  80954. /**
  80955. * Clones, or makes a deep copy, of the CSG
  80956. * @returns A new CSG
  80957. */
  80958. CSG.prototype.clone = function () {
  80959. var csg = new CSG();
  80960. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  80961. csg.copyTransformAttributes(this);
  80962. return csg;
  80963. };
  80964. /**
  80965. * Unions this CSG with another CSG
  80966. * @param csg The CSG to union against this CSG
  80967. * @returns The unioned CSG
  80968. */
  80969. CSG.prototype.union = function (csg) {
  80970. var a = new Node(this.clone().polygons);
  80971. var b = new Node(csg.clone().polygons);
  80972. a.clipTo(b);
  80973. b.clipTo(a);
  80974. b.invert();
  80975. b.clipTo(a);
  80976. b.invert();
  80977. a.build(b.allPolygons());
  80978. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  80979. };
  80980. /**
  80981. * Unions this CSG with another CSG in place
  80982. * @param csg The CSG to union against this CSG
  80983. */
  80984. CSG.prototype.unionInPlace = function (csg) {
  80985. var a = new Node(this.polygons);
  80986. var b = new Node(csg.polygons);
  80987. a.clipTo(b);
  80988. b.clipTo(a);
  80989. b.invert();
  80990. b.clipTo(a);
  80991. b.invert();
  80992. a.build(b.allPolygons());
  80993. this.polygons = a.allPolygons();
  80994. };
  80995. /**
  80996. * Subtracts this CSG with another CSG
  80997. * @param csg The CSG to subtract against this CSG
  80998. * @returns A new CSG
  80999. */
  81000. CSG.prototype.subtract = function (csg) {
  81001. var a = new Node(this.clone().polygons);
  81002. var b = new Node(csg.clone().polygons);
  81003. a.invert();
  81004. a.clipTo(b);
  81005. b.clipTo(a);
  81006. b.invert();
  81007. b.clipTo(a);
  81008. b.invert();
  81009. a.build(b.allPolygons());
  81010. a.invert();
  81011. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81012. };
  81013. /**
  81014. * Subtracts this CSG with another CSG in place
  81015. * @param csg The CSG to subtact against this CSG
  81016. */
  81017. CSG.prototype.subtractInPlace = function (csg) {
  81018. var a = new Node(this.polygons);
  81019. var b = new Node(csg.polygons);
  81020. a.invert();
  81021. a.clipTo(b);
  81022. b.clipTo(a);
  81023. b.invert();
  81024. b.clipTo(a);
  81025. b.invert();
  81026. a.build(b.allPolygons());
  81027. a.invert();
  81028. this.polygons = a.allPolygons();
  81029. };
  81030. /**
  81031. * Intersect this CSG with another CSG
  81032. * @param csg The CSG to intersect against this CSG
  81033. * @returns A new CSG
  81034. */
  81035. CSG.prototype.intersect = function (csg) {
  81036. var a = new Node(this.clone().polygons);
  81037. var b = new Node(csg.clone().polygons);
  81038. a.invert();
  81039. b.clipTo(a);
  81040. b.invert();
  81041. a.clipTo(b);
  81042. b.clipTo(a);
  81043. a.build(b.allPolygons());
  81044. a.invert();
  81045. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81046. };
  81047. /**
  81048. * Intersects this CSG with another CSG in place
  81049. * @param csg The CSG to intersect against this CSG
  81050. */
  81051. CSG.prototype.intersectInPlace = function (csg) {
  81052. var a = new Node(this.polygons);
  81053. var b = new Node(csg.polygons);
  81054. a.invert();
  81055. b.clipTo(a);
  81056. b.invert();
  81057. a.clipTo(b);
  81058. b.clipTo(a);
  81059. a.build(b.allPolygons());
  81060. a.invert();
  81061. this.polygons = a.allPolygons();
  81062. };
  81063. /**
  81064. * Return a new CSG solid with solid and empty space switched. This solid is
  81065. * not modified.
  81066. * @returns A new CSG solid with solid and empty space switched
  81067. */
  81068. CSG.prototype.inverse = function () {
  81069. var csg = this.clone();
  81070. csg.inverseInPlace();
  81071. return csg;
  81072. };
  81073. /**
  81074. * Inverses the CSG in place
  81075. */
  81076. CSG.prototype.inverseInPlace = function () {
  81077. this.polygons.map(function (p) { p.flip(); });
  81078. };
  81079. /**
  81080. * This is used to keep meshes transformations so they can be restored
  81081. * when we build back a Babylon Mesh
  81082. * NB : All CSG operations are performed in world coordinates
  81083. * @param csg The CSG to copy the transform attributes from
  81084. * @returns This CSG
  81085. */
  81086. CSG.prototype.copyTransformAttributes = function (csg) {
  81087. this.matrix = csg.matrix;
  81088. this.position = csg.position;
  81089. this.rotation = csg.rotation;
  81090. this.scaling = csg.scaling;
  81091. this.rotationQuaternion = csg.rotationQuaternion;
  81092. return this;
  81093. };
  81094. /**
  81095. * Build Raw mesh from CSG
  81096. * Coordinates here are in world space
  81097. * @param name The name of the mesh geometry
  81098. * @param scene The Scene
  81099. * @param keepSubMeshes Specifies if the submeshes should be kept
  81100. * @returns A new Mesh
  81101. */
  81102. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  81103. var matrix = this.matrix.clone();
  81104. matrix.invert();
  81105. 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;
  81106. if (keepSubMeshes) {
  81107. // Sort Polygons, since subMeshes are indices range
  81108. polygons.sort(function (a, b) {
  81109. if (a.shared.meshId === b.shared.meshId) {
  81110. return a.shared.subMeshId - b.shared.subMeshId;
  81111. }
  81112. else {
  81113. return a.shared.meshId - b.shared.meshId;
  81114. }
  81115. });
  81116. }
  81117. for (var i = 0, il = polygons.length; i < il; i++) {
  81118. polygon = polygons[i];
  81119. // Building SubMeshes
  81120. if (!subMesh_dict[polygon.shared.meshId]) {
  81121. subMesh_dict[polygon.shared.meshId] = {};
  81122. }
  81123. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  81124. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  81125. indexStart: +Infinity,
  81126. indexEnd: -Infinity,
  81127. materialIndex: polygon.shared.materialIndex
  81128. };
  81129. }
  81130. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  81131. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  81132. polygonIndices[0] = 0;
  81133. polygonIndices[1] = j - 1;
  81134. polygonIndices[2] = j;
  81135. for (var k = 0; k < 3; k++) {
  81136. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  81137. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  81138. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  81139. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  81140. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  81141. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  81142. // Check if 2 points can be merged
  81143. if (!(typeof vertex_idx !== 'undefined' &&
  81144. normals[vertex_idx * 3] === localNormal.x &&
  81145. normals[vertex_idx * 3 + 1] === localNormal.y &&
  81146. normals[vertex_idx * 3 + 2] === localNormal.z &&
  81147. uvs[vertex_idx * 2] === uv.x &&
  81148. uvs[vertex_idx * 2 + 1] === uv.y)) {
  81149. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  81150. uvs.push(uv.x, uv.y);
  81151. normals.push(normal.x, normal.y, normal.z);
  81152. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  81153. }
  81154. indices.push(vertex_idx);
  81155. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  81156. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  81157. currentIndex++;
  81158. }
  81159. }
  81160. }
  81161. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  81162. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  81163. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  81164. mesh.setIndices(indices, null);
  81165. if (keepSubMeshes) {
  81166. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  81167. var materialIndexOffset = 0, materialMaxIndex;
  81168. mesh.subMeshes = new Array();
  81169. for (var m in subMesh_dict) {
  81170. materialMaxIndex = -1;
  81171. for (var sm in subMesh_dict[m]) {
  81172. subMesh_obj = subMesh_dict[m][sm];
  81173. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  81174. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  81175. }
  81176. materialIndexOffset += ++materialMaxIndex;
  81177. }
  81178. }
  81179. return mesh;
  81180. };
  81181. /**
  81182. * Build Mesh from CSG taking material and transforms into account
  81183. * @param name The name of the Mesh
  81184. * @param material The material of the Mesh
  81185. * @param scene The Scene
  81186. * @param keepSubMeshes Specifies if submeshes should be kept
  81187. * @returns The new Mesh
  81188. */
  81189. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  81190. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  81191. mesh.material = material;
  81192. mesh.position.copyFrom(this.position);
  81193. mesh.rotation.copyFrom(this.rotation);
  81194. if (this.rotationQuaternion) {
  81195. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  81196. }
  81197. mesh.scaling.copyFrom(this.scaling);
  81198. mesh.computeWorldMatrix(true);
  81199. return mesh;
  81200. };
  81201. return CSG;
  81202. }());
  81203. /***/ }),
  81204. /***/ "./Meshes/geometry.ts":
  81205. /*!****************************!*\
  81206. !*** ./Meshes/geometry.ts ***!
  81207. \****************************/
  81208. /*! exports provided: Geometry */
  81209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81210. "use strict";
  81211. __webpack_require__.r(__webpack_exports__);
  81212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  81213. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81214. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81215. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81216. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81217. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  81218. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81219. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81220. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81221. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  81222. /**
  81223. * Class used to store geometry data (vertex buffers + index buffer)
  81224. */
  81225. var Geometry = /** @class */ (function () {
  81226. /**
  81227. * Creates a new geometry
  81228. * @param id defines the unique ID
  81229. * @param scene defines the hosting scene
  81230. * @param vertexData defines the VertexData used to get geometry data
  81231. * @param updatable defines if geometry must be updatable (false by default)
  81232. * @param mesh defines the mesh that will be associated with the geometry
  81233. */
  81234. function Geometry(id, scene, vertexData, updatable, mesh) {
  81235. if (updatable === void 0) { updatable = false; }
  81236. if (mesh === void 0) { mesh = null; }
  81237. /**
  81238. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81239. */
  81240. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81241. this._totalVertices = 0;
  81242. this._isDisposed = false;
  81243. this._indexBufferIsUpdatable = false;
  81244. this.id = id;
  81245. this.uniqueId = scene.getUniqueId();
  81246. this._engine = scene.getEngine();
  81247. this._meshes = [];
  81248. this._scene = scene;
  81249. //Init vertex buffer cache
  81250. this._vertexBuffers = {};
  81251. this._indices = [];
  81252. this._updatable = updatable;
  81253. // vertexData
  81254. if (vertexData) {
  81255. this.setAllVerticesData(vertexData, updatable);
  81256. }
  81257. else {
  81258. this._totalVertices = 0;
  81259. this._indices = [];
  81260. }
  81261. if (this._engine.getCaps().vertexArrayObject) {
  81262. this._vertexArrayObjects = {};
  81263. }
  81264. // applyToMesh
  81265. if (mesh) {
  81266. this.applyToMesh(mesh);
  81267. mesh.computeWorldMatrix(true);
  81268. }
  81269. }
  81270. Object.defineProperty(Geometry.prototype, "boundingBias", {
  81271. /**
  81272. * 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
  81273. */
  81274. get: function () {
  81275. return this._boundingBias;
  81276. },
  81277. /**
  81278. * 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
  81279. */
  81280. set: function (value) {
  81281. if (this._boundingBias) {
  81282. this._boundingBias.copyFrom(value);
  81283. }
  81284. else {
  81285. this._boundingBias = value.clone();
  81286. }
  81287. this._updateBoundingInfo(true, null);
  81288. },
  81289. enumerable: true,
  81290. configurable: true
  81291. });
  81292. /**
  81293. * Static function used to attach a new empty geometry to a mesh
  81294. * @param mesh defines the mesh to attach the geometry to
  81295. * @returns the new Geometry
  81296. */
  81297. Geometry.CreateGeometryForMesh = function (mesh) {
  81298. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  81299. geometry.applyToMesh(mesh);
  81300. return geometry;
  81301. };
  81302. Object.defineProperty(Geometry.prototype, "extend", {
  81303. /**
  81304. * Gets the current extend of the geometry
  81305. */
  81306. get: function () {
  81307. return this._extend;
  81308. },
  81309. enumerable: true,
  81310. configurable: true
  81311. });
  81312. /**
  81313. * Gets the hosting scene
  81314. * @returns the hosting Scene
  81315. */
  81316. Geometry.prototype.getScene = function () {
  81317. return this._scene;
  81318. };
  81319. /**
  81320. * Gets the hosting engine
  81321. * @returns the hosting Engine
  81322. */
  81323. Geometry.prototype.getEngine = function () {
  81324. return this._engine;
  81325. };
  81326. /**
  81327. * Defines if the geometry is ready to use
  81328. * @returns true if the geometry is ready to be used
  81329. */
  81330. Geometry.prototype.isReady = function () {
  81331. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81332. };
  81333. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  81334. /**
  81335. * Gets a value indicating that the geometry should not be serialized
  81336. */
  81337. get: function () {
  81338. for (var index = 0; index < this._meshes.length; index++) {
  81339. if (!this._meshes[index].doNotSerialize) {
  81340. return false;
  81341. }
  81342. }
  81343. return true;
  81344. },
  81345. enumerable: true,
  81346. configurable: true
  81347. });
  81348. /** @hidden */
  81349. Geometry.prototype._rebuild = function () {
  81350. if (this._vertexArrayObjects) {
  81351. this._vertexArrayObjects = {};
  81352. }
  81353. // Index buffer
  81354. if (this._meshes.length !== 0 && this._indices) {
  81355. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81356. }
  81357. // Vertex buffers
  81358. for (var key in this._vertexBuffers) {
  81359. var vertexBuffer = this._vertexBuffers[key];
  81360. vertexBuffer._rebuild();
  81361. }
  81362. };
  81363. /**
  81364. * Affects all geometry data in one call
  81365. * @param vertexData defines the geometry data
  81366. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81367. */
  81368. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  81369. vertexData.applyToGeometry(this, updatable);
  81370. this.notifyUpdate();
  81371. };
  81372. /**
  81373. * Set specific vertex data
  81374. * @param kind defines the data kind (Position, normal, etc...)
  81375. * @param data defines the vertex data to use
  81376. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81377. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81378. */
  81379. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81380. if (updatable === void 0) { updatable = false; }
  81381. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  81382. this.setVerticesBuffer(buffer);
  81383. };
  81384. /**
  81385. * Removes a specific vertex data
  81386. * @param kind defines the data kind (Position, normal, etc...)
  81387. */
  81388. Geometry.prototype.removeVerticesData = function (kind) {
  81389. if (this._vertexBuffers[kind]) {
  81390. this._vertexBuffers[kind].dispose();
  81391. delete this._vertexBuffers[kind];
  81392. }
  81393. };
  81394. /**
  81395. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81396. * @param buffer defines the vertex buffer to use
  81397. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81398. */
  81399. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  81400. if (totalVertices === void 0) { totalVertices = null; }
  81401. var kind = buffer.getKind();
  81402. if (this._vertexBuffers[kind]) {
  81403. this._vertexBuffers[kind].dispose();
  81404. }
  81405. this._vertexBuffers[kind] = buffer;
  81406. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81407. var data = buffer.getData();
  81408. if (totalVertices != null) {
  81409. this._totalVertices = totalVertices;
  81410. }
  81411. else {
  81412. if (data != null) {
  81413. this._totalVertices = data.length / (buffer.byteStride / 4);
  81414. }
  81415. }
  81416. this._updateExtend(data);
  81417. this._resetPointsArrayCache();
  81418. var meshes = this._meshes;
  81419. var numOfMeshes = meshes.length;
  81420. for (var index = 0; index < numOfMeshes; index++) {
  81421. var mesh = meshes[index];
  81422. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81423. mesh._createGlobalSubMesh(false);
  81424. mesh.computeWorldMatrix(true);
  81425. }
  81426. }
  81427. this.notifyUpdate(kind);
  81428. if (this._vertexArrayObjects) {
  81429. this._disposeVertexArrayObjects();
  81430. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  81431. }
  81432. };
  81433. /**
  81434. * Update a specific vertex buffer
  81435. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81436. * It will do nothing if the buffer is not updatable
  81437. * @param kind defines the data kind (Position, normal, etc...)
  81438. * @param data defines the data to use
  81439. * @param offset defines the offset in the target buffer where to store the data
  81440. * @param useBytes set to true if the offset is in bytes
  81441. */
  81442. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  81443. if (useBytes === void 0) { useBytes = false; }
  81444. var vertexBuffer = this.getVertexBuffer(kind);
  81445. if (!vertexBuffer) {
  81446. return;
  81447. }
  81448. vertexBuffer.updateDirectly(data, offset, useBytes);
  81449. this.notifyUpdate(kind);
  81450. };
  81451. /**
  81452. * Update a specific vertex buffer
  81453. * This function will create a new buffer if the current one is not updatable
  81454. * @param kind defines the data kind (Position, normal, etc...)
  81455. * @param data defines the data to use
  81456. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81457. */
  81458. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  81459. if (updateExtends === void 0) { updateExtends = false; }
  81460. var vertexBuffer = this.getVertexBuffer(kind);
  81461. if (!vertexBuffer) {
  81462. return;
  81463. }
  81464. vertexBuffer.update(data);
  81465. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81466. this._updateBoundingInfo(updateExtends, data);
  81467. }
  81468. this.notifyUpdate(kind);
  81469. };
  81470. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  81471. if (updateExtends) {
  81472. this._updateExtend(data);
  81473. }
  81474. this._resetPointsArrayCache();
  81475. if (updateExtends) {
  81476. var meshes = this._meshes;
  81477. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81478. var mesh = meshes_1[_i];
  81479. if (mesh._boundingInfo) {
  81480. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  81481. }
  81482. else {
  81483. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81484. }
  81485. var subMeshes = mesh.subMeshes;
  81486. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  81487. var subMesh = subMeshes_1[_a];
  81488. subMesh.refreshBoundingInfo();
  81489. }
  81490. }
  81491. }
  81492. };
  81493. /** @hidden */
  81494. Geometry.prototype._bind = function (effect, indexToBind) {
  81495. if (!effect) {
  81496. return;
  81497. }
  81498. if (indexToBind === undefined) {
  81499. indexToBind = this._indexBuffer;
  81500. }
  81501. var vbs = this.getVertexBuffers();
  81502. if (!vbs) {
  81503. return;
  81504. }
  81505. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  81506. this._engine.bindBuffers(vbs, indexToBind, effect);
  81507. return;
  81508. }
  81509. // Using VAO
  81510. if (!this._vertexArrayObjects[effect.key]) {
  81511. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  81512. }
  81513. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  81514. };
  81515. /**
  81516. * Gets total number of vertices
  81517. * @returns the total number of vertices
  81518. */
  81519. Geometry.prototype.getTotalVertices = function () {
  81520. if (!this.isReady()) {
  81521. return 0;
  81522. }
  81523. return this._totalVertices;
  81524. };
  81525. /**
  81526. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81527. * @param kind defines the data kind (Position, normal, etc...)
  81528. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81530. * @returns a float array containing vertex data
  81531. */
  81532. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  81533. var vertexBuffer = this.getVertexBuffer(kind);
  81534. if (!vertexBuffer) {
  81535. return null;
  81536. }
  81537. var data = vertexBuffer.getData();
  81538. if (!data) {
  81539. return null;
  81540. }
  81541. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  81542. var count = this._totalVertices * vertexBuffer.getSize();
  81543. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  81544. var copy_1 = [];
  81545. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  81546. return copy_1;
  81547. }
  81548. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  81549. if (data instanceof Array) {
  81550. var offset = vertexBuffer.byteOffset / 4;
  81551. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  81552. }
  81553. else if (data instanceof ArrayBuffer) {
  81554. return new Float32Array(data, vertexBuffer.byteOffset, count);
  81555. }
  81556. else {
  81557. var offset = data.byteOffset + vertexBuffer.byteOffset;
  81558. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81559. var result = new Float32Array(count);
  81560. var source = new Float32Array(data.buffer, offset, count);
  81561. result.set(source);
  81562. return result;
  81563. }
  81564. return new Float32Array(data.buffer, offset, count);
  81565. }
  81566. }
  81567. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81568. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  81569. }
  81570. return data;
  81571. };
  81572. /**
  81573. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81574. * @param kind defines the data kind (Position, normal, etc...)
  81575. * @returns true if the vertex buffer with the specified kind is updatable
  81576. */
  81577. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  81578. var vb = this._vertexBuffers[kind];
  81579. if (!vb) {
  81580. return false;
  81581. }
  81582. return vb.isUpdatable();
  81583. };
  81584. /**
  81585. * Gets a specific vertex buffer
  81586. * @param kind defines the data kind (Position, normal, etc...)
  81587. * @returns a VertexBuffer
  81588. */
  81589. Geometry.prototype.getVertexBuffer = function (kind) {
  81590. if (!this.isReady()) {
  81591. return null;
  81592. }
  81593. return this._vertexBuffers[kind];
  81594. };
  81595. /**
  81596. * Returns all vertex buffers
  81597. * @return an object holding all vertex buffers indexed by kind
  81598. */
  81599. Geometry.prototype.getVertexBuffers = function () {
  81600. if (!this.isReady()) {
  81601. return null;
  81602. }
  81603. return this._vertexBuffers;
  81604. };
  81605. /**
  81606. * Gets a boolean indicating if specific vertex buffer is present
  81607. * @param kind defines the data kind (Position, normal, etc...)
  81608. * @returns true if data is present
  81609. */
  81610. Geometry.prototype.isVerticesDataPresent = function (kind) {
  81611. if (!this._vertexBuffers) {
  81612. if (this._delayInfo) {
  81613. return this._delayInfo.indexOf(kind) !== -1;
  81614. }
  81615. return false;
  81616. }
  81617. return this._vertexBuffers[kind] !== undefined;
  81618. };
  81619. /**
  81620. * Gets a list of all attached data kinds (Position, normal, etc...)
  81621. * @returns a list of string containing all kinds
  81622. */
  81623. Geometry.prototype.getVerticesDataKinds = function () {
  81624. var result = [];
  81625. var kind;
  81626. if (!this._vertexBuffers && this._delayInfo) {
  81627. for (kind in this._delayInfo) {
  81628. result.push(kind);
  81629. }
  81630. }
  81631. else {
  81632. for (kind in this._vertexBuffers) {
  81633. result.push(kind);
  81634. }
  81635. }
  81636. return result;
  81637. };
  81638. /**
  81639. * Update index buffer
  81640. * @param indices defines the indices to store in the index buffer
  81641. * @param offset defines the offset in the target buffer where to store the data
  81642. */
  81643. Geometry.prototype.updateIndices = function (indices, offset) {
  81644. if (!this._indexBuffer) {
  81645. return;
  81646. }
  81647. if (!this._indexBufferIsUpdatable) {
  81648. this.setIndices(indices, null, true);
  81649. }
  81650. else {
  81651. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  81652. this._indices = indices;
  81653. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  81654. if (needToUpdateSubMeshes) {
  81655. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81656. var mesh = _a[_i];
  81657. mesh._createGlobalSubMesh(true);
  81658. }
  81659. }
  81660. }
  81661. };
  81662. /**
  81663. * Creates a new index buffer
  81664. * @param indices defines the indices to store in the index buffer
  81665. * @param totalVertices defines the total number of vertices (could be null)
  81666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81667. */
  81668. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  81669. if (totalVertices === void 0) { totalVertices = null; }
  81670. if (updatable === void 0) { updatable = false; }
  81671. if (this._indexBuffer) {
  81672. this._engine._releaseBuffer(this._indexBuffer);
  81673. }
  81674. this._disposeVertexArrayObjects();
  81675. this._indices = indices;
  81676. this._indexBufferIsUpdatable = updatable;
  81677. if (this._meshes.length !== 0 && this._indices) {
  81678. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  81679. }
  81680. if (totalVertices != undefined) { // including null and undefined
  81681. this._totalVertices = totalVertices;
  81682. }
  81683. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81684. var mesh = _a[_i];
  81685. mesh._createGlobalSubMesh(true);
  81686. }
  81687. this.notifyUpdate();
  81688. };
  81689. /**
  81690. * Return the total number of indices
  81691. * @returns the total number of indices
  81692. */
  81693. Geometry.prototype.getTotalIndices = function () {
  81694. if (!this.isReady()) {
  81695. return 0;
  81696. }
  81697. return this._indices.length;
  81698. };
  81699. /**
  81700. * Gets the index buffer array
  81701. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81703. * @returns the index buffer array
  81704. */
  81705. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  81706. if (!this.isReady()) {
  81707. return null;
  81708. }
  81709. var orig = this._indices;
  81710. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  81711. return orig;
  81712. }
  81713. else {
  81714. var len = orig.length;
  81715. var copy = [];
  81716. for (var i = 0; i < len; i++) {
  81717. copy.push(orig[i]);
  81718. }
  81719. return copy;
  81720. }
  81721. };
  81722. /**
  81723. * Gets the index buffer
  81724. * @return the index buffer
  81725. */
  81726. Geometry.prototype.getIndexBuffer = function () {
  81727. if (!this.isReady()) {
  81728. return null;
  81729. }
  81730. return this._indexBuffer;
  81731. };
  81732. /** @hidden */
  81733. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  81734. if (effect === void 0) { effect = null; }
  81735. if (!effect || !this._vertexArrayObjects) {
  81736. return;
  81737. }
  81738. if (this._vertexArrayObjects[effect.key]) {
  81739. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  81740. delete this._vertexArrayObjects[effect.key];
  81741. }
  81742. };
  81743. /**
  81744. * Release the associated resources for a specific mesh
  81745. * @param mesh defines the source mesh
  81746. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81747. */
  81748. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  81749. var meshes = this._meshes;
  81750. var index = meshes.indexOf(mesh);
  81751. if (index === -1) {
  81752. return;
  81753. }
  81754. meshes.splice(index, 1);
  81755. mesh._geometry = null;
  81756. if (meshes.length === 0 && shouldDispose) {
  81757. this.dispose();
  81758. }
  81759. };
  81760. /**
  81761. * Apply current geometry to a given mesh
  81762. * @param mesh defines the mesh to apply geometry to
  81763. */
  81764. Geometry.prototype.applyToMesh = function (mesh) {
  81765. if (mesh._geometry === this) {
  81766. return;
  81767. }
  81768. var previousGeometry = mesh._geometry;
  81769. if (previousGeometry) {
  81770. previousGeometry.releaseForMesh(mesh);
  81771. }
  81772. var meshes = this._meshes;
  81773. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  81774. mesh._geometry = this;
  81775. this._scene.pushGeometry(this);
  81776. meshes.push(mesh);
  81777. if (this.isReady()) {
  81778. this._applyToMesh(mesh);
  81779. }
  81780. else {
  81781. mesh._boundingInfo = this._boundingInfo;
  81782. }
  81783. };
  81784. Geometry.prototype._updateExtend = function (data) {
  81785. if (data === void 0) { data = null; }
  81786. if (!data) {
  81787. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  81788. }
  81789. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  81790. };
  81791. Geometry.prototype._applyToMesh = function (mesh) {
  81792. var numOfMeshes = this._meshes.length;
  81793. // vertexBuffers
  81794. for (var kind in this._vertexBuffers) {
  81795. if (numOfMeshes === 1) {
  81796. this._vertexBuffers[kind].create();
  81797. }
  81798. var buffer = this._vertexBuffers[kind].getBuffer();
  81799. if (buffer) {
  81800. buffer.references = numOfMeshes;
  81801. }
  81802. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81803. if (!this._extend) {
  81804. this._updateExtend();
  81805. }
  81806. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81807. mesh._createGlobalSubMesh(false);
  81808. //bounding info was just created again, world matrix should be applied again.
  81809. mesh._updateBoundingInfo();
  81810. }
  81811. }
  81812. // indexBuffer
  81813. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  81814. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81815. }
  81816. if (this._indexBuffer) {
  81817. this._indexBuffer.references = numOfMeshes;
  81818. }
  81819. // morphTargets
  81820. mesh._syncGeometryWithMorphTargetManager();
  81821. // instances
  81822. mesh.synchronizeInstances();
  81823. };
  81824. Geometry.prototype.notifyUpdate = function (kind) {
  81825. if (this.onGeometryUpdated) {
  81826. this.onGeometryUpdated(this, kind);
  81827. }
  81828. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81829. var mesh = _a[_i];
  81830. mesh._markSubMeshesAsAttributesDirty();
  81831. }
  81832. };
  81833. /**
  81834. * Load the geometry if it was flagged as delay loaded
  81835. * @param scene defines the hosting scene
  81836. * @param onLoaded defines a callback called when the geometry is loaded
  81837. */
  81838. Geometry.prototype.load = function (scene, onLoaded) {
  81839. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  81840. return;
  81841. }
  81842. if (this.isReady()) {
  81843. if (onLoaded) {
  81844. onLoaded();
  81845. }
  81846. return;
  81847. }
  81848. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  81849. this._queueLoad(scene, onLoaded);
  81850. };
  81851. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  81852. var _this = this;
  81853. if (!this.delayLoadingFile) {
  81854. return;
  81855. }
  81856. scene._addPendingData(this);
  81857. scene._loadFile(this.delayLoadingFile, function (data) {
  81858. if (!_this._delayLoadingFunction) {
  81859. return;
  81860. }
  81861. _this._delayLoadingFunction(JSON.parse(data), _this);
  81862. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  81863. _this._delayInfo = [];
  81864. scene._removePendingData(_this);
  81865. var meshes = _this._meshes;
  81866. var numOfMeshes = meshes.length;
  81867. for (var index = 0; index < numOfMeshes; index++) {
  81868. _this._applyToMesh(meshes[index]);
  81869. }
  81870. if (onLoaded) {
  81871. onLoaded();
  81872. }
  81873. }, undefined, true);
  81874. };
  81875. /**
  81876. * Invert the geometry to move from a right handed system to a left handed one.
  81877. */
  81878. Geometry.prototype.toLeftHanded = function () {
  81879. // Flip faces
  81880. var tIndices = this.getIndices(false);
  81881. if (tIndices != null && tIndices.length > 0) {
  81882. for (var i = 0; i < tIndices.length; i += 3) {
  81883. var tTemp = tIndices[i + 0];
  81884. tIndices[i + 0] = tIndices[i + 2];
  81885. tIndices[i + 2] = tTemp;
  81886. }
  81887. this.setIndices(tIndices);
  81888. }
  81889. // Negate position.z
  81890. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  81891. if (tPositions != null && tPositions.length > 0) {
  81892. for (var i = 0; i < tPositions.length; i += 3) {
  81893. tPositions[i + 2] = -tPositions[i + 2];
  81894. }
  81895. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  81896. }
  81897. // Negate normal.z
  81898. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  81899. if (tNormals != null && tNormals.length > 0) {
  81900. for (var i = 0; i < tNormals.length; i += 3) {
  81901. tNormals[i + 2] = -tNormals[i + 2];
  81902. }
  81903. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  81904. }
  81905. };
  81906. // Cache
  81907. /** @hidden */
  81908. Geometry.prototype._resetPointsArrayCache = function () {
  81909. this._positions = null;
  81910. };
  81911. /** @hidden */
  81912. Geometry.prototype._generatePointsArray = function () {
  81913. if (this._positions) {
  81914. return true;
  81915. }
  81916. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  81917. if (!data || data.length === 0) {
  81918. return false;
  81919. }
  81920. this._positions = [];
  81921. for (var index = 0; index < data.length; index += 3) {
  81922. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  81923. }
  81924. return true;
  81925. };
  81926. /**
  81927. * Gets a value indicating if the geometry is disposed
  81928. * @returns true if the geometry was disposed
  81929. */
  81930. Geometry.prototype.isDisposed = function () {
  81931. return this._isDisposed;
  81932. };
  81933. Geometry.prototype._disposeVertexArrayObjects = function () {
  81934. if (this._vertexArrayObjects) {
  81935. for (var kind in this._vertexArrayObjects) {
  81936. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  81937. }
  81938. this._vertexArrayObjects = {};
  81939. }
  81940. };
  81941. /**
  81942. * Free all associated resources
  81943. */
  81944. Geometry.prototype.dispose = function () {
  81945. var meshes = this._meshes;
  81946. var numOfMeshes = meshes.length;
  81947. var index;
  81948. for (index = 0; index < numOfMeshes; index++) {
  81949. this.releaseForMesh(meshes[index]);
  81950. }
  81951. this._meshes = [];
  81952. this._disposeVertexArrayObjects();
  81953. for (var kind in this._vertexBuffers) {
  81954. this._vertexBuffers[kind].dispose();
  81955. }
  81956. this._vertexBuffers = {};
  81957. this._totalVertices = 0;
  81958. if (this._indexBuffer) {
  81959. this._engine._releaseBuffer(this._indexBuffer);
  81960. }
  81961. this._indexBuffer = null;
  81962. this._indices = [];
  81963. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81964. this.delayLoadingFile = null;
  81965. this._delayLoadingFunction = null;
  81966. this._delayInfo = [];
  81967. this._boundingInfo = null;
  81968. this._scene.removeGeometry(this);
  81969. this._isDisposed = true;
  81970. };
  81971. /**
  81972. * Clone the current geometry into a new geometry
  81973. * @param id defines the unique ID of the new geometry
  81974. * @returns a new geometry object
  81975. */
  81976. Geometry.prototype.copy = function (id) {
  81977. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  81978. vertexData.indices = [];
  81979. var indices = this.getIndices();
  81980. if (indices) {
  81981. for (var index = 0; index < indices.length; index++) {
  81982. vertexData.indices.push(indices[index]);
  81983. }
  81984. }
  81985. var updatable = false;
  81986. var stopChecking = false;
  81987. var kind;
  81988. for (kind in this._vertexBuffers) {
  81989. // using slice() to make a copy of the array and not just reference it
  81990. var data = this.getVerticesData(kind);
  81991. if (data) {
  81992. if (data instanceof Float32Array) {
  81993. vertexData.set(new Float32Array(data), kind);
  81994. }
  81995. else {
  81996. vertexData.set(data.slice(0), kind);
  81997. }
  81998. if (!stopChecking) {
  81999. var vb = this.getVertexBuffer(kind);
  82000. if (vb) {
  82001. updatable = vb.isUpdatable();
  82002. stopChecking = !updatable;
  82003. }
  82004. }
  82005. }
  82006. }
  82007. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  82008. geometry.delayLoadState = this.delayLoadState;
  82009. geometry.delayLoadingFile = this.delayLoadingFile;
  82010. geometry._delayLoadingFunction = this._delayLoadingFunction;
  82011. for (kind in this._delayInfo) {
  82012. geometry._delayInfo = geometry._delayInfo || [];
  82013. geometry._delayInfo.push(kind);
  82014. }
  82015. // Bounding info
  82016. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82017. return geometry;
  82018. };
  82019. /**
  82020. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82021. * @return a JSON representation of the current geometry data (without the vertices data)
  82022. */
  82023. Geometry.prototype.serialize = function () {
  82024. var serializationObject = {};
  82025. serializationObject.id = this.id;
  82026. serializationObject.updatable = this._updatable;
  82027. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  82028. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  82029. }
  82030. return serializationObject;
  82031. };
  82032. Geometry.prototype.toNumberArray = function (origin) {
  82033. if (Array.isArray(origin)) {
  82034. return origin;
  82035. }
  82036. else {
  82037. return Array.prototype.slice.call(origin);
  82038. }
  82039. };
  82040. /**
  82041. * Serialize all vertices data into a JSON oject
  82042. * @returns a JSON representation of the current geometry data
  82043. */
  82044. Geometry.prototype.serializeVerticeData = function () {
  82045. var serializationObject = this.serialize();
  82046. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82047. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  82048. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82049. serializationObject.positions._updatable = true;
  82050. }
  82051. }
  82052. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82053. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  82054. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82055. serializationObject.normals._updatable = true;
  82056. }
  82057. }
  82058. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82059. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  82060. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82061. serializationObject.tangets._updatable = true;
  82062. }
  82063. }
  82064. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82065. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  82066. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82067. serializationObject.uvs._updatable = true;
  82068. }
  82069. }
  82070. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82071. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  82072. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82073. serializationObject.uv2s._updatable = true;
  82074. }
  82075. }
  82076. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82077. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  82078. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82079. serializationObject.uv3s._updatable = true;
  82080. }
  82081. }
  82082. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82083. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  82084. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82085. serializationObject.uv4s._updatable = true;
  82086. }
  82087. }
  82088. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82089. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  82090. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82091. serializationObject.uv5s._updatable = true;
  82092. }
  82093. }
  82094. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82095. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  82096. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82097. serializationObject.uv6s._updatable = true;
  82098. }
  82099. }
  82100. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82101. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  82102. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82103. serializationObject.colors._updatable = true;
  82104. }
  82105. }
  82106. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82107. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  82108. serializationObject.matricesIndices._isExpanded = true;
  82109. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82110. serializationObject.matricesIndices._updatable = true;
  82111. }
  82112. }
  82113. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82114. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  82115. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82116. serializationObject.matricesWeights._updatable = true;
  82117. }
  82118. }
  82119. serializationObject.indices = this.toNumberArray(this.getIndices());
  82120. return serializationObject;
  82121. };
  82122. // Statics
  82123. /**
  82124. * Extracts a clone of a mesh geometry
  82125. * @param mesh defines the source mesh
  82126. * @param id defines the unique ID of the new geometry object
  82127. * @returns the new geometry object
  82128. */
  82129. Geometry.ExtractFromMesh = function (mesh, id) {
  82130. var geometry = mesh._geometry;
  82131. if (!geometry) {
  82132. return null;
  82133. }
  82134. return geometry.copy(id);
  82135. };
  82136. /**
  82137. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82138. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82139. * Be aware Math.random() could cause collisions, but:
  82140. * "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"
  82141. * @returns a string containing a new GUID
  82142. */
  82143. Geometry.RandomId = function () {
  82144. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  82145. };
  82146. /** @hidden */
  82147. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  82148. var scene = mesh.getScene();
  82149. // Geometry
  82150. var geometryId = parsedGeometry.geometryId;
  82151. if (geometryId) {
  82152. var geometry = scene.getGeometryByID(geometryId);
  82153. if (geometry) {
  82154. geometry.applyToMesh(mesh);
  82155. }
  82156. }
  82157. else if (parsedGeometry instanceof ArrayBuffer) {
  82158. var binaryInfo = mesh._binaryInfo;
  82159. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  82160. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  82161. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  82162. }
  82163. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  82164. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  82165. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  82166. }
  82167. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  82168. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  82169. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  82170. }
  82171. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  82172. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  82173. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  82174. }
  82175. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  82176. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  82177. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  82178. }
  82179. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  82180. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  82181. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  82182. }
  82183. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  82184. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  82185. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  82186. }
  82187. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  82188. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  82189. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  82190. }
  82191. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  82192. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  82193. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  82194. }
  82195. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  82196. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  82197. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  82198. }
  82199. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  82200. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  82201. var floatIndices = [];
  82202. for (var i = 0; i < matricesIndicesData.length; i++) {
  82203. var index = matricesIndicesData[i];
  82204. floatIndices.push(index & 0x000000FF);
  82205. floatIndices.push((index & 0x0000FF00) >> 8);
  82206. floatIndices.push((index & 0x00FF0000) >> 16);
  82207. floatIndices.push(index >> 24);
  82208. }
  82209. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  82210. }
  82211. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  82212. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  82213. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  82214. }
  82215. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  82216. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  82217. mesh.setIndices(indicesData, null);
  82218. }
  82219. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  82220. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  82221. mesh.subMeshes = [];
  82222. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  82223. var materialIndex = subMeshesData[(i * 5) + 0];
  82224. var verticesStart = subMeshesData[(i * 5) + 1];
  82225. var verticesCount = subMeshesData[(i * 5) + 2];
  82226. var indexStart = subMeshesData[(i * 5) + 3];
  82227. var indexCount = subMeshesData[(i * 5) + 4];
  82228. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  82229. }
  82230. }
  82231. }
  82232. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  82233. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  82234. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  82235. if (parsedGeometry.tangents) {
  82236. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  82237. }
  82238. if (parsedGeometry.uvs) {
  82239. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  82240. }
  82241. if (parsedGeometry.uvs2) {
  82242. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  82243. }
  82244. if (parsedGeometry.uvs3) {
  82245. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  82246. }
  82247. if (parsedGeometry.uvs4) {
  82248. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  82249. }
  82250. if (parsedGeometry.uvs5) {
  82251. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  82252. }
  82253. if (parsedGeometry.uvs6) {
  82254. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  82255. }
  82256. if (parsedGeometry.colors) {
  82257. 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);
  82258. }
  82259. if (parsedGeometry.matricesIndices) {
  82260. if (!parsedGeometry.matricesIndices._isExpanded) {
  82261. var floatIndices = [];
  82262. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  82263. var matricesIndex = parsedGeometry.matricesIndices[i];
  82264. floatIndices.push(matricesIndex & 0x000000FF);
  82265. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82266. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82267. floatIndices.push(matricesIndex >> 24);
  82268. }
  82269. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  82270. }
  82271. else {
  82272. delete parsedGeometry.matricesIndices._isExpanded;
  82273. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  82274. }
  82275. }
  82276. if (parsedGeometry.matricesIndicesExtra) {
  82277. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  82278. var floatIndices = [];
  82279. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  82280. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  82281. floatIndices.push(matricesIndex & 0x000000FF);
  82282. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82283. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82284. floatIndices.push(matricesIndex >> 24);
  82285. }
  82286. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  82287. }
  82288. else {
  82289. delete parsedGeometry.matricesIndices._isExpanded;
  82290. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  82291. }
  82292. }
  82293. if (parsedGeometry.matricesWeights) {
  82294. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  82295. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  82296. }
  82297. if (parsedGeometry.matricesWeightsExtra) {
  82298. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  82299. }
  82300. mesh.setIndices(parsedGeometry.indices, null);
  82301. }
  82302. // SubMeshes
  82303. if (parsedGeometry.subMeshes) {
  82304. mesh.subMeshes = [];
  82305. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  82306. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  82307. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  82308. }
  82309. }
  82310. // Flat shading
  82311. if (mesh._shouldGenerateFlatShading) {
  82312. mesh.convertToFlatShadedMesh();
  82313. delete mesh._shouldGenerateFlatShading;
  82314. }
  82315. // Update
  82316. mesh.computeWorldMatrix(true);
  82317. scene.onMeshImportedObservable.notifyObservers(mesh);
  82318. };
  82319. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  82320. var epsilon = 1e-3;
  82321. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  82322. return;
  82323. }
  82324. var noInfluenceBoneIndex = 0.0;
  82325. if (parsedGeometry.skeletonId > -1) {
  82326. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  82327. if (!skeleton) {
  82328. return;
  82329. }
  82330. noInfluenceBoneIndex = skeleton.bones.length;
  82331. }
  82332. else {
  82333. return;
  82334. }
  82335. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82336. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  82337. var matricesWeights = parsedGeometry.matricesWeights;
  82338. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  82339. var influencers = parsedGeometry.numBoneInfluencer;
  82340. var size = matricesWeights.length;
  82341. for (var i = 0; i < size; i += 4) {
  82342. var weight = 0.0;
  82343. var firstZeroWeight = -1;
  82344. for (var j = 0; j < 4; j++) {
  82345. var w = matricesWeights[i + j];
  82346. weight += w;
  82347. if (w < epsilon && firstZeroWeight < 0) {
  82348. firstZeroWeight = j;
  82349. }
  82350. }
  82351. if (matricesWeightsExtra) {
  82352. for (var j = 0; j < 4; j++) {
  82353. var w = matricesWeightsExtra[i + j];
  82354. weight += w;
  82355. if (w < epsilon && firstZeroWeight < 0) {
  82356. firstZeroWeight = j + 4;
  82357. }
  82358. }
  82359. }
  82360. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  82361. firstZeroWeight = influencers - 1;
  82362. }
  82363. if (weight > epsilon) {
  82364. var mweight = 1.0 / weight;
  82365. for (var j = 0; j < 4; j++) {
  82366. matricesWeights[i + j] *= mweight;
  82367. }
  82368. if (matricesWeightsExtra) {
  82369. for (var j = 0; j < 4; j++) {
  82370. matricesWeightsExtra[i + j] *= mweight;
  82371. }
  82372. }
  82373. }
  82374. else {
  82375. if (firstZeroWeight >= 4) {
  82376. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  82377. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  82378. }
  82379. else {
  82380. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  82381. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  82382. }
  82383. }
  82384. }
  82385. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  82386. if (parsedGeometry.matricesWeightsExtra) {
  82387. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  82388. }
  82389. };
  82390. /**
  82391. * Create a new geometry from persisted data (Using .babylon file format)
  82392. * @param parsedVertexData defines the persisted data
  82393. * @param scene defines the hosting scene
  82394. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82395. * @returns the new geometry object
  82396. */
  82397. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  82398. if (scene.getGeometryByID(parsedVertexData.id)) {
  82399. return null; // null since geometry could be something else than a box...
  82400. }
  82401. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  82402. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  82403. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  82404. }
  82405. if (parsedVertexData.delayLoadingFile) {
  82406. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82407. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  82408. 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));
  82409. geometry._delayInfo = [];
  82410. if (parsedVertexData.hasUVs) {
  82411. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  82412. }
  82413. if (parsedVertexData.hasUVs2) {
  82414. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  82415. }
  82416. if (parsedVertexData.hasUVs3) {
  82417. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  82418. }
  82419. if (parsedVertexData.hasUVs4) {
  82420. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  82421. }
  82422. if (parsedVertexData.hasUVs5) {
  82423. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  82424. }
  82425. if (parsedVertexData.hasUVs6) {
  82426. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  82427. }
  82428. if (parsedVertexData.hasColors) {
  82429. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82430. }
  82431. if (parsedVertexData.hasMatricesIndices) {
  82432. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82433. }
  82434. if (parsedVertexData.hasMatricesWeights) {
  82435. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  82436. }
  82437. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  82438. }
  82439. else {
  82440. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  82441. }
  82442. scene.pushGeometry(geometry, true);
  82443. return geometry;
  82444. };
  82445. return Geometry;
  82446. }());
  82447. /***/ }),
  82448. /***/ "./Meshes/groundMesh.ts":
  82449. /*!******************************!*\
  82450. !*** ./Meshes/groundMesh.ts ***!
  82451. \******************************/
  82452. /*! exports provided: GroundMesh */
  82453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82454. "use strict";
  82455. __webpack_require__.r(__webpack_exports__);
  82456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  82457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82458. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82459. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82460. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82461. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  82462. return GroundMesh.Parse(parsedMesh, scene);
  82463. };
  82464. /**
  82465. * Mesh representing the gorund
  82466. */
  82467. var GroundMesh = /** @class */ (function (_super) {
  82468. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  82469. function GroundMesh(name, scene) {
  82470. var _this = _super.call(this, name, scene) || this;
  82471. /** If octree should be generated */
  82472. _this.generateOctree = false;
  82473. return _this;
  82474. }
  82475. /**
  82476. * "GroundMesh"
  82477. * @returns "GroundMesh"
  82478. */
  82479. GroundMesh.prototype.getClassName = function () {
  82480. return "GroundMesh";
  82481. };
  82482. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  82483. /**
  82484. * The minimum of x and y subdivisions
  82485. */
  82486. get: function () {
  82487. return Math.min(this._subdivisionsX, this._subdivisionsY);
  82488. },
  82489. enumerable: true,
  82490. configurable: true
  82491. });
  82492. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  82493. /**
  82494. * X subdivisions
  82495. */
  82496. get: function () {
  82497. return this._subdivisionsX;
  82498. },
  82499. enumerable: true,
  82500. configurable: true
  82501. });
  82502. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  82503. /**
  82504. * Y subdivisions
  82505. */
  82506. get: function () {
  82507. return this._subdivisionsY;
  82508. },
  82509. enumerable: true,
  82510. configurable: true
  82511. });
  82512. /**
  82513. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82514. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82515. * @param chunksCount the number of subdivisions for x and y
  82516. * @param octreeBlocksSize (Default: 32)
  82517. */
  82518. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  82519. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  82520. this._subdivisionsX = chunksCount;
  82521. this._subdivisionsY = chunksCount;
  82522. this.subdivide(chunksCount);
  82523. // Call the octree system optimization if it is defined.
  82524. var thisAsAny = this;
  82525. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  82526. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  82527. }
  82528. };
  82529. /**
  82530. * Returns a height (y) value in the Worl system :
  82531. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82532. * @param x x coordinate
  82533. * @param z z coordinate
  82534. * @returns the ground y position if (x, z) are outside the ground surface.
  82535. */
  82536. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  82537. var world = this.getWorldMatrix();
  82538. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82539. world.invertToRef(invMat);
  82540. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82541. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  82542. x = tmpVect.x;
  82543. z = tmpVect.z;
  82544. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82545. return this.position.y;
  82546. }
  82547. if (!this._heightQuads || this._heightQuads.length == 0) {
  82548. this._initHeightQuads();
  82549. this._computeHeightQuads();
  82550. }
  82551. var facet = this._getFacetAt(x, z);
  82552. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  82553. // return y in the World system
  82554. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  82555. return tmpVect.y;
  82556. };
  82557. /**
  82558. * Returns a normalized vector (Vector3) orthogonal to the ground
  82559. * at the ground coordinates (x, z) expressed in the World system.
  82560. * @param x x coordinate
  82561. * @param z z coordinate
  82562. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82563. */
  82564. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  82565. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  82566. this.getNormalAtCoordinatesToRef(x, z, normal);
  82567. return normal;
  82568. };
  82569. /**
  82570. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82571. * at the ground coordinates (x, z) expressed in the World system.
  82572. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82573. * @param x x coordinate
  82574. * @param z z coordinate
  82575. * @param ref vector to store the result
  82576. * @returns the GroundMesh.
  82577. */
  82578. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  82579. var world = this.getWorldMatrix();
  82580. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82581. world.invertToRef(tmpMat);
  82582. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82583. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  82584. x = tmpVect.x;
  82585. z = tmpVect.z;
  82586. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82587. return this;
  82588. }
  82589. if (!this._heightQuads || this._heightQuads.length == 0) {
  82590. this._initHeightQuads();
  82591. this._computeHeightQuads();
  82592. }
  82593. var facet = this._getFacetAt(x, z);
  82594. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  82595. return this;
  82596. };
  82597. /**
  82598. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82599. * if the ground has been updated.
  82600. * This can be used in the render loop.
  82601. * @returns the GroundMesh.
  82602. */
  82603. GroundMesh.prototype.updateCoordinateHeights = function () {
  82604. if (!this._heightQuads || this._heightQuads.length == 0) {
  82605. this._initHeightQuads();
  82606. }
  82607. this._computeHeightQuads();
  82608. return this;
  82609. };
  82610. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  82611. GroundMesh.prototype._getFacetAt = function (x, z) {
  82612. // retrieve col and row from x, z coordinates in the ground local system
  82613. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  82614. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  82615. var quad = this._heightQuads[row * this._subdivisionsX + col];
  82616. var facet;
  82617. if (z < quad.slope.x * x + quad.slope.y) {
  82618. facet = quad.facet1;
  82619. }
  82620. else {
  82621. facet = quad.facet2;
  82622. }
  82623. return facet;
  82624. };
  82625. // Creates and populates the heightMap array with "facet" elements :
  82626. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  82627. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82628. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82629. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82630. // Returns the GroundMesh.
  82631. GroundMesh.prototype._initHeightQuads = function () {
  82632. var subdivisionsX = this._subdivisionsX;
  82633. var subdivisionsY = this._subdivisionsY;
  82634. this._heightQuads = new Array();
  82635. for (var row = 0; row < subdivisionsY; row++) {
  82636. for (var col = 0; col < subdivisionsX; col++) {
  82637. 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) };
  82638. this._heightQuads[row * subdivisionsX + col] = quad;
  82639. }
  82640. }
  82641. return this;
  82642. };
  82643. // Compute each quad element values and update the the heightMap array :
  82644. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82645. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82646. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82647. // Returns the GroundMesh.
  82648. GroundMesh.prototype._computeHeightQuads = function () {
  82649. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82650. if (!positions) {
  82651. return this;
  82652. }
  82653. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  82654. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  82655. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  82656. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  82657. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  82658. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  82659. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  82660. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  82661. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82662. var i = 0;
  82663. var j = 0;
  82664. var k = 0;
  82665. var cd = 0; // 2D slope coefficient : z = cd * x + h
  82666. var h = 0;
  82667. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  82668. var d2 = 0;
  82669. var subdivisionsX = this._subdivisionsX;
  82670. var subdivisionsY = this._subdivisionsY;
  82671. for (var row = 0; row < subdivisionsY; row++) {
  82672. for (var col = 0; col < subdivisionsX; col++) {
  82673. i = col * 3;
  82674. j = row * (subdivisionsX + 1) * 3;
  82675. k = (row + 1) * (subdivisionsX + 1) * 3;
  82676. v1.x = positions[j + i];
  82677. v1.y = positions[j + i + 1];
  82678. v1.z = positions[j + i + 2];
  82679. v2.x = positions[j + i + 3];
  82680. v2.y = positions[j + i + 4];
  82681. v2.z = positions[j + i + 5];
  82682. v3.x = positions[k + i];
  82683. v3.y = positions[k + i + 1];
  82684. v3.z = positions[k + i + 2];
  82685. v4.x = positions[k + i + 3];
  82686. v4.y = positions[k + i + 4];
  82687. v4.z = positions[k + i + 5];
  82688. // 2D slope V1V4
  82689. cd = (v4.z - v1.z) / (v4.x - v1.x);
  82690. h = v1.z - cd * v1.x; // v1 belongs to the slope
  82691. // facet equations :
  82692. // we compute each facet normal vector
  82693. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  82694. // we compute the value d by applying the equation to v1 which belongs to the plane
  82695. // then we store the facet equation in a Vector4
  82696. v2.subtractToRef(v1, v1v2);
  82697. v3.subtractToRef(v1, v1v3);
  82698. v4.subtractToRef(v1, v1v4);
  82699. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  82700. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  82701. norm1.normalize();
  82702. norm2.normalize();
  82703. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  82704. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  82705. var quad = this._heightQuads[row * subdivisionsX + col];
  82706. quad.slope.copyFromFloats(cd, h);
  82707. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  82708. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  82709. }
  82710. }
  82711. return this;
  82712. };
  82713. /**
  82714. * Serializes this ground mesh
  82715. * @param serializationObject object to write serialization to
  82716. */
  82717. GroundMesh.prototype.serialize = function (serializationObject) {
  82718. _super.prototype.serialize.call(this, serializationObject);
  82719. serializationObject.subdivisionsX = this._subdivisionsX;
  82720. serializationObject.subdivisionsY = this._subdivisionsY;
  82721. serializationObject.minX = this._minX;
  82722. serializationObject.maxX = this._maxX;
  82723. serializationObject.minZ = this._minZ;
  82724. serializationObject.maxZ = this._maxZ;
  82725. serializationObject.width = this._width;
  82726. serializationObject.height = this._height;
  82727. };
  82728. /**
  82729. * Parses a serialized ground mesh
  82730. * @param parsedMesh the serialized mesh
  82731. * @param scene the scene to create the ground mesh in
  82732. * @returns the created ground mesh
  82733. */
  82734. GroundMesh.Parse = function (parsedMesh, scene) {
  82735. var result = new GroundMesh(parsedMesh.name, scene);
  82736. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  82737. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  82738. result._minX = parsedMesh.minX;
  82739. result._maxX = parsedMesh.maxX;
  82740. result._minZ = parsedMesh.minZ;
  82741. result._maxZ = parsedMesh.maxZ;
  82742. result._width = parsedMesh.width;
  82743. result._height = parsedMesh.height;
  82744. return result;
  82745. };
  82746. return GroundMesh;
  82747. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  82748. /***/ }),
  82749. /***/ "./Meshes/index.ts":
  82750. /*!*************************!*\
  82751. !*** ./Meshes/index.ts ***!
  82752. \*************************/
  82753. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  82754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82755. "use strict";
  82756. __webpack_require__.r(__webpack_exports__);
  82757. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  82758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  82759. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  82760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  82761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  82762. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  82763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  82764. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  82765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  82766. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  82767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  82768. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  82769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  82770. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  82771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  82772. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  82773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  82774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  82775. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  82776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  82777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  82778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  82779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  82780. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  82782. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  82783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  82784. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  82785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  82786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  82787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  82788. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  82789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  82790. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  82791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  82792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  82793. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  82794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  82795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  82796. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  82797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  82798. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  82799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["BoxBuilder"]; });
  82800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DiscBuilder"]; });
  82801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["SphereBuilder"]; });
  82802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["CylinderBuilder"]; });
  82803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LinesBuilder"]; });
  82804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PlaneBuilder"]; });
  82805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["RibbonBuilder"]; });
  82806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusBuilder"]; });
  82807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusKnotBuilder"]; });
  82808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolygonBuilder"]; });
  82809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["ShapeBuilder"]; });
  82810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LatheBuilder"]; });
  82811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["GroundBuilder"]; });
  82812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TubeBuilder"]; });
  82813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolyhedronBuilder"]; });
  82814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  82815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  82816. /***/ }),
  82817. /***/ "./Meshes/instancedMesh.ts":
  82818. /*!*********************************!*\
  82819. !*** ./Meshes/instancedMesh.ts ***!
  82820. \*********************************/
  82821. /*! exports provided: InstancedMesh */
  82822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82823. "use strict";
  82824. __webpack_require__.r(__webpack_exports__);
  82825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  82826. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82827. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  82828. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  82829. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82830. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  82831. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  82832. return new InstancedMesh(name, mesh);
  82833. };
  82834. /**
  82835. * Creates an instance based on a source mesh.
  82836. */
  82837. var InstancedMesh = /** @class */ (function (_super) {
  82838. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  82839. function InstancedMesh(name, source) {
  82840. var _this = _super.call(this, name, source.getScene()) || this;
  82841. /** @hidden */
  82842. _this._indexInSourceMeshInstanceArray = -1;
  82843. source.addInstance(_this);
  82844. _this._sourceMesh = source;
  82845. _this.position.copyFrom(source.position);
  82846. _this.rotation.copyFrom(source.rotation);
  82847. _this.scaling.copyFrom(source.scaling);
  82848. if (source.rotationQuaternion) {
  82849. _this.rotationQuaternion = source.rotationQuaternion.clone();
  82850. }
  82851. _this.infiniteDistance = source.infiniteDistance;
  82852. _this.setPivotMatrix(source.getPivotMatrix());
  82853. _this.refreshBoundingInfo();
  82854. _this._syncSubMeshes();
  82855. return _this;
  82856. }
  82857. /**
  82858. * Returns the string "InstancedMesh".
  82859. */
  82860. InstancedMesh.prototype.getClassName = function () {
  82861. return "InstancedMesh";
  82862. };
  82863. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  82864. // Methods
  82865. /**
  82866. * If the source mesh receives shadows
  82867. */
  82868. get: function () {
  82869. return this._sourceMesh.receiveShadows;
  82870. },
  82871. enumerable: true,
  82872. configurable: true
  82873. });
  82874. Object.defineProperty(InstancedMesh.prototype, "material", {
  82875. /**
  82876. * The material of the source mesh
  82877. */
  82878. get: function () {
  82879. return this._sourceMesh.material;
  82880. },
  82881. enumerable: true,
  82882. configurable: true
  82883. });
  82884. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  82885. /**
  82886. * Visibility of the source mesh
  82887. */
  82888. get: function () {
  82889. return this._sourceMesh.visibility;
  82890. },
  82891. enumerable: true,
  82892. configurable: true
  82893. });
  82894. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  82895. /**
  82896. * Skeleton of the source mesh
  82897. */
  82898. get: function () {
  82899. return this._sourceMesh.skeleton;
  82900. },
  82901. enumerable: true,
  82902. configurable: true
  82903. });
  82904. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  82905. /**
  82906. * Rendering ground id of the source mesh
  82907. */
  82908. get: function () {
  82909. return this._sourceMesh.renderingGroupId;
  82910. },
  82911. set: function (value) {
  82912. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  82913. return;
  82914. }
  82915. //no-op with warning
  82916. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  82917. },
  82918. enumerable: true,
  82919. configurable: true
  82920. });
  82921. /**
  82922. * Returns the total number of vertices (integer).
  82923. */
  82924. InstancedMesh.prototype.getTotalVertices = function () {
  82925. return this._sourceMesh.getTotalVertices();
  82926. };
  82927. /**
  82928. * Returns a positive integer : the total number of indices in this mesh geometry.
  82929. * @returns the numner of indices or zero if the mesh has no geometry.
  82930. */
  82931. InstancedMesh.prototype.getTotalIndices = function () {
  82932. return this._sourceMesh.getTotalIndices();
  82933. };
  82934. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  82935. /**
  82936. * The source mesh of the instance
  82937. */
  82938. get: function () {
  82939. return this._sourceMesh;
  82940. },
  82941. enumerable: true,
  82942. configurable: true
  82943. });
  82944. /**
  82945. * Is this node ready to be used/rendered
  82946. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82947. * @return {boolean} is it ready
  82948. */
  82949. InstancedMesh.prototype.isReady = function (completeCheck) {
  82950. if (completeCheck === void 0) { completeCheck = false; }
  82951. return this._sourceMesh.isReady(completeCheck, true);
  82952. };
  82953. /**
  82954. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82955. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82956. * @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.
  82957. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82958. */
  82959. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  82960. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  82961. };
  82962. /**
  82963. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82964. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82965. * The `data` are either a numeric array either a Float32Array.
  82966. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82967. * 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).
  82968. * Note that a new underlying VertexBuffer object is created each call.
  82969. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82970. *
  82971. * Possible `kind` values :
  82972. * - VertexBuffer.PositionKind
  82973. * - VertexBuffer.UVKind
  82974. * - VertexBuffer.UV2Kind
  82975. * - VertexBuffer.UV3Kind
  82976. * - VertexBuffer.UV4Kind
  82977. * - VertexBuffer.UV5Kind
  82978. * - VertexBuffer.UV6Kind
  82979. * - VertexBuffer.ColorKind
  82980. * - VertexBuffer.MatricesIndicesKind
  82981. * - VertexBuffer.MatricesIndicesExtraKind
  82982. * - VertexBuffer.MatricesWeightsKind
  82983. * - VertexBuffer.MatricesWeightsExtraKind
  82984. *
  82985. * Returns the Mesh.
  82986. */
  82987. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  82988. if (this.sourceMesh) {
  82989. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  82990. }
  82991. return this.sourceMesh;
  82992. };
  82993. /**
  82994. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82995. * If the mesh has no geometry, it is simply returned as it is.
  82996. * The `data` are either a numeric array either a Float32Array.
  82997. * No new underlying VertexBuffer object is created.
  82998. * 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.
  82999. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83000. *
  83001. * Possible `kind` values :
  83002. * - VertexBuffer.PositionKind
  83003. * - VertexBuffer.UVKind
  83004. * - VertexBuffer.UV2Kind
  83005. * - VertexBuffer.UV3Kind
  83006. * - VertexBuffer.UV4Kind
  83007. * - VertexBuffer.UV5Kind
  83008. * - VertexBuffer.UV6Kind
  83009. * - VertexBuffer.ColorKind
  83010. * - VertexBuffer.MatricesIndicesKind
  83011. * - VertexBuffer.MatricesIndicesExtraKind
  83012. * - VertexBuffer.MatricesWeightsKind
  83013. * - VertexBuffer.MatricesWeightsExtraKind
  83014. *
  83015. * Returns the Mesh.
  83016. */
  83017. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83018. if (this.sourceMesh) {
  83019. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  83020. }
  83021. return this.sourceMesh;
  83022. };
  83023. /**
  83024. * Sets the mesh indices.
  83025. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83026. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83027. * This method creates a new index buffer each call.
  83028. * Returns the Mesh.
  83029. */
  83030. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  83031. if (totalVertices === void 0) { totalVertices = null; }
  83032. if (this.sourceMesh) {
  83033. this.sourceMesh.setIndices(indices, totalVertices);
  83034. }
  83035. return this.sourceMesh;
  83036. };
  83037. /**
  83038. * Boolean : True if the mesh owns the requested kind of data.
  83039. */
  83040. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  83041. return this._sourceMesh.isVerticesDataPresent(kind);
  83042. };
  83043. /**
  83044. * Returns an array of indices (IndicesArray).
  83045. */
  83046. InstancedMesh.prototype.getIndices = function () {
  83047. return this._sourceMesh.getIndices();
  83048. };
  83049. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  83050. get: function () {
  83051. return this._sourceMesh._positions;
  83052. },
  83053. enumerable: true,
  83054. configurable: true
  83055. });
  83056. /**
  83057. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83058. * This means the mesh underlying bounding box and sphere are recomputed.
  83059. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83060. * @returns the current mesh
  83061. */
  83062. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83063. if (applySkeleton === void 0) { applySkeleton = false; }
  83064. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83065. return this;
  83066. }
  83067. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  83068. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  83069. return this;
  83070. };
  83071. /** @hidden */
  83072. InstancedMesh.prototype._preActivate = function () {
  83073. if (this._currentLOD) {
  83074. this._currentLOD._preActivate();
  83075. }
  83076. return this;
  83077. };
  83078. /** @hidden */
  83079. InstancedMesh.prototype._activate = function (renderId) {
  83080. if (this._currentLOD) {
  83081. this._currentLOD._registerInstanceForRenderId(this, renderId);
  83082. }
  83083. return this;
  83084. };
  83085. /**
  83086. * Returns the current associated LOD AbstractMesh.
  83087. */
  83088. InstancedMesh.prototype.getLOD = function (camera) {
  83089. if (!camera) {
  83090. return this;
  83091. }
  83092. var boundingInfo = this.getBoundingInfo();
  83093. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  83094. if (this._currentLOD === this.sourceMesh) {
  83095. return this;
  83096. }
  83097. return this._currentLOD;
  83098. };
  83099. /** @hidden */
  83100. InstancedMesh.prototype._syncSubMeshes = function () {
  83101. this.releaseSubMeshes();
  83102. if (this._sourceMesh.subMeshes) {
  83103. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  83104. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  83105. }
  83106. }
  83107. return this;
  83108. };
  83109. /** @hidden */
  83110. InstancedMesh.prototype._generatePointsArray = function () {
  83111. return this._sourceMesh._generatePointsArray();
  83112. };
  83113. /**
  83114. * Creates a new InstancedMesh from the current mesh.
  83115. * - name (string) : the cloned mesh name
  83116. * - newParent (optional Node) : the optional Node to parent the clone to.
  83117. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83118. *
  83119. * Returns the clone.
  83120. */
  83121. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83122. var result = this._sourceMesh.createInstance(name);
  83123. // Deep copy
  83124. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  83125. // Bounding info
  83126. this.refreshBoundingInfo();
  83127. // Parent
  83128. if (newParent) {
  83129. result.parent = newParent;
  83130. }
  83131. if (!doNotCloneChildren) {
  83132. // Children
  83133. for (var index = 0; index < this.getScene().meshes.length; index++) {
  83134. var mesh = this.getScene().meshes[index];
  83135. if (mesh.parent === this) {
  83136. mesh.clone(mesh.name, result);
  83137. }
  83138. }
  83139. }
  83140. result.computeWorldMatrix(true);
  83141. return result;
  83142. };
  83143. /**
  83144. * Disposes the InstancedMesh.
  83145. * Returns nothing.
  83146. */
  83147. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83148. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83149. // Remove from mesh
  83150. this._sourceMesh.removeInstance(this);
  83151. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83152. };
  83153. return InstancedMesh;
  83154. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  83155. /***/ }),
  83156. /***/ "./Meshes/linesMesh.ts":
  83157. /*!*****************************!*\
  83158. !*** ./Meshes/linesMesh.ts ***!
  83159. \*****************************/
  83160. /*! exports provided: LinesMesh, InstancedLinesMesh */
  83161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83162. "use strict";
  83163. __webpack_require__.r(__webpack_exports__);
  83164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  83165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  83166. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83167. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83168. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83169. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83170. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  83171. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83172. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  83173. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  83174. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  83175. /**
  83176. * Line mesh
  83177. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83178. */
  83179. var LinesMesh = /** @class */ (function (_super) {
  83180. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  83181. /**
  83182. * Creates a new LinesMesh
  83183. * @param name defines the name
  83184. * @param scene defines the hosting scene
  83185. * @param parent defines the parent mesh if any
  83186. * @param source defines the optional source LinesMesh used to clone data from
  83187. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83188. * When false, achieved by calling a clone(), also passing False.
  83189. * This will make creation of children, recursive.
  83190. * @param useVertexColor defines if this LinesMesh supports vertex color
  83191. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83192. */
  83193. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  83194. /**
  83195. * If vertex color should be applied to the mesh
  83196. */
  83197. useVertexColor,
  83198. /**
  83199. * If vertex alpha should be applied to the mesh
  83200. */
  83201. useVertexAlpha) {
  83202. if (scene === void 0) { scene = null; }
  83203. if (parent === void 0) { parent = null; }
  83204. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  83205. _this.useVertexColor = useVertexColor;
  83206. _this.useVertexAlpha = useVertexAlpha;
  83207. /**
  83208. * Color of the line (Default: White)
  83209. */
  83210. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  83211. /**
  83212. * Alpha of the line (Default: 1)
  83213. */
  83214. _this.alpha = 1;
  83215. if (source) {
  83216. _this.color = source.color.clone();
  83217. _this.alpha = source.alpha;
  83218. _this.useVertexColor = source.useVertexColor;
  83219. _this.useVertexAlpha = source.useVertexAlpha;
  83220. }
  83221. _this.intersectionThreshold = 0.1;
  83222. var defines = [];
  83223. var options = {
  83224. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  83225. uniforms: ["world", "viewProjection"],
  83226. needAlphaBlending: true,
  83227. defines: defines
  83228. };
  83229. if (useVertexAlpha === false) {
  83230. options.needAlphaBlending = false;
  83231. }
  83232. if (!useVertexColor) {
  83233. options.uniforms.push("color");
  83234. }
  83235. else {
  83236. options.defines.push("#define VERTEXCOLOR");
  83237. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  83238. }
  83239. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  83240. return _this;
  83241. }
  83242. /**
  83243. * Returns the string "LineMesh"
  83244. */
  83245. LinesMesh.prototype.getClassName = function () {
  83246. return "LinesMesh";
  83247. };
  83248. Object.defineProperty(LinesMesh.prototype, "material", {
  83249. /**
  83250. * @hidden
  83251. */
  83252. get: function () {
  83253. return this._colorShader;
  83254. },
  83255. /**
  83256. * @hidden
  83257. */
  83258. set: function (value) {
  83259. // Do nothing
  83260. },
  83261. enumerable: true,
  83262. configurable: true
  83263. });
  83264. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  83265. /**
  83266. * @hidden
  83267. */
  83268. get: function () {
  83269. return false;
  83270. },
  83271. enumerable: true,
  83272. configurable: true
  83273. });
  83274. /** @hidden */
  83275. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  83276. if (!this._geometry) {
  83277. return this;
  83278. }
  83279. // VBOs
  83280. this._geometry._bind(this._colorShader.getEffect());
  83281. // Color
  83282. if (!this.useVertexColor) {
  83283. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  83284. }
  83285. return this;
  83286. };
  83287. /** @hidden */
  83288. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  83289. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  83290. return this;
  83291. }
  83292. var engine = this.getScene().getEngine();
  83293. // Draw order
  83294. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  83295. return this;
  83296. };
  83297. /**
  83298. * Disposes of the line mesh
  83299. * @param doNotRecurse If children should be disposed
  83300. */
  83301. LinesMesh.prototype.dispose = function (doNotRecurse) {
  83302. this._colorShader.dispose(false, false, true);
  83303. _super.prototype.dispose.call(this, doNotRecurse);
  83304. };
  83305. /**
  83306. * Returns a new LineMesh object cloned from the current one.
  83307. */
  83308. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83309. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  83310. };
  83311. /**
  83312. * Creates a new InstancedLinesMesh object from the mesh model.
  83313. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83314. * @param name defines the name of the new instance
  83315. * @returns a new InstancedLinesMesh
  83316. */
  83317. LinesMesh.prototype.createInstance = function (name) {
  83318. return new InstancedLinesMesh(name, this);
  83319. };
  83320. return LinesMesh;
  83321. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83322. /**
  83323. * Creates an instance based on a source LinesMesh
  83324. */
  83325. var InstancedLinesMesh = /** @class */ (function (_super) {
  83326. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  83327. function InstancedLinesMesh(name, source) {
  83328. var _this = _super.call(this, name, source) || this;
  83329. _this.intersectionThreshold = source.intersectionThreshold;
  83330. return _this;
  83331. }
  83332. /**
  83333. * Returns the string "InstancedLinesMesh".
  83334. */
  83335. InstancedLinesMesh.prototype.getClassName = function () {
  83336. return "InstancedLinesMesh";
  83337. };
  83338. return InstancedLinesMesh;
  83339. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  83340. /***/ }),
  83341. /***/ "./Meshes/mesh.ts":
  83342. /*!************************!*\
  83343. !*** ./Meshes/mesh.ts ***!
  83344. \************************/
  83345. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  83346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83347. "use strict";
  83348. __webpack_require__.r(__webpack_exports__);
  83349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  83350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  83351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  83352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  83353. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83354. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  83355. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83356. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83357. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83358. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83359. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  83360. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83361. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83362. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83363. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83364. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83365. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83366. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83367. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83368. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  83369. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83370. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  83371. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83372. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  83373. /**
  83374. * Class used to represent a specific level of detail of a mesh
  83375. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83376. */
  83377. var MeshLODLevel = /** @class */ (function () {
  83378. /**
  83379. * Creates a new LOD level
  83380. * @param distance defines the distance where this level should star being displayed
  83381. * @param mesh defines the mesh to use to render this level
  83382. */
  83383. function MeshLODLevel(
  83384. /** Defines the distance where this level should star being displayed */
  83385. distance,
  83386. /** Defines the mesh to use to render this level */
  83387. mesh) {
  83388. this.distance = distance;
  83389. this.mesh = mesh;
  83390. }
  83391. return MeshLODLevel;
  83392. }());
  83393. /**
  83394. * @hidden
  83395. **/
  83396. var _CreationDataStorage = /** @class */ (function () {
  83397. function _CreationDataStorage() {
  83398. }
  83399. return _CreationDataStorage;
  83400. }());
  83401. /**
  83402. * @hidden
  83403. **/
  83404. var _InstanceDataStorage = /** @class */ (function () {
  83405. function _InstanceDataStorage() {
  83406. this.visibleInstances = {};
  83407. this.renderIdForInstances = new Array();
  83408. this.batchCache = new _InstancesBatch();
  83409. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  83410. }
  83411. return _InstanceDataStorage;
  83412. }());
  83413. /**
  83414. * @hidden
  83415. **/
  83416. var _InstancesBatch = /** @class */ (function () {
  83417. function _InstancesBatch() {
  83418. this.mustReturn = false;
  83419. this.visibleInstances = new Array();
  83420. this.renderSelf = new Array();
  83421. }
  83422. return _InstancesBatch;
  83423. }());
  83424. /**
  83425. * Class used to represent renderable models
  83426. */
  83427. var Mesh = /** @class */ (function (_super) {
  83428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  83429. /**
  83430. * @constructor
  83431. * @param name The value used by scene.getMeshByName() to do a lookup.
  83432. * @param scene The scene to add this mesh to.
  83433. * @param parent The parent of this mesh, if it has one
  83434. * @param source An optional Mesh from which geometry is shared, cloned.
  83435. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83436. * When false, achieved by calling a clone(), also passing False.
  83437. * This will make creation of children, recursive.
  83438. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83439. */
  83440. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  83441. if (scene === void 0) { scene = null; }
  83442. if (parent === void 0) { parent = null; }
  83443. if (source === void 0) { source = null; }
  83444. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  83445. var _this = _super.call(this, name, scene) || this;
  83446. // Members
  83447. /**
  83448. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83449. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83450. */
  83451. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  83452. /**
  83453. * Gets the list of instances created from this mesh
  83454. * it is not supposed to be modified manually.
  83455. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83456. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83457. */
  83458. _this.instances = new Array();
  83459. _this._LODLevels = new Array();
  83460. /** @hidden */
  83461. _this._instanceDataStorage = new _InstanceDataStorage();
  83462. // Use by builder only to know what orientation were the mesh build in.
  83463. /** @hidden */
  83464. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  83465. /**
  83466. * Use this property to change the original side orientation defined at construction time
  83467. */
  83468. _this.overrideMaterialSideOrientation = null;
  83469. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  83470. // Will be used to save a source mesh reference, If any
  83471. _this._source = null;
  83472. /** @hidden */
  83473. _this._isMesh = true;
  83474. scene = _this.getScene();
  83475. if (source) {
  83476. // Geometry
  83477. if (source._geometry) {
  83478. source._geometry.applyToMesh(_this);
  83479. }
  83480. // Deep copy
  83481. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  83482. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  83483. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  83484. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  83485. "onDisposeObservable"
  83486. ], ["_poseMatrix"]);
  83487. // Source mesh
  83488. _this._source = source;
  83489. if (scene.useClonedMeshhMap) {
  83490. if (!source.meshMap) {
  83491. source.meshMap = {};
  83492. }
  83493. source.meshMap[_this.uniqueId] = _this;
  83494. }
  83495. // Construction Params
  83496. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  83497. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  83498. _this._creationDataStorage = source._creationDataStorage;
  83499. // Animation ranges
  83500. if (_this._source._ranges) {
  83501. var ranges = _this._source._ranges;
  83502. for (var name in ranges) {
  83503. if (!ranges.hasOwnProperty(name)) {
  83504. continue;
  83505. }
  83506. if (!ranges[name]) {
  83507. continue;
  83508. }
  83509. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  83510. }
  83511. }
  83512. // Metadata
  83513. if (source.metadata && source.metadata.clone) {
  83514. _this.metadata = source.metadata.clone();
  83515. }
  83516. else {
  83517. _this.metadata = source.metadata;
  83518. }
  83519. // Tags
  83520. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  83521. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  83522. }
  83523. // Parent
  83524. _this.parent = source.parent;
  83525. // Pivot
  83526. _this.setPivotMatrix(source.getPivotMatrix());
  83527. _this.id = name + "." + source.id;
  83528. // Material
  83529. _this.material = source.material;
  83530. var index;
  83531. if (!doNotCloneChildren) {
  83532. // Children
  83533. var directDescendants = source.getDescendants(true);
  83534. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  83535. var child = directDescendants[index_1];
  83536. if (child.clone) {
  83537. child.clone(name + "." + child.name, _this);
  83538. }
  83539. }
  83540. }
  83541. // Physics clone
  83542. var physicsEngine = _this.getScene().getPhysicsEngine();
  83543. if (clonePhysicsImpostor && physicsEngine) {
  83544. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  83545. if (impostor) {
  83546. _this.physicsImpostor = impostor.clone(_this);
  83547. }
  83548. }
  83549. // Particles
  83550. for (index = 0; index < scene.particleSystems.length; index++) {
  83551. var system = scene.particleSystems[index];
  83552. if (system.emitter === source) {
  83553. system.clone(system.name, _this);
  83554. }
  83555. }
  83556. _this.refreshBoundingInfo();
  83557. _this.computeWorldMatrix(true);
  83558. }
  83559. // Parent
  83560. if (parent !== null) {
  83561. _this.parent = parent;
  83562. }
  83563. return _this;
  83564. }
  83565. /**
  83566. * Gets the default side orientation.
  83567. * @param orientation the orientation to value to attempt to get
  83568. * @returns the default orientation
  83569. * @hidden
  83570. */
  83571. Mesh._GetDefaultSideOrientation = function (orientation) {
  83572. if (orientation == Mesh.DOUBLESIDE) {
  83573. return Mesh.DOUBLESIDE;
  83574. }
  83575. if (orientation === undefined || orientation === null) {
  83576. return Mesh.FRONTSIDE;
  83577. }
  83578. return orientation;
  83579. };
  83580. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  83581. /**
  83582. * An event triggered before rendering the mesh
  83583. */
  83584. get: function () {
  83585. if (!this._onBeforeRenderObservable) {
  83586. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83587. }
  83588. return this._onBeforeRenderObservable;
  83589. },
  83590. enumerable: true,
  83591. configurable: true
  83592. });
  83593. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  83594. /**
  83595. * An event triggered before binding the mesh
  83596. */
  83597. get: function () {
  83598. if (!this._onBeforeBindObservable) {
  83599. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83600. }
  83601. return this._onBeforeBindObservable;
  83602. },
  83603. enumerable: true,
  83604. configurable: true
  83605. });
  83606. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  83607. /**
  83608. * An event triggered after rendering the mesh
  83609. */
  83610. get: function () {
  83611. if (!this._onAfterRenderObservable) {
  83612. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83613. }
  83614. return this._onAfterRenderObservable;
  83615. },
  83616. enumerable: true,
  83617. configurable: true
  83618. });
  83619. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  83620. /**
  83621. * An event triggered before drawing the mesh
  83622. */
  83623. get: function () {
  83624. if (!this._onBeforeDrawObservable) {
  83625. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83626. }
  83627. return this._onBeforeDrawObservable;
  83628. },
  83629. enumerable: true,
  83630. configurable: true
  83631. });
  83632. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  83633. /**
  83634. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83635. */
  83636. set: function (callback) {
  83637. if (this._onBeforeDrawObserver) {
  83638. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  83639. }
  83640. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  83641. },
  83642. enumerable: true,
  83643. configurable: true
  83644. });
  83645. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  83646. /**
  83647. * Gets or sets the morph target manager
  83648. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83649. */
  83650. get: function () {
  83651. return this._morphTargetManager;
  83652. },
  83653. set: function (value) {
  83654. if (this._morphTargetManager === value) {
  83655. return;
  83656. }
  83657. this._morphTargetManager = value;
  83658. this._syncGeometryWithMorphTargetManager();
  83659. },
  83660. enumerable: true,
  83661. configurable: true
  83662. });
  83663. Object.defineProperty(Mesh.prototype, "source", {
  83664. /**
  83665. * Gets the source mesh (the one used to clone this one from)
  83666. */
  83667. get: function () {
  83668. return this._source;
  83669. },
  83670. enumerable: true,
  83671. configurable: true
  83672. });
  83673. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  83674. /**
  83675. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83676. */
  83677. get: function () {
  83678. return this._unIndexed;
  83679. },
  83680. set: function (value) {
  83681. if (this._unIndexed !== value) {
  83682. this._unIndexed = value;
  83683. this._markSubMeshesAsAttributesDirty();
  83684. }
  83685. },
  83686. enumerable: true,
  83687. configurable: true
  83688. });
  83689. // Methods
  83690. /**
  83691. * Gets the class name
  83692. * @returns the string "Mesh".
  83693. */
  83694. Mesh.prototype.getClassName = function () {
  83695. return "Mesh";
  83696. };
  83697. /**
  83698. * Returns a description of this mesh
  83699. * @param fullDetails define if full details about this mesh must be used
  83700. * @returns a descriptive string representing this mesh
  83701. */
  83702. Mesh.prototype.toString = function (fullDetails) {
  83703. var ret = _super.prototype.toString.call(this, fullDetails);
  83704. ret += ", n vertices: " + this.getTotalVertices();
  83705. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  83706. if (this.animations) {
  83707. for (var i = 0; i < this.animations.length; i++) {
  83708. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  83709. }
  83710. }
  83711. if (fullDetails) {
  83712. if (this._geometry) {
  83713. var ib = this.getIndices();
  83714. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83715. if (vb && ib) {
  83716. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  83717. }
  83718. }
  83719. else {
  83720. ret += ", flat shading: UNKNOWN";
  83721. }
  83722. }
  83723. return ret;
  83724. };
  83725. /** @hidden */
  83726. Mesh.prototype._unBindEffect = function () {
  83727. _super.prototype._unBindEffect.call(this);
  83728. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  83729. var instance = _a[_i];
  83730. instance._unBindEffect();
  83731. }
  83732. };
  83733. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  83734. /**
  83735. * Gets a boolean indicating if this mesh has LOD
  83736. */
  83737. get: function () {
  83738. return this._LODLevels.length > 0;
  83739. },
  83740. enumerable: true,
  83741. configurable: true
  83742. });
  83743. /**
  83744. * Gets the list of MeshLODLevel associated with the current mesh
  83745. * @returns an array of MeshLODLevel
  83746. */
  83747. Mesh.prototype.getLODLevels = function () {
  83748. return this._LODLevels;
  83749. };
  83750. Mesh.prototype._sortLODLevels = function () {
  83751. this._LODLevels.sort(function (a, b) {
  83752. if (a.distance < b.distance) {
  83753. return 1;
  83754. }
  83755. if (a.distance > b.distance) {
  83756. return -1;
  83757. }
  83758. return 0;
  83759. });
  83760. };
  83761. /**
  83762. * Add a mesh as LOD level triggered at the given distance.
  83763. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83764. * @param distance The distance from the center of the object to show this level
  83765. * @param mesh The mesh to be added as LOD level (can be null)
  83766. * @return This mesh (for chaining)
  83767. */
  83768. Mesh.prototype.addLODLevel = function (distance, mesh) {
  83769. if (mesh && mesh._masterMesh) {
  83770. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  83771. return this;
  83772. }
  83773. var level = new MeshLODLevel(distance, mesh);
  83774. this._LODLevels.push(level);
  83775. if (mesh) {
  83776. mesh._masterMesh = this;
  83777. }
  83778. this._sortLODLevels();
  83779. return this;
  83780. };
  83781. /**
  83782. * Returns the LOD level mesh at the passed distance or null if not found.
  83783. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83784. * @param distance The distance from the center of the object to show this level
  83785. * @returns a Mesh or `null`
  83786. */
  83787. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  83788. for (var index = 0; index < this._LODLevels.length; index++) {
  83789. var level = this._LODLevels[index];
  83790. if (level.distance === distance) {
  83791. return level.mesh;
  83792. }
  83793. }
  83794. return null;
  83795. };
  83796. /**
  83797. * Remove a mesh from the LOD array
  83798. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83799. * @param mesh defines the mesh to be removed
  83800. * @return This mesh (for chaining)
  83801. */
  83802. Mesh.prototype.removeLODLevel = function (mesh) {
  83803. for (var index = 0; index < this._LODLevels.length; index++) {
  83804. if (this._LODLevels[index].mesh === mesh) {
  83805. this._LODLevels.splice(index, 1);
  83806. if (mesh) {
  83807. mesh._masterMesh = null;
  83808. }
  83809. }
  83810. }
  83811. this._sortLODLevels();
  83812. return this;
  83813. };
  83814. /**
  83815. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  83816. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83817. * @param camera defines the camera to use to compute distance
  83818. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  83819. * @return This mesh (for chaining)
  83820. */
  83821. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  83822. if (!this._LODLevels || this._LODLevels.length === 0) {
  83823. return this;
  83824. }
  83825. var bSphere;
  83826. if (boundingSphere) {
  83827. bSphere = boundingSphere;
  83828. }
  83829. else {
  83830. var boundingInfo = this.getBoundingInfo();
  83831. bSphere = boundingInfo.boundingSphere;
  83832. }
  83833. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  83834. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  83835. if (this.onLODLevelSelection) {
  83836. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  83837. }
  83838. return this;
  83839. }
  83840. for (var index = 0; index < this._LODLevels.length; index++) {
  83841. var level = this._LODLevels[index];
  83842. if (level.distance < distanceToCamera) {
  83843. if (level.mesh) {
  83844. level.mesh._preActivate();
  83845. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  83846. }
  83847. if (this.onLODLevelSelection) {
  83848. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  83849. }
  83850. return level.mesh;
  83851. }
  83852. }
  83853. if (this.onLODLevelSelection) {
  83854. this.onLODLevelSelection(distanceToCamera, this, this);
  83855. }
  83856. return this;
  83857. };
  83858. Object.defineProperty(Mesh.prototype, "geometry", {
  83859. /**
  83860. * Gets the mesh internal Geometry object
  83861. */
  83862. get: function () {
  83863. return this._geometry;
  83864. },
  83865. enumerable: true,
  83866. configurable: true
  83867. });
  83868. /**
  83869. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  83870. * @returns the total number of vertices
  83871. */
  83872. Mesh.prototype.getTotalVertices = function () {
  83873. if (this._geometry === null || this._geometry === undefined) {
  83874. return 0;
  83875. }
  83876. return this._geometry.getTotalVertices();
  83877. };
  83878. /**
  83879. * Returns the content of an associated vertex buffer
  83880. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83881. * - VertexBuffer.PositionKind
  83882. * - VertexBuffer.UVKind
  83883. * - VertexBuffer.UV2Kind
  83884. * - VertexBuffer.UV3Kind
  83885. * - VertexBuffer.UV4Kind
  83886. * - VertexBuffer.UV5Kind
  83887. * - VertexBuffer.UV6Kind
  83888. * - VertexBuffer.ColorKind
  83889. * - VertexBuffer.MatricesIndicesKind
  83890. * - VertexBuffer.MatricesIndicesExtraKind
  83891. * - VertexBuffer.MatricesWeightsKind
  83892. * - VertexBuffer.MatricesWeightsExtraKind
  83893. * @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
  83894. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  83895. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  83896. */
  83897. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  83898. if (!this._geometry) {
  83899. return null;
  83900. }
  83901. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  83902. };
  83903. /**
  83904. * Returns the mesh VertexBuffer object from the requested `kind`
  83905. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83906. * - VertexBuffer.PositionKind
  83907. * - VertexBuffer.UVKind
  83908. * - VertexBuffer.UV2Kind
  83909. * - VertexBuffer.UV3Kind
  83910. * - VertexBuffer.UV4Kind
  83911. * - VertexBuffer.UV5Kind
  83912. * - VertexBuffer.UV6Kind
  83913. * - VertexBuffer.ColorKind
  83914. * - VertexBuffer.MatricesIndicesKind
  83915. * - VertexBuffer.MatricesIndicesExtraKind
  83916. * - VertexBuffer.MatricesWeightsKind
  83917. * - VertexBuffer.MatricesWeightsExtraKind
  83918. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  83919. */
  83920. Mesh.prototype.getVertexBuffer = function (kind) {
  83921. if (!this._geometry) {
  83922. return null;
  83923. }
  83924. return this._geometry.getVertexBuffer(kind);
  83925. };
  83926. /**
  83927. * Tests if a specific vertex buffer is associated with this mesh
  83928. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83929. * - VertexBuffer.PositionKind
  83930. * - VertexBuffer.UVKind
  83931. * - VertexBuffer.UV2Kind
  83932. * - VertexBuffer.UV3Kind
  83933. * - VertexBuffer.UV4Kind
  83934. * - VertexBuffer.UV5Kind
  83935. * - VertexBuffer.UV6Kind
  83936. * - VertexBuffer.ColorKind
  83937. * - VertexBuffer.MatricesIndicesKind
  83938. * - VertexBuffer.MatricesIndicesExtraKind
  83939. * - VertexBuffer.MatricesWeightsKind
  83940. * - VertexBuffer.MatricesWeightsExtraKind
  83941. * @returns a boolean
  83942. */
  83943. Mesh.prototype.isVerticesDataPresent = function (kind) {
  83944. if (!this._geometry) {
  83945. if (this._delayInfo) {
  83946. return this._delayInfo.indexOf(kind) !== -1;
  83947. }
  83948. return false;
  83949. }
  83950. return this._geometry.isVerticesDataPresent(kind);
  83951. };
  83952. /**
  83953. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  83954. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83955. * - VertexBuffer.PositionKind
  83956. * - VertexBuffer.UVKind
  83957. * - VertexBuffer.UV2Kind
  83958. * - VertexBuffer.UV3Kind
  83959. * - VertexBuffer.UV4Kind
  83960. * - VertexBuffer.UV5Kind
  83961. * - VertexBuffer.UV6Kind
  83962. * - VertexBuffer.ColorKind
  83963. * - VertexBuffer.MatricesIndicesKind
  83964. * - VertexBuffer.MatricesIndicesExtraKind
  83965. * - VertexBuffer.MatricesWeightsKind
  83966. * - VertexBuffer.MatricesWeightsExtraKind
  83967. * @returns a boolean
  83968. */
  83969. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  83970. if (!this._geometry) {
  83971. if (this._delayInfo) {
  83972. return this._delayInfo.indexOf(kind) !== -1;
  83973. }
  83974. return false;
  83975. }
  83976. return this._geometry.isVertexBufferUpdatable(kind);
  83977. };
  83978. /**
  83979. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  83980. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83981. * - VertexBuffer.PositionKind
  83982. * - VertexBuffer.UVKind
  83983. * - VertexBuffer.UV2Kind
  83984. * - VertexBuffer.UV3Kind
  83985. * - VertexBuffer.UV4Kind
  83986. * - VertexBuffer.UV5Kind
  83987. * - VertexBuffer.UV6Kind
  83988. * - VertexBuffer.ColorKind
  83989. * - VertexBuffer.MatricesIndicesKind
  83990. * - VertexBuffer.MatricesIndicesExtraKind
  83991. * - VertexBuffer.MatricesWeightsKind
  83992. * - VertexBuffer.MatricesWeightsExtraKind
  83993. * @returns an array of strings
  83994. */
  83995. Mesh.prototype.getVerticesDataKinds = function () {
  83996. if (!this._geometry) {
  83997. var result = new Array();
  83998. if (this._delayInfo) {
  83999. this._delayInfo.forEach(function (kind) {
  84000. result.push(kind);
  84001. });
  84002. }
  84003. return result;
  84004. }
  84005. return this._geometry.getVerticesDataKinds();
  84006. };
  84007. /**
  84008. * Returns a positive integer : the total number of indices in this mesh geometry.
  84009. * @returns the numner of indices or zero if the mesh has no geometry.
  84010. */
  84011. Mesh.prototype.getTotalIndices = function () {
  84012. if (!this._geometry) {
  84013. return 0;
  84014. }
  84015. return this._geometry.getTotalIndices();
  84016. };
  84017. /**
  84018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84019. * @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.
  84020. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84021. * @returns the indices array or an empty array if the mesh has no geometry
  84022. */
  84023. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84024. if (!this._geometry) {
  84025. return [];
  84026. }
  84027. return this._geometry.getIndices(copyWhenShared, forceCopy);
  84028. };
  84029. Object.defineProperty(Mesh.prototype, "isBlocked", {
  84030. get: function () {
  84031. return this._masterMesh !== null && this._masterMesh !== undefined;
  84032. },
  84033. enumerable: true,
  84034. configurable: true
  84035. });
  84036. /**
  84037. * Determine if the current mesh is ready to be rendered
  84038. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84039. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  84040. * @returns true if all associated assets are ready (material, textures, shaders)
  84041. */
  84042. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  84043. if (completeCheck === void 0) { completeCheck = false; }
  84044. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  84045. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  84046. return false;
  84047. }
  84048. if (!_super.prototype.isReady.call(this, completeCheck)) {
  84049. return false;
  84050. }
  84051. if (!this.subMeshes || this.subMeshes.length === 0) {
  84052. return true;
  84053. }
  84054. if (!completeCheck) {
  84055. return true;
  84056. }
  84057. var engine = this.getEngine();
  84058. var scene = this.getScene();
  84059. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  84060. this.computeWorldMatrix();
  84061. var mat = this.material || scene.defaultMaterial;
  84062. if (mat) {
  84063. if (mat._storeEffectOnSubMeshes) {
  84064. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84065. var subMesh = _a[_i];
  84066. var effectiveMaterial = subMesh.getMaterial();
  84067. if (effectiveMaterial) {
  84068. if (effectiveMaterial._storeEffectOnSubMeshes) {
  84069. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84070. return false;
  84071. }
  84072. }
  84073. else {
  84074. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84075. return false;
  84076. }
  84077. }
  84078. }
  84079. }
  84080. }
  84081. else {
  84082. if (!mat.isReady(this, hardwareInstancedRendering)) {
  84083. return false;
  84084. }
  84085. }
  84086. }
  84087. // Shadows
  84088. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  84089. var light = _c[_b];
  84090. var generator = light.getShadowGenerator();
  84091. if (generator) {
  84092. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  84093. var subMesh = _e[_d];
  84094. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  84095. return false;
  84096. }
  84097. }
  84098. }
  84099. }
  84100. // LOD
  84101. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  84102. var lod = _g[_f];
  84103. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  84104. return false;
  84105. }
  84106. }
  84107. return true;
  84108. };
  84109. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  84110. /**
  84111. * 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.
  84112. */
  84113. get: function () {
  84114. return this._areNormalsFrozen;
  84115. },
  84116. enumerable: true,
  84117. configurable: true
  84118. });
  84119. /**
  84120. * 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.
  84121. * @returns the current mesh
  84122. */
  84123. Mesh.prototype.freezeNormals = function () {
  84124. this._areNormalsFrozen = true;
  84125. return this;
  84126. };
  84127. /**
  84128. * 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
  84129. * @returns the current mesh
  84130. */
  84131. Mesh.prototype.unfreezeNormals = function () {
  84132. this._areNormalsFrozen = false;
  84133. return this;
  84134. };
  84135. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  84136. /**
  84137. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  84138. */
  84139. set: function (count) {
  84140. this._instanceDataStorage.overridenInstanceCount = count;
  84141. },
  84142. enumerable: true,
  84143. configurable: true
  84144. });
  84145. // Methods
  84146. /** @hidden */
  84147. Mesh.prototype._preActivate = function () {
  84148. var sceneRenderId = this.getScene().getRenderId();
  84149. if (this._preActivateId === sceneRenderId) {
  84150. return this;
  84151. }
  84152. this._preActivateId = sceneRenderId;
  84153. this._instanceDataStorage.visibleInstances = null;
  84154. return this;
  84155. };
  84156. /** @hidden */
  84157. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84158. if (this._instanceDataStorage.visibleInstances) {
  84159. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  84160. }
  84161. return this;
  84162. };
  84163. /** @hidden */
  84164. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  84165. if (!this._instanceDataStorage.visibleInstances) {
  84166. this._instanceDataStorage.visibleInstances = {
  84167. defaultRenderId: renderId,
  84168. selfDefaultRenderId: this._renderId
  84169. };
  84170. }
  84171. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  84172. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  84173. }
  84174. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  84175. return this;
  84176. };
  84177. /**
  84178. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84179. * This means the mesh underlying bounding box and sphere are recomputed.
  84180. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84181. * @returns the current mesh
  84182. */
  84183. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84184. if (applySkeleton === void 0) { applySkeleton = false; }
  84185. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84186. return this;
  84187. }
  84188. var bias = this.geometry ? this.geometry.boundingBias : null;
  84189. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  84190. return this;
  84191. };
  84192. /** @hidden */
  84193. Mesh.prototype._createGlobalSubMesh = function (force) {
  84194. var totalVertices = this.getTotalVertices();
  84195. if (!totalVertices || !this.getIndices()) {
  84196. return null;
  84197. }
  84198. // Check if we need to recreate the submeshes
  84199. if (this.subMeshes && this.subMeshes.length > 0) {
  84200. var ib = this.getIndices();
  84201. if (!ib) {
  84202. return null;
  84203. }
  84204. var totalIndices = ib.length;
  84205. var needToRecreate = false;
  84206. if (force) {
  84207. needToRecreate = true;
  84208. }
  84209. else {
  84210. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84211. var submesh = _a[_i];
  84212. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  84213. needToRecreate = true;
  84214. break;
  84215. }
  84216. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  84217. needToRecreate = true;
  84218. break;
  84219. }
  84220. }
  84221. }
  84222. if (!needToRecreate) {
  84223. return this.subMeshes[0];
  84224. }
  84225. }
  84226. this.releaseSubMeshes();
  84227. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  84228. };
  84229. /**
  84230. * This function will subdivide the mesh into multiple submeshes
  84231. * @param count defines the expected number of submeshes
  84232. */
  84233. Mesh.prototype.subdivide = function (count) {
  84234. if (count < 1) {
  84235. return;
  84236. }
  84237. var totalIndices = this.getTotalIndices();
  84238. var subdivisionSize = (totalIndices / count) | 0;
  84239. var offset = 0;
  84240. // Ensure that subdivisionSize is a multiple of 3
  84241. while (subdivisionSize % 3 !== 0) {
  84242. subdivisionSize++;
  84243. }
  84244. this.releaseSubMeshes();
  84245. for (var index = 0; index < count; index++) {
  84246. if (offset >= totalIndices) {
  84247. break;
  84248. }
  84249. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  84250. offset += subdivisionSize;
  84251. }
  84252. this.synchronizeInstances();
  84253. };
  84254. /**
  84255. * Copy a FloatArray into a specific associated vertex buffer
  84256. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84257. * - VertexBuffer.PositionKind
  84258. * - VertexBuffer.UVKind
  84259. * - VertexBuffer.UV2Kind
  84260. * - VertexBuffer.UV3Kind
  84261. * - VertexBuffer.UV4Kind
  84262. * - VertexBuffer.UV5Kind
  84263. * - VertexBuffer.UV6Kind
  84264. * - VertexBuffer.ColorKind
  84265. * - VertexBuffer.MatricesIndicesKind
  84266. * - VertexBuffer.MatricesIndicesExtraKind
  84267. * - VertexBuffer.MatricesWeightsKind
  84268. * - VertexBuffer.MatricesWeightsExtraKind
  84269. * @param data defines the data source
  84270. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84271. * @param stride defines the data stride size (can be null)
  84272. * @returns the current mesh
  84273. */
  84274. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84275. if (updatable === void 0) { updatable = false; }
  84276. if (!this._geometry) {
  84277. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84278. vertexData.set(data, kind);
  84279. var scene = this.getScene();
  84280. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84281. }
  84282. else {
  84283. this._geometry.setVerticesData(kind, data, updatable, stride);
  84284. }
  84285. return this;
  84286. };
  84287. /**
  84288. * Flags an associated vertex buffer as updatable
  84289. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  84290. * - VertexBuffer.PositionKind
  84291. * - VertexBuffer.UVKind
  84292. * - VertexBuffer.UV2Kind
  84293. * - VertexBuffer.UV3Kind
  84294. * - VertexBuffer.UV4Kind
  84295. * - VertexBuffer.UV5Kind
  84296. * - VertexBuffer.UV6Kind
  84297. * - VertexBuffer.ColorKind
  84298. * - VertexBuffer.MatricesIndicesKind
  84299. * - VertexBuffer.MatricesIndicesExtraKind
  84300. * - VertexBuffer.MatricesWeightsKind
  84301. * - VertexBuffer.MatricesWeightsExtraKind
  84302. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84303. */
  84304. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  84305. if (updatable === void 0) { updatable = true; }
  84306. var vb = this.getVertexBuffer(kind);
  84307. if (!vb || vb.isUpdatable() === updatable) {
  84308. return;
  84309. }
  84310. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  84311. };
  84312. /**
  84313. * Sets the mesh global Vertex Buffer
  84314. * @param buffer defines the buffer to use
  84315. * @returns the current mesh
  84316. */
  84317. Mesh.prototype.setVerticesBuffer = function (buffer) {
  84318. if (!this._geometry) {
  84319. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  84320. }
  84321. this._geometry.setVerticesBuffer(buffer);
  84322. return this;
  84323. };
  84324. /**
  84325. * Update a specific associated vertex buffer
  84326. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84327. * - VertexBuffer.PositionKind
  84328. * - VertexBuffer.UVKind
  84329. * - VertexBuffer.UV2Kind
  84330. * - VertexBuffer.UV3Kind
  84331. * - VertexBuffer.UV4Kind
  84332. * - VertexBuffer.UV5Kind
  84333. * - VertexBuffer.UV6Kind
  84334. * - VertexBuffer.ColorKind
  84335. * - VertexBuffer.MatricesIndicesKind
  84336. * - VertexBuffer.MatricesIndicesExtraKind
  84337. * - VertexBuffer.MatricesWeightsKind
  84338. * - VertexBuffer.MatricesWeightsExtraKind
  84339. * @param data defines the data source
  84340. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84341. * @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)
  84342. * @returns the current mesh
  84343. */
  84344. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84345. if (!this._geometry) {
  84346. return this;
  84347. }
  84348. if (!makeItUnique) {
  84349. this._geometry.updateVerticesData(kind, data, updateExtends);
  84350. }
  84351. else {
  84352. this.makeGeometryUnique();
  84353. this.updateVerticesData(kind, data, updateExtends, false);
  84354. }
  84355. return this;
  84356. };
  84357. /**
  84358. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  84359. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  84360. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  84361. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  84362. * @returns the current mesh
  84363. */
  84364. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  84365. if (computeNormals === void 0) { computeNormals = true; }
  84366. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84367. if (!positions) {
  84368. return this;
  84369. }
  84370. positionFunction(positions);
  84371. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  84372. if (computeNormals) {
  84373. var indices = this.getIndices();
  84374. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  84375. if (!normals) {
  84376. return this;
  84377. }
  84378. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  84379. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  84380. }
  84381. return this;
  84382. };
  84383. /**
  84384. * Creates a un-shared specific occurence of the geometry for the mesh.
  84385. * @returns the current mesh
  84386. */
  84387. Mesh.prototype.makeGeometryUnique = function () {
  84388. if (!this._geometry) {
  84389. return this;
  84390. }
  84391. var oldGeometry = this._geometry;
  84392. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  84393. oldGeometry.releaseForMesh(this, true);
  84394. geometry.applyToMesh(this);
  84395. return this;
  84396. };
  84397. /**
  84398. * Set the index buffer of this mesh
  84399. * @param indices defines the source data
  84400. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  84401. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  84402. * @returns the current mesh
  84403. */
  84404. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  84405. if (totalVertices === void 0) { totalVertices = null; }
  84406. if (updatable === void 0) { updatable = false; }
  84407. if (!this._geometry) {
  84408. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84409. vertexData.indices = indices;
  84410. var scene = this.getScene();
  84411. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84412. }
  84413. else {
  84414. this._geometry.setIndices(indices, totalVertices, updatable);
  84415. }
  84416. return this;
  84417. };
  84418. /**
  84419. * Update the current index buffer
  84420. * @param indices defines the source data
  84421. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84422. * @returns the current mesh
  84423. */
  84424. Mesh.prototype.updateIndices = function (indices, offset) {
  84425. if (!this._geometry) {
  84426. return this;
  84427. }
  84428. this._geometry.updateIndices(indices, offset);
  84429. return this;
  84430. };
  84431. /**
  84432. * Invert the geometry to move from a right handed system to a left handed one.
  84433. * @returns the current mesh
  84434. */
  84435. Mesh.prototype.toLeftHanded = function () {
  84436. if (!this._geometry) {
  84437. return this;
  84438. }
  84439. this._geometry.toLeftHanded();
  84440. return this;
  84441. };
  84442. /** @hidden */
  84443. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  84444. if (!this._geometry) {
  84445. return this;
  84446. }
  84447. var engine = this.getScene().getEngine();
  84448. // Wireframe
  84449. var indexToBind;
  84450. if (this._unIndexed) {
  84451. indexToBind = null;
  84452. }
  84453. else {
  84454. switch (fillMode) {
  84455. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  84456. indexToBind = null;
  84457. break;
  84458. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  84459. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  84460. break;
  84461. default:
  84462. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  84463. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  84464. break;
  84465. }
  84466. }
  84467. // VBOs
  84468. this._geometry._bind(effect, indexToBind);
  84469. return this;
  84470. };
  84471. /** @hidden */
  84472. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  84473. if (alternate === void 0) { alternate = false; }
  84474. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84475. return this;
  84476. }
  84477. if (this._onBeforeDrawObservable) {
  84478. this._onBeforeDrawObservable.notifyObservers(this);
  84479. }
  84480. var scene = this.getScene();
  84481. var engine = scene.getEngine();
  84482. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  84483. // or triangles as points
  84484. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  84485. }
  84486. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  84487. // Triangles as wireframe
  84488. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  84489. }
  84490. else {
  84491. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84492. }
  84493. if (scene._isAlternateRenderingEnabled && !alternate) {
  84494. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  84495. if (!effect || !scene.activeCamera) {
  84496. return this;
  84497. }
  84498. scene._switchToAlternateCameraConfiguration(true);
  84499. this._effectiveMaterial.bindView(effect);
  84500. this._effectiveMaterial.bindViewProjection(effect);
  84501. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  84502. this._draw(subMesh, fillMode, instancesCount, true);
  84503. engine.setViewport(scene.activeCamera.viewport);
  84504. scene._switchToAlternateCameraConfiguration(false);
  84505. this._effectiveMaterial.bindView(effect);
  84506. this._effectiveMaterial.bindViewProjection(effect);
  84507. }
  84508. return this;
  84509. };
  84510. /**
  84511. * Registers for this mesh a javascript function called just before the rendering process
  84512. * @param func defines the function to call before rendering this mesh
  84513. * @returns the current mesh
  84514. */
  84515. Mesh.prototype.registerBeforeRender = function (func) {
  84516. this.onBeforeRenderObservable.add(func);
  84517. return this;
  84518. };
  84519. /**
  84520. * Disposes a previously registered javascript function called before the rendering
  84521. * @param func defines the function to remove
  84522. * @returns the current mesh
  84523. */
  84524. Mesh.prototype.unregisterBeforeRender = function (func) {
  84525. this.onBeforeRenderObservable.removeCallback(func);
  84526. return this;
  84527. };
  84528. /**
  84529. * Registers for this mesh a javascript function called just after the rendering is complete
  84530. * @param func defines the function to call after rendering this mesh
  84531. * @returns the current mesh
  84532. */
  84533. Mesh.prototype.registerAfterRender = function (func) {
  84534. this.onAfterRenderObservable.add(func);
  84535. return this;
  84536. };
  84537. /**
  84538. * Disposes a previously registered javascript function called after the rendering.
  84539. * @param func defines the function to remove
  84540. * @returns the current mesh
  84541. */
  84542. Mesh.prototype.unregisterAfterRender = function (func) {
  84543. this.onAfterRenderObservable.removeCallback(func);
  84544. return this;
  84545. };
  84546. /** @hidden */
  84547. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  84548. var scene = this.getScene();
  84549. var batchCache = this._instanceDataStorage.batchCache;
  84550. batchCache.mustReturn = false;
  84551. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  84552. batchCache.visibleInstances[subMeshId] = null;
  84553. if (this._instanceDataStorage.visibleInstances) {
  84554. var visibleInstances = this._instanceDataStorage.visibleInstances;
  84555. var currentRenderId = scene.getRenderId();
  84556. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  84557. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  84558. var selfRenderId = this._renderId;
  84559. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  84560. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  84561. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  84562. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  84563. }
  84564. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  84565. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  84566. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  84567. batchCache.mustReturn = true;
  84568. return batchCache;
  84569. }
  84570. if (currentRenderId !== selfRenderId) {
  84571. batchCache.renderSelf[subMeshId] = false;
  84572. }
  84573. }
  84574. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  84575. }
  84576. return batchCache;
  84577. };
  84578. /** @hidden */
  84579. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  84580. var visibleInstances = batch.visibleInstances[subMesh._id];
  84581. if (!visibleInstances) {
  84582. return this;
  84583. }
  84584. var matricesCount = visibleInstances.length + 1;
  84585. var bufferSize = matricesCount * 16 * 4;
  84586. var instanceStorage = this._instanceDataStorage;
  84587. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  84588. var instancesBuffer = instanceStorage.instancesBuffer;
  84589. while (instanceStorage.instancesBufferSize < bufferSize) {
  84590. instanceStorage.instancesBufferSize *= 2;
  84591. }
  84592. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84593. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  84594. }
  84595. var offset = 0;
  84596. var instancesCount = 0;
  84597. var world = this.getWorldMatrix();
  84598. if (batch.renderSelf[subMesh._id]) {
  84599. world.copyToArray(instanceStorage.instancesData, offset);
  84600. offset += 16;
  84601. instancesCount++;
  84602. }
  84603. if (visibleInstances) {
  84604. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  84605. var instance = visibleInstances[instanceIndex];
  84606. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  84607. offset += 16;
  84608. instancesCount++;
  84609. }
  84610. }
  84611. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84612. if (instancesBuffer) {
  84613. instancesBuffer.dispose();
  84614. }
  84615. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  84616. instanceStorage.instancesBuffer = instancesBuffer;
  84617. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  84618. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  84619. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  84620. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  84621. }
  84622. else {
  84623. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  84624. }
  84625. this._bind(subMesh, effect, fillMode);
  84626. this._draw(subMesh, fillMode, instancesCount);
  84627. engine.unbindInstanceAttributes();
  84628. return this;
  84629. };
  84630. /** @hidden */
  84631. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  84632. var scene = this.getScene();
  84633. var engine = scene.getEngine();
  84634. if (hardwareInstancedRendering) {
  84635. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  84636. }
  84637. else {
  84638. if (batch.renderSelf[subMesh._id]) {
  84639. // Draw
  84640. if (onBeforeDraw) {
  84641. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  84642. }
  84643. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  84644. }
  84645. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  84646. if (visibleInstancesForSubMesh) {
  84647. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  84648. var instance = visibleInstancesForSubMesh[instanceIndex];
  84649. // World
  84650. var world = instance.getWorldMatrix();
  84651. if (onBeforeDraw) {
  84652. onBeforeDraw(true, world, effectiveMaterial);
  84653. }
  84654. // Draw
  84655. this._draw(subMesh, fillMode);
  84656. }
  84657. }
  84658. }
  84659. return this;
  84660. };
  84661. /**
  84662. * 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
  84663. * @param subMesh defines the subMesh to render
  84664. * @param enableAlphaMode defines if alpha mode can be changed
  84665. * @returns the current mesh
  84666. */
  84667. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  84668. if (this._checkOcclusionQuery()) {
  84669. return this;
  84670. }
  84671. var scene = this.getScene();
  84672. // Managing instances
  84673. var batch = this._getInstancesRenderList(subMesh._id);
  84674. if (batch.mustReturn) {
  84675. return this;
  84676. }
  84677. // Checking geometry state
  84678. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84679. return this;
  84680. }
  84681. if (this._onBeforeRenderObservable) {
  84682. this._onBeforeRenderObservable.notifyObservers(this);
  84683. }
  84684. var engine = scene.getEngine();
  84685. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  84686. // Material
  84687. var material = subMesh.getMaterial();
  84688. if (!material) {
  84689. return this;
  84690. }
  84691. this._effectiveMaterial = material;
  84692. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84693. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84694. return this;
  84695. }
  84696. }
  84697. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84698. return this;
  84699. }
  84700. // Alpha mode
  84701. if (enableAlphaMode) {
  84702. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  84703. }
  84704. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  84705. var step = _a[_i];
  84706. step.action(this, subMesh, batch);
  84707. }
  84708. var effect;
  84709. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84710. effect = subMesh.effect;
  84711. }
  84712. else {
  84713. effect = this._effectiveMaterial.getEffect();
  84714. }
  84715. if (!effect) {
  84716. return this;
  84717. }
  84718. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  84719. var sideOrientation = this.overrideMaterialSideOrientation;
  84720. if (sideOrientation == null) {
  84721. sideOrientation = this._effectiveMaterial.sideOrientation;
  84722. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  84723. 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);
  84724. }
  84725. }
  84726. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  84727. if (this._effectiveMaterial.forceDepthWrite) {
  84728. engine.setDepthWrite(true);
  84729. }
  84730. // Bind
  84731. 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);
  84732. if (this._onBeforeBindObservable) {
  84733. this._onBeforeBindObservable.notifyObservers(this);
  84734. }
  84735. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  84736. this._bind(subMesh, effect, fillMode);
  84737. }
  84738. var world = effectiveMesh.getWorldMatrix();
  84739. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84740. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  84741. }
  84742. else {
  84743. this._effectiveMaterial.bind(world, this);
  84744. }
  84745. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  84746. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  84747. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  84748. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  84749. }
  84750. // Draw
  84751. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  84752. // Unbind
  84753. this._effectiveMaterial.unbind();
  84754. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  84755. var step = _c[_b];
  84756. step.action(this, subMesh, batch);
  84757. }
  84758. if (this._onAfterRenderObservable) {
  84759. this._onAfterRenderObservable.notifyObservers(this);
  84760. }
  84761. return this;
  84762. };
  84763. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  84764. if (isInstance && effectiveMaterial) {
  84765. effectiveMaterial.bindOnlyWorldMatrix(world);
  84766. }
  84767. };
  84768. /**
  84769. * Renormalize the mesh and patch it up if there are no weights
  84770. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  84771. * However in the case of zero weights then we set just a single influence to 1.
  84772. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  84773. */
  84774. Mesh.prototype.cleanMatrixWeights = function () {
  84775. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  84776. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  84777. this.normalizeSkinWeightsAndExtra();
  84778. }
  84779. else {
  84780. this.normalizeSkinFourWeights();
  84781. }
  84782. }
  84783. };
  84784. // faster 4 weight version.
  84785. Mesh.prototype.normalizeSkinFourWeights = function () {
  84786. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  84787. var numWeights = matricesWeights.length;
  84788. for (var a = 0; a < numWeights; a += 4) {
  84789. // accumulate weights
  84790. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  84791. // check for invalid weight and just set it to 1.
  84792. if (t === 0) {
  84793. matricesWeights[a] = 1;
  84794. }
  84795. else {
  84796. // renormalize so everything adds to 1 use reciprical
  84797. var recip = 1 / t;
  84798. matricesWeights[a] *= recip;
  84799. matricesWeights[a + 1] *= recip;
  84800. matricesWeights[a + 2] *= recip;
  84801. matricesWeights[a + 3] *= recip;
  84802. }
  84803. }
  84804. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  84805. };
  84806. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  84807. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  84808. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  84809. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  84810. var numWeights = matricesWeights.length;
  84811. for (var a = 0; a < numWeights; a += 4) {
  84812. // accumulate weights
  84813. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  84814. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  84815. // check for invalid weight and just set it to 1.
  84816. if (t === 0) {
  84817. matricesWeights[a] = 1;
  84818. }
  84819. else {
  84820. // renormalize so everything adds to 1 use reciprical
  84821. var recip = 1 / t;
  84822. matricesWeights[a] *= recip;
  84823. matricesWeights[a + 1] *= recip;
  84824. matricesWeights[a + 2] *= recip;
  84825. matricesWeights[a + 3] *= recip;
  84826. // same goes for extras
  84827. matricesWeightsExtra[a] *= recip;
  84828. matricesWeightsExtra[a + 1] *= recip;
  84829. matricesWeightsExtra[a + 2] *= recip;
  84830. matricesWeightsExtra[a + 3] *= recip;
  84831. }
  84832. }
  84833. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  84834. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  84835. };
  84836. /**
  84837. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  84838. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  84839. * the user know there was an issue with importing the mesh
  84840. * @returns a validation object with skinned, valid and report string
  84841. */
  84842. Mesh.prototype.validateSkinning = function () {
  84843. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  84844. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  84845. if (matricesWeights === null || this.skeleton == null) {
  84846. return { skinned: false, valid: true, report: "not skinned" };
  84847. }
  84848. var numWeights = matricesWeights.length;
  84849. var numberNotSorted = 0;
  84850. var missingWeights = 0;
  84851. var maxUsedWeights = 0;
  84852. var numberNotNormalized = 0;
  84853. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  84854. var usedWeightCounts = new Array();
  84855. for (var a = 0; a <= numInfluences; a++) {
  84856. usedWeightCounts[a] = 0;
  84857. }
  84858. var toleranceEpsilon = 0.001;
  84859. for (var a = 0; a < numWeights; a += 4) {
  84860. var lastWeight = matricesWeights[a];
  84861. var t = lastWeight;
  84862. var usedWeights = t === 0 ? 0 : 1;
  84863. for (var b = 1; b < numInfluences; b++) {
  84864. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  84865. if (d > lastWeight) {
  84866. numberNotSorted++;
  84867. }
  84868. if (d !== 0) {
  84869. usedWeights++;
  84870. }
  84871. t += d;
  84872. lastWeight = d;
  84873. }
  84874. // count the buffer weights usage
  84875. usedWeightCounts[usedWeights]++;
  84876. // max influences
  84877. if (usedWeights > maxUsedWeights) {
  84878. maxUsedWeights = usedWeights;
  84879. }
  84880. // check for invalid weight and just set it to 1.
  84881. if (t === 0) {
  84882. missingWeights++;
  84883. }
  84884. else {
  84885. // renormalize so everything adds to 1 use reciprical
  84886. var recip = 1 / t;
  84887. var tolerance = 0;
  84888. for (b = 0; b < numInfluences; b++) {
  84889. if (b < 4) {
  84890. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  84891. }
  84892. else {
  84893. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  84894. }
  84895. }
  84896. // arbitary epsilon value for dicdating not normalized
  84897. if (tolerance > toleranceEpsilon) {
  84898. numberNotNormalized++;
  84899. }
  84900. }
  84901. }
  84902. // validate bone indices are in range of the skeleton
  84903. var numBones = this.skeleton.bones.length;
  84904. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  84905. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  84906. var numBadBoneIndices = 0;
  84907. for (var a = 0; a < numWeights; a++) {
  84908. for (var b = 0; b < numInfluences; b++) {
  84909. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  84910. if (index >= numBones || index < 0) {
  84911. numBadBoneIndices++;
  84912. }
  84913. }
  84914. }
  84915. // log mesh stats
  84916. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  84917. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  84918. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  84919. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  84920. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  84921. };
  84922. /** @hidden */
  84923. Mesh.prototype._checkDelayState = function () {
  84924. var scene = this.getScene();
  84925. if (this._geometry) {
  84926. this._geometry.load(scene);
  84927. }
  84928. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  84929. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  84930. this._queueLoad(scene);
  84931. }
  84932. return this;
  84933. };
  84934. Mesh.prototype._queueLoad = function (scene) {
  84935. var _this = this;
  84936. scene._addPendingData(this);
  84937. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  84938. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  84939. if (data instanceof ArrayBuffer) {
  84940. _this._delayLoadingFunction(data, _this);
  84941. }
  84942. else {
  84943. _this._delayLoadingFunction(JSON.parse(data), _this);
  84944. }
  84945. _this.instances.forEach(function (instance) {
  84946. instance._syncSubMeshes();
  84947. });
  84948. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  84949. scene._removePendingData(_this);
  84950. }, function () { }, scene.offlineProvider, getBinaryData);
  84951. return this;
  84952. };
  84953. /**
  84954. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84955. * A mesh is in the frustum if its bounding box intersects the frustum
  84956. * @param frustumPlanes defines the frustum to test
  84957. * @returns true if the mesh is in the frustum planes
  84958. */
  84959. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  84960. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  84961. return false;
  84962. }
  84963. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  84964. return false;
  84965. }
  84966. this._checkDelayState();
  84967. return true;
  84968. };
  84969. /**
  84970. * Sets the mesh material by the material or multiMaterial `id` property
  84971. * @param id is a string identifying the material or the multiMaterial
  84972. * @returns the current mesh
  84973. */
  84974. Mesh.prototype.setMaterialByID = function (id) {
  84975. var materials = this.getScene().materials;
  84976. var index;
  84977. for (index = materials.length - 1; index > -1; index--) {
  84978. if (materials[index].id === id) {
  84979. this.material = materials[index];
  84980. return this;
  84981. }
  84982. }
  84983. // Multi
  84984. var multiMaterials = this.getScene().multiMaterials;
  84985. for (index = multiMaterials.length - 1; index > -1; index--) {
  84986. if (multiMaterials[index].id === id) {
  84987. this.material = multiMaterials[index];
  84988. return this;
  84989. }
  84990. }
  84991. return this;
  84992. };
  84993. /**
  84994. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  84995. * @returns an array of IAnimatable
  84996. */
  84997. Mesh.prototype.getAnimatables = function () {
  84998. var results = new Array();
  84999. if (this.material) {
  85000. results.push(this.material);
  85001. }
  85002. if (this.skeleton) {
  85003. results.push(this.skeleton);
  85004. }
  85005. return results;
  85006. };
  85007. /**
  85008. * Modifies the mesh geometry according to the passed transformation matrix.
  85009. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  85010. * The mesh normals are modified using the same transformation.
  85011. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85012. * @param transform defines the transform matrix to use
  85013. * @see http://doc.babylonjs.com/resources/baking_transformations
  85014. * @returns the current mesh
  85015. */
  85016. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  85017. // Position
  85018. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  85019. return this;
  85020. }
  85021. var submeshes = this.subMeshes.splice(0);
  85022. this._resetPointsArrayCache();
  85023. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85024. var temp = new Array();
  85025. var index;
  85026. for (index = 0; index < data.length; index += 3) {
  85027. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  85028. }
  85029. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  85030. // Normals
  85031. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  85032. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85033. temp = [];
  85034. for (index = 0; index < data.length; index += 3) {
  85035. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  85036. }
  85037. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  85038. }
  85039. // flip faces?
  85040. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  85041. this.flipFaces();
  85042. }
  85043. // Restore submeshes
  85044. this.releaseSubMeshes();
  85045. this.subMeshes = submeshes;
  85046. return this;
  85047. };
  85048. /**
  85049. * Modifies the mesh geometry according to its own current World Matrix.
  85050. * The mesh World Matrix is then reset.
  85051. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  85052. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85053. * @see http://doc.babylonjs.com/resources/baking_transformations
  85054. * @returns the current mesh
  85055. */
  85056. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  85057. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  85058. this.scaling.copyFromFloats(1, 1, 1);
  85059. this.position.copyFromFloats(0, 0, 0);
  85060. this.rotation.copyFromFloats(0, 0, 0);
  85061. //only if quaternion is already set
  85062. if (this.rotationQuaternion) {
  85063. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  85064. }
  85065. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  85066. return this;
  85067. };
  85068. Object.defineProperty(Mesh.prototype, "_positions", {
  85069. // Cache
  85070. /** @hidden */
  85071. get: function () {
  85072. if (this._geometry) {
  85073. return this._geometry._positions;
  85074. }
  85075. return null;
  85076. },
  85077. enumerable: true,
  85078. configurable: true
  85079. });
  85080. /** @hidden */
  85081. Mesh.prototype._resetPointsArrayCache = function () {
  85082. if (this._geometry) {
  85083. this._geometry._resetPointsArrayCache();
  85084. }
  85085. return this;
  85086. };
  85087. /** @hidden */
  85088. Mesh.prototype._generatePointsArray = function () {
  85089. if (this._geometry) {
  85090. return this._geometry._generatePointsArray();
  85091. }
  85092. return false;
  85093. };
  85094. /**
  85095. * Returns a new Mesh object generated from the current mesh properties.
  85096. * This method must not get confused with createInstance()
  85097. * @param name is a string, the name given to the new mesh
  85098. * @param newParent can be any Node object (default `null`)
  85099. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  85100. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  85101. * @returns a new mesh
  85102. */
  85103. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  85104. if (name === void 0) { name = ""; }
  85105. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85106. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  85107. };
  85108. /**
  85109. * Releases resources associated with this mesh.
  85110. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85111. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85112. */
  85113. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85114. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85115. this.morphTargetManager = null;
  85116. if (this._geometry) {
  85117. this._geometry.releaseForMesh(this, true);
  85118. }
  85119. if (this._onBeforeDrawObservable) {
  85120. this._onBeforeDrawObservable.clear();
  85121. }
  85122. if (this._onBeforeBindObservable) {
  85123. this._onBeforeBindObservable.clear();
  85124. }
  85125. if (this._onBeforeRenderObservable) {
  85126. this._onBeforeRenderObservable.clear();
  85127. }
  85128. if (this._onAfterRenderObservable) {
  85129. this._onAfterRenderObservable.clear();
  85130. }
  85131. // Sources
  85132. if (this._scene.useClonedMeshhMap) {
  85133. if (this.meshMap) {
  85134. for (var uniqueId in this.meshMap) {
  85135. var mesh = this.meshMap[uniqueId];
  85136. if (mesh) {
  85137. mesh._source = null;
  85138. this.meshMap[uniqueId] = undefined;
  85139. }
  85140. }
  85141. }
  85142. if (this._source && this._source.meshMap) {
  85143. this._source.meshMap[this.uniqueId] = undefined;
  85144. }
  85145. }
  85146. else {
  85147. var meshes = this.getScene().meshes;
  85148. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85149. var abstractMesh = meshes_1[_i];
  85150. var mesh = abstractMesh;
  85151. if (mesh._source && mesh._source === this) {
  85152. mesh._source = null;
  85153. }
  85154. }
  85155. }
  85156. this._source = null;
  85157. // Instances
  85158. if (this._instanceDataStorage.instancesBuffer) {
  85159. this._instanceDataStorage.instancesBuffer.dispose();
  85160. this._instanceDataStorage.instancesBuffer = null;
  85161. }
  85162. while (this.instances.length) {
  85163. this.instances[0].dispose();
  85164. }
  85165. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85166. };
  85167. /**
  85168. * Modifies the mesh geometry according to a displacement map.
  85169. * 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.
  85170. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85171. * @param url is a string, the URL from the image file is to be downloaded.
  85172. * @param minHeight is the lower limit of the displacement.
  85173. * @param maxHeight is the upper limit of the displacement.
  85174. * @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.
  85175. * @param uvOffset is an optional vector2 used to offset UV.
  85176. * @param uvScale is an optional vector2 used to scale UV.
  85177. * @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.
  85178. * @returns the Mesh.
  85179. */
  85180. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  85181. var _this = this;
  85182. if (forceUpdate === void 0) { forceUpdate = false; }
  85183. var scene = this.getScene();
  85184. var onload = function (img) {
  85185. // Getting height map data
  85186. var canvas = document.createElement("canvas");
  85187. var context = canvas.getContext("2d");
  85188. var heightMapWidth = img.width;
  85189. var heightMapHeight = img.height;
  85190. canvas.width = heightMapWidth;
  85191. canvas.height = heightMapHeight;
  85192. context.drawImage(img, 0, 0);
  85193. // Create VertexData from map data
  85194. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  85195. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  85196. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  85197. //execute success callback, if set
  85198. if (onSuccess) {
  85199. onSuccess(_this);
  85200. }
  85201. };
  85202. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  85203. return this;
  85204. };
  85205. /**
  85206. * Modifies the mesh geometry according to a displacementMap buffer.
  85207. * 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.
  85208. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85209. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  85210. * @param heightMapWidth is the width of the buffer image.
  85211. * @param heightMapHeight is the height of the buffer image.
  85212. * @param minHeight is the lower limit of the displacement.
  85213. * @param maxHeight is the upper limit of the displacement.
  85214. * @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.
  85215. * @param uvOffset is an optional vector2 used to offset UV.
  85216. * @param uvScale is an optional vector2 used to scale UV.
  85217. * @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.
  85218. * @returns the Mesh.
  85219. */
  85220. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  85221. if (forceUpdate === void 0) { forceUpdate = false; }
  85222. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  85223. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  85224. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  85225. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  85226. return this;
  85227. }
  85228. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  85229. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85230. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85231. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85232. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85233. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85234. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85235. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  85236. for (var index = 0; index < positions.length; index += 3) {
  85237. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  85238. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  85239. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  85240. // Compute height
  85241. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  85242. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  85243. var pos = (u + v * heightMapWidth) * 4;
  85244. var r = buffer[pos] / 255.0;
  85245. var g = buffer[pos + 1] / 255.0;
  85246. var b = buffer[pos + 2] / 255.0;
  85247. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  85248. normal.normalize();
  85249. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  85250. position = position.add(normal);
  85251. position.toArray(positions, index);
  85252. }
  85253. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  85254. if (forceUpdate) {
  85255. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85256. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85257. }
  85258. else {
  85259. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85260. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85261. }
  85262. return this;
  85263. };
  85264. /**
  85265. * Modify the mesh to get a flat shading rendering.
  85266. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  85267. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  85268. * @returns current mesh
  85269. */
  85270. Mesh.prototype.convertToFlatShadedMesh = function () {
  85271. var kinds = this.getVerticesDataKinds();
  85272. var vbs = {};
  85273. var data = {};
  85274. var newdata = {};
  85275. var updatableNormals = false;
  85276. var kindIndex;
  85277. var kind;
  85278. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85279. kind = kinds[kindIndex];
  85280. var vertexBuffer = this.getVertexBuffer(kind);
  85281. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  85282. updatableNormals = vertexBuffer.isUpdatable();
  85283. kinds.splice(kindIndex, 1);
  85284. kindIndex--;
  85285. continue;
  85286. }
  85287. vbs[kind] = vertexBuffer;
  85288. data[kind] = vbs[kind].getData();
  85289. newdata[kind] = [];
  85290. }
  85291. // Save previous submeshes
  85292. var previousSubmeshes = this.subMeshes.slice(0);
  85293. var indices = this.getIndices();
  85294. var totalIndices = this.getTotalIndices();
  85295. // Generating unique vertices per face
  85296. var index;
  85297. for (index = 0; index < totalIndices; index++) {
  85298. var vertexIndex = indices[index];
  85299. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85300. kind = kinds[kindIndex];
  85301. var stride = vbs[kind].getStrideSize();
  85302. for (var offset = 0; offset < stride; offset++) {
  85303. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85304. }
  85305. }
  85306. }
  85307. // Updating faces & normal
  85308. var normals = [];
  85309. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  85310. for (index = 0; index < totalIndices; index += 3) {
  85311. indices[index] = index;
  85312. indices[index + 1] = index + 1;
  85313. indices[index + 2] = index + 2;
  85314. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  85315. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  85316. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  85317. var p1p2 = p1.subtract(p2);
  85318. var p3p2 = p3.subtract(p2);
  85319. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  85320. // Store same normals for every vertex
  85321. for (var localIndex = 0; localIndex < 3; localIndex++) {
  85322. normals.push(normal.x);
  85323. normals.push(normal.y);
  85324. normals.push(normal.z);
  85325. }
  85326. }
  85327. this.setIndices(indices);
  85328. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  85329. // Updating vertex buffers
  85330. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85331. kind = kinds[kindIndex];
  85332. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85333. }
  85334. // Updating submeshes
  85335. this.releaseSubMeshes();
  85336. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85337. var previousOne = previousSubmeshes[submeshIndex];
  85338. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85339. }
  85340. this.synchronizeInstances();
  85341. return this;
  85342. };
  85343. /**
  85344. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  85345. * In other words, more vertices, no more indices and a single bigger VBO.
  85346. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  85347. * @returns current mesh
  85348. */
  85349. Mesh.prototype.convertToUnIndexedMesh = function () {
  85350. var kinds = this.getVerticesDataKinds();
  85351. var vbs = {};
  85352. var data = {};
  85353. var newdata = {};
  85354. var kindIndex;
  85355. var kind;
  85356. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85357. kind = kinds[kindIndex];
  85358. var vertexBuffer = this.getVertexBuffer(kind);
  85359. vbs[kind] = vertexBuffer;
  85360. data[kind] = vbs[kind].getData();
  85361. newdata[kind] = [];
  85362. }
  85363. // Save previous submeshes
  85364. var previousSubmeshes = this.subMeshes.slice(0);
  85365. var indices = this.getIndices();
  85366. var totalIndices = this.getTotalIndices();
  85367. // Generating unique vertices per face
  85368. var index;
  85369. for (index = 0; index < totalIndices; index++) {
  85370. var vertexIndex = indices[index];
  85371. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85372. kind = kinds[kindIndex];
  85373. var stride = vbs[kind].getStrideSize();
  85374. for (var offset = 0; offset < stride; offset++) {
  85375. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85376. }
  85377. }
  85378. }
  85379. // Updating indices
  85380. for (index = 0; index < totalIndices; index += 3) {
  85381. indices[index] = index;
  85382. indices[index + 1] = index + 1;
  85383. indices[index + 2] = index + 2;
  85384. }
  85385. this.setIndices(indices);
  85386. // Updating vertex buffers
  85387. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85388. kind = kinds[kindIndex];
  85389. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85390. }
  85391. // Updating submeshes
  85392. this.releaseSubMeshes();
  85393. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85394. var previousOne = previousSubmeshes[submeshIndex];
  85395. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85396. }
  85397. this._unIndexed = true;
  85398. this.synchronizeInstances();
  85399. return this;
  85400. };
  85401. /**
  85402. * Inverses facet orientations.
  85403. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  85404. * @param flipNormals will also inverts the normals
  85405. * @returns current mesh
  85406. */
  85407. Mesh.prototype.flipFaces = function (flipNormals) {
  85408. if (flipNormals === void 0) { flipNormals = false; }
  85409. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  85410. var i;
  85411. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  85412. for (i = 0; i < vertex_data.normals.length; i++) {
  85413. vertex_data.normals[i] *= -1;
  85414. }
  85415. }
  85416. if (vertex_data.indices) {
  85417. var temp;
  85418. for (i = 0; i < vertex_data.indices.length; i += 3) {
  85419. // reassign indices
  85420. temp = vertex_data.indices[i + 1];
  85421. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  85422. vertex_data.indices[i + 2] = temp;
  85423. }
  85424. }
  85425. vertex_data.applyToMesh(this);
  85426. return this;
  85427. };
  85428. /**
  85429. * Creates a new InstancedMesh object from the mesh model.
  85430. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85431. * @param name defines the name of the new instance
  85432. * @returns a new InstancedMesh
  85433. */
  85434. Mesh.prototype.createInstance = function (name) {
  85435. return Mesh._instancedMeshFactory(name, this);
  85436. };
  85437. /**
  85438. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  85439. * After this call, all the mesh instances have the same submeshes than the current mesh.
  85440. * @returns the current mesh
  85441. */
  85442. Mesh.prototype.synchronizeInstances = function () {
  85443. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  85444. var instance = this.instances[instanceIndex];
  85445. instance._syncSubMeshes();
  85446. }
  85447. return this;
  85448. };
  85449. /**
  85450. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  85451. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  85452. * This should be used together with the simplification to avoid disappearing triangles.
  85453. * @param successCallback an optional success callback to be called after the optimization finished.
  85454. * @returns the current mesh
  85455. */
  85456. Mesh.prototype.optimizeIndices = function (successCallback) {
  85457. var _this = this;
  85458. var indices = this.getIndices();
  85459. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85460. if (!positions || !indices) {
  85461. return this;
  85462. }
  85463. var vectorPositions = new Array();
  85464. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  85465. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  85466. }
  85467. var dupes = new Array();
  85468. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  85469. var realPos = vectorPositions.length - 1 - iteration;
  85470. var testedPosition = vectorPositions[realPos];
  85471. for (var j = 0; j < realPos; ++j) {
  85472. var againstPosition = vectorPositions[j];
  85473. if (testedPosition.equals(againstPosition)) {
  85474. dupes[realPos] = j;
  85475. break;
  85476. }
  85477. }
  85478. }, function () {
  85479. for (var i = 0; i < indices.length; ++i) {
  85480. indices[i] = dupes[indices[i]] || indices[i];
  85481. }
  85482. //indices are now reordered
  85483. var originalSubMeshes = _this.subMeshes.slice(0);
  85484. _this.setIndices(indices);
  85485. _this.subMeshes = originalSubMeshes;
  85486. if (successCallback) {
  85487. successCallback(_this);
  85488. }
  85489. });
  85490. return this;
  85491. };
  85492. /**
  85493. * Serialize current mesh
  85494. * @param serializationObject defines the object which will receive the serialization data
  85495. */
  85496. Mesh.prototype.serialize = function (serializationObject) {
  85497. serializationObject.name = this.name;
  85498. serializationObject.id = this.id;
  85499. serializationObject.type = this.getClassName();
  85500. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  85501. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  85502. }
  85503. serializationObject.position = this.position.asArray();
  85504. if (this.rotationQuaternion) {
  85505. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  85506. }
  85507. else if (this.rotation) {
  85508. serializationObject.rotation = this.rotation.asArray();
  85509. }
  85510. serializationObject.scaling = this.scaling.asArray();
  85511. if (this._postMultiplyPivotMatrix) {
  85512. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  85513. }
  85514. else {
  85515. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  85516. }
  85517. serializationObject.isEnabled = this.isEnabled(false);
  85518. serializationObject.isVisible = this.isVisible;
  85519. serializationObject.infiniteDistance = this.infiniteDistance;
  85520. serializationObject.pickable = this.isPickable;
  85521. serializationObject.receiveShadows = this.receiveShadows;
  85522. serializationObject.billboardMode = this.billboardMode;
  85523. serializationObject.visibility = this.visibility;
  85524. serializationObject.checkCollisions = this.checkCollisions;
  85525. serializationObject.isBlocker = this.isBlocker;
  85526. // Parent
  85527. if (this.parent) {
  85528. serializationObject.parentId = this.parent.id;
  85529. }
  85530. // Geometry
  85531. serializationObject.isUnIndexed = this.isUnIndexed;
  85532. var geometry = this._geometry;
  85533. if (geometry) {
  85534. var geometryId = geometry.id;
  85535. serializationObject.geometryId = geometryId;
  85536. // SubMeshes
  85537. serializationObject.subMeshes = [];
  85538. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  85539. var subMesh = this.subMeshes[subIndex];
  85540. serializationObject.subMeshes.push({
  85541. materialIndex: subMesh.materialIndex,
  85542. verticesStart: subMesh.verticesStart,
  85543. verticesCount: subMesh.verticesCount,
  85544. indexStart: subMesh.indexStart,
  85545. indexCount: subMesh.indexCount
  85546. });
  85547. }
  85548. }
  85549. // Material
  85550. if (this.material) {
  85551. serializationObject.materialId = this.material.id;
  85552. }
  85553. else {
  85554. this.material = null;
  85555. }
  85556. // Morph targets
  85557. if (this.morphTargetManager) {
  85558. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  85559. }
  85560. // Skeleton
  85561. if (this.skeleton) {
  85562. serializationObject.skeletonId = this.skeleton.id;
  85563. }
  85564. // Physics
  85565. //TODO implement correct serialization for physics impostors.
  85566. var impostor = this.getPhysicsImpostor();
  85567. if (impostor) {
  85568. serializationObject.physicsMass = impostor.getParam("mass");
  85569. serializationObject.physicsFriction = impostor.getParam("friction");
  85570. serializationObject.physicsRestitution = impostor.getParam("mass");
  85571. serializationObject.physicsImpostor = impostor.type;
  85572. }
  85573. // Metadata
  85574. if (this.metadata) {
  85575. serializationObject.metadata = this.metadata;
  85576. }
  85577. // Instances
  85578. serializationObject.instances = [];
  85579. for (var index = 0; index < this.instances.length; index++) {
  85580. var instance = this.instances[index];
  85581. if (instance.doNotSerialize) {
  85582. continue;
  85583. }
  85584. var serializationInstance = {
  85585. name: instance.name,
  85586. id: instance.id,
  85587. position: instance.position.asArray(),
  85588. scaling: instance.scaling.asArray()
  85589. };
  85590. if (instance.parent) {
  85591. serializationInstance.parentId = instance.parent.id;
  85592. }
  85593. if (instance.rotationQuaternion) {
  85594. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  85595. }
  85596. else if (instance.rotation) {
  85597. serializationInstance.rotation = instance.rotation.asArray();
  85598. }
  85599. serializationObject.instances.push(serializationInstance);
  85600. // Animations
  85601. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  85602. serializationInstance.ranges = instance.serializeAnimationRanges();
  85603. }
  85604. //
  85605. // Animations
  85606. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  85607. serializationObject.ranges = this.serializeAnimationRanges();
  85608. // Layer mask
  85609. serializationObject.layerMask = this.layerMask;
  85610. // Alpha
  85611. serializationObject.alphaIndex = this.alphaIndex;
  85612. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  85613. // Overlay
  85614. serializationObject.overlayAlpha = this.overlayAlpha;
  85615. serializationObject.overlayColor = this.overlayColor.asArray();
  85616. serializationObject.renderOverlay = this.renderOverlay;
  85617. // Fog
  85618. serializationObject.applyFog = this.applyFog;
  85619. // Action Manager
  85620. if (this.actionManager) {
  85621. serializationObject.actions = this.actionManager.serialize(this.name);
  85622. }
  85623. };
  85624. /** @hidden */
  85625. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  85626. if (!this.geometry) {
  85627. return;
  85628. }
  85629. this._markSubMeshesAsAttributesDirty();
  85630. var morphTargetManager = this._morphTargetManager;
  85631. if (morphTargetManager && morphTargetManager.vertexCount) {
  85632. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  85633. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  85634. this.morphTargetManager = null;
  85635. return;
  85636. }
  85637. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  85638. var morphTarget = morphTargetManager.getActiveTarget(index);
  85639. var positions = morphTarget.getPositions();
  85640. if (!positions) {
  85641. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  85642. return;
  85643. }
  85644. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  85645. var normals = morphTarget.getNormals();
  85646. if (normals) {
  85647. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  85648. }
  85649. var tangents = morphTarget.getTangents();
  85650. if (tangents) {
  85651. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  85652. }
  85653. }
  85654. }
  85655. else {
  85656. var index = 0;
  85657. // Positions
  85658. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  85659. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  85660. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  85661. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  85662. }
  85663. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  85664. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  85665. }
  85666. index++;
  85667. }
  85668. }
  85669. };
  85670. /**
  85671. * Returns a new Mesh object parsed from the source provided.
  85672. * @param parsedMesh is the source
  85673. * @param scene defines the hosting scene
  85674. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  85675. * @returns a new Mesh
  85676. */
  85677. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  85678. var mesh;
  85679. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  85680. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  85681. }
  85682. else {
  85683. mesh = new Mesh(parsedMesh.name, scene);
  85684. }
  85685. mesh.id = parsedMesh.id;
  85686. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  85687. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  85688. }
  85689. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  85690. if (parsedMesh.metadata !== undefined) {
  85691. mesh.metadata = parsedMesh.metadata;
  85692. }
  85693. if (parsedMesh.rotationQuaternion) {
  85694. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  85695. }
  85696. else if (parsedMesh.rotation) {
  85697. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  85698. }
  85699. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  85700. if (parsedMesh.localMatrix) {
  85701. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  85702. }
  85703. else if (parsedMesh.pivotMatrix) {
  85704. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  85705. }
  85706. mesh.setEnabled(parsedMesh.isEnabled);
  85707. mesh.isVisible = parsedMesh.isVisible;
  85708. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  85709. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  85710. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  85711. if (parsedMesh.applyFog !== undefined) {
  85712. mesh.applyFog = parsedMesh.applyFog;
  85713. }
  85714. if (parsedMesh.pickable !== undefined) {
  85715. mesh.isPickable = parsedMesh.pickable;
  85716. }
  85717. if (parsedMesh.alphaIndex !== undefined) {
  85718. mesh.alphaIndex = parsedMesh.alphaIndex;
  85719. }
  85720. mesh.receiveShadows = parsedMesh.receiveShadows;
  85721. mesh.billboardMode = parsedMesh.billboardMode;
  85722. if (parsedMesh.visibility !== undefined) {
  85723. mesh.visibility = parsedMesh.visibility;
  85724. }
  85725. mesh.checkCollisions = parsedMesh.checkCollisions;
  85726. if (parsedMesh.isBlocker !== undefined) {
  85727. mesh.isBlocker = parsedMesh.isBlocker;
  85728. }
  85729. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  85730. // freezeWorldMatrix
  85731. if (parsedMesh.freezeWorldMatrix) {
  85732. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  85733. }
  85734. // Parent
  85735. if (parsedMesh.parentId) {
  85736. mesh._waitingParentId = parsedMesh.parentId;
  85737. }
  85738. // Actions
  85739. if (parsedMesh.actions !== undefined) {
  85740. mesh._waitingActions = parsedMesh.actions;
  85741. }
  85742. // Overlay
  85743. if (parsedMesh.overlayAlpha !== undefined) {
  85744. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  85745. }
  85746. if (parsedMesh.overlayColor !== undefined) {
  85747. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  85748. }
  85749. if (parsedMesh.renderOverlay !== undefined) {
  85750. mesh.renderOverlay = parsedMesh.renderOverlay;
  85751. }
  85752. // Geometry
  85753. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  85754. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  85755. if (parsedMesh.delayLoadingFile) {
  85756. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  85757. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  85758. 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));
  85759. if (parsedMesh._binaryInfo) {
  85760. mesh._binaryInfo = parsedMesh._binaryInfo;
  85761. }
  85762. mesh._delayInfo = [];
  85763. if (parsedMesh.hasUVs) {
  85764. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85765. }
  85766. if (parsedMesh.hasUVs2) {
  85767. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  85768. }
  85769. if (parsedMesh.hasUVs3) {
  85770. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  85771. }
  85772. if (parsedMesh.hasUVs4) {
  85773. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  85774. }
  85775. if (parsedMesh.hasUVs5) {
  85776. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  85777. }
  85778. if (parsedMesh.hasUVs6) {
  85779. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  85780. }
  85781. if (parsedMesh.hasColors) {
  85782. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  85783. }
  85784. if (parsedMesh.hasMatricesIndices) {
  85785. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85786. }
  85787. if (parsedMesh.hasMatricesWeights) {
  85788. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85789. }
  85790. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  85791. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_14__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  85792. mesh._checkDelayState();
  85793. }
  85794. }
  85795. else {
  85796. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  85797. }
  85798. // Material
  85799. if (parsedMesh.materialId) {
  85800. mesh.setMaterialByID(parsedMesh.materialId);
  85801. }
  85802. else {
  85803. mesh.material = null;
  85804. }
  85805. // Morph targets
  85806. if (parsedMesh.morphTargetManagerId > -1) {
  85807. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  85808. }
  85809. // Skeleton
  85810. if (parsedMesh.skeletonId > -1) {
  85811. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  85812. if (parsedMesh.numBoneInfluencers) {
  85813. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  85814. }
  85815. }
  85816. // Animations
  85817. if (parsedMesh.animations) {
  85818. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  85819. var parsedAnimation = parsedMesh.animations[animationIndex];
  85820. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  85821. if (internalClass) {
  85822. mesh.animations.push(internalClass.Parse(parsedAnimation));
  85823. }
  85824. }
  85825. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  85826. }
  85827. if (parsedMesh.autoAnimate) {
  85828. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  85829. }
  85830. // Layer Mask
  85831. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  85832. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  85833. }
  85834. else {
  85835. mesh.layerMask = 0x0FFFFFFF;
  85836. }
  85837. // Physics
  85838. if (parsedMesh.physicsImpostor) {
  85839. mesh.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_15__["PhysicsImpostor"](mesh, parsedMesh.physicsImpostor, {
  85840. mass: parsedMesh.physicsMass,
  85841. friction: parsedMesh.physicsFriction,
  85842. restitution: parsedMesh.physicsRestitution
  85843. }, scene);
  85844. }
  85845. // Instances
  85846. if (parsedMesh.instances) {
  85847. for (var index = 0; index < parsedMesh.instances.length; index++) {
  85848. var parsedInstance = parsedMesh.instances[index];
  85849. var instance = mesh.createInstance(parsedInstance.name);
  85850. if (parsedInstance.id) {
  85851. instance.id = parsedInstance.id;
  85852. }
  85853. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  85854. if (parsedInstance.tags) {
  85855. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  85856. }
  85857. else {
  85858. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  85859. }
  85860. }
  85861. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  85862. if (parsedInstance.parentId) {
  85863. instance._waitingParentId = parsedInstance.parentId;
  85864. }
  85865. if (parsedInstance.rotationQuaternion) {
  85866. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  85867. }
  85868. else if (parsedInstance.rotation) {
  85869. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  85870. }
  85871. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  85872. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  85873. instance.checkCollisions = parsedInstance.checkCollisions;
  85874. }
  85875. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  85876. instance.isPickable = parsedInstance.pickable;
  85877. }
  85878. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  85879. instance.showBoundingBox = parsedInstance.showBoundingBox;
  85880. }
  85881. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  85882. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  85883. }
  85884. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  85885. instance.alphaIndex = parsedInstance.alphaIndex;
  85886. }
  85887. // Physics
  85888. if (parsedInstance.physicsImpostor) {
  85889. instance.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_15__["PhysicsImpostor"](instance, parsedInstance.physicsImpostor, {
  85890. mass: parsedInstance.physicsMass,
  85891. friction: parsedInstance.physicsFriction,
  85892. restitution: parsedInstance.physicsRestitution
  85893. }, scene);
  85894. }
  85895. // Animation
  85896. if (parsedInstance.animations) {
  85897. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  85898. parsedAnimation = parsedInstance.animations[animationIndex];
  85899. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  85900. if (internalClass) {
  85901. instance.animations.push(internalClass.Parse(parsedAnimation));
  85902. }
  85903. }
  85904. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  85905. if (parsedInstance.autoAnimate) {
  85906. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  85907. }
  85908. }
  85909. }
  85910. }
  85911. return mesh;
  85912. };
  85913. /**
  85914. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  85915. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  85916. * @param name defines the name of the mesh to create
  85917. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  85918. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  85919. * @param closePath creates a seam between the first and the last points of each path of the path array
  85920. * @param offset is taken in account only if the `pathArray` is containing a single path
  85921. * @param scene defines the hosting scene
  85922. * @param updatable defines if the mesh must be flagged as updatable
  85923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  85924. * @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)
  85925. * @returns a new Mesh
  85926. */
  85927. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  85928. throw "Import MeshBuilder before creating meshes.";
  85929. };
  85930. /**
  85931. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  85932. * @param name defines the name of the mesh to create
  85933. * @param radius sets the radius size (float) of the polygon (default 0.5)
  85934. * @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
  85935. * @param scene defines the hosting scene
  85936. * @param updatable defines if the mesh must be flagged as updatable
  85937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  85938. * @returns a new Mesh
  85939. */
  85940. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  85941. if (scene === void 0) { scene = null; }
  85942. throw "Import MeshBuilder before creating meshes.";
  85943. };
  85944. /**
  85945. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  85946. * @param name defines the name of the mesh to create
  85947. * @param size sets the size (float) of each box side (default 1)
  85948. * @param scene defines the hosting scene
  85949. * @param updatable defines if the mesh must be flagged as updatable
  85950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  85951. * @returns a new Mesh
  85952. */
  85953. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  85954. if (scene === void 0) { scene = null; }
  85955. throw "Import MeshBuilder before creating meshes.";
  85956. };
  85957. /**
  85958. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  85959. * @param name defines the name of the mesh to create
  85960. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  85961. * @param diameter sets the diameter size (float) of the sphere (default 1)
  85962. * @param scene defines the hosting scene
  85963. * @param updatable defines if the mesh must be flagged as updatable
  85964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  85965. * @returns a new Mesh
  85966. */
  85967. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  85968. throw "Import MeshBuilder before creating meshes.";
  85969. };
  85970. /**
  85971. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  85972. * @param name defines the name of the mesh to create
  85973. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  85974. * @param diameterTop set the top cap diameter (floats, default 1)
  85975. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  85976. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  85977. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  85978. * @param scene defines the hosting scene
  85979. * @param updatable defines if the mesh must be flagged as updatable
  85980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  85981. * @returns a new Mesh
  85982. */
  85983. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  85984. throw "Import MeshBuilder before creating meshes.";
  85985. };
  85986. // Torus (Code from SharpDX.org)
  85987. /**
  85988. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  85989. * @param name defines the name of the mesh to create
  85990. * @param diameter sets the diameter size (float) of the torus (default 1)
  85991. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  85992. * @param tessellation sets the number of torus sides (postive integer, default 16)
  85993. * @param scene defines the hosting scene
  85994. * @param updatable defines if the mesh must be flagged as updatable
  85995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  85996. * @returns a new Mesh
  85997. */
  85998. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  85999. throw "Import MeshBuilder before creating meshes.";
  86000. };
  86001. /**
  86002. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  86003. * @param name defines the name of the mesh to create
  86004. * @param radius sets the global radius size (float) of the torus knot (default 2)
  86005. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  86006. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  86007. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  86008. * @param p the number of windings on X axis (positive integers, default 2)
  86009. * @param q the number of windings on Y axis (positive integers, default 3)
  86010. * @param scene defines the hosting scene
  86011. * @param updatable defines if the mesh must be flagged as updatable
  86012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86013. * @returns a new Mesh
  86014. */
  86015. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86016. throw "Import MeshBuilder before creating meshes.";
  86017. };
  86018. /**
  86019. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  86020. * @param name defines the name of the mesh to create
  86021. * @param points is an array successive Vector3
  86022. * @param scene defines the hosting scene
  86023. * @param updatable defines if the mesh must be flagged as updatable
  86024. * @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).
  86025. * @returns a new Mesh
  86026. */
  86027. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  86028. if (scene === void 0) { scene = null; }
  86029. if (updatable === void 0) { updatable = false; }
  86030. if (instance === void 0) { instance = null; }
  86031. throw "Import MeshBuilder before creating meshes.";
  86032. };
  86033. /**
  86034. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  86035. * @param name defines the name of the mesh to create
  86036. * @param points is an array successive Vector3
  86037. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  86038. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86039. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  86040. * @param scene defines the hosting scene
  86041. * @param updatable defines if the mesh must be flagged as updatable
  86042. * @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)
  86043. * @returns a new Mesh
  86044. */
  86045. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86046. if (scene === void 0) { scene = null; }
  86047. throw "Import MeshBuilder before creating meshes.";
  86048. };
  86049. /**
  86050. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  86051. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  86052. * 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.
  86053. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86054. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86055. * Remember you can only change the shape positions, not their number when updating a polygon.
  86056. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  86057. * @param name defines the name of the mesh to create
  86058. * @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
  86059. * @param scene defines the hosting scene
  86060. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86061. * @param updatable defines if the mesh must be flagged as updatable
  86062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86063. * @param earcutInjection can be used to inject your own earcut reference
  86064. * @returns a new Mesh
  86065. */
  86066. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  86067. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86068. throw "Import MeshBuilder before creating meshes.";
  86069. };
  86070. /**
  86071. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  86072. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  86073. * @param name defines the name of the mesh to create
  86074. * @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
  86075. * @param depth defines the height of extrusion
  86076. * @param scene defines the hosting scene
  86077. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86078. * @param updatable defines if the mesh must be flagged as updatable
  86079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86080. * @param earcutInjection can be used to inject your own earcut reference
  86081. * @returns a new Mesh
  86082. */
  86083. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  86084. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86085. throw "Import MeshBuilder before creating meshes.";
  86086. };
  86087. /**
  86088. * Creates an extruded shape mesh.
  86089. * 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
  86090. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86092. * @param name defines the name of the mesh to create
  86093. * @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
  86094. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86095. * @param scale is the value to scale the shape
  86096. * @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
  86097. * @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
  86098. * @param scene defines the hosting scene
  86099. * @param updatable defines if the mesh must be flagged as updatable
  86100. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86101. * @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)
  86102. * @returns a new Mesh
  86103. */
  86104. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86105. if (scene === void 0) { scene = null; }
  86106. throw "Import MeshBuilder before creating meshes.";
  86107. };
  86108. /**
  86109. * Creates an custom extruded shape mesh.
  86110. * The custom extrusion is a parametric shape.
  86111. * It has no predefined shape. Its final shape will depend on the input parameters.
  86112. * Please consider using the same method from the MeshBuilder class instead
  86113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86114. * @param name defines the name of the mesh to create
  86115. * @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
  86116. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86117. * @param scaleFunction is a custom Javascript function called on each path point
  86118. * @param rotationFunction is a custom Javascript function called on each path point
  86119. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86120. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  86121. * @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
  86122. * @param scene defines the hosting scene
  86123. * @param updatable defines if the mesh must be flagged as updatable
  86124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86125. * @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)
  86126. * @returns a new Mesh
  86127. */
  86128. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86129. throw "Import MeshBuilder before creating meshes.";
  86130. };
  86131. /**
  86132. * Creates lathe mesh.
  86133. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  86134. * Please consider using the same method from the MeshBuilder class instead
  86135. * @param name defines the name of the mesh to create
  86136. * @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
  86137. * @param radius is the radius value of the lathe
  86138. * @param tessellation is the side number of the lathe.
  86139. * @param scene defines the hosting scene
  86140. * @param updatable defines if the mesh must be flagged as updatable
  86141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86142. * @returns a new Mesh
  86143. */
  86144. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86145. throw "Import MeshBuilder before creating meshes.";
  86146. };
  86147. /**
  86148. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  86149. * @param name defines the name of the mesh to create
  86150. * @param size sets the size (float) of both sides of the plane at once (default 1)
  86151. * @param scene defines the hosting scene
  86152. * @param updatable defines if the mesh must be flagged as updatable
  86153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86154. * @returns a new Mesh
  86155. */
  86156. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86157. throw "Import MeshBuilder before creating meshes.";
  86158. };
  86159. /**
  86160. * Creates a ground mesh.
  86161. * Please consider using the same method from the MeshBuilder class instead
  86162. * @param name defines the name of the mesh to create
  86163. * @param width set the width of the ground
  86164. * @param height set the height of the ground
  86165. * @param subdivisions sets the number of subdivisions per side
  86166. * @param scene defines the hosting scene
  86167. * @param updatable defines if the mesh must be flagged as updatable
  86168. * @returns a new Mesh
  86169. */
  86170. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86171. throw "Import MeshBuilder before creating meshes.";
  86172. };
  86173. /**
  86174. * Creates a tiled ground mesh.
  86175. * Please consider using the same method from the MeshBuilder class instead
  86176. * @param name defines the name of the mesh to create
  86177. * @param xmin set the ground minimum X coordinate
  86178. * @param zmin set the ground minimum Y coordinate
  86179. * @param xmax set the ground maximum X coordinate
  86180. * @param zmax set the ground maximum Z coordinate
  86181. * @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
  86182. * @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
  86183. * @param scene defines the hosting scene
  86184. * @param updatable defines if the mesh must be flagged as updatable
  86185. * @returns a new Mesh
  86186. */
  86187. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86188. throw "Import MeshBuilder before creating meshes.";
  86189. };
  86190. /**
  86191. * Creates a ground mesh from a height map.
  86192. * Please consider using the same method from the MeshBuilder class instead
  86193. * @see http://doc.babylonjs.com/babylon101/height_map
  86194. * @param name defines the name of the mesh to create
  86195. * @param url sets the URL of the height map image resource
  86196. * @param width set the ground width size
  86197. * @param height set the ground height size
  86198. * @param subdivisions sets the number of subdivision per side
  86199. * @param minHeight is the minimum altitude on the ground
  86200. * @param maxHeight is the maximum altitude on the ground
  86201. * @param scene defines the hosting scene
  86202. * @param updatable defines if the mesh must be flagged as updatable
  86203. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  86204. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86205. * @returns a new Mesh
  86206. */
  86207. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86208. throw "Import MeshBuilder before creating meshes.";
  86209. };
  86210. /**
  86211. * Creates a tube mesh.
  86212. * The tube is a parametric shape.
  86213. * It has no predefined shape. Its final shape will depend on the input parameters.
  86214. * Please consider using the same method from the MeshBuilder class instead
  86215. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86216. * @param name defines the name of the mesh to create
  86217. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  86218. * @param radius sets the tube radius size
  86219. * @param tessellation is the number of sides on the tubular surface
  86220. * @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
  86221. * @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
  86222. * @param scene defines the hosting scene
  86223. * @param updatable defines if the mesh must be flagged as updatable
  86224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86225. * @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)
  86226. * @returns a new Mesh
  86227. */
  86228. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86229. throw "Import MeshBuilder before creating meshes.";
  86230. };
  86231. /**
  86232. * Creates a polyhedron mesh.
  86233. * Please consider using the same method from the MeshBuilder class instead.
  86234. * * 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
  86235. * * The parameter `size` (positive float, default 1) sets the polygon size
  86236. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  86237. * * 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`
  86238. * * 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
  86239. * * 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)`)
  86240. * * 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
  86241. * * 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
  86242. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86243. * * 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
  86244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86245. * @param name defines the name of the mesh to create
  86246. * @param options defines the options used to create the mesh
  86247. * @param scene defines the hosting scene
  86248. * @returns a new Mesh
  86249. */
  86250. Mesh.CreatePolyhedron = function (name, options, scene) {
  86251. throw "Import MeshBuilder before creating meshes.";
  86252. };
  86253. /**
  86254. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86255. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86256. * * 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`)
  86257. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86258. * * 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
  86259. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86260. * * 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
  86261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86262. * @param name defines the name of the mesh
  86263. * @param options defines the options used to create the mesh
  86264. * @param scene defines the hosting scene
  86265. * @returns a new Mesh
  86266. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86267. */
  86268. Mesh.CreateIcoSphere = function (name, options, scene) {
  86269. throw "Import MeshBuilder before creating meshes.";
  86270. };
  86271. /**
  86272. * Creates a decal mesh.
  86273. * Please consider using the same method from the MeshBuilder class instead.
  86274. * A decal is a mesh usually applied as a model onto the surface of another mesh
  86275. * @param name defines the name of the mesh
  86276. * @param sourceMesh defines the mesh receiving the decal
  86277. * @param position sets the position of the decal in world coordinates
  86278. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  86279. * @param size sets the decal scaling
  86280. * @param angle sets the angle to rotate the decal
  86281. * @returns a new Mesh
  86282. */
  86283. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86284. throw "Import MeshBuilder before creating meshes.";
  86285. };
  86286. // Skeletons
  86287. /**
  86288. * Prepare internal position array for software CPU skinning
  86289. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  86290. */
  86291. Mesh.prototype.setPositionsForCPUSkinning = function () {
  86292. if (!this._sourcePositions) {
  86293. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86294. if (!source) {
  86295. return this._sourcePositions;
  86296. }
  86297. this._sourcePositions = new Float32Array(source);
  86298. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86299. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  86300. }
  86301. }
  86302. return this._sourcePositions;
  86303. };
  86304. /**
  86305. * Prepare internal normal array for software CPU skinning
  86306. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  86307. */
  86308. Mesh.prototype.setNormalsForCPUSkinning = function () {
  86309. if (!this._sourceNormals) {
  86310. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86311. if (!source) {
  86312. return this._sourceNormals;
  86313. }
  86314. this._sourceNormals = new Float32Array(source);
  86315. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86316. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  86317. }
  86318. }
  86319. return this._sourceNormals;
  86320. };
  86321. /**
  86322. * Updates the vertex buffer by applying transformation from the bones
  86323. * @param skeleton defines the skeleton to apply to current mesh
  86324. * @returns the current mesh
  86325. */
  86326. Mesh.prototype.applySkeleton = function (skeleton) {
  86327. if (!this.geometry) {
  86328. return this;
  86329. }
  86330. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  86331. return this;
  86332. }
  86333. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  86334. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86335. return this;
  86336. }
  86337. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86338. return this;
  86339. }
  86340. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  86341. return this;
  86342. }
  86343. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86344. return this;
  86345. }
  86346. if (!this._sourcePositions) {
  86347. var submeshes = this.subMeshes.slice();
  86348. this.setPositionsForCPUSkinning();
  86349. this.subMeshes = submeshes;
  86350. }
  86351. if (!this._sourceNormals) {
  86352. this.setNormalsForCPUSkinning();
  86353. }
  86354. // positionsData checks for not being Float32Array will only pass at most once
  86355. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86356. if (!positionsData) {
  86357. return this;
  86358. }
  86359. if (!(positionsData instanceof Float32Array)) {
  86360. positionsData = new Float32Array(positionsData);
  86361. }
  86362. // normalsData checks for not being Float32Array will only pass at most once
  86363. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86364. if (!normalsData) {
  86365. return this;
  86366. }
  86367. if (!(normalsData instanceof Float32Array)) {
  86368. normalsData = new Float32Array(normalsData);
  86369. }
  86370. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86371. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86372. if (!matricesWeightsData || !matricesIndicesData) {
  86373. return this;
  86374. }
  86375. var needExtras = this.numBoneInfluencers > 4;
  86376. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  86377. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  86378. var skeletonMatrices = skeleton.getTransformMatrices(this);
  86379. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86380. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86381. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86382. var matWeightIdx = 0;
  86383. var inf;
  86384. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  86385. var weight;
  86386. for (inf = 0; inf < 4; inf++) {
  86387. weight = matricesWeightsData[matWeightIdx + inf];
  86388. if (weight > 0) {
  86389. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86390. finalMatrix.addToSelf(tempMatrix);
  86391. }
  86392. }
  86393. if (needExtras) {
  86394. for (inf = 0; inf < 4; inf++) {
  86395. weight = matricesWeightsExtraData[matWeightIdx + inf];
  86396. if (weight > 0) {
  86397. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86398. finalMatrix.addToSelf(tempMatrix);
  86399. }
  86400. }
  86401. }
  86402. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  86403. tempVector3.toArray(positionsData, index);
  86404. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  86405. tempVector3.toArray(normalsData, index);
  86406. finalMatrix.reset();
  86407. }
  86408. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  86409. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  86410. return this;
  86411. };
  86412. // Tools
  86413. /**
  86414. * 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
  86415. * @param meshes defines the list of meshes to scan
  86416. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  86417. */
  86418. Mesh.MinMax = function (meshes) {
  86419. var minVector = null;
  86420. var maxVector = null;
  86421. meshes.forEach(function (mesh) {
  86422. var boundingInfo = mesh.getBoundingInfo();
  86423. var boundingBox = boundingInfo.boundingBox;
  86424. if (!minVector || !maxVector) {
  86425. minVector = boundingBox.minimumWorld;
  86426. maxVector = boundingBox.maximumWorld;
  86427. }
  86428. else {
  86429. minVector.minimizeInPlace(boundingBox.minimumWorld);
  86430. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  86431. }
  86432. });
  86433. if (!minVector || !maxVector) {
  86434. return {
  86435. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  86436. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  86437. };
  86438. }
  86439. return {
  86440. min: minVector,
  86441. max: maxVector
  86442. };
  86443. };
  86444. /**
  86445. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  86446. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  86447. * @returns a vector3
  86448. */
  86449. Mesh.Center = function (meshesOrMinMaxVector) {
  86450. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  86451. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  86452. };
  86453. /**
  86454. * Merge the array of meshes into a single mesh for performance reasons.
  86455. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  86456. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  86457. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  86458. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  86459. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  86460. * @returns a new mesh
  86461. */
  86462. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes) {
  86463. if (disposeSource === void 0) { disposeSource = true; }
  86464. var index;
  86465. if (!allow32BitsIndices) {
  86466. var totalVertices = 0;
  86467. // Counting vertices
  86468. for (index = 0; index < meshes.length; index++) {
  86469. if (meshes[index]) {
  86470. totalVertices += meshes[index].getTotalVertices();
  86471. if (totalVertices > 65536) {
  86472. _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");
  86473. return null;
  86474. }
  86475. }
  86476. }
  86477. }
  86478. // Merge
  86479. var vertexData = null;
  86480. var otherVertexData;
  86481. var indiceArray = new Array();
  86482. var source = null;
  86483. for (index = 0; index < meshes.length; index++) {
  86484. if (meshes[index]) {
  86485. var wm = meshes[index].computeWorldMatrix(true);
  86486. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(meshes[index], true, true);
  86487. otherVertexData.transform(wm);
  86488. if (vertexData) {
  86489. vertexData.merge(otherVertexData, allow32BitsIndices);
  86490. }
  86491. else {
  86492. vertexData = otherVertexData;
  86493. source = meshes[index];
  86494. }
  86495. if (subdivideWithSubMeshes) {
  86496. indiceArray.push(meshes[index].getTotalIndices());
  86497. }
  86498. }
  86499. }
  86500. source = source;
  86501. if (!meshSubclass) {
  86502. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  86503. }
  86504. vertexData.applyToMesh(meshSubclass);
  86505. // Setting properties
  86506. meshSubclass.material = source.material;
  86507. meshSubclass.checkCollisions = source.checkCollisions;
  86508. // Cleaning
  86509. if (disposeSource) {
  86510. for (index = 0; index < meshes.length; index++) {
  86511. if (meshes[index]) {
  86512. meshes[index].dispose();
  86513. }
  86514. }
  86515. }
  86516. // Subdivide
  86517. if (subdivideWithSubMeshes) {
  86518. //-- removal of global submesh
  86519. meshSubclass.releaseSubMeshes();
  86520. index = 0;
  86521. var offset = 0;
  86522. //-- apply subdivision according to index table
  86523. while (index < indiceArray.length) {
  86524. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  86525. offset += indiceArray[index];
  86526. index++;
  86527. }
  86528. }
  86529. return meshSubclass;
  86530. };
  86531. /** @hidden */
  86532. Mesh.prototype.addInstance = function (instance) {
  86533. instance._indexInSourceMeshInstanceArray = this.instances.length;
  86534. this.instances.push(instance);
  86535. };
  86536. /** @hidden */
  86537. Mesh.prototype.removeInstance = function (instance) {
  86538. // Remove from mesh
  86539. var index = instance._indexInSourceMeshInstanceArray;
  86540. if (index != -1) {
  86541. if (index !== this.instances.length - 1) {
  86542. var last = this.instances[this.instances.length - 1];
  86543. this.instances[index] = last;
  86544. last._indexInSourceMeshInstanceArray = index;
  86545. }
  86546. instance._indexInSourceMeshInstanceArray = -1;
  86547. this.instances.pop();
  86548. }
  86549. };
  86550. // Consts
  86551. /**
  86552. * Mesh side orientation : usually the external or front surface
  86553. */
  86554. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  86555. /**
  86556. * Mesh side orientation : usually the internal or back surface
  86557. */
  86558. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  86559. /**
  86560. * Mesh side orientation : both internal and external or front and back surfaces
  86561. */
  86562. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  86563. /**
  86564. * Mesh side orientation : by default, `FRONTSIDE`
  86565. */
  86566. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  86567. /**
  86568. * Mesh cap setting : no cap
  86569. */
  86570. Mesh.NO_CAP = 0;
  86571. /**
  86572. * Mesh cap setting : one cap at the beginning of the mesh
  86573. */
  86574. Mesh.CAP_START = 1;
  86575. /**
  86576. * Mesh cap setting : one cap at the end of the mesh
  86577. */
  86578. Mesh.CAP_END = 2;
  86579. /**
  86580. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86581. */
  86582. Mesh.CAP_ALL = 3;
  86583. // Instances
  86584. /** @hidden */
  86585. Mesh._instancedMeshFactory = function (name, mesh) {
  86586. throw "Import InstancedMesh before creating instances.";
  86587. };
  86588. // Statics
  86589. /** @hidden */
  86590. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  86591. throw "Import GroundMesh before trying to parse it.";
  86592. };
  86593. return Mesh;
  86594. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  86595. /***/ }),
  86596. /***/ "./Meshes/mesh.vertexData.ts":
  86597. /*!***********************************!*\
  86598. !*** ./Meshes/mesh.vertexData.ts ***!
  86599. \***********************************/
  86600. /*! exports provided: VertexData */
  86601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86602. "use strict";
  86603. __webpack_require__.r(__webpack_exports__);
  86604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  86605. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86606. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86607. /**
  86608. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86609. */
  86610. var VertexData = /** @class */ (function () {
  86611. function VertexData() {
  86612. }
  86613. /**
  86614. * Uses the passed data array to set the set the values for the specified kind of data
  86615. * @param data a linear array of floating numbers
  86616. * @param kind the type of data that is being set, eg positions, colors etc
  86617. */
  86618. VertexData.prototype.set = function (data, kind) {
  86619. switch (kind) {
  86620. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  86621. this.positions = data;
  86622. break;
  86623. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  86624. this.normals = data;
  86625. break;
  86626. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  86627. this.tangents = data;
  86628. break;
  86629. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  86630. this.uvs = data;
  86631. break;
  86632. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  86633. this.uvs2 = data;
  86634. break;
  86635. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  86636. this.uvs3 = data;
  86637. break;
  86638. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  86639. this.uvs4 = data;
  86640. break;
  86641. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  86642. this.uvs5 = data;
  86643. break;
  86644. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  86645. this.uvs6 = data;
  86646. break;
  86647. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  86648. this.colors = data;
  86649. break;
  86650. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  86651. this.matricesIndices = data;
  86652. break;
  86653. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  86654. this.matricesWeights = data;
  86655. break;
  86656. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  86657. this.matricesIndicesExtra = data;
  86658. break;
  86659. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  86660. this.matricesWeightsExtra = data;
  86661. break;
  86662. }
  86663. };
  86664. /**
  86665. * Associates the vertexData to the passed Mesh.
  86666. * Sets it as updatable or not (default `false`)
  86667. * @param mesh the mesh the vertexData is applied to
  86668. * @param updatable when used and having the value true allows new data to update the vertexData
  86669. * @returns the VertexData
  86670. */
  86671. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  86672. this._applyTo(mesh, updatable);
  86673. return this;
  86674. };
  86675. /**
  86676. * Associates the vertexData to the passed Geometry.
  86677. * Sets it as updatable or not (default `false`)
  86678. * @param geometry the geometry the vertexData is applied to
  86679. * @param updatable when used and having the value true allows new data to update the vertexData
  86680. * @returns VertexData
  86681. */
  86682. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  86683. this._applyTo(geometry, updatable);
  86684. return this;
  86685. };
  86686. /**
  86687. * Updates the associated mesh
  86688. * @param mesh the mesh to be updated
  86689. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86690. * @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
  86691. * @returns VertexData
  86692. */
  86693. VertexData.prototype.updateMesh = function (mesh) {
  86694. this._update(mesh);
  86695. return this;
  86696. };
  86697. /**
  86698. * Updates the associated geometry
  86699. * @param geometry the geometry to be updated
  86700. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86701. * @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
  86702. * @returns VertexData.
  86703. */
  86704. VertexData.prototype.updateGeometry = function (geometry) {
  86705. this._update(geometry);
  86706. return this;
  86707. };
  86708. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  86709. if (updatable === void 0) { updatable = false; }
  86710. if (this.positions) {
  86711. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  86712. }
  86713. if (this.normals) {
  86714. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  86715. }
  86716. if (this.tangents) {
  86717. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  86718. }
  86719. if (this.uvs) {
  86720. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  86721. }
  86722. if (this.uvs2) {
  86723. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  86724. }
  86725. if (this.uvs3) {
  86726. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  86727. }
  86728. if (this.uvs4) {
  86729. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  86730. }
  86731. if (this.uvs5) {
  86732. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  86733. }
  86734. if (this.uvs6) {
  86735. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  86736. }
  86737. if (this.colors) {
  86738. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  86739. }
  86740. if (this.matricesIndices) {
  86741. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  86742. }
  86743. if (this.matricesWeights) {
  86744. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  86745. }
  86746. if (this.matricesIndicesExtra) {
  86747. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  86748. }
  86749. if (this.matricesWeightsExtra) {
  86750. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  86751. }
  86752. if (this.indices) {
  86753. meshOrGeometry.setIndices(this.indices, null, updatable);
  86754. }
  86755. else {
  86756. meshOrGeometry.setIndices([], null);
  86757. }
  86758. return this;
  86759. };
  86760. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  86761. if (this.positions) {
  86762. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  86763. }
  86764. if (this.normals) {
  86765. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  86766. }
  86767. if (this.tangents) {
  86768. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  86769. }
  86770. if (this.uvs) {
  86771. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  86772. }
  86773. if (this.uvs2) {
  86774. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  86775. }
  86776. if (this.uvs3) {
  86777. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  86778. }
  86779. if (this.uvs4) {
  86780. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  86781. }
  86782. if (this.uvs5) {
  86783. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  86784. }
  86785. if (this.uvs6) {
  86786. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  86787. }
  86788. if (this.colors) {
  86789. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  86790. }
  86791. if (this.matricesIndices) {
  86792. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  86793. }
  86794. if (this.matricesWeights) {
  86795. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  86796. }
  86797. if (this.matricesIndicesExtra) {
  86798. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  86799. }
  86800. if (this.matricesWeightsExtra) {
  86801. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  86802. }
  86803. if (this.indices) {
  86804. meshOrGeometry.setIndices(this.indices, null);
  86805. }
  86806. return this;
  86807. };
  86808. /**
  86809. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86810. * @param matrix the transforming matrix
  86811. * @returns the VertexData
  86812. */
  86813. VertexData.prototype.transform = function (matrix) {
  86814. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  86815. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  86816. var index;
  86817. if (this.positions) {
  86818. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  86819. for (index = 0; index < this.positions.length; index += 3) {
  86820. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  86821. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  86822. this.positions[index] = transformed.x;
  86823. this.positions[index + 1] = transformed.y;
  86824. this.positions[index + 2] = transformed.z;
  86825. }
  86826. }
  86827. if (this.normals) {
  86828. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  86829. for (index = 0; index < this.normals.length; index += 3) {
  86830. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  86831. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  86832. this.normals[index] = transformed.x;
  86833. this.normals[index + 1] = transformed.y;
  86834. this.normals[index + 2] = transformed.z;
  86835. }
  86836. }
  86837. if (this.tangents) {
  86838. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  86839. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  86840. for (index = 0; index < this.tangents.length; index += 4) {
  86841. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  86842. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  86843. this.tangents[index] = tangentTransformed.x;
  86844. this.tangents[index + 1] = tangentTransformed.y;
  86845. this.tangents[index + 2] = tangentTransformed.z;
  86846. this.tangents[index + 3] = tangentTransformed.w;
  86847. }
  86848. }
  86849. if (flip && this.indices) {
  86850. for (index = 0; index < this.indices.length; index += 3) {
  86851. var tmp = this.indices[index + 1];
  86852. this.indices[index + 1] = this.indices[index + 2];
  86853. this.indices[index + 2] = tmp;
  86854. }
  86855. }
  86856. return this;
  86857. };
  86858. /**
  86859. * Merges the passed VertexData into the current one
  86860. * @param other the VertexData to be merged into the current one
  86861. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86862. * @returns the modified VertexData
  86863. */
  86864. VertexData.prototype.merge = function (other, use32BitsIndices) {
  86865. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  86866. this._validate();
  86867. other._validate();
  86868. if (!this.normals !== !other.normals ||
  86869. !this.tangents !== !other.tangents ||
  86870. !this.uvs !== !other.uvs ||
  86871. !this.uvs2 !== !other.uvs2 ||
  86872. !this.uvs3 !== !other.uvs3 ||
  86873. !this.uvs4 !== !other.uvs4 ||
  86874. !this.uvs5 !== !other.uvs5 ||
  86875. !this.uvs6 !== !other.uvs6 ||
  86876. !this.colors !== !other.colors ||
  86877. !this.matricesIndices !== !other.matricesIndices ||
  86878. !this.matricesWeights !== !other.matricesWeights ||
  86879. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  86880. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  86881. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  86882. }
  86883. if (other.indices) {
  86884. if (!this.indices) {
  86885. this.indices = [];
  86886. }
  86887. var offset = this.positions ? this.positions.length / 3 : 0;
  86888. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  86889. if (isSrcTypedArray) {
  86890. var len = this.indices.length + other.indices.length;
  86891. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  86892. temp.set(this.indices);
  86893. var decal = this.indices.length;
  86894. for (var index = 0; index < other.indices.length; index++) {
  86895. temp[decal + index] = other.indices[index] + offset;
  86896. }
  86897. this.indices = temp;
  86898. }
  86899. else {
  86900. for (var index = 0; index < other.indices.length; index++) {
  86901. this.indices.push(other.indices[index] + offset);
  86902. }
  86903. }
  86904. }
  86905. this.positions = this._mergeElement(this.positions, other.positions);
  86906. this.normals = this._mergeElement(this.normals, other.normals);
  86907. this.tangents = this._mergeElement(this.tangents, other.tangents);
  86908. this.uvs = this._mergeElement(this.uvs, other.uvs);
  86909. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  86910. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  86911. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  86912. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  86913. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  86914. this.colors = this._mergeElement(this.colors, other.colors);
  86915. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  86916. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  86917. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  86918. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  86919. return this;
  86920. };
  86921. VertexData.prototype._mergeElement = function (source, other) {
  86922. if (!source) {
  86923. return other;
  86924. }
  86925. if (!other) {
  86926. return source;
  86927. }
  86928. var len = other.length + source.length;
  86929. var isSrcTypedArray = source instanceof Float32Array;
  86930. var isOthTypedArray = other instanceof Float32Array;
  86931. // use non-loop method when the source is Float32Array
  86932. if (isSrcTypedArray) {
  86933. var ret32 = new Float32Array(len);
  86934. ret32.set(source);
  86935. ret32.set(other, source.length);
  86936. return ret32;
  86937. // source is number[], when other is also use concat
  86938. }
  86939. else if (!isOthTypedArray) {
  86940. return source.concat(other);
  86941. // source is a number[], but other is a Float32Array, loop required
  86942. }
  86943. else {
  86944. var ret = source.slice(0); // copy source to a separate array
  86945. for (var i = 0, len = other.length; i < len; i++) {
  86946. ret.push(other[i]);
  86947. }
  86948. return ret;
  86949. }
  86950. };
  86951. VertexData.prototype._validate = function () {
  86952. if (!this.positions) {
  86953. throw new Error("Positions are required");
  86954. }
  86955. var getElementCount = function (kind, values) {
  86956. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  86957. if ((values.length % stride) !== 0) {
  86958. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  86959. }
  86960. return values.length / stride;
  86961. };
  86962. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  86963. var validateElementCount = function (kind, values) {
  86964. var elementCount = getElementCount(kind, values);
  86965. if (elementCount !== positionsElementCount) {
  86966. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  86967. }
  86968. };
  86969. if (this.normals) {
  86970. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  86971. }
  86972. if (this.tangents) {
  86973. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  86974. }
  86975. if (this.uvs) {
  86976. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  86977. }
  86978. if (this.uvs2) {
  86979. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  86980. }
  86981. if (this.uvs3) {
  86982. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  86983. }
  86984. if (this.uvs4) {
  86985. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  86986. }
  86987. if (this.uvs5) {
  86988. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  86989. }
  86990. if (this.uvs6) {
  86991. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  86992. }
  86993. if (this.colors) {
  86994. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  86995. }
  86996. if (this.matricesIndices) {
  86997. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  86998. }
  86999. if (this.matricesWeights) {
  87000. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  87001. }
  87002. if (this.matricesIndicesExtra) {
  87003. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  87004. }
  87005. if (this.matricesWeightsExtra) {
  87006. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  87007. }
  87008. };
  87009. /**
  87010. * Serializes the VertexData
  87011. * @returns a serialized object
  87012. */
  87013. VertexData.prototype.serialize = function () {
  87014. var serializationObject = this.serialize();
  87015. if (this.positions) {
  87016. serializationObject.positions = this.positions;
  87017. }
  87018. if (this.normals) {
  87019. serializationObject.normals = this.normals;
  87020. }
  87021. if (this.tangents) {
  87022. serializationObject.tangents = this.tangents;
  87023. }
  87024. if (this.uvs) {
  87025. serializationObject.uvs = this.uvs;
  87026. }
  87027. if (this.uvs2) {
  87028. serializationObject.uvs2 = this.uvs2;
  87029. }
  87030. if (this.uvs3) {
  87031. serializationObject.uvs3 = this.uvs3;
  87032. }
  87033. if (this.uvs4) {
  87034. serializationObject.uvs4 = this.uvs4;
  87035. }
  87036. if (this.uvs5) {
  87037. serializationObject.uvs5 = this.uvs5;
  87038. }
  87039. if (this.uvs6) {
  87040. serializationObject.uvs6 = this.uvs6;
  87041. }
  87042. if (this.colors) {
  87043. serializationObject.colors = this.colors;
  87044. }
  87045. if (this.matricesIndices) {
  87046. serializationObject.matricesIndices = this.matricesIndices;
  87047. serializationObject.matricesIndices._isExpanded = true;
  87048. }
  87049. if (this.matricesWeights) {
  87050. serializationObject.matricesWeights = this.matricesWeights;
  87051. }
  87052. if (this.matricesIndicesExtra) {
  87053. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  87054. serializationObject.matricesIndicesExtra._isExpanded = true;
  87055. }
  87056. if (this.matricesWeightsExtra) {
  87057. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  87058. }
  87059. serializationObject.indices = this.indices;
  87060. return serializationObject;
  87061. };
  87062. // Statics
  87063. /**
  87064. * Extracts the vertexData from a mesh
  87065. * @param mesh the mesh from which to extract the VertexData
  87066. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87067. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87068. * @returns the object VertexData associated to the passed mesh
  87069. */
  87070. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  87071. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  87072. };
  87073. /**
  87074. * Extracts the vertexData from the geometry
  87075. * @param geometry the geometry from which to extract the VertexData
  87076. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87077. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87078. * @returns the object VertexData associated to the passed mesh
  87079. */
  87080. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  87081. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  87082. };
  87083. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  87084. var result = new VertexData();
  87085. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  87086. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  87087. }
  87088. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  87089. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  87090. }
  87091. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  87092. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  87093. }
  87094. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  87095. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  87096. }
  87097. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  87098. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  87099. }
  87100. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  87101. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  87102. }
  87103. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  87104. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  87105. }
  87106. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  87107. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  87108. }
  87109. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  87110. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  87111. }
  87112. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  87113. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  87114. }
  87115. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  87116. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  87117. }
  87118. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  87119. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  87120. }
  87121. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  87122. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  87123. }
  87124. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87125. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  87126. }
  87127. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  87128. return result;
  87129. };
  87130. /**
  87131. * Creates the VertexData for a Ribbon
  87132. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87133. * * pathArray array of paths, each of which an array of successive Vector3
  87134. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87135. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87136. * * 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
  87137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87138. * * 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)
  87139. * * 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)
  87140. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87141. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87142. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87143. * @returns the VertexData of the ribbon
  87144. */
  87145. VertexData.CreateRibbon = function (options) {
  87146. throw "Import Meshes/Builders/ribbonBuilder before trying to create ribbons.";
  87147. };
  87148. /**
  87149. * Creates the VertexData for a box
  87150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87151. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87152. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87153. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87154. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87155. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87156. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87158. * * 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)
  87159. * * 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)
  87160. * @returns the VertexData of the box
  87161. */
  87162. VertexData.CreateBox = function (options) {
  87163. throw "Import Meshes/Builders/boxBuilder before trying to create boxes.";
  87164. };
  87165. /**
  87166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87168. * * segments sets the number of horizontal strips optional, default 32
  87169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87173. * * 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
  87174. * * 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
  87175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87176. * * 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)
  87177. * * 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)
  87178. * @returns the VertexData of the ellipsoid
  87179. */
  87180. VertexData.CreateSphere = function (options) {
  87181. throw "Import Meshes/Builders/sphereBuilder before trying to create spheres.";
  87182. };
  87183. /**
  87184. * Creates the VertexData for a cylinder, cone or prism
  87185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87186. * * height sets the height (y direction) of the cylinder, optional, default 2
  87187. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87188. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87189. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87190. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87191. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87192. * * 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
  87193. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87194. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87195. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87196. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87198. * * 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)
  87199. * * 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)
  87200. * @returns the VertexData of the cylinder, cone or prism
  87201. */
  87202. VertexData.CreateCylinder = function (options) {
  87203. throw "Import Meshes/Builders/cylinderBuilder before trying to create cylinders.";
  87204. };
  87205. /**
  87206. * Creates the VertexData for a torus
  87207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87208. * * diameter the diameter of the torus, optional default 1
  87209. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87210. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87212. * * 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)
  87213. * * 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)
  87214. * @returns the VertexData of the torus
  87215. */
  87216. VertexData.CreateTorus = function (options) {
  87217. throw "Import Meshes/Builders/torusBuilder before trying to create torus.";
  87218. };
  87219. /**
  87220. * Creates the VertexData of the LineSystem
  87221. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87222. * - lines an array of lines, each line being an array of successive Vector3
  87223. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87224. * @returns the VertexData of the LineSystem
  87225. */
  87226. VertexData.CreateLineSystem = function (options) {
  87227. throw "Import Meshes/Builders/linesBuilder before trying to create lines.";
  87228. };
  87229. /**
  87230. * Create the VertexData for a DashedLines
  87231. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87232. * - points an array successive Vector3
  87233. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87234. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87235. * - dashNb the intended total number of dashes, optional, default 200
  87236. * @returns the VertexData for the DashedLines
  87237. */
  87238. VertexData.CreateDashedLines = function (options) {
  87239. throw "Import Meshes/Builders/linesBuilder before trying to create dashed lines.";
  87240. };
  87241. /**
  87242. * Creates the VertexData for a Ground
  87243. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87244. * - width the width (x direction) of the ground, optional, default 1
  87245. * - height the height (z direction) of the ground, optional, default 1
  87246. * - subdivisions the number of subdivisions per side, optional, default 1
  87247. * @returns the VertexData of the Ground
  87248. */
  87249. VertexData.CreateGround = function (options) {
  87250. throw "Import Meshes/Builders/groundBuilder before trying to create grounds.";
  87251. };
  87252. /**
  87253. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87254. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87255. * * xmin the ground minimum X coordinate, optional, default -1
  87256. * * zmin the ground minimum Z coordinate, optional, default -1
  87257. * * xmax the ground maximum X coordinate, optional, default 1
  87258. * * zmax the ground maximum Z coordinate, optional, default 1
  87259. * * 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}
  87260. * * 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}
  87261. * @returns the VertexData of the TiledGround
  87262. */
  87263. VertexData.CreateTiledGround = function (options) {
  87264. throw "Import Meshes/Builders/groundBuilder before trying to create grounds.";
  87265. };
  87266. /**
  87267. * Creates the VertexData of the Ground designed from a heightmap
  87268. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87269. * * width the width (x direction) of the ground
  87270. * * height the height (z direction) of the ground
  87271. * * subdivisions the number of subdivisions per side
  87272. * * minHeight the minimum altitude on the ground, optional, default 0
  87273. * * maxHeight the maximum altitude on the ground, optional default 1
  87274. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87275. * * buffer the array holding the image color data
  87276. * * bufferWidth the width of image
  87277. * * bufferHeight the height of image
  87278. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87279. * @returns the VertexData of the Ground designed from a heightmap
  87280. */
  87281. VertexData.CreateGroundFromHeightMap = function (options) {
  87282. throw "Import Meshes/Builders/groundBuilder before trying to create grounds.";
  87283. };
  87284. /**
  87285. * Creates the VertexData for a Plane
  87286. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87287. * * size sets the width and height of the plane to the value of size, optional default 1
  87288. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87289. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87291. * * 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)
  87292. * * 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)
  87293. * @returns the VertexData of the box
  87294. */
  87295. VertexData.CreatePlane = function (options) {
  87296. throw "Import Meshes/Builders/planeBuilder before trying to create planes.";
  87297. };
  87298. /**
  87299. * Creates the VertexData of the Disc or regular Polygon
  87300. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87301. * * radius the radius of the disc, optional default 0.5
  87302. * * tessellation the number of polygon sides, optional, default 64
  87303. * * 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
  87304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87305. * * 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)
  87306. * * 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)
  87307. * @returns the VertexData of the box
  87308. */
  87309. VertexData.CreateDisc = function (options) {
  87310. throw "Import Meshes/Builders/discBuilder before trying to create discs.";
  87311. };
  87312. /**
  87313. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87314. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87315. * @param polygon a mesh built from polygonTriangulation.build()
  87316. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87317. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87318. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87319. * @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)
  87320. * @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)
  87321. * @returns the VertexData of the Polygon
  87322. */
  87323. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  87324. throw "Import Meshes/Builders/polygonBuilder before trying to create polygons.";
  87325. };
  87326. /**
  87327. * Creates the VertexData of the IcoSphere
  87328. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87329. * * radius the radius of the IcoSphere, optional default 1
  87330. * * radiusX allows stretching in the x direction, optional, default radius
  87331. * * radiusY allows stretching in the y direction, optional, default radius
  87332. * * radiusZ allows stretching in the z direction, optional, default radius
  87333. * * flat when true creates a flat shaded mesh, optional, default true
  87334. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87336. * * 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)
  87337. * * 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)
  87338. * @returns the VertexData of the IcoSphere
  87339. */
  87340. VertexData.CreateIcoSphere = function (options) {
  87341. throw "Import Meshes/Builders/icoSphereBuilder before trying to create icoSpheres.";
  87342. };
  87343. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  87344. /**
  87345. * Creates the VertexData for a Polyhedron
  87346. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87347. * * type provided types are:
  87348. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87349. * * 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)
  87350. * * size the size of the IcoSphere, optional default 1
  87351. * * sizeX allows stretching in the x direction, optional, default size
  87352. * * sizeY allows stretching in the y direction, optional, default size
  87353. * * sizeZ allows stretching in the z direction, optional, default size
  87354. * * 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
  87355. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87356. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87357. * * flat when true creates a flat shaded mesh, optional, default true
  87358. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87360. * * 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)
  87361. * * 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)
  87362. * @returns the VertexData of the Polyhedron
  87363. */
  87364. VertexData.CreatePolyhedron = function (options) {
  87365. throw "Import Meshes/Builders/polyhedronBuilder before trying to create polyhedrons.";
  87366. };
  87367. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  87368. /**
  87369. * Creates the VertexData for a TorusKnot
  87370. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87371. * * radius the radius of the torus knot, optional, default 2
  87372. * * tube the thickness of the tube, optional, default 0.5
  87373. * * radialSegments the number of sides on each tube segments, optional, default 32
  87374. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87375. * * p the number of windings around the z axis, optional, default 2
  87376. * * q the number of windings around the x axis, optional, default 3
  87377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87378. * * 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)
  87379. * * 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)
  87380. * @returns the VertexData of the Torus Knot
  87381. */
  87382. VertexData.CreateTorusKnot = function (options) {
  87383. throw "Import Meshes/Builders/torusKnotBuilder before trying to create torusKnots.";
  87384. };
  87385. // Tools
  87386. /**
  87387. * Compute normals for given positions and indices
  87388. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87389. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87390. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87391. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87392. * * facetNormals : optional array of facet normals (vector3)
  87393. * * facetPositions : optional array of facet positions (vector3)
  87394. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87395. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87396. * * bInfo : optional bounding info, required for facetPartitioning computation
  87397. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87398. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87399. * * useRightHandedSystem: optional boolean to for right handed system computation
  87400. * * depthSort : optional boolean to enable the facet depth sort computation
  87401. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87402. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87403. */
  87404. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  87405. // temporary scalar variables
  87406. var index = 0; // facet index
  87407. var p1p2x = 0.0; // p1p2 vector x coordinate
  87408. var p1p2y = 0.0; // p1p2 vector y coordinate
  87409. var p1p2z = 0.0; // p1p2 vector z coordinate
  87410. var p3p2x = 0.0; // p3p2 vector x coordinate
  87411. var p3p2y = 0.0; // p3p2 vector y coordinate
  87412. var p3p2z = 0.0; // p3p2 vector z coordinate
  87413. var faceNormalx = 0.0; // facet normal x coordinate
  87414. var faceNormaly = 0.0; // facet normal y coordinate
  87415. var faceNormalz = 0.0; // facet normal z coordinate
  87416. var length = 0.0; // facet normal length before normalization
  87417. var v1x = 0; // vector1 x index in the positions array
  87418. var v1y = 0; // vector1 y index in the positions array
  87419. var v1z = 0; // vector1 z index in the positions array
  87420. var v2x = 0; // vector2 x index in the positions array
  87421. var v2y = 0; // vector2 y index in the positions array
  87422. var v2z = 0; // vector2 z index in the positions array
  87423. var v3x = 0; // vector3 x index in the positions array
  87424. var v3y = 0; // vector3 y index in the positions array
  87425. var v3z = 0; // vector3 z index in the positions array
  87426. var computeFacetNormals = false;
  87427. var computeFacetPositions = false;
  87428. var computeFacetPartitioning = false;
  87429. var computeDepthSort = false;
  87430. var faceNormalSign = 1;
  87431. var ratio = 0;
  87432. var distanceTo = null;
  87433. if (options) {
  87434. computeFacetNormals = (options.facetNormals) ? true : false;
  87435. computeFacetPositions = (options.facetPositions) ? true : false;
  87436. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  87437. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  87438. ratio = options.ratio || 0;
  87439. computeDepthSort = (options.depthSort) ? true : false;
  87440. distanceTo = (options.distanceTo);
  87441. if (computeDepthSort) {
  87442. if (distanceTo === undefined) {
  87443. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87444. }
  87445. var depthSortedFacets = options.depthSortedFacets;
  87446. }
  87447. }
  87448. // facetPartitioning reinit if needed
  87449. var xSubRatio = 0;
  87450. var ySubRatio = 0;
  87451. var zSubRatio = 0;
  87452. var subSq = 0;
  87453. if (computeFacetPartitioning && options && options.bbSize) {
  87454. var ox = 0; // X partitioning index for facet position
  87455. var oy = 0; // Y partinioning index for facet position
  87456. var oz = 0; // Z partinioning index for facet position
  87457. var b1x = 0; // X partitioning index for facet v1 vertex
  87458. var b1y = 0; // Y partitioning index for facet v1 vertex
  87459. var b1z = 0; // z partitioning index for facet v1 vertex
  87460. var b2x = 0; // X partitioning index for facet v2 vertex
  87461. var b2y = 0; // Y partitioning index for facet v2 vertex
  87462. var b2z = 0; // Z partitioning index for facet v2 vertex
  87463. var b3x = 0; // X partitioning index for facet v3 vertex
  87464. var b3y = 0; // Y partitioning index for facet v3 vertex
  87465. var b3z = 0; // Z partitioning index for facet v3 vertex
  87466. var block_idx_o = 0; // facet barycenter block index
  87467. var block_idx_v1 = 0; // v1 vertex block index
  87468. var block_idx_v2 = 0; // v2 vertex block index
  87469. var block_idx_v3 = 0; // v3 vertex block index
  87470. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  87471. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  87472. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  87473. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  87474. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  87475. subSq = options.subDiv.max * options.subDiv.max;
  87476. options.facetPartitioning.length = 0;
  87477. }
  87478. // reset the normals
  87479. for (index = 0; index < positions.length; index++) {
  87480. normals[index] = 0.0;
  87481. }
  87482. // Loop : 1 indice triplet = 1 facet
  87483. var nbFaces = (indices.length / 3) | 0;
  87484. for (index = 0; index < nbFaces; index++) {
  87485. // get the indexes of the coordinates of each vertex of the facet
  87486. v1x = indices[index * 3] * 3;
  87487. v1y = v1x + 1;
  87488. v1z = v1x + 2;
  87489. v2x = indices[index * 3 + 1] * 3;
  87490. v2y = v2x + 1;
  87491. v2z = v2x + 2;
  87492. v3x = indices[index * 3 + 2] * 3;
  87493. v3y = v3x + 1;
  87494. v3z = v3x + 2;
  87495. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  87496. p1p2y = positions[v1y] - positions[v2y];
  87497. p1p2z = positions[v1z] - positions[v2z];
  87498. p3p2x = positions[v3x] - positions[v2x];
  87499. p3p2y = positions[v3y] - positions[v2y];
  87500. p3p2z = positions[v3z] - positions[v2z];
  87501. // compute the face normal with the cross product
  87502. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  87503. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  87504. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  87505. // normalize this normal and store it in the array facetData
  87506. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87507. length = (length === 0) ? 1.0 : length;
  87508. faceNormalx /= length;
  87509. faceNormaly /= length;
  87510. faceNormalz /= length;
  87511. if (computeFacetNormals && options) {
  87512. options.facetNormals[index].x = faceNormalx;
  87513. options.facetNormals[index].y = faceNormaly;
  87514. options.facetNormals[index].z = faceNormalz;
  87515. }
  87516. if (computeFacetPositions && options) {
  87517. // compute and the facet barycenter coordinates in the array facetPositions
  87518. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  87519. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  87520. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  87521. }
  87522. if (computeFacetPartitioning && options) {
  87523. // store the facet indexes in arrays in the main facetPartitioning array :
  87524. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  87525. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  87526. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  87527. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  87528. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87529. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87530. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87531. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87532. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87533. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87534. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87535. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87536. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87537. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  87538. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  87539. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  87540. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  87541. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  87542. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  87543. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  87544. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  87545. // push each facet index in each block containing the vertex
  87546. options.facetPartitioning[block_idx_v1].push(index);
  87547. if (block_idx_v2 != block_idx_v1) {
  87548. options.facetPartitioning[block_idx_v2].push(index);
  87549. }
  87550. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  87551. options.facetPartitioning[block_idx_v3].push(index);
  87552. }
  87553. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  87554. options.facetPartitioning[block_idx_o].push(index);
  87555. }
  87556. }
  87557. if (computeDepthSort && options && options.facetPositions) {
  87558. var dsf = depthSortedFacets[index];
  87559. dsf.ind = index * 3;
  87560. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  87561. }
  87562. // compute the normals anyway
  87563. normals[v1x] += faceNormalx; // accumulate all the normals per face
  87564. normals[v1y] += faceNormaly;
  87565. normals[v1z] += faceNormalz;
  87566. normals[v2x] += faceNormalx;
  87567. normals[v2y] += faceNormaly;
  87568. normals[v2z] += faceNormalz;
  87569. normals[v3x] += faceNormalx;
  87570. normals[v3y] += faceNormaly;
  87571. normals[v3z] += faceNormalz;
  87572. }
  87573. // last normalization of each normal
  87574. for (index = 0; index < normals.length / 3; index++) {
  87575. faceNormalx = normals[index * 3];
  87576. faceNormaly = normals[index * 3 + 1];
  87577. faceNormalz = normals[index * 3 + 2];
  87578. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87579. length = (length === 0) ? 1.0 : length;
  87580. faceNormalx /= length;
  87581. faceNormaly /= length;
  87582. faceNormalz /= length;
  87583. normals[index * 3] = faceNormalx;
  87584. normals[index * 3 + 1] = faceNormaly;
  87585. normals[index * 3 + 2] = faceNormalz;
  87586. }
  87587. };
  87588. /** @hidden */
  87589. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  87590. var li = indices.length;
  87591. var ln = normals.length;
  87592. var i;
  87593. var n;
  87594. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  87595. switch (sideOrientation) {
  87596. case VertexData.FRONTSIDE:
  87597. // nothing changed
  87598. break;
  87599. case VertexData.BACKSIDE:
  87600. var tmp;
  87601. // indices
  87602. for (i = 0; i < li; i += 3) {
  87603. tmp = indices[i];
  87604. indices[i] = indices[i + 2];
  87605. indices[i + 2] = tmp;
  87606. }
  87607. // normals
  87608. for (n = 0; n < ln; n++) {
  87609. normals[n] = -normals[n];
  87610. }
  87611. break;
  87612. case VertexData.DOUBLESIDE:
  87613. // positions
  87614. var lp = positions.length;
  87615. var l = lp / 3;
  87616. for (var p = 0; p < lp; p++) {
  87617. positions[lp + p] = positions[p];
  87618. }
  87619. // indices
  87620. for (i = 0; i < li; i += 3) {
  87621. indices[i + li] = indices[i + 2] + l;
  87622. indices[i + 1 + li] = indices[i + 1] + l;
  87623. indices[i + 2 + li] = indices[i] + l;
  87624. }
  87625. // normals
  87626. for (n = 0; n < ln; n++) {
  87627. normals[ln + n] = -normals[n];
  87628. }
  87629. // uvs
  87630. var lu = uvs.length;
  87631. var u = 0;
  87632. for (u = 0; u < lu; u++) {
  87633. uvs[u + lu] = uvs[u];
  87634. }
  87635. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87636. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87637. u = 0;
  87638. for (i = 0; i < lu / 2; i++) {
  87639. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  87640. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  87641. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  87642. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  87643. u += 2;
  87644. }
  87645. break;
  87646. }
  87647. };
  87648. /**
  87649. * Applies VertexData created from the imported parameters to the geometry
  87650. * @param parsedVertexData the parsed data from an imported file
  87651. * @param geometry the geometry to apply the VertexData to
  87652. */
  87653. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  87654. var vertexData = new VertexData();
  87655. // positions
  87656. var positions = parsedVertexData.positions;
  87657. if (positions) {
  87658. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  87659. }
  87660. // normals
  87661. var normals = parsedVertexData.normals;
  87662. if (normals) {
  87663. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  87664. }
  87665. // tangents
  87666. var tangents = parsedVertexData.tangents;
  87667. if (tangents) {
  87668. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  87669. }
  87670. // uvs
  87671. var uvs = parsedVertexData.uvs;
  87672. if (uvs) {
  87673. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  87674. }
  87675. // uv2s
  87676. var uv2s = parsedVertexData.uv2s;
  87677. if (uv2s) {
  87678. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  87679. }
  87680. // uv3s
  87681. var uv3s = parsedVertexData.uv3s;
  87682. if (uv3s) {
  87683. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  87684. }
  87685. // uv4s
  87686. var uv4s = parsedVertexData.uv4s;
  87687. if (uv4s) {
  87688. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  87689. }
  87690. // uv5s
  87691. var uv5s = parsedVertexData.uv5s;
  87692. if (uv5s) {
  87693. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  87694. }
  87695. // uv6s
  87696. var uv6s = parsedVertexData.uv6s;
  87697. if (uv6s) {
  87698. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  87699. }
  87700. // colors
  87701. var colors = parsedVertexData.colors;
  87702. if (colors) {
  87703. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  87704. }
  87705. // matricesIndices
  87706. var matricesIndices = parsedVertexData.matricesIndices;
  87707. if (matricesIndices) {
  87708. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  87709. }
  87710. // matricesWeights
  87711. var matricesWeights = parsedVertexData.matricesWeights;
  87712. if (matricesWeights) {
  87713. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  87714. }
  87715. // indices
  87716. var indices = parsedVertexData.indices;
  87717. if (indices) {
  87718. vertexData.indices = indices;
  87719. }
  87720. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  87721. };
  87722. /**
  87723. * Mesh side orientation : usually the external or front surface
  87724. */
  87725. VertexData.FRONTSIDE = 0;
  87726. /**
  87727. * Mesh side orientation : usually the internal or back surface
  87728. */
  87729. VertexData.BACKSIDE = 1;
  87730. /**
  87731. * Mesh side orientation : both internal and external or front and back surfaces
  87732. */
  87733. VertexData.DOUBLESIDE = 2;
  87734. /**
  87735. * Mesh side orientation : by default, `FRONTSIDE`
  87736. */
  87737. VertexData.DEFAULTSIDE = 0;
  87738. return VertexData;
  87739. }());
  87740. /***/ }),
  87741. /***/ "./Meshes/meshBuilder.ts":
  87742. /*!*******************************!*\
  87743. !*** ./Meshes/meshBuilder.ts ***!
  87744. \*******************************/
  87745. /*! exports provided: MeshBuilder */
  87746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87747. "use strict";
  87748. __webpack_require__.r(__webpack_exports__);
  87749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  87750. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  87751. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  87752. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  87753. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  87754. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  87755. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  87756. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  87757. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  87758. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  87759. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  87760. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  87761. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  87762. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  87763. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  87764. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  87765. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  87766. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  87767. /**
  87768. * Class containing static functions to help procedurally build meshes
  87769. */
  87770. var MeshBuilder = /** @class */ (function () {
  87771. function MeshBuilder() {
  87772. }
  87773. /**
  87774. * Creates a box mesh
  87775. * * The parameter `size` sets the size (float) of each box side (default 1)
  87776. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  87777. * * 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)
  87778. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  87779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87780. * * 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
  87781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87782. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  87783. * @param name defines the name of the mesh
  87784. * @param options defines the options used to create the mesh
  87785. * @param scene defines the hosting scene
  87786. * @returns the box mesh
  87787. */
  87788. MeshBuilder.CreateBox = function (name, options, scene) {
  87789. if (scene === void 0) { scene = null; }
  87790. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  87791. };
  87792. /**
  87793. * Creates a sphere mesh
  87794. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  87795. * * 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`)
  87796. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  87797. * * 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
  87798. * * 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)
  87799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87800. * * 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
  87801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87802. * @param name defines the name of the mesh
  87803. * @param options defines the options used to create the mesh
  87804. * @param scene defines the hosting scene
  87805. * @returns the sphere mesh
  87806. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  87807. */
  87808. MeshBuilder.CreateSphere = function (name, options, scene) {
  87809. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  87810. };
  87811. /**
  87812. * Creates a plane polygonal mesh. By default, this is a disc
  87813. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  87814. * * 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
  87815. * * 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
  87816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87817. * * 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
  87818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87819. * @param name defines the name of the mesh
  87820. * @param options defines the options used to create the mesh
  87821. * @param scene defines the hosting scene
  87822. * @returns the plane polygonal mesh
  87823. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  87824. */
  87825. MeshBuilder.CreateDisc = function (name, options, scene) {
  87826. if (scene === void 0) { scene = null; }
  87827. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  87828. };
  87829. /**
  87830. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  87831. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  87832. * * 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`)
  87833. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  87834. * * 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
  87835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87836. * * 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
  87837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87838. * @param name defines the name of the mesh
  87839. * @param options defines the options used to create the mesh
  87840. * @param scene defines the hosting scene
  87841. * @returns the icosahedron mesh
  87842. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  87843. */
  87844. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  87845. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  87846. };
  87847. /**
  87848. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  87849. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  87850. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  87851. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  87852. * * 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
  87853. * * 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
  87854. * * 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
  87855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87856. * * 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
  87857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  87858. * * 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
  87859. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  87860. * * 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
  87861. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  87862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87863. * @param name defines the name of the mesh
  87864. * @param options defines the options used to create the mesh
  87865. * @param scene defines the hosting scene
  87866. * @returns the ribbon mesh
  87867. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  87868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  87869. */
  87870. MeshBuilder.CreateRibbon = function (name, options, scene) {
  87871. if (scene === void 0) { scene = null; }
  87872. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  87873. };
  87874. /**
  87875. * Creates a cylinder or a cone mesh
  87876. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  87877. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  87878. * * 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.
  87879. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  87880. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  87881. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  87882. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  87883. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  87884. * * 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).
  87885. * * 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
  87886. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  87887. * * 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
  87888. * * 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.
  87889. * * If `enclose` is false, a ring surface is one element.
  87890. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  87891. * * 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
  87892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87893. * * 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
  87894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87895. * @param name defines the name of the mesh
  87896. * @param options defines the options used to create the mesh
  87897. * @param scene defines the hosting scene
  87898. * @returns the cylinder mesh
  87899. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  87900. */
  87901. MeshBuilder.CreateCylinder = function (name, options, scene) {
  87902. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  87903. };
  87904. /**
  87905. * Creates a torus mesh
  87906. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  87907. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  87908. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  87909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87910. * * 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
  87911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87912. * @param name defines the name of the mesh
  87913. * @param options defines the options used to create the mesh
  87914. * @param scene defines the hosting scene
  87915. * @returns the torus mesh
  87916. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  87917. */
  87918. MeshBuilder.CreateTorus = function (name, options, scene) {
  87919. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  87920. };
  87921. /**
  87922. * Creates a torus knot mesh
  87923. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  87924. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  87925. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  87926. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  87927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87928. * * 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
  87929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87930. * @param name defines the name of the mesh
  87931. * @param options defines the options used to create the mesh
  87932. * @param scene defines the hosting scene
  87933. * @returns the torus knot mesh
  87934. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  87935. */
  87936. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  87937. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  87938. };
  87939. /**
  87940. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  87941. * * 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
  87942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  87943. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  87944. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  87945. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  87946. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  87947. * * 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
  87948. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  87949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  87951. * @param name defines the name of the new line system
  87952. * @param options defines the options used to create the line system
  87953. * @param scene defines the hosting scene
  87954. * @returns a new line system mesh
  87955. */
  87956. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  87957. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  87958. };
  87959. /**
  87960. * Creates a line mesh
  87961. * 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
  87962. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  87963. * * The parameter `points` is an array successive Vector3
  87964. * * 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
  87965. * * The optional parameter `colors` is an array of successive Color4, one per line point
  87966. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  87967. * * When updating an instance, remember that only point positions can change, not the number of points
  87968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  87970. * @param name defines the name of the new line system
  87971. * @param options defines the options used to create the line system
  87972. * @param scene defines the hosting scene
  87973. * @returns a new line mesh
  87974. */
  87975. MeshBuilder.CreateLines = function (name, options, scene) {
  87976. if (scene === void 0) { scene = null; }
  87977. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  87978. };
  87979. /**
  87980. * Creates a dashed line mesh
  87981. * * 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
  87982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  87983. * * The parameter `points` is an array successive Vector3
  87984. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  87985. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  87986. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87987. * * 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
  87988. * * When updating an instance, remember that only point positions can change, not the number of points
  87989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87990. * @param name defines the name of the mesh
  87991. * @param options defines the options used to create the mesh
  87992. * @param scene defines the hosting scene
  87993. * @returns the dashed line mesh
  87994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  87995. */
  87996. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  87997. if (scene === void 0) { scene = null; }
  87998. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  87999. };
  88000. /**
  88001. * 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.
  88002. * * 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.
  88003. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88004. * * 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.
  88005. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  88006. * * 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
  88007. * * 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
  88008. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  88009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88010. * * 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
  88011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  88012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88013. * @param name defines the name of the mesh
  88014. * @param options defines the options used to create the mesh
  88015. * @param scene defines the hosting scene
  88016. * @returns the extruded shape mesh
  88017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88019. */
  88020. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  88021. if (scene === void 0) { scene = null; }
  88022. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  88023. };
  88024. /**
  88025. * Creates an custom extruded shape mesh.
  88026. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  88027. * * 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.
  88028. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88029. * * 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
  88030. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  88031. * * 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
  88032. * * It must returns a float value that will be the scale value applied to the shape on each path point
  88033. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88034. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  88035. * * 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
  88036. * * 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
  88037. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  88038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88039. * * 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
  88040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88042. * @param name defines the name of the mesh
  88043. * @param options defines the options used to create the mesh
  88044. * @param scene defines the hosting scene
  88045. * @returns the custom extruded shape mesh
  88046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  88047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88049. */
  88050. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  88051. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  88052. };
  88053. /**
  88054. * Creates lathe mesh.
  88055. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  88056. * * 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
  88057. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  88058. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  88059. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  88060. * * 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
  88061. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  88062. * * 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
  88063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88064. * * 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
  88065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88067. * @param name defines the name of the mesh
  88068. * @param options defines the options used to create the mesh
  88069. * @param scene defines the hosting scene
  88070. * @returns the lathe mesh
  88071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  88072. */
  88073. MeshBuilder.CreateLathe = function (name, options, scene) {
  88074. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  88075. };
  88076. /**
  88077. * Creates a plane mesh
  88078. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  88079. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  88080. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  88081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88082. * * 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
  88083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88084. * @param name defines the name of the mesh
  88085. * @param options defines the options used to create the mesh
  88086. * @param scene defines the hosting scene
  88087. * @returns the plane mesh
  88088. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  88089. */
  88090. MeshBuilder.CreatePlane = function (name, options, scene) {
  88091. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  88092. };
  88093. /**
  88094. * Creates a ground mesh
  88095. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  88096. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  88097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88098. * @param name defines the name of the mesh
  88099. * @param options defines the options used to create the mesh
  88100. * @param scene defines the hosting scene
  88101. * @returns the ground mesh
  88102. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  88103. */
  88104. MeshBuilder.CreateGround = function (name, options, scene) {
  88105. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  88106. };
  88107. /**
  88108. * Creates a tiled ground mesh
  88109. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  88110. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  88111. * * 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
  88112. * * 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
  88113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88114. * @param name defines the name of the mesh
  88115. * @param options defines the options used to create the mesh
  88116. * @param scene defines the hosting scene
  88117. * @returns the tiled ground mesh
  88118. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  88119. */
  88120. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  88121. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  88122. };
  88123. /**
  88124. * Creates a ground mesh from a height map
  88125. * * The parameter `url` sets the URL of the height map image resource.
  88126. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  88127. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  88128. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  88129. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  88130. * * 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.
  88131. * * 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).
  88132. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88134. * @param name defines the name of the mesh
  88135. * @param url defines the url to the height map
  88136. * @param options defines the options used to create the mesh
  88137. * @param scene defines the hosting scene
  88138. * @returns the ground mesh
  88139. * @see https://doc.babylonjs.com/babylon101/height_map
  88140. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  88141. */
  88142. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  88143. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  88144. };
  88145. /**
  88146. * Creates a polygon mesh
  88147. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  88148. * * 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
  88149. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88151. * * 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)
  88152. * * Remember you can only change the shape positions, not their number when updating a polygon
  88153. * @param name defines the name of the mesh
  88154. * @param options defines the options used to create the mesh
  88155. * @param scene defines the hosting scene
  88156. * @param earcutInjection can be used to inject your own earcut reference
  88157. * @returns the polygon mesh
  88158. */
  88159. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  88160. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88161. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  88162. };
  88163. /**
  88164. * Creates an extruded polygon mesh, with depth in the Y direction.
  88165. * * 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)
  88166. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88167. * @param name defines the name of the mesh
  88168. * @param options defines the options used to create the mesh
  88169. * @param scene defines the hosting scene
  88170. * @param earcutInjection can be used to inject your own earcut reference
  88171. * @returns the polygon mesh
  88172. */
  88173. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  88174. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88175. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  88176. };
  88177. /**
  88178. * Creates a tube mesh.
  88179. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88180. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  88181. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  88182. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  88183. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  88184. * * 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)
  88185. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  88186. * * 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
  88187. * * 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
  88188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88189. * * 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
  88190. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88192. * @param name defines the name of the mesh
  88193. * @param options defines the options used to create the mesh
  88194. * @param scene defines the hosting scene
  88195. * @returns the tube mesh
  88196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88197. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  88198. */
  88199. MeshBuilder.CreateTube = function (name, options, scene) {
  88200. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  88201. };
  88202. /**
  88203. * Creates a polyhedron mesh
  88204. * * 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
  88205. * * The parameter `size` (positive float, default 1) sets the polygon size
  88206. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88207. * * 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`
  88208. * * 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
  88209. * * 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)`)
  88210. * * 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
  88211. * * 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
  88212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88213. * * 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
  88214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88215. * @param name defines the name of the mesh
  88216. * @param options defines the options used to create the mesh
  88217. * @param scene defines the hosting scene
  88218. * @returns the polyhedron mesh
  88219. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  88220. */
  88221. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  88222. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  88223. };
  88224. /**
  88225. * Creates a decal mesh.
  88226. * 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
  88227. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  88228. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  88229. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  88230. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  88231. * @param name defines the name of the mesh
  88232. * @param sourceMesh defines the mesh where the decal must be applied
  88233. * @param options defines the options used to create the mesh
  88234. * @param scene defines the hosting scene
  88235. * @returns the decal mesh
  88236. * @see https://doc.babylonjs.com/how_to/decals
  88237. */
  88238. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  88239. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  88240. };
  88241. return MeshBuilder;
  88242. }());
  88243. /***/ }),
  88244. /***/ "./Meshes/meshSimplification.ts":
  88245. /*!**************************************!*\
  88246. !*** ./Meshes/meshSimplification.ts ***!
  88247. \**************************************/
  88248. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  88249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88250. "use strict";
  88251. __webpack_require__.r(__webpack_exports__);
  88252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  88253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  88254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  88255. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88256. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88257. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  88258. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88259. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88260. /**
  88261. * Class used to specify simplification options
  88262. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88263. */
  88264. var SimplificationSettings = /** @class */ (function () {
  88265. /**
  88266. * Creates a SimplificationSettings
  88267. * @param quality expected quality
  88268. * @param distance distance when this optimized version should be used
  88269. * @param optimizeMesh already optimized mesh
  88270. */
  88271. function SimplificationSettings(
  88272. /** expected quality */
  88273. quality,
  88274. /** distance when this optimized version should be used */
  88275. distance,
  88276. /** already optimized mesh */
  88277. optimizeMesh) {
  88278. this.quality = quality;
  88279. this.distance = distance;
  88280. this.optimizeMesh = optimizeMesh;
  88281. }
  88282. return SimplificationSettings;
  88283. }());
  88284. /**
  88285. * Queue used to order the simplification tasks
  88286. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88287. */
  88288. var SimplificationQueue = /** @class */ (function () {
  88289. /**
  88290. * Creates a new queue
  88291. */
  88292. function SimplificationQueue() {
  88293. this.running = false;
  88294. this._simplificationArray = [];
  88295. }
  88296. /**
  88297. * Adds a new simplification task
  88298. * @param task defines a task to add
  88299. */
  88300. SimplificationQueue.prototype.addTask = function (task) {
  88301. this._simplificationArray.push(task);
  88302. };
  88303. /**
  88304. * Execute next task
  88305. */
  88306. SimplificationQueue.prototype.executeNext = function () {
  88307. var task = this._simplificationArray.pop();
  88308. if (task) {
  88309. this.running = true;
  88310. this.runSimplification(task);
  88311. }
  88312. else {
  88313. this.running = false;
  88314. }
  88315. };
  88316. /**
  88317. * Execute a simplification task
  88318. * @param task defines the task to run
  88319. */
  88320. SimplificationQueue.prototype.runSimplification = function (task) {
  88321. var _this = this;
  88322. if (task.parallelProcessing) {
  88323. //parallel simplifier
  88324. task.settings.forEach(function (setting) {
  88325. var simplifier = _this.getSimplifier(task);
  88326. simplifier.simplify(setting, function (newMesh) {
  88327. task.mesh.addLODLevel(setting.distance, newMesh);
  88328. newMesh.isVisible = true;
  88329. //check if it is the last
  88330. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  88331. //all done, run the success callback.
  88332. task.successCallback();
  88333. }
  88334. _this.executeNext();
  88335. });
  88336. });
  88337. }
  88338. else {
  88339. //single simplifier.
  88340. var simplifier = this.getSimplifier(task);
  88341. var runDecimation = function (setting, callback) {
  88342. simplifier.simplify(setting, function (newMesh) {
  88343. task.mesh.addLODLevel(setting.distance, newMesh);
  88344. newMesh.isVisible = true;
  88345. //run the next quality level
  88346. callback();
  88347. });
  88348. };
  88349. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  88350. runDecimation(task.settings[loop.index], function () {
  88351. loop.executeNext();
  88352. });
  88353. }, function () {
  88354. //execution ended, run the success callback.
  88355. if (task.successCallback) {
  88356. task.successCallback();
  88357. }
  88358. _this.executeNext();
  88359. });
  88360. }
  88361. };
  88362. SimplificationQueue.prototype.getSimplifier = function (task) {
  88363. switch (task.simplificationType) {
  88364. case SimplificationType.QUADRATIC:
  88365. default:
  88366. return new QuadraticErrorSimplification(task.mesh);
  88367. }
  88368. };
  88369. return SimplificationQueue;
  88370. }());
  88371. /**
  88372. * The implemented types of simplification
  88373. * At the moment only Quadratic Error Decimation is implemented
  88374. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88375. */
  88376. var SimplificationType;
  88377. (function (SimplificationType) {
  88378. /** Quadratic error decimation */
  88379. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  88380. })(SimplificationType || (SimplificationType = {}));
  88381. var DecimationTriangle = /** @class */ (function () {
  88382. function DecimationTriangle(vertices) {
  88383. this.vertices = vertices;
  88384. this.error = new Array(4);
  88385. this.deleted = false;
  88386. this.isDirty = false;
  88387. this.deletePending = false;
  88388. this.borderFactor = 0;
  88389. }
  88390. return DecimationTriangle;
  88391. }());
  88392. var DecimationVertex = /** @class */ (function () {
  88393. function DecimationVertex(position, id) {
  88394. this.position = position;
  88395. this.id = id;
  88396. this.isBorder = true;
  88397. this.q = new QuadraticMatrix();
  88398. this.triangleCount = 0;
  88399. this.triangleStart = 0;
  88400. this.originalOffsets = [];
  88401. }
  88402. DecimationVertex.prototype.updatePosition = function (newPosition) {
  88403. this.position.copyFrom(newPosition);
  88404. };
  88405. return DecimationVertex;
  88406. }());
  88407. var QuadraticMatrix = /** @class */ (function () {
  88408. function QuadraticMatrix(data) {
  88409. this.data = new Array(10);
  88410. for (var i = 0; i < 10; ++i) {
  88411. if (data && data[i]) {
  88412. this.data[i] = data[i];
  88413. }
  88414. else {
  88415. this.data[i] = 0;
  88416. }
  88417. }
  88418. }
  88419. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  88420. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  88421. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  88422. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  88423. return det;
  88424. };
  88425. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  88426. for (var i = 0; i < 10; ++i) {
  88427. this.data[i] += matrix.data[i];
  88428. }
  88429. };
  88430. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  88431. for (var i = 0; i < 10; ++i) {
  88432. this.data[i] += data[i];
  88433. }
  88434. };
  88435. QuadraticMatrix.prototype.add = function (matrix) {
  88436. var m = new QuadraticMatrix();
  88437. for (var i = 0; i < 10; ++i) {
  88438. m.data[i] = this.data[i] + matrix.data[i];
  88439. }
  88440. return m;
  88441. };
  88442. QuadraticMatrix.FromData = function (a, b, c, d) {
  88443. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  88444. };
  88445. //returning an array to avoid garbage collection
  88446. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  88447. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  88448. };
  88449. return QuadraticMatrix;
  88450. }());
  88451. var Reference = /** @class */ (function () {
  88452. function Reference(vertexId, triangleId) {
  88453. this.vertexId = vertexId;
  88454. this.triangleId = triangleId;
  88455. }
  88456. return Reference;
  88457. }());
  88458. /**
  88459. * An implementation of the Quadratic Error simplification algorithm.
  88460. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  88461. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  88462. * @author RaananW
  88463. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88464. */
  88465. var QuadraticErrorSimplification = /** @class */ (function () {
  88466. function QuadraticErrorSimplification(_mesh) {
  88467. this._mesh = _mesh;
  88468. this.syncIterations = 5000;
  88469. this.aggressiveness = 7;
  88470. this.decimationIterations = 100;
  88471. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  88472. }
  88473. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  88474. var _this = this;
  88475. this.initDecimatedMesh();
  88476. //iterating through the submeshes array, one after the other.
  88477. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  88478. _this.initWithMesh(loop.index, function () {
  88479. _this.runDecimation(settings, loop.index, function () {
  88480. loop.executeNext();
  88481. });
  88482. }, settings.optimizeMesh);
  88483. }, function () {
  88484. setTimeout(function () {
  88485. successCallback(_this._reconstructedMesh);
  88486. }, 0);
  88487. });
  88488. };
  88489. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  88490. var _this = this;
  88491. var targetCount = ~~(this.triangles.length * settings.quality);
  88492. var deletedTriangles = 0;
  88493. var triangleCount = this.triangles.length;
  88494. var iterationFunction = function (iteration, callback) {
  88495. setTimeout(function () {
  88496. if (iteration % 5 === 0) {
  88497. _this.updateMesh(iteration === 0);
  88498. }
  88499. for (var i = 0; i < _this.triangles.length; ++i) {
  88500. _this.triangles[i].isDirty = false;
  88501. }
  88502. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  88503. var trianglesIterator = function (i) {
  88504. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  88505. var t = _this.triangles[tIdx];
  88506. if (!t) {
  88507. return;
  88508. }
  88509. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  88510. return;
  88511. }
  88512. for (var j = 0; j < 3; ++j) {
  88513. if (t.error[j] < threshold) {
  88514. var deleted0 = [];
  88515. var deleted1 = [];
  88516. var v0 = t.vertices[j];
  88517. var v1 = t.vertices[(j + 1) % 3];
  88518. if (v0.isBorder || v1.isBorder) {
  88519. continue;
  88520. }
  88521. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88522. // var n = Vector3.Zero();
  88523. // var uv = Vector2.Zero();
  88524. // var color = new Color4(0, 0, 0, 1);
  88525. _this.calculateError(v0, v1, p);
  88526. var delTr = new Array();
  88527. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  88528. continue;
  88529. }
  88530. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  88531. continue;
  88532. }
  88533. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  88534. continue;
  88535. }
  88536. var uniqueArray = new Array();
  88537. delTr.forEach(function (deletedT) {
  88538. if (uniqueArray.indexOf(deletedT) === -1) {
  88539. deletedT.deletePending = true;
  88540. uniqueArray.push(deletedT);
  88541. }
  88542. });
  88543. if (uniqueArray.length % 2 !== 0) {
  88544. continue;
  88545. }
  88546. v0.q = v1.q.add(v0.q);
  88547. v0.updatePosition(p);
  88548. var tStart = _this.references.length;
  88549. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  88550. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  88551. var tCount = _this.references.length - tStart;
  88552. if (tCount <= v0.triangleCount) {
  88553. if (tCount) {
  88554. for (var c = 0; c < tCount; c++) {
  88555. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  88556. }
  88557. }
  88558. }
  88559. else {
  88560. v0.triangleStart = tStart;
  88561. }
  88562. v0.triangleCount = tCount;
  88563. break;
  88564. }
  88565. }
  88566. };
  88567. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  88568. }, 0);
  88569. };
  88570. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  88571. if (triangleCount - deletedTriangles <= targetCount) {
  88572. loop.breakLoop();
  88573. }
  88574. else {
  88575. iterationFunction(loop.index, function () {
  88576. loop.executeNext();
  88577. });
  88578. }
  88579. }, function () {
  88580. setTimeout(function () {
  88581. //reconstruct this part of the mesh
  88582. _this.reconstructMesh(submeshIndex);
  88583. successCallback();
  88584. }, 0);
  88585. });
  88586. };
  88587. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  88588. var _this = this;
  88589. this.vertices = [];
  88590. this.triangles = [];
  88591. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88592. var indices = this._mesh.getIndices();
  88593. var submesh = this._mesh.subMeshes[submeshIndex];
  88594. var findInVertices = function (positionToSearch) {
  88595. if (optimizeMesh) {
  88596. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  88597. if (_this.vertices[ii].position.equals(positionToSearch)) {
  88598. return _this.vertices[ii];
  88599. }
  88600. }
  88601. }
  88602. return null;
  88603. };
  88604. var vertexReferences = [];
  88605. var vertexInit = function (i) {
  88606. if (!positionData) {
  88607. return;
  88608. }
  88609. var offset = i + submesh.verticesStart;
  88610. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  88611. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  88612. vertex.originalOffsets.push(offset);
  88613. if (vertex.id === _this.vertices.length) {
  88614. _this.vertices.push(vertex);
  88615. }
  88616. vertexReferences.push(vertex.id);
  88617. };
  88618. //var totalVertices = mesh.getTotalVertices();
  88619. var totalVertices = submesh.verticesCount;
  88620. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  88621. var indicesInit = function (i) {
  88622. if (!indices) {
  88623. return;
  88624. }
  88625. var offset = (submesh.indexStart / 3) + i;
  88626. var pos = (offset * 3);
  88627. var i0 = indices[pos + 0];
  88628. var i1 = indices[pos + 1];
  88629. var i2 = indices[pos + 2];
  88630. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  88631. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  88632. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  88633. var triangle = new DecimationTriangle([v0, v1, v2]);
  88634. triangle.originalOffset = pos;
  88635. _this.triangles.push(triangle);
  88636. };
  88637. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  88638. _this.init(callback);
  88639. });
  88640. });
  88641. };
  88642. QuadraticErrorSimplification.prototype.init = function (callback) {
  88643. var _this = this;
  88644. var triangleInit1 = function (i) {
  88645. var t = _this.triangles[i];
  88646. 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();
  88647. for (var j = 0; j < 3; j++) {
  88648. 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))));
  88649. }
  88650. };
  88651. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  88652. var triangleInit2 = function (i) {
  88653. var t = _this.triangles[i];
  88654. for (var j = 0; j < 3; ++j) {
  88655. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  88656. }
  88657. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88658. };
  88659. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  88660. callback();
  88661. });
  88662. });
  88663. };
  88664. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  88665. var newTriangles = [];
  88666. var i;
  88667. for (i = 0; i < this.vertices.length; ++i) {
  88668. this.vertices[i].triangleCount = 0;
  88669. }
  88670. var t;
  88671. var j;
  88672. for (i = 0; i < this.triangles.length; ++i) {
  88673. if (!this.triangles[i].deleted) {
  88674. t = this.triangles[i];
  88675. for (j = 0; j < 3; ++j) {
  88676. t.vertices[j].triangleCount = 1;
  88677. }
  88678. newTriangles.push(t);
  88679. }
  88680. }
  88681. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  88682. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  88683. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  88684. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  88685. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88686. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88687. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88688. var vertexCount = 0;
  88689. for (i = 0; i < this.vertices.length; ++i) {
  88690. var vertex = this.vertices[i];
  88691. vertex.id = vertexCount;
  88692. if (vertex.triangleCount) {
  88693. vertex.originalOffsets.forEach(function (originalOffset) {
  88694. if (!normalData) {
  88695. return;
  88696. }
  88697. newPositionData.push(vertex.position.x);
  88698. newPositionData.push(vertex.position.y);
  88699. newPositionData.push(vertex.position.z);
  88700. newNormalData.push(normalData[originalOffset * 3]);
  88701. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  88702. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  88703. if (uvs && uvs.length) {
  88704. newUVsData.push(uvs[(originalOffset * 2)]);
  88705. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  88706. }
  88707. else if (colorsData && colorsData.length) {
  88708. newColorsData.push(colorsData[(originalOffset * 4)]);
  88709. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  88710. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  88711. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  88712. }
  88713. ++vertexCount;
  88714. });
  88715. }
  88716. }
  88717. var startingIndex = this._reconstructedMesh.getTotalIndices();
  88718. var startingVertex = this._reconstructedMesh.getTotalVertices();
  88719. var submeshesArray = this._reconstructedMesh.subMeshes;
  88720. this._reconstructedMesh.subMeshes = [];
  88721. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  88722. var originalIndices = this._mesh.getIndices();
  88723. for (i = 0; i < newTriangles.length; ++i) {
  88724. t = newTriangles[i]; //now get the new referencing point for each vertex
  88725. [0, 1, 2].forEach(function (idx) {
  88726. var id = originalIndices[t.originalOffset + idx];
  88727. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  88728. if (offset < 0) {
  88729. offset = 0;
  88730. }
  88731. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  88732. });
  88733. }
  88734. //overwriting the old vertex buffers and indices.
  88735. this._reconstructedMesh.setIndices(newIndicesArray);
  88736. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  88737. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  88738. if (newUVsData.length > 0) {
  88739. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  88740. }
  88741. if (newColorsData.length > 0) {
  88742. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  88743. }
  88744. //create submesh
  88745. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  88746. if (submeshIndex > 0) {
  88747. this._reconstructedMesh.subMeshes = [];
  88748. submeshesArray.forEach(function (submesh) {
  88749. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  88750. });
  88751. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  88752. }
  88753. };
  88754. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  88755. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  88756. this._reconstructedMesh.material = this._mesh.material;
  88757. this._reconstructedMesh.parent = this._mesh.parent;
  88758. this._reconstructedMesh.isVisible = false;
  88759. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  88760. };
  88761. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  88762. for (var i = 0; i < vertex1.triangleCount; ++i) {
  88763. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  88764. if (t.deleted) {
  88765. continue;
  88766. }
  88767. var s = this.references[vertex1.triangleStart + i].vertexId;
  88768. var v1 = t.vertices[(s + 1) % 3];
  88769. var v2 = t.vertices[(s + 2) % 3];
  88770. if ((v1 === vertex2 || v2 === vertex2)) {
  88771. deletedArray[i] = true;
  88772. delTr.push(t);
  88773. continue;
  88774. }
  88775. var d1 = v1.position.subtract(point);
  88776. d1 = d1.normalize();
  88777. var d2 = v2.position.subtract(point);
  88778. d2 = d2.normalize();
  88779. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  88780. return true;
  88781. }
  88782. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  88783. deletedArray[i] = false;
  88784. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  88785. return true;
  88786. }
  88787. }
  88788. return false;
  88789. };
  88790. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  88791. var newDeleted = deletedTriangles;
  88792. for (var i = 0; i < vertex.triangleCount; ++i) {
  88793. var ref = this.references[vertex.triangleStart + i];
  88794. var t = this.triangles[ref.triangleId];
  88795. if (t.deleted) {
  88796. continue;
  88797. }
  88798. if (deletedArray[i] && t.deletePending) {
  88799. t.deleted = true;
  88800. newDeleted++;
  88801. continue;
  88802. }
  88803. t.vertices[ref.vertexId] = origVertex;
  88804. t.isDirty = true;
  88805. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  88806. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  88807. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  88808. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88809. this.references.push(ref);
  88810. }
  88811. return newDeleted;
  88812. };
  88813. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  88814. for (var i = 0; i < this.vertices.length; ++i) {
  88815. var vCount = [];
  88816. var vId = [];
  88817. var v = this.vertices[i];
  88818. var j;
  88819. for (j = 0; j < v.triangleCount; ++j) {
  88820. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  88821. for (var ii = 0; ii < 3; ii++) {
  88822. var ofs = 0;
  88823. var vv = triangle.vertices[ii];
  88824. while (ofs < vCount.length) {
  88825. if (vId[ofs] === vv.id) {
  88826. break;
  88827. }
  88828. ++ofs;
  88829. }
  88830. if (ofs === vCount.length) {
  88831. vCount.push(1);
  88832. vId.push(vv.id);
  88833. }
  88834. else {
  88835. vCount[ofs]++;
  88836. }
  88837. }
  88838. }
  88839. for (j = 0; j < vCount.length; ++j) {
  88840. if (vCount[j] === 1) {
  88841. this.vertices[vId[j]].isBorder = true;
  88842. }
  88843. else {
  88844. this.vertices[vId[j]].isBorder = false;
  88845. }
  88846. }
  88847. }
  88848. };
  88849. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  88850. if (identifyBorders === void 0) { identifyBorders = false; }
  88851. var i;
  88852. if (!identifyBorders) {
  88853. var newTrianglesVector = [];
  88854. for (i = 0; i < this.triangles.length; ++i) {
  88855. if (!this.triangles[i].deleted) {
  88856. newTrianglesVector.push(this.triangles[i]);
  88857. }
  88858. }
  88859. this.triangles = newTrianglesVector;
  88860. }
  88861. for (i = 0; i < this.vertices.length; ++i) {
  88862. this.vertices[i].triangleCount = 0;
  88863. this.vertices[i].triangleStart = 0;
  88864. }
  88865. var t;
  88866. var j;
  88867. var v;
  88868. for (i = 0; i < this.triangles.length; ++i) {
  88869. t = this.triangles[i];
  88870. for (j = 0; j < 3; ++j) {
  88871. v = t.vertices[j];
  88872. v.triangleCount++;
  88873. }
  88874. }
  88875. var tStart = 0;
  88876. for (i = 0; i < this.vertices.length; ++i) {
  88877. this.vertices[i].triangleStart = tStart;
  88878. tStart += this.vertices[i].triangleCount;
  88879. this.vertices[i].triangleCount = 0;
  88880. }
  88881. var newReferences = new Array(this.triangles.length * 3);
  88882. for (i = 0; i < this.triangles.length; ++i) {
  88883. t = this.triangles[i];
  88884. for (j = 0; j < 3; ++j) {
  88885. v = t.vertices[j];
  88886. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  88887. v.triangleCount++;
  88888. }
  88889. }
  88890. this.references = newReferences;
  88891. if (identifyBorders) {
  88892. this.identifyBorder();
  88893. }
  88894. };
  88895. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  88896. var x = point.x;
  88897. var y = point.y;
  88898. var z = point.z;
  88899. 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
  88900. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  88901. };
  88902. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  88903. var q = vertex1.q.add(vertex2.q);
  88904. var border = vertex1.isBorder && vertex2.isBorder;
  88905. var error = 0;
  88906. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  88907. if (qDet !== 0 && !border) {
  88908. if (!pointResult) {
  88909. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88910. }
  88911. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  88912. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  88913. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  88914. error = this.vertexError(q, pointResult);
  88915. }
  88916. else {
  88917. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  88918. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  88919. var error1 = this.vertexError(q, vertex1.position);
  88920. var error2 = this.vertexError(q, vertex2.position);
  88921. var error3 = this.vertexError(q, p3);
  88922. error = Math.min(error1, error2, error3);
  88923. if (error === error1) {
  88924. if (pointResult) {
  88925. pointResult.copyFrom(vertex1.position);
  88926. }
  88927. }
  88928. else if (error === error2) {
  88929. if (pointResult) {
  88930. pointResult.copyFrom(vertex2.position);
  88931. }
  88932. }
  88933. else {
  88934. if (pointResult) {
  88935. pointResult.copyFrom(p3);
  88936. }
  88937. }
  88938. }
  88939. return error;
  88940. };
  88941. return QuadraticErrorSimplification;
  88942. }());
  88943. /***/ }),
  88944. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  88945. /*!****************************************************!*\
  88946. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  88947. \****************************************************/
  88948. /*! exports provided: SimplicationQueueSceneComponent */
  88949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88950. "use strict";
  88951. __webpack_require__.r(__webpack_exports__);
  88952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  88953. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  88954. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  88955. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  88956. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  88957. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  88958. get: function () {
  88959. if (!this._simplificationQueue) {
  88960. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  88961. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  88962. if (!component) {
  88963. component = new SimplicationQueueSceneComponent(this);
  88964. this._addComponent(component);
  88965. }
  88966. }
  88967. return this._simplificationQueue;
  88968. },
  88969. set: function (value) {
  88970. this._simplificationQueue = value;
  88971. },
  88972. enumerable: true,
  88973. configurable: true
  88974. });
  88975. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  88976. if (parallelProcessing === void 0) { parallelProcessing = true; }
  88977. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  88978. this.getScene().simplificationQueue.addTask({
  88979. settings: settings,
  88980. parallelProcessing: parallelProcessing,
  88981. mesh: this,
  88982. simplificationType: simplificationType,
  88983. successCallback: successCallback
  88984. });
  88985. return this;
  88986. };
  88987. /**
  88988. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  88989. * created in a scene
  88990. */
  88991. var SimplicationQueueSceneComponent = /** @class */ (function () {
  88992. /**
  88993. * Creates a new instance of the component for the given scene
  88994. * @param scene Defines the scene to register the component in
  88995. */
  88996. function SimplicationQueueSceneComponent(scene) {
  88997. /**
  88998. * The component name helpfull to identify the component in the list of scene components.
  88999. */
  89000. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  89001. this.scene = scene;
  89002. }
  89003. /**
  89004. * Registers the component in a given scene
  89005. */
  89006. SimplicationQueueSceneComponent.prototype.register = function () {
  89007. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  89008. };
  89009. /**
  89010. * Rebuilds the elements related to this component in case of
  89011. * context lost for instance.
  89012. */
  89013. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  89014. // Nothing to do for this component
  89015. };
  89016. /**
  89017. * Disposes the component and the associated ressources
  89018. */
  89019. SimplicationQueueSceneComponent.prototype.dispose = function () {
  89020. // Nothing to do for this component
  89021. };
  89022. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  89023. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  89024. this.scene._simplificationQueue.executeNext();
  89025. }
  89026. };
  89027. return SimplicationQueueSceneComponent;
  89028. }());
  89029. /***/ }),
  89030. /***/ "./Meshes/polygonMesh.ts":
  89031. /*!*******************************!*\
  89032. !*** ./Meshes/polygonMesh.ts ***!
  89033. \*******************************/
  89034. /*! exports provided: Polygon, PolygonMeshBuilder */
  89035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89036. "use strict";
  89037. __webpack_require__.r(__webpack_exports__);
  89038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  89039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  89040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89041. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89043. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89044. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89045. /**
  89046. * Vector2 wth index property
  89047. */
  89048. var IndexedVector2 = /** @class */ (function (_super) {
  89049. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  89050. function IndexedVector2(original,
  89051. /** Index of the vector2 */
  89052. index) {
  89053. var _this = _super.call(this, original.x, original.y) || this;
  89054. _this.index = index;
  89055. return _this;
  89056. }
  89057. return IndexedVector2;
  89058. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  89059. /**
  89060. * Defines points to create a polygon
  89061. */
  89062. var PolygonPoints = /** @class */ (function () {
  89063. function PolygonPoints() {
  89064. this.elements = new Array();
  89065. }
  89066. PolygonPoints.prototype.add = function (originalPoints) {
  89067. var _this = this;
  89068. var result = new Array();
  89069. originalPoints.forEach(function (point) {
  89070. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  89071. var newPoint = new IndexedVector2(point, _this.elements.length);
  89072. result.push(newPoint);
  89073. _this.elements.push(newPoint);
  89074. }
  89075. });
  89076. return result;
  89077. };
  89078. PolygonPoints.prototype.computeBounds = function () {
  89079. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89080. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89081. this.elements.forEach(function (point) {
  89082. // x
  89083. if (point.x < lmin.x) {
  89084. lmin.x = point.x;
  89085. }
  89086. else if (point.x > lmax.x) {
  89087. lmax.x = point.x;
  89088. }
  89089. // y
  89090. if (point.y < lmin.y) {
  89091. lmin.y = point.y;
  89092. }
  89093. else if (point.y > lmax.y) {
  89094. lmax.y = point.y;
  89095. }
  89096. });
  89097. return {
  89098. min: lmin,
  89099. max: lmax,
  89100. width: lmax.x - lmin.x,
  89101. height: lmax.y - lmin.y
  89102. };
  89103. };
  89104. return PolygonPoints;
  89105. }());
  89106. /**
  89107. * Polygon
  89108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89109. */
  89110. var Polygon = /** @class */ (function () {
  89111. function Polygon() {
  89112. }
  89113. /**
  89114. * Creates a rectangle
  89115. * @param xmin bottom X coord
  89116. * @param ymin bottom Y coord
  89117. * @param xmax top X coord
  89118. * @param ymax top Y coord
  89119. * @returns points that make the resulting rectation
  89120. */
  89121. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  89122. return [
  89123. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  89124. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  89125. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  89126. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  89127. ];
  89128. };
  89129. /**
  89130. * Creates a circle
  89131. * @param radius radius of circle
  89132. * @param cx scale in x
  89133. * @param cy scale in y
  89134. * @param numberOfSides number of sides that make up the circle
  89135. * @returns points that make the resulting circle
  89136. */
  89137. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  89138. if (cx === void 0) { cx = 0; }
  89139. if (cy === void 0) { cy = 0; }
  89140. if (numberOfSides === void 0) { numberOfSides = 32; }
  89141. var result = new Array();
  89142. var angle = 0;
  89143. var increment = (Math.PI * 2) / numberOfSides;
  89144. for (var i = 0; i < numberOfSides; i++) {
  89145. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  89146. angle -= increment;
  89147. }
  89148. return result;
  89149. };
  89150. /**
  89151. * Creates a polygon from input string
  89152. * @param input Input polygon data
  89153. * @returns the parsed points
  89154. */
  89155. Polygon.Parse = function (input) {
  89156. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  89157. var i, result = [];
  89158. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  89159. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  89160. }
  89161. return result;
  89162. };
  89163. /**
  89164. * Starts building a polygon from x and y coordinates
  89165. * @param x x coordinate
  89166. * @param y y coordinate
  89167. * @returns the started path2
  89168. */
  89169. Polygon.StartingAt = function (x, y) {
  89170. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  89171. };
  89172. return Polygon;
  89173. }());
  89174. /**
  89175. * Builds a polygon
  89176. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  89177. */
  89178. var PolygonMeshBuilder = /** @class */ (function () {
  89179. /**
  89180. * Creates a PolygonMeshBuilder
  89181. * @param name name of the builder
  89182. * @param contours Path of the polygon
  89183. * @param scene scene to add to
  89184. * @param earcutInjection can be used to inject your own earcut reference
  89185. */
  89186. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  89187. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89188. this._points = new PolygonPoints();
  89189. this._outlinepoints = new PolygonPoints();
  89190. this._holes = new Array();
  89191. this._epoints = new Array();
  89192. this._eholes = new Array();
  89193. this.bjsEarcut = earcutInjection;
  89194. this._name = name;
  89195. this._scene = scene;
  89196. var points;
  89197. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  89198. points = contours.getPoints();
  89199. }
  89200. else {
  89201. points = contours;
  89202. }
  89203. this._addToepoint(points);
  89204. this._points.add(points);
  89205. this._outlinepoints.add(points);
  89206. if (typeof this.bjsEarcut === 'undefined') {
  89207. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  89208. }
  89209. }
  89210. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  89211. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  89212. var p = points_1[_i];
  89213. this._epoints.push(p.x, p.y);
  89214. }
  89215. };
  89216. /**
  89217. * Adds a whole within the polygon
  89218. * @param hole Array of points defining the hole
  89219. * @returns this
  89220. */
  89221. PolygonMeshBuilder.prototype.addHole = function (hole) {
  89222. this._points.add(hole);
  89223. var holepoints = new PolygonPoints();
  89224. holepoints.add(hole);
  89225. this._holes.push(holepoints);
  89226. this._eholes.push(this._epoints.length / 2);
  89227. this._addToepoint(hole);
  89228. return this;
  89229. };
  89230. /**
  89231. * Creates the polygon
  89232. * @param updatable If the mesh should be updatable
  89233. * @param depth The depth of the mesh created
  89234. * @returns the created mesh
  89235. */
  89236. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  89237. var _this = this;
  89238. if (updatable === void 0) { updatable = false; }
  89239. if (depth === void 0) { depth = 0; }
  89240. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  89241. var normals = new Array();
  89242. var positions = new Array();
  89243. var uvs = new Array();
  89244. var bounds = this._points.computeBounds();
  89245. this._points.elements.forEach(function (p) {
  89246. normals.push(0, 1.0, 0);
  89247. positions.push(p.x, 0, p.y);
  89248. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  89249. });
  89250. var indices = new Array();
  89251. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  89252. for (var i = 0; i < res.length; i++) {
  89253. indices.push(res[i]);
  89254. }
  89255. if (depth > 0) {
  89256. var positionscount = (positions.length / 3); //get the current pointcount
  89257. this._points.elements.forEach(function (p) {
  89258. normals.push(0, -1.0, 0);
  89259. positions.push(p.x, -depth, p.y);
  89260. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  89261. });
  89262. var totalCount = indices.length;
  89263. for (var i = 0; i < totalCount; i += 3) {
  89264. var i0 = indices[i + 0];
  89265. var i1 = indices[i + 1];
  89266. var i2 = indices[i + 2];
  89267. indices.push(i2 + positionscount);
  89268. indices.push(i1 + positionscount);
  89269. indices.push(i0 + positionscount);
  89270. }
  89271. //Add the sides
  89272. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  89273. this._holes.forEach(function (hole) {
  89274. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  89275. });
  89276. }
  89277. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  89278. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  89279. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  89280. result.setIndices(indices);
  89281. return result;
  89282. };
  89283. /**
  89284. * Adds a side to the polygon
  89285. * @param positions points that make the polygon
  89286. * @param normals normals of the polygon
  89287. * @param uvs uvs of the polygon
  89288. * @param indices indices of the polygon
  89289. * @param bounds bounds of the polygon
  89290. * @param points points of the polygon
  89291. * @param depth depth of the polygon
  89292. * @param flip flip of the polygon
  89293. */
  89294. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  89295. var StartIndex = positions.length / 3;
  89296. var ulength = 0;
  89297. for (var i = 0; i < points.elements.length; i++) {
  89298. var p = points.elements[i];
  89299. var p1;
  89300. if ((i + 1) > points.elements.length - 1) {
  89301. p1 = points.elements[0];
  89302. }
  89303. else {
  89304. p1 = points.elements[i + 1];
  89305. }
  89306. positions.push(p.x, 0, p.y);
  89307. positions.push(p.x, -depth, p.y);
  89308. positions.push(p1.x, 0, p1.y);
  89309. positions.push(p1.x, -depth, p1.y);
  89310. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  89311. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  89312. var v3 = v2.subtract(v1);
  89313. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  89314. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  89315. vn = vn.normalize();
  89316. uvs.push(ulength / bounds.width, 0);
  89317. uvs.push(ulength / bounds.width, 1);
  89318. ulength += v3.length();
  89319. uvs.push((ulength / bounds.width), 0);
  89320. uvs.push((ulength / bounds.width), 1);
  89321. if (!flip) {
  89322. normals.push(-vn.x, -vn.y, -vn.z);
  89323. normals.push(-vn.x, -vn.y, -vn.z);
  89324. normals.push(-vn.x, -vn.y, -vn.z);
  89325. normals.push(-vn.x, -vn.y, -vn.z);
  89326. indices.push(StartIndex);
  89327. indices.push(StartIndex + 1);
  89328. indices.push(StartIndex + 2);
  89329. indices.push(StartIndex + 1);
  89330. indices.push(StartIndex + 3);
  89331. indices.push(StartIndex + 2);
  89332. }
  89333. else {
  89334. normals.push(vn.x, vn.y, vn.z);
  89335. normals.push(vn.x, vn.y, vn.z);
  89336. normals.push(vn.x, vn.y, vn.z);
  89337. normals.push(vn.x, vn.y, vn.z);
  89338. indices.push(StartIndex);
  89339. indices.push(StartIndex + 2);
  89340. indices.push(StartIndex + 1);
  89341. indices.push(StartIndex + 1);
  89342. indices.push(StartIndex + 2);
  89343. indices.push(StartIndex + 3);
  89344. }
  89345. StartIndex += 4;
  89346. }
  89347. };
  89348. return PolygonMeshBuilder;
  89349. }());
  89350. /***/ }),
  89351. /***/ "./Meshes/subMesh.ts":
  89352. /*!***************************!*\
  89353. !*** ./Meshes/subMesh.ts ***!
  89354. \***************************/
  89355. /*! exports provided: BaseSubMesh, SubMesh */
  89356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89357. "use strict";
  89358. __webpack_require__.r(__webpack_exports__);
  89359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  89360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  89361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89362. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89363. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  89364. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  89365. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  89366. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  89367. /**
  89368. * Base class for submeshes
  89369. */
  89370. var BaseSubMesh = /** @class */ (function () {
  89371. function BaseSubMesh() {
  89372. }
  89373. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  89374. /**
  89375. * Gets associated effect
  89376. */
  89377. get: function () {
  89378. return this._materialEffect;
  89379. },
  89380. enumerable: true,
  89381. configurable: true
  89382. });
  89383. /**
  89384. * Sets associated effect (effect used to render this submesh)
  89385. * @param effect defines the effect to associate with
  89386. * @param defines defines the set of defines used to compile this effect
  89387. */
  89388. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  89389. if (defines === void 0) { defines = null; }
  89390. if (this._materialEffect === effect) {
  89391. if (!effect) {
  89392. this._materialDefines = null;
  89393. }
  89394. return;
  89395. }
  89396. this._materialDefines = defines;
  89397. this._materialEffect = effect;
  89398. };
  89399. return BaseSubMesh;
  89400. }());
  89401. /**
  89402. * Defines a subdivision inside a mesh
  89403. */
  89404. var SubMesh = /** @class */ (function (_super) {
  89405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  89406. /**
  89407. * Creates a new submesh
  89408. * @param materialIndex defines the material index to use
  89409. * @param verticesStart defines vertex index start
  89410. * @param verticesCount defines vertices count
  89411. * @param indexStart defines index start
  89412. * @param indexCount defines indices count
  89413. * @param mesh defines the parent mesh
  89414. * @param renderingMesh defines an optional rendering mesh
  89415. * @param createBoundingBox defines if bounding box should be created for this submesh
  89416. */
  89417. function SubMesh(
  89418. /** the material index to use */
  89419. materialIndex,
  89420. /** vertex index start */
  89421. verticesStart,
  89422. /** vertices count */
  89423. verticesCount,
  89424. /** index start */
  89425. indexStart,
  89426. /** indices count */
  89427. indexCount, mesh, renderingMesh, createBoundingBox) {
  89428. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89429. var _this = _super.call(this) || this;
  89430. _this.materialIndex = materialIndex;
  89431. _this.verticesStart = verticesStart;
  89432. _this.verticesCount = verticesCount;
  89433. _this.indexStart = indexStart;
  89434. _this.indexCount = indexCount;
  89435. /** @hidden */
  89436. _this._renderId = 0;
  89437. _this._mesh = mesh;
  89438. _this._renderingMesh = renderingMesh || mesh;
  89439. mesh.subMeshes.push(_this);
  89440. _this._trianglePlanes = [];
  89441. _this._id = mesh.subMeshes.length - 1;
  89442. if (createBoundingBox) {
  89443. _this.refreshBoundingInfo();
  89444. mesh.computeWorldMatrix(true);
  89445. }
  89446. return _this;
  89447. }
  89448. /**
  89449. * Add a new submesh to a mesh
  89450. * @param materialIndex defines the material index to use
  89451. * @param verticesStart defines vertex index start
  89452. * @param verticesCount defines vertices count
  89453. * @param indexStart defines index start
  89454. * @param indexCount defines indices count
  89455. * @param mesh defines the parent mesh
  89456. * @param renderingMesh defines an optional rendering mesh
  89457. * @param createBoundingBox defines if bounding box should be created for this submesh
  89458. * @returns the new submesh
  89459. */
  89460. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  89461. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89462. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  89463. };
  89464. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  89465. /**
  89466. * Returns true if this submesh covers the entire parent mesh
  89467. * @ignorenaming
  89468. */
  89469. get: function () {
  89470. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  89471. },
  89472. enumerable: true,
  89473. configurable: true
  89474. });
  89475. /**
  89476. * Returns the submesh BoudingInfo object
  89477. * @returns current bounding info (or mesh's one if the submesh is global)
  89478. */
  89479. SubMesh.prototype.getBoundingInfo = function () {
  89480. if (this.IsGlobal) {
  89481. return this._mesh.getBoundingInfo();
  89482. }
  89483. return this._boundingInfo;
  89484. };
  89485. /**
  89486. * Sets the submesh BoundingInfo
  89487. * @param boundingInfo defines the new bounding info to use
  89488. * @returns the SubMesh
  89489. */
  89490. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  89491. this._boundingInfo = boundingInfo;
  89492. return this;
  89493. };
  89494. /**
  89495. * Returns the mesh of the current submesh
  89496. * @return the parent mesh
  89497. */
  89498. SubMesh.prototype.getMesh = function () {
  89499. return this._mesh;
  89500. };
  89501. /**
  89502. * Returns the rendering mesh of the submesh
  89503. * @returns the rendering mesh (could be different from parent mesh)
  89504. */
  89505. SubMesh.prototype.getRenderingMesh = function () {
  89506. return this._renderingMesh;
  89507. };
  89508. /**
  89509. * Returns the submesh material
  89510. * @returns null or the current material
  89511. */
  89512. SubMesh.prototype.getMaterial = function () {
  89513. var rootMaterial = this._renderingMesh.material;
  89514. if (rootMaterial === null || rootMaterial === undefined) {
  89515. return this._mesh.getScene().defaultMaterial;
  89516. }
  89517. else if (rootMaterial.getSubMaterial) {
  89518. var multiMaterial = rootMaterial;
  89519. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  89520. if (this._currentMaterial !== effectiveMaterial) {
  89521. this._currentMaterial = effectiveMaterial;
  89522. this._materialDefines = null;
  89523. }
  89524. return effectiveMaterial;
  89525. }
  89526. return rootMaterial;
  89527. };
  89528. // Methods
  89529. /**
  89530. * Sets a new updated BoundingInfo object to the submesh
  89531. * @returns the SubMesh
  89532. */
  89533. SubMesh.prototype.refreshBoundingInfo = function () {
  89534. this._lastColliderWorldVertices = null;
  89535. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  89536. return this;
  89537. }
  89538. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  89539. if (!data) {
  89540. this._boundingInfo = this._mesh.getBoundingInfo();
  89541. return this;
  89542. }
  89543. var indices = this._renderingMesh.getIndices();
  89544. var extend;
  89545. //is this the only submesh?
  89546. if (this.indexStart === 0 && this.indexCount === indices.length) {
  89547. var boundingInfo = this._renderingMesh.getBoundingInfo();
  89548. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  89549. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  89550. }
  89551. else {
  89552. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  89553. }
  89554. if (this._boundingInfo) {
  89555. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  89556. }
  89557. else {
  89558. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  89559. }
  89560. return this;
  89561. };
  89562. /** @hidden */
  89563. SubMesh.prototype._checkCollision = function (collider) {
  89564. var boundingInfo = this.getBoundingInfo();
  89565. return boundingInfo._checkCollision(collider);
  89566. };
  89567. /**
  89568. * Updates the submesh BoundingInfo
  89569. * @param world defines the world matrix to use to update the bounding info
  89570. * @returns the submesh
  89571. */
  89572. SubMesh.prototype.updateBoundingInfo = function (world) {
  89573. var boundingInfo = this.getBoundingInfo();
  89574. if (!boundingInfo) {
  89575. this.refreshBoundingInfo();
  89576. boundingInfo = this.getBoundingInfo();
  89577. }
  89578. boundingInfo.update(world);
  89579. return this;
  89580. };
  89581. /**
  89582. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89583. * @param frustumPlanes defines the frustum planes
  89584. * @returns true if the submesh is intersecting with the frustum
  89585. */
  89586. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  89587. var boundingInfo = this.getBoundingInfo();
  89588. if (!boundingInfo) {
  89589. return false;
  89590. }
  89591. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  89592. };
  89593. /**
  89594. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89595. * @param frustumPlanes defines the frustum planes
  89596. * @returns true if the submesh is inside the frustum
  89597. */
  89598. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  89599. var boundingInfo = this.getBoundingInfo();
  89600. if (!boundingInfo) {
  89601. return false;
  89602. }
  89603. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  89604. };
  89605. /**
  89606. * Renders the submesh
  89607. * @param enableAlphaMode defines if alpha needs to be used
  89608. * @returns the submesh
  89609. */
  89610. SubMesh.prototype.render = function (enableAlphaMode) {
  89611. this._renderingMesh.render(this, enableAlphaMode);
  89612. return this;
  89613. };
  89614. /**
  89615. * @hidden
  89616. */
  89617. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  89618. if (!this._linesIndexBuffer) {
  89619. var linesIndices = [];
  89620. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89621. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  89622. }
  89623. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  89624. this._linesIndexCount = linesIndices.length;
  89625. }
  89626. return this._linesIndexBuffer;
  89627. };
  89628. /**
  89629. * Checks if the submesh intersects with a ray
  89630. * @param ray defines the ray to test
  89631. * @returns true is the passed ray intersects the submesh bounding box
  89632. */
  89633. SubMesh.prototype.canIntersects = function (ray) {
  89634. var boundingInfo = this.getBoundingInfo();
  89635. if (!boundingInfo) {
  89636. return false;
  89637. }
  89638. return ray.intersectsBox(boundingInfo.boundingBox);
  89639. };
  89640. /**
  89641. * Intersects current submesh with a ray
  89642. * @param ray defines the ray to test
  89643. * @param positions defines mesh's positions array
  89644. * @param indices defines mesh's indices array
  89645. * @param fastCheck defines if only bounding info should be used
  89646. * @returns intersection info or null if no intersection
  89647. */
  89648. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  89649. var material = this.getMaterial();
  89650. if (!material) {
  89651. return null;
  89652. }
  89653. switch (material.fillMode) {
  89654. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  89655. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  89656. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  89657. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  89658. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  89659. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  89660. return null;
  89661. }
  89662. // LineMesh first as it's also a Mesh...
  89663. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  89664. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  89665. }
  89666. return this._intersectTriangles(ray, positions, indices, fastCheck);
  89667. };
  89668. /** @hidden */
  89669. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  89670. var intersectInfo = null;
  89671. // Line test
  89672. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  89673. var p0 = positions[indices[index]];
  89674. var p1 = positions[indices[index + 1]];
  89675. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  89676. if (length < 0) {
  89677. continue;
  89678. }
  89679. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  89680. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  89681. intersectInfo.faceId = index / 2;
  89682. if (fastCheck) {
  89683. break;
  89684. }
  89685. }
  89686. }
  89687. return intersectInfo;
  89688. };
  89689. /** @hidden */
  89690. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  89691. var intersectInfo = null;
  89692. // Triangles test
  89693. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89694. var p0 = positions[indices[index]];
  89695. var p1 = positions[indices[index + 1]];
  89696. var p2 = positions[indices[index + 2]];
  89697. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  89698. if (currentIntersectInfo) {
  89699. if (currentIntersectInfo.distance < 0) {
  89700. continue;
  89701. }
  89702. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  89703. intersectInfo = currentIntersectInfo;
  89704. intersectInfo.faceId = index / 3;
  89705. if (fastCheck) {
  89706. break;
  89707. }
  89708. }
  89709. }
  89710. }
  89711. return intersectInfo;
  89712. };
  89713. /** @hidden */
  89714. SubMesh.prototype._rebuild = function () {
  89715. if (this._linesIndexBuffer) {
  89716. this._linesIndexBuffer = null;
  89717. }
  89718. };
  89719. // Clone
  89720. /**
  89721. * Creates a new submesh from the passed mesh
  89722. * @param newMesh defines the new hosting mesh
  89723. * @param newRenderingMesh defines an optional rendering mesh
  89724. * @returns the new submesh
  89725. */
  89726. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  89727. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  89728. if (!this.IsGlobal) {
  89729. var boundingInfo = this.getBoundingInfo();
  89730. if (!boundingInfo) {
  89731. return result;
  89732. }
  89733. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  89734. }
  89735. return result;
  89736. };
  89737. // Dispose
  89738. /**
  89739. * Release associated resources
  89740. */
  89741. SubMesh.prototype.dispose = function () {
  89742. if (this._linesIndexBuffer) {
  89743. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  89744. this._linesIndexBuffer = null;
  89745. }
  89746. // Remove from mesh
  89747. var index = this._mesh.subMeshes.indexOf(this);
  89748. this._mesh.subMeshes.splice(index, 1);
  89749. };
  89750. /**
  89751. * Gets the class name
  89752. * @returns the string "SubMesh".
  89753. */
  89754. SubMesh.prototype.getClassName = function () {
  89755. return "SubMesh";
  89756. };
  89757. // Statics
  89758. /**
  89759. * Creates a new submesh from indices data
  89760. * @param materialIndex the index of the main mesh material
  89761. * @param startIndex the index where to start the copy in the mesh indices array
  89762. * @param indexCount the number of indices to copy then from the startIndex
  89763. * @param mesh the main mesh to create the submesh from
  89764. * @param renderingMesh the optional rendering mesh
  89765. * @returns a new submesh
  89766. */
  89767. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  89768. var minVertexIndex = Number.MAX_VALUE;
  89769. var maxVertexIndex = -Number.MAX_VALUE;
  89770. var whatWillRender = (renderingMesh || mesh);
  89771. var indices = whatWillRender.getIndices();
  89772. for (var index = startIndex; index < startIndex + indexCount; index++) {
  89773. var vertexIndex = indices[index];
  89774. if (vertexIndex < minVertexIndex) {
  89775. minVertexIndex = vertexIndex;
  89776. }
  89777. if (vertexIndex > maxVertexIndex) {
  89778. maxVertexIndex = vertexIndex;
  89779. }
  89780. }
  89781. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  89782. };
  89783. return SubMesh;
  89784. }(BaseSubMesh));
  89785. /***/ }),
  89786. /***/ "./Meshes/transformNode.ts":
  89787. /*!*********************************!*\
  89788. !*** ./Meshes/transformNode.ts ***!
  89789. \*********************************/
  89790. /*! exports provided: TransformNode */
  89791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89792. "use strict";
  89793. __webpack_require__.r(__webpack_exports__);
  89794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  89795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89796. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  89797. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  89798. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  89799. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89800. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  89801. /**
  89802. * 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.
  89803. * @see https://doc.babylonjs.com/how_to/transformnode
  89804. */
  89805. var TransformNode = /** @class */ (function (_super) {
  89806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  89807. function TransformNode(name, scene, isPure) {
  89808. if (scene === void 0) { scene = null; }
  89809. if (isPure === void 0) { isPure = true; }
  89810. var _this = _super.call(this, name, scene) || this;
  89811. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 1);
  89812. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, -1);
  89813. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0);
  89814. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](1, 0, 0);
  89815. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-1, 0, 0);
  89816. // Properties
  89817. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89818. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89819. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  89820. _this._isDirty = false;
  89821. /**
  89822. * Set the billboard mode. Default is 0.
  89823. *
  89824. * | Value | Type | Description |
  89825. * | --- | --- | --- |
  89826. * | 0 | BILLBOARDMODE_NONE | |
  89827. * | 1 | BILLBOARDMODE_X | |
  89828. * | 2 | BILLBOARDMODE_Y | |
  89829. * | 4 | BILLBOARDMODE_Z | |
  89830. * | 7 | BILLBOARDMODE_ALL | |
  89831. *
  89832. */
  89833. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  89834. /**
  89835. * 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
  89836. */
  89837. _this.scalingDeterminant = 1;
  89838. /**
  89839. * Sets the distance of the object to max, often used by skybox
  89840. */
  89841. _this.infiniteDistance = false;
  89842. /**
  89843. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89844. * By default the system will update normals to compensate
  89845. */
  89846. _this.ignoreNonUniformScaling = false;
  89847. /** @hidden */
  89848. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  89849. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89850. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  89851. _this._postMultiplyPivotMatrix = false;
  89852. _this._isWorldMatrixFrozen = false;
  89853. /** @hidden */
  89854. _this._indexInSceneTransformNodesArray = -1;
  89855. /**
  89856. * An event triggered after the world matrix is updated
  89857. */
  89858. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  89859. _this._nonUniformScaling = false;
  89860. if (isPure) {
  89861. _this.getScene().addTransformNode(_this);
  89862. }
  89863. return _this;
  89864. }
  89865. /**
  89866. * Gets a string identifying the name of the class
  89867. * @returns "TransformNode" string
  89868. */
  89869. TransformNode.prototype.getClassName = function () {
  89870. return "TransformNode";
  89871. };
  89872. Object.defineProperty(TransformNode.prototype, "position", {
  89873. /**
  89874. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89875. */
  89876. get: function () {
  89877. return this._position;
  89878. },
  89879. set: function (newPosition) {
  89880. this._position = newPosition;
  89881. this._isDirty = true;
  89882. },
  89883. enumerable: true,
  89884. configurable: true
  89885. });
  89886. Object.defineProperty(TransformNode.prototype, "rotation", {
  89887. /**
  89888. * 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)).
  89889. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89890. */
  89891. get: function () {
  89892. return this._rotation;
  89893. },
  89894. set: function (newRotation) {
  89895. this._rotation = newRotation;
  89896. this._isDirty = true;
  89897. },
  89898. enumerable: true,
  89899. configurable: true
  89900. });
  89901. Object.defineProperty(TransformNode.prototype, "scaling", {
  89902. /**
  89903. * 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)).
  89904. */
  89905. get: function () {
  89906. return this._scaling;
  89907. },
  89908. set: function (newScaling) {
  89909. this._scaling = newScaling;
  89910. this._isDirty = true;
  89911. },
  89912. enumerable: true,
  89913. configurable: true
  89914. });
  89915. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  89916. /**
  89917. * 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).
  89918. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89919. */
  89920. get: function () {
  89921. return this._rotationQuaternion;
  89922. },
  89923. set: function (quaternion) {
  89924. this._rotationQuaternion = quaternion;
  89925. //reset the rotation vector.
  89926. if (quaternion) {
  89927. this.rotation.setAll(0.0);
  89928. }
  89929. },
  89930. enumerable: true,
  89931. configurable: true
  89932. });
  89933. Object.defineProperty(TransformNode.prototype, "forward", {
  89934. /**
  89935. * The forward direction of that transform in world space.
  89936. */
  89937. get: function () {
  89938. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  89939. },
  89940. enumerable: true,
  89941. configurable: true
  89942. });
  89943. Object.defineProperty(TransformNode.prototype, "up", {
  89944. /**
  89945. * The up direction of that transform in world space.
  89946. */
  89947. get: function () {
  89948. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  89949. },
  89950. enumerable: true,
  89951. configurable: true
  89952. });
  89953. Object.defineProperty(TransformNode.prototype, "right", {
  89954. /**
  89955. * The right direction of that transform in world space.
  89956. */
  89957. get: function () {
  89958. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  89959. },
  89960. enumerable: true,
  89961. configurable: true
  89962. });
  89963. /**
  89964. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89965. * @param matrix the matrix to copy the pose from
  89966. * @returns this TransformNode.
  89967. */
  89968. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  89969. this._poseMatrix.copyFrom(matrix);
  89970. return this;
  89971. };
  89972. /**
  89973. * Returns the mesh Pose matrix.
  89974. * @returns the pose matrix
  89975. */
  89976. TransformNode.prototype.getPoseMatrix = function () {
  89977. return this._poseMatrix;
  89978. };
  89979. /** @hidden */
  89980. TransformNode.prototype._isSynchronized = function () {
  89981. if (this._isDirty) {
  89982. return false;
  89983. }
  89984. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  89985. return false;
  89986. }
  89987. if (this._cache.pivotMatrixUpdated) {
  89988. return false;
  89989. }
  89990. if (this.infiniteDistance) {
  89991. return false;
  89992. }
  89993. if (!this._cache.position.equals(this._position)) {
  89994. return false;
  89995. }
  89996. if (this._rotationQuaternion) {
  89997. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  89998. return false;
  89999. }
  90000. }
  90001. if (!this._cache.rotation.equals(this._rotation)) {
  90002. return false;
  90003. }
  90004. if (!this._cache.scaling.equals(this._scaling)) {
  90005. return false;
  90006. }
  90007. return true;
  90008. };
  90009. /** @hidden */
  90010. TransformNode.prototype._initCache = function () {
  90011. _super.prototype._initCache.call(this);
  90012. this._cache.localMatrixUpdated = false;
  90013. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  90014. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  90015. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  90016. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"](0, 0, 0, 0);
  90017. this._cache.billboardMode = -1;
  90018. this._cache.infiniteDistance = false;
  90019. };
  90020. /**
  90021. * Flag the transform node as dirty (Forcing it to update everything)
  90022. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  90023. * @returns this transform node
  90024. */
  90025. TransformNode.prototype.markAsDirty = function (property) {
  90026. if (property === "rotation") {
  90027. this.rotationQuaternion = null;
  90028. }
  90029. this._currentRenderId = Number.MAX_VALUE;
  90030. this._isDirty = true;
  90031. return this;
  90032. };
  90033. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  90034. /**
  90035. * Returns the current mesh absolute position.
  90036. * Returns a Vector3.
  90037. */
  90038. get: function () {
  90039. return this._absolutePosition;
  90040. },
  90041. enumerable: true,
  90042. configurable: true
  90043. });
  90044. /**
  90045. * Sets a new matrix to apply before all other transformation
  90046. * @param matrix defines the transform matrix
  90047. * @returns the current TransformNode
  90048. */
  90049. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  90050. return this.setPivotMatrix(matrix, false);
  90051. };
  90052. /**
  90053. * Sets a new pivot matrix to the current node
  90054. * @param matrix defines the new pivot matrix to use
  90055. * @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
  90056. * @returns the current TransformNode
  90057. */
  90058. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  90059. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  90060. this._pivotMatrix.copyFrom(matrix);
  90061. this._cache.pivotMatrixUpdated = true;
  90062. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  90063. if (this._postMultiplyPivotMatrix) {
  90064. if (!this._pivotMatrixInverse) {
  90065. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._pivotMatrix);
  90066. }
  90067. else {
  90068. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  90069. }
  90070. }
  90071. return this;
  90072. };
  90073. /**
  90074. * Returns the mesh pivot matrix.
  90075. * Default : Identity.
  90076. * @returns the matrix
  90077. */
  90078. TransformNode.prototype.getPivotMatrix = function () {
  90079. return this._pivotMatrix;
  90080. };
  90081. /**
  90082. * Prevents the World matrix to be computed any longer.
  90083. * @returns the TransformNode.
  90084. */
  90085. TransformNode.prototype.freezeWorldMatrix = function () {
  90086. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  90087. this.computeWorldMatrix(true);
  90088. this._isWorldMatrixFrozen = true;
  90089. return this;
  90090. };
  90091. /**
  90092. * Allows back the World matrix computation.
  90093. * @returns the TransformNode.
  90094. */
  90095. TransformNode.prototype.unfreezeWorldMatrix = function () {
  90096. this._isWorldMatrixFrozen = false;
  90097. this.computeWorldMatrix(true);
  90098. return this;
  90099. };
  90100. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  90101. /**
  90102. * True if the World matrix has been frozen.
  90103. */
  90104. get: function () {
  90105. return this._isWorldMatrixFrozen;
  90106. },
  90107. enumerable: true,
  90108. configurable: true
  90109. });
  90110. /**
  90111. * Retuns the mesh absolute position in the World.
  90112. * @returns a Vector3.
  90113. */
  90114. TransformNode.prototype.getAbsolutePosition = function () {
  90115. this.computeWorldMatrix();
  90116. return this._absolutePosition;
  90117. };
  90118. /**
  90119. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  90120. * @param absolutePosition the absolute position to set
  90121. * @returns the TransformNode.
  90122. */
  90123. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  90124. if (!absolutePosition) {
  90125. return this;
  90126. }
  90127. var absolutePositionX;
  90128. var absolutePositionY;
  90129. var absolutePositionZ;
  90130. if (absolutePosition.x === undefined) {
  90131. if (arguments.length < 3) {
  90132. return this;
  90133. }
  90134. absolutePositionX = arguments[0];
  90135. absolutePositionY = arguments[1];
  90136. absolutePositionZ = arguments[2];
  90137. }
  90138. else {
  90139. absolutePositionX = absolutePosition.x;
  90140. absolutePositionY = absolutePosition.y;
  90141. absolutePositionZ = absolutePosition.z;
  90142. }
  90143. if (this.parent) {
  90144. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90145. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90146. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  90147. }
  90148. else {
  90149. this.position.x = absolutePositionX;
  90150. this.position.y = absolutePositionY;
  90151. this.position.z = absolutePositionZ;
  90152. }
  90153. return this;
  90154. };
  90155. /**
  90156. * Sets the mesh position in its local space.
  90157. * @param vector3 the position to set in localspace
  90158. * @returns the TransformNode.
  90159. */
  90160. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  90161. this.computeWorldMatrix();
  90162. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(vector3, this._localMatrix);
  90163. return this;
  90164. };
  90165. /**
  90166. * Returns the mesh position in the local space from the current World matrix values.
  90167. * @returns a new Vector3.
  90168. */
  90169. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  90170. this.computeWorldMatrix();
  90171. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90172. this._localMatrix.invertToRef(invLocalWorldMatrix);
  90173. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  90174. };
  90175. /**
  90176. * Translates the mesh along the passed Vector3 in its local space.
  90177. * @param vector3 the distance to translate in localspace
  90178. * @returns the TransformNode.
  90179. */
  90180. TransformNode.prototype.locallyTranslate = function (vector3) {
  90181. this.computeWorldMatrix(true);
  90182. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  90183. return this;
  90184. };
  90185. /**
  90186. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  90187. * @param targetPoint the position (must be in same space as current mesh) to look at
  90188. * @param yawCor optional yaw (y-axis) correction in radians
  90189. * @param pitchCor optional pitch (x-axis) correction in radians
  90190. * @param rollCor optional roll (z-axis) correction in radians
  90191. * @param space the choosen space of the target
  90192. * @returns the TransformNode.
  90193. */
  90194. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  90195. if (yawCor === void 0) { yawCor = 0; }
  90196. if (pitchCor === void 0) { pitchCor = 0; }
  90197. if (rollCor === void 0) { rollCor = 0; }
  90198. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  90199. var dv = TransformNode._lookAtVectorCache;
  90200. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  90201. targetPoint.subtractToRef(pos, dv);
  90202. this.setDirection(dv, yawCor, pitchCor, rollCor);
  90203. // Correct for parent's rotation offset
  90204. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD && this.parent) {
  90205. if (this.rotationQuaternion) {
  90206. // Get local rotation matrix of the looking object
  90207. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90208. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  90209. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90210. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  90211. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90212. parentRotationMatrix.invert();
  90213. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90214. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  90215. }
  90216. else {
  90217. // Get local rotation matrix of the looking object
  90218. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  90219. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  90220. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90221. quaternionRotation.toRotationMatrix(rotationMatrix);
  90222. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90223. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  90224. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90225. parentRotationMatrix.invert();
  90226. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90227. quaternionRotation.fromRotationMatrix(rotationMatrix);
  90228. quaternionRotation.toEulerAnglesToRef(this.rotation);
  90229. }
  90230. }
  90231. return this;
  90232. };
  90233. /**
  90234. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90235. * This Vector3 is expressed in the World space.
  90236. * @param localAxis axis to rotate
  90237. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90238. */
  90239. TransformNode.prototype.getDirection = function (localAxis) {
  90240. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  90241. this.getDirectionToRef(localAxis, result);
  90242. return result;
  90243. };
  90244. /**
  90245. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  90246. * localAxis is expressed in the mesh local space.
  90247. * result is computed in the Wordl space from the mesh World matrix.
  90248. * @param localAxis axis to rotate
  90249. * @param result the resulting transformnode
  90250. * @returns this TransformNode.
  90251. */
  90252. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  90253. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  90254. return this;
  90255. };
  90256. /**
  90257. * Sets this transform node rotation to the given local axis.
  90258. * @param localAxis the axis in local space
  90259. * @param yawCor optional yaw (y-axis) correction in radians
  90260. * @param pitchCor optional pitch (x-axis) correction in radians
  90261. * @param rollCor optional roll (z-axis) correction in radians
  90262. * @returns this TransformNode
  90263. */
  90264. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  90265. if (yawCor === void 0) { yawCor = 0; }
  90266. if (pitchCor === void 0) { pitchCor = 0; }
  90267. if (rollCor === void 0) { rollCor = 0; }
  90268. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  90269. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  90270. var pitch = -Math.atan2(localAxis.y, len);
  90271. if (this.rotationQuaternion) {
  90272. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  90273. }
  90274. else {
  90275. this.rotation.x = pitch + pitchCor;
  90276. this.rotation.y = yaw + yawCor;
  90277. this.rotation.z = rollCor;
  90278. }
  90279. return this;
  90280. };
  90281. /**
  90282. * Sets a new pivot point to the current node
  90283. * @param point defines the new pivot point to use
  90284. * @param space defines if the point is in world or local space (local by default)
  90285. * @returns the current TransformNode
  90286. */
  90287. TransformNode.prototype.setPivotPoint = function (point, space) {
  90288. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  90289. if (this.getScene().getRenderId() == 0) {
  90290. this.computeWorldMatrix(true);
  90291. }
  90292. var wm = this.getWorldMatrix();
  90293. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD) {
  90294. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90295. wm.invertToRef(tmat);
  90296. point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(point, tmat);
  90297. }
  90298. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  90299. };
  90300. /**
  90301. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  90302. * @returns the pivot point
  90303. */
  90304. TransformNode.prototype.getPivotPoint = function () {
  90305. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  90306. this.getPivotPointToRef(point);
  90307. return point;
  90308. };
  90309. /**
  90310. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  90311. * @param result the vector3 to store the result
  90312. * @returns this TransformNode.
  90313. */
  90314. TransformNode.prototype.getPivotPointToRef = function (result) {
  90315. result.x = -this._pivotMatrix.m[12];
  90316. result.y = -this._pivotMatrix.m[13];
  90317. result.z = -this._pivotMatrix.m[14];
  90318. return this;
  90319. };
  90320. /**
  90321. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90322. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90323. */
  90324. TransformNode.prototype.getAbsolutePivotPoint = function () {
  90325. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  90326. this.getAbsolutePivotPointToRef(point);
  90327. return point;
  90328. };
  90329. /**
  90330. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90331. * @param result vector3 to store the result
  90332. * @returns this TransformNode.
  90333. */
  90334. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  90335. result.x = this._pivotMatrix.m[12];
  90336. result.y = this._pivotMatrix.m[13];
  90337. result.z = this._pivotMatrix.m[14];
  90338. this.getPivotPointToRef(result);
  90339. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  90340. return this;
  90341. };
  90342. /**
  90343. * Defines the passed node as the parent of the current node.
  90344. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90345. * @param node the node ot set as the parent
  90346. * @returns this TransformNode.
  90347. */
  90348. TransformNode.prototype.setParent = function (node) {
  90349. if (!node && !this.parent) {
  90350. return this;
  90351. }
  90352. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  90353. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  90354. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  90355. if (!node) {
  90356. if (this.parent && this.parent.computeWorldMatrix) {
  90357. this.parent.computeWorldMatrix(true);
  90358. }
  90359. this.computeWorldMatrix(true);
  90360. this.getWorldMatrix().decompose(scale, quatRotation, position);
  90361. }
  90362. else {
  90363. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90364. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  90365. this.computeWorldMatrix(true);
  90366. node.computeWorldMatrix(true);
  90367. node.getWorldMatrix().invertToRef(invParentMatrix);
  90368. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  90369. diffMatrix.decompose(scale, quatRotation, position);
  90370. }
  90371. if (this.rotationQuaternion) {
  90372. this.rotationQuaternion.copyFrom(quatRotation);
  90373. }
  90374. else {
  90375. quatRotation.toEulerAnglesToRef(this.rotation);
  90376. }
  90377. this.scaling.copyFrom(scale);
  90378. this.position.copyFrom(position);
  90379. this.parent = node;
  90380. return this;
  90381. };
  90382. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  90383. /**
  90384. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90385. */
  90386. get: function () {
  90387. return this._nonUniformScaling;
  90388. },
  90389. enumerable: true,
  90390. configurable: true
  90391. });
  90392. /** @hidden */
  90393. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  90394. if (this._nonUniformScaling === value) {
  90395. return false;
  90396. }
  90397. this._nonUniformScaling = value;
  90398. return true;
  90399. };
  90400. /**
  90401. * Attach the current TransformNode to another TransformNode associated with a bone
  90402. * @param bone Bone affecting the TransformNode
  90403. * @param affectedTransformNode TransformNode associated with the bone
  90404. * @returns this object
  90405. */
  90406. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  90407. this._transformToBoneReferal = affectedTransformNode;
  90408. this.parent = bone;
  90409. if (bone.getWorldMatrix().determinant() < 0) {
  90410. this.scalingDeterminant *= -1;
  90411. }
  90412. return this;
  90413. };
  90414. /**
  90415. * Detach the transform node if its associated with a bone
  90416. * @returns this object
  90417. */
  90418. TransformNode.prototype.detachFromBone = function () {
  90419. if (!this.parent) {
  90420. return this;
  90421. }
  90422. if (this.parent.getWorldMatrix().determinant() < 0) {
  90423. this.scalingDeterminant *= -1;
  90424. }
  90425. this._transformToBoneReferal = null;
  90426. this.parent = null;
  90427. return this;
  90428. };
  90429. /**
  90430. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90431. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90432. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90433. * The passed axis is also normalized.
  90434. * @param axis the axis to rotate around
  90435. * @param amount the amount to rotate in radians
  90436. * @param space Space to rotate in (Default: local)
  90437. * @returns the TransformNode.
  90438. */
  90439. TransformNode.prototype.rotate = function (axis, amount, space) {
  90440. axis.normalize();
  90441. if (!this.rotationQuaternion) {
  90442. this.rotationQuaternion = this.rotation.toQuaternion();
  90443. this.rotation.setAll(0);
  90444. }
  90445. var rotationQuaternion;
  90446. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  90447. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90448. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  90449. }
  90450. else {
  90451. if (this.parent) {
  90452. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  90453. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90454. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  90455. }
  90456. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90457. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90458. }
  90459. return this;
  90460. };
  90461. /**
  90462. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90463. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90464. * The passed axis is also normalized. .
  90465. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90466. * @param point the point to rotate around
  90467. * @param axis the axis to rotate around
  90468. * @param amount the amount to rotate in radians
  90469. * @returns the TransformNode
  90470. */
  90471. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  90472. axis.normalize();
  90473. if (!this.rotationQuaternion) {
  90474. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  90475. this.rotation.setAll(0);
  90476. }
  90477. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  90478. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  90479. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  90480. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  90481. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]; // T
  90482. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]; // T'
  90483. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]; // R
  90484. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[3]; // T' x R x T
  90485. point.subtractToRef(this.position, tmpVector);
  90486. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  90487. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  90488. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  90489. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  90490. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  90491. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  90492. this.position.addInPlace(finalTranslation);
  90493. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90494. return this;
  90495. };
  90496. /**
  90497. * Translates the mesh along the axis vector for the passed distance in the given space.
  90498. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90499. * @param axis the axis to translate in
  90500. * @param distance the distance to translate
  90501. * @param space Space to rotate in (Default: local)
  90502. * @returns the TransformNode.
  90503. */
  90504. TransformNode.prototype.translate = function (axis, distance, space) {
  90505. var displacementVector = axis.scale(distance);
  90506. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  90507. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  90508. this.setPositionWithLocalVector(tempV3);
  90509. }
  90510. else {
  90511. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  90512. }
  90513. return this;
  90514. };
  90515. /**
  90516. * Adds a rotation step to the mesh current rotation.
  90517. * x, y, z are Euler angles expressed in radians.
  90518. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90519. * This means this rotation is made in the mesh local space only.
  90520. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90521. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90522. * ```javascript
  90523. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90524. * ```
  90525. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90526. * 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.
  90527. * @param x Rotation to add
  90528. * @param y Rotation to add
  90529. * @param z Rotation to add
  90530. * @returns the TransformNode.
  90531. */
  90532. TransformNode.prototype.addRotation = function (x, y, z) {
  90533. var rotationQuaternion;
  90534. if (this.rotationQuaternion) {
  90535. rotationQuaternion = this.rotationQuaternion;
  90536. }
  90537. else {
  90538. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  90539. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  90540. }
  90541. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  90542. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  90543. rotationQuaternion.multiplyInPlace(accumulation);
  90544. if (!this.rotationQuaternion) {
  90545. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  90546. }
  90547. return this;
  90548. };
  90549. /**
  90550. * Computes the world matrix of the node
  90551. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90552. * @returns the world matrix
  90553. */
  90554. TransformNode.prototype.computeWorldMatrix = function (force) {
  90555. if (this._isWorldMatrixFrozen) {
  90556. return this._worldMatrix;
  90557. }
  90558. if (!force && this.isSynchronized()) {
  90559. this._currentRenderId = this.getScene().getRenderId();
  90560. return this._worldMatrix;
  90561. }
  90562. this._updateCache();
  90563. this._cache.position.copyFrom(this.position);
  90564. this._cache.scaling.copyFrom(this.scaling);
  90565. this._cache.pivotMatrixUpdated = false;
  90566. this._cache.billboardMode = this.billboardMode;
  90567. this._cache.infiniteDistance = this.infiniteDistance;
  90568. this._currentRenderId = this.getScene().getRenderId();
  90569. this._childRenderId = this.getScene().getRenderId();
  90570. this._isDirty = false;
  90571. // Scaling
  90572. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]);
  90573. // Rotation
  90574. //rotate, if quaternion is set and rotation was used
  90575. if (this.rotationQuaternion) {
  90576. var len = this.rotation.length();
  90577. if (len) {
  90578. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  90579. this.rotation.copyFromFloats(0, 0, 0);
  90580. }
  90581. }
  90582. if (this.rotationQuaternion) {
  90583. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  90584. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  90585. }
  90586. else {
  90587. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  90588. this._cache.rotation.copyFrom(this.rotation);
  90589. }
  90590. // Translation
  90591. var camera = this.getScene().activeCamera;
  90592. if (this.infiniteDistance && !this.parent && camera) {
  90593. var cameraWorldMatrix = camera.getWorldMatrix();
  90594. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  90595. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]);
  90596. }
  90597. else {
  90598. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]);
  90599. }
  90600. // Composing transformations
  90601. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4]);
  90602. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  90603. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  90604. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  90605. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  90606. // Need to decompose each rotation here
  90607. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  90608. if (this.parent && this.parent.getWorldMatrix) {
  90609. if (this._transformToBoneReferal) {
  90610. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90611. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6], currentPosition);
  90612. }
  90613. else {
  90614. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  90615. }
  90616. }
  90617. else {
  90618. currentPosition.copyFrom(this.position);
  90619. }
  90620. currentPosition.subtractInPlace(camera.globalPosition);
  90621. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  90622. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  90623. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  90624. }
  90625. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  90626. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  90627. }
  90628. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  90629. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  90630. }
  90631. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  90632. }
  90633. else {
  90634. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  90635. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  90636. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  90637. }
  90638. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  90639. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  90640. }
  90641. // Post multiply inverse of pivotMatrix
  90642. if (this._postMultiplyPivotMatrix) {
  90643. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  90644. }
  90645. // Local world
  90646. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2], this._localMatrix);
  90647. // Parent
  90648. if (this.parent && this.parent.getWorldMatrix) {
  90649. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90650. if (this._transformToBoneReferal) {
  90651. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90652. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90653. }
  90654. else {
  90655. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  90656. }
  90657. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  90658. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  90659. this._worldMatrix.copyFrom(this._localMatrix);
  90660. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  90661. }
  90662. else {
  90663. if (this._transformToBoneReferal) {
  90664. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  90665. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  90666. }
  90667. else {
  90668. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  90669. }
  90670. }
  90671. this._markSyncedWithParent();
  90672. }
  90673. else {
  90674. this._worldMatrix.copyFrom(this._localMatrix);
  90675. }
  90676. // Normal matrix
  90677. if (!this.ignoreNonUniformScaling) {
  90678. if (this.scaling.isNonUniform) {
  90679. this._updateNonUniformScalingState(true);
  90680. }
  90681. else if (this.parent && this.parent._nonUniformScaling) {
  90682. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  90683. }
  90684. else {
  90685. this._updateNonUniformScalingState(false);
  90686. }
  90687. }
  90688. else {
  90689. this._updateNonUniformScalingState(false);
  90690. }
  90691. this._afterComputeWorldMatrix();
  90692. // Absolute position
  90693. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  90694. // Callbacks
  90695. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  90696. if (!this._poseMatrix) {
  90697. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._worldMatrix);
  90698. }
  90699. // Cache the determinant
  90700. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  90701. return this._worldMatrix;
  90702. };
  90703. TransformNode.prototype._afterComputeWorldMatrix = function () {
  90704. };
  90705. /**
  90706. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90707. * @param func callback function to add
  90708. *
  90709. * @returns the TransformNode.
  90710. */
  90711. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  90712. this.onAfterWorldMatrixUpdateObservable.add(func);
  90713. return this;
  90714. };
  90715. /**
  90716. * Removes a registered callback function.
  90717. * @param func callback function to remove
  90718. * @returns the TransformNode.
  90719. */
  90720. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  90721. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  90722. return this;
  90723. };
  90724. /**
  90725. * Gets the position of the current mesh in camera space
  90726. * @param camera defines the camera to use
  90727. * @returns a position
  90728. */
  90729. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  90730. if (camera === void 0) { camera = null; }
  90731. if (!camera) {
  90732. camera = this.getScene().activeCamera;
  90733. }
  90734. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  90735. };
  90736. /**
  90737. * Returns the distance from the mesh to the active camera
  90738. * @param camera defines the camera to use
  90739. * @returns the distance
  90740. */
  90741. TransformNode.prototype.getDistanceToCamera = function (camera) {
  90742. if (camera === void 0) { camera = null; }
  90743. if (!camera) {
  90744. camera = this.getScene().activeCamera;
  90745. }
  90746. return this.absolutePosition.subtract(camera.position).length();
  90747. };
  90748. /**
  90749. * Clone the current transform node
  90750. * @param name Name of the new clone
  90751. * @param newParent New parent for the clone
  90752. * @param doNotCloneChildren Do not clone children hierarchy
  90753. * @returns the new transform node
  90754. */
  90755. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  90756. var _this = this;
  90757. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  90758. result.name = name;
  90759. result.id = name;
  90760. if (newParent) {
  90761. result.parent = newParent;
  90762. }
  90763. if (!doNotCloneChildren) {
  90764. // Children
  90765. var directDescendants = this.getDescendants(true);
  90766. for (var index = 0; index < directDescendants.length; index++) {
  90767. var child = directDescendants[index];
  90768. if (child.clone) {
  90769. child.clone(name + "." + child.name, result);
  90770. }
  90771. }
  90772. }
  90773. return result;
  90774. };
  90775. /**
  90776. * Serializes the objects information.
  90777. * @param currentSerializationObject defines the object to serialize in
  90778. * @returns the serialized object
  90779. */
  90780. TransformNode.prototype.serialize = function (currentSerializationObject) {
  90781. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  90782. serializationObject.type = this.getClassName();
  90783. // Parent
  90784. if (this.parent) {
  90785. serializationObject.parentId = this.parent.id;
  90786. }
  90787. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].HasTags(this)) {
  90788. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  90789. }
  90790. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  90791. serializationObject.isEnabled = this.isEnabled();
  90792. // Parent
  90793. if (this.parent) {
  90794. serializationObject.parentId = this.parent.id;
  90795. }
  90796. return serializationObject;
  90797. };
  90798. // Statics
  90799. /**
  90800. * Returns a new TransformNode object parsed from the source provided.
  90801. * @param parsedTransformNode is the source.
  90802. * @param scene the scne the object belongs to
  90803. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90804. * @returns a new TransformNode object parsed from the source provided.
  90805. */
  90806. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  90807. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  90808. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  90809. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(transformNode, parsedTransformNode.tags);
  90810. }
  90811. if (parsedTransformNode.localMatrix) {
  90812. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  90813. }
  90814. else if (parsedTransformNode.pivotMatrix) {
  90815. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  90816. }
  90817. transformNode.setEnabled(parsedTransformNode.isEnabled);
  90818. // Parent
  90819. if (parsedTransformNode.parentId) {
  90820. transformNode._waitingParentId = parsedTransformNode.parentId;
  90821. }
  90822. return transformNode;
  90823. };
  90824. /**
  90825. * Get all child-transformNodes of this node
  90826. * @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
  90827. * @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
  90828. * @returns an array of TransformNode
  90829. */
  90830. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  90831. var results = [];
  90832. this._getDescendants(results, directDescendantsOnly, function (node) {
  90833. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  90834. });
  90835. return results;
  90836. };
  90837. /**
  90838. * Releases resources associated with this transform node.
  90839. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90840. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90841. */
  90842. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  90843. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  90844. // Animations
  90845. this.getScene().stopAnimation(this);
  90846. // Remove from scene
  90847. this.getScene().removeTransformNode(this);
  90848. this.onAfterWorldMatrixUpdateObservable.clear();
  90849. if (doNotRecurse) {
  90850. var transformNodes = this.getChildTransformNodes(true);
  90851. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  90852. var transformNode = transformNodes_1[_i];
  90853. transformNode.parent = null;
  90854. transformNode.computeWorldMatrix(true);
  90855. }
  90856. }
  90857. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  90858. };
  90859. // Statics
  90860. /**
  90861. * Object will not rotate to face the camera
  90862. */
  90863. TransformNode.BILLBOARDMODE_NONE = 0;
  90864. /**
  90865. * Object will rotate to face the camera but only on the x axis
  90866. */
  90867. TransformNode.BILLBOARDMODE_X = 1;
  90868. /**
  90869. * Object will rotate to face the camera but only on the y axis
  90870. */
  90871. TransformNode.BILLBOARDMODE_Y = 2;
  90872. /**
  90873. * Object will rotate to face the camera but only on the z axis
  90874. */
  90875. TransformNode.BILLBOARDMODE_Z = 4;
  90876. /**
  90877. * Object will rotate to face the camera
  90878. */
  90879. TransformNode.BILLBOARDMODE_ALL = 7;
  90880. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 0);
  90881. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  90882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  90884. ], TransformNode.prototype, "_position", void 0);
  90885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  90887. ], TransformNode.prototype, "_rotation", void 0);
  90888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  90890. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  90891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  90893. ], TransformNode.prototype, "_scaling", void 0);
  90894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90896. ], TransformNode.prototype, "billboardMode", void 0);
  90897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90899. ], TransformNode.prototype, "scalingDeterminant", void 0);
  90900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90902. ], TransformNode.prototype, "infiniteDistance", void 0);
  90903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90905. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  90906. return TransformNode;
  90907. }(_node__WEBPACK_IMPORTED_MODULE_5__["Node"]));
  90908. /***/ }),
  90909. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  90910. /*!***************************************************************!*\
  90911. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  90912. \***************************************************************/
  90913. /*! exports provided: CubeMapToSphericalPolynomialTools */
  90914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90915. "use strict";
  90916. __webpack_require__.r(__webpack_exports__);
  90917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  90918. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  90919. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  90920. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  90921. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  90922. var FileFaceOrientation = /** @class */ (function () {
  90923. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  90924. this.name = name;
  90925. this.worldAxisForNormal = worldAxisForNormal;
  90926. this.worldAxisForFileX = worldAxisForFileX;
  90927. this.worldAxisForFileY = worldAxisForFileY;
  90928. }
  90929. return FileFaceOrientation;
  90930. }());
  90931. /**
  90932. * Helper class dealing with the extraction of spherical polynomial dataArray
  90933. * from a cube map.
  90934. */
  90935. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  90936. function CubeMapToSphericalPolynomialTools() {
  90937. }
  90938. /**
  90939. * Converts a texture to the according Spherical Polynomial data.
  90940. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90941. *
  90942. * @param texture The texture to extract the information from.
  90943. * @return The Spherical Polynomial data.
  90944. */
  90945. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  90946. if (!texture.isCube) {
  90947. // Only supports cube Textures currently.
  90948. return null;
  90949. }
  90950. var size = texture.getSize().width;
  90951. var right = texture.readPixels(0);
  90952. var left = texture.readPixels(1);
  90953. var up;
  90954. var down;
  90955. if (texture.isRenderTarget) {
  90956. up = texture.readPixels(3);
  90957. down = texture.readPixels(2);
  90958. }
  90959. else {
  90960. up = texture.readPixels(2);
  90961. down = texture.readPixels(3);
  90962. }
  90963. var front = texture.readPixels(4);
  90964. var back = texture.readPixels(5);
  90965. var gammaSpace = texture.gammaSpace;
  90966. // Always read as RGBA.
  90967. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  90968. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  90969. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90970. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  90971. }
  90972. var cubeInfo = {
  90973. size: size,
  90974. right: right,
  90975. left: left,
  90976. up: up,
  90977. down: down,
  90978. front: front,
  90979. back: back,
  90980. format: format,
  90981. type: type,
  90982. gammaSpace: gammaSpace,
  90983. };
  90984. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  90985. };
  90986. /**
  90987. * Converts a cubemap to the according Spherical Polynomial data.
  90988. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90989. *
  90990. * @param cubeInfo The Cube map to extract the information from.
  90991. * @return The Spherical Polynomial data.
  90992. */
  90993. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  90994. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  90995. var totalSolidAngle = 0.0;
  90996. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  90997. var du = 2.0 / cubeInfo.size;
  90998. var dv = du;
  90999. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  91000. var minUV = du * 0.5 - 1.0;
  91001. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  91002. var fileFace = this.FileFaces[faceIndex];
  91003. var dataArray = cubeInfo[fileFace.name];
  91004. var v = minUV;
  91005. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  91006. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  91007. // Because SP is still linear, so summation is fine in that basis.
  91008. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  91009. for (var y = 0; y < cubeInfo.size; y++) {
  91010. var u = minUV;
  91011. for (var x = 0; x < cubeInfo.size; x++) {
  91012. // World direction (not normalised)
  91013. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  91014. worldDirection.normalize();
  91015. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  91016. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  91017. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  91018. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  91019. // Handle Integer types.
  91020. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91021. r /= 255;
  91022. g /= 255;
  91023. b /= 255;
  91024. }
  91025. // Handle Gamma space textures.
  91026. if (cubeInfo.gammaSpace) {
  91027. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91028. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91029. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91030. }
  91031. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  91032. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  91033. totalSolidAngle += deltaSolidAngle;
  91034. u += du;
  91035. }
  91036. v += dv;
  91037. }
  91038. }
  91039. // Solid angle for entire sphere is 4*pi
  91040. var sphereSolidAngle = 4.0 * Math.PI;
  91041. // Adjust the solid angle to allow for how many faces we processed.
  91042. var facesProcessed = 6.0;
  91043. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  91044. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  91045. // This is needed because the numerical integration over the cube uses a
  91046. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  91047. // and also to compensate for accumulative error due to float precision in the summation.
  91048. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  91049. sphericalHarmonics.scale(correctionFactor);
  91050. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  91051. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  91052. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  91053. };
  91054. CubeMapToSphericalPolynomialTools.FileFaces = [
  91055. 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)),
  91056. 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)),
  91057. 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)),
  91058. 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)),
  91059. 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)),
  91060. 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
  91061. ];
  91062. return CubeMapToSphericalPolynomialTools;
  91063. }());
  91064. /***/ }),
  91065. /***/ "./Misc/HighDynamicRange/hdr.ts":
  91066. /*!**************************************!*\
  91067. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  91068. \**************************************/
  91069. /*! exports provided: HDRTools */
  91070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91071. "use strict";
  91072. __webpack_require__.r(__webpack_exports__);
  91073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  91074. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91075. /**
  91076. * This groups tools to convert HDR texture to native colors array.
  91077. */
  91078. var HDRTools = /** @class */ (function () {
  91079. function HDRTools() {
  91080. }
  91081. HDRTools.Ldexp = function (mantissa, exponent) {
  91082. if (exponent > 1023) {
  91083. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  91084. }
  91085. if (exponent < -1074) {
  91086. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  91087. }
  91088. return mantissa * Math.pow(2, exponent);
  91089. };
  91090. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  91091. if (exponent > 0) { /*nonzero pixel*/
  91092. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  91093. float32array[index + 0] = red * exponent;
  91094. float32array[index + 1] = green * exponent;
  91095. float32array[index + 2] = blue * exponent;
  91096. }
  91097. else {
  91098. float32array[index + 0] = 0;
  91099. float32array[index + 1] = 0;
  91100. float32array[index + 2] = 0;
  91101. }
  91102. };
  91103. HDRTools.readStringLine = function (uint8array, startIndex) {
  91104. var line = "";
  91105. var character = "";
  91106. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  91107. character = String.fromCharCode(uint8array[i]);
  91108. if (character == "\n") {
  91109. break;
  91110. }
  91111. line += character;
  91112. }
  91113. return line;
  91114. };
  91115. /**
  91116. * Reads header information from an RGBE texture stored in a native array.
  91117. * More information on this format are available here:
  91118. * https://en.wikipedia.org/wiki/RGBE_image_format
  91119. *
  91120. * @param uint8array The binary file stored in native array.
  91121. * @return The header information.
  91122. */
  91123. HDRTools.RGBE_ReadHeader = function (uint8array) {
  91124. var height = 0;
  91125. var width = 0;
  91126. var line = this.readStringLine(uint8array, 0);
  91127. if (line[0] != '#' || line[1] != '?') {
  91128. throw "Bad HDR Format.";
  91129. }
  91130. var endOfHeader = false;
  91131. var findFormat = false;
  91132. var lineIndex = 0;
  91133. do {
  91134. lineIndex += (line.length + 1);
  91135. line = this.readStringLine(uint8array, lineIndex);
  91136. if (line == "FORMAT=32-bit_rle_rgbe") {
  91137. findFormat = true;
  91138. }
  91139. else if (line.length == 0) {
  91140. endOfHeader = true;
  91141. }
  91142. } while (!endOfHeader);
  91143. if (!findFormat) {
  91144. throw "HDR Bad header format, unsupported FORMAT";
  91145. }
  91146. lineIndex += (line.length + 1);
  91147. line = this.readStringLine(uint8array, lineIndex);
  91148. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  91149. var match = sizeRegexp.exec(line);
  91150. // TODO. Support +Y and -X if needed.
  91151. if (!match || match.length < 3) {
  91152. throw "HDR Bad header format, no size";
  91153. }
  91154. width = parseInt(match[2]);
  91155. height = parseInt(match[1]);
  91156. if (width < 8 || width > 0x7fff) {
  91157. throw "HDR Bad header format, unsupported size";
  91158. }
  91159. lineIndex += (line.length + 1);
  91160. return {
  91161. height: height,
  91162. width: width,
  91163. dataPosition: lineIndex
  91164. };
  91165. };
  91166. /**
  91167. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  91168. * This RGBE texture needs to store the information as a panorama.
  91169. *
  91170. * More information on this format are available here:
  91171. * https://en.wikipedia.org/wiki/RGBE_image_format
  91172. *
  91173. * @param buffer The binary file stored in an array buffer.
  91174. * @param size The expected size of the extracted cubemap.
  91175. * @return The Cube Map information.
  91176. */
  91177. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  91178. var uint8array = new Uint8Array(buffer);
  91179. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  91180. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91181. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  91182. return cubeMapData;
  91183. };
  91184. /**
  91185. * Returns the pixels data extracted from an RGBE texture.
  91186. * This pixels will be stored left to right up to down in the R G B order in one array.
  91187. *
  91188. * More information on this format are available here:
  91189. * https://en.wikipedia.org/wiki/RGBE_image_format
  91190. *
  91191. * @param uint8array The binary file stored in an array buffer.
  91192. * @param hdrInfo The header information of the file.
  91193. * @return The pixels data in RGB right to left up to down order.
  91194. */
  91195. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  91196. // Keep for multi format supports.
  91197. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91198. };
  91199. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  91200. var num_scanlines = hdrInfo.height;
  91201. var scanline_width = hdrInfo.width;
  91202. var a, b, c, d, count;
  91203. var dataIndex = hdrInfo.dataPosition;
  91204. var index = 0, endIndex = 0, i = 0;
  91205. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  91206. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  91207. // 3 channels of 4 bytes per pixel in float.
  91208. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  91209. var resultArray = new Float32Array(resultBuffer);
  91210. // read in each successive scanline
  91211. while (num_scanlines > 0) {
  91212. a = uint8array[dataIndex++];
  91213. b = uint8array[dataIndex++];
  91214. c = uint8array[dataIndex++];
  91215. d = uint8array[dataIndex++];
  91216. if (a != 2 || b != 2 || (c & 0x80)) {
  91217. // this file is not run length encoded
  91218. throw "HDR Bad header format, not RLE";
  91219. }
  91220. if (((c << 8) | d) != scanline_width) {
  91221. throw "HDR Bad header format, wrong scan line width";
  91222. }
  91223. index = 0;
  91224. // read each of the four channels for the scanline into the buffer
  91225. for (i = 0; i < 4; i++) {
  91226. endIndex = (i + 1) * scanline_width;
  91227. while (index < endIndex) {
  91228. a = uint8array[dataIndex++];
  91229. b = uint8array[dataIndex++];
  91230. if (a > 128) {
  91231. // a run of the same value
  91232. count = a - 128;
  91233. if ((count == 0) || (count > endIndex - index)) {
  91234. throw "HDR Bad Format, bad scanline data (run)";
  91235. }
  91236. while (count-- > 0) {
  91237. scanLineArray[index++] = b;
  91238. }
  91239. }
  91240. else {
  91241. // a non-run
  91242. count = a;
  91243. if ((count == 0) || (count > endIndex - index)) {
  91244. throw "HDR Bad Format, bad scanline data (non-run)";
  91245. }
  91246. scanLineArray[index++] = b;
  91247. if (--count > 0) {
  91248. for (var j = 0; j < count; j++) {
  91249. scanLineArray[index++] = uint8array[dataIndex++];
  91250. }
  91251. }
  91252. }
  91253. }
  91254. }
  91255. // now convert data from buffer into floats
  91256. for (i = 0; i < scanline_width; i++) {
  91257. a = scanLineArray[i];
  91258. b = scanLineArray[i + scanline_width];
  91259. c = scanLineArray[i + 2 * scanline_width];
  91260. d = scanLineArray[i + 3 * scanline_width];
  91261. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  91262. }
  91263. num_scanlines--;
  91264. }
  91265. return resultArray;
  91266. };
  91267. return HDRTools;
  91268. }());
  91269. /***/ }),
  91270. /***/ "./Misc/HighDynamicRange/index.ts":
  91271. /*!****************************************!*\
  91272. !*** ./Misc/HighDynamicRange/index.ts ***!
  91273. \****************************************/
  91274. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  91275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91276. "use strict";
  91277. __webpack_require__.r(__webpack_exports__);
  91278. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  91280. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  91281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  91282. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  91284. /***/ }),
  91285. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  91286. /*!****************************************************!*\
  91287. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  91288. \****************************************************/
  91289. /*! exports provided: PanoramaToCubeMapTools */
  91290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91291. "use strict";
  91292. __webpack_require__.r(__webpack_exports__);
  91293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  91294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91295. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91296. /**
  91297. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91298. */
  91299. var PanoramaToCubeMapTools = /** @class */ (function () {
  91300. function PanoramaToCubeMapTools() {
  91301. }
  91302. /**
  91303. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91304. *
  91305. * @param float32Array The source data.
  91306. * @param inputWidth The width of the input panorama.
  91307. * @param inputHeight The height of the input panorama.
  91308. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91309. * @return The cubemap data
  91310. */
  91311. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  91312. if (!float32Array) {
  91313. throw "ConvertPanoramaToCubemap: input cannot be null";
  91314. }
  91315. if (float32Array.length != inputWidth * inputHeight * 3) {
  91316. throw "ConvertPanoramaToCubemap: input size is wrong";
  91317. }
  91318. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  91319. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  91320. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  91321. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  91322. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  91323. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  91324. return {
  91325. front: textureFront,
  91326. back: textureBack,
  91327. left: textureLeft,
  91328. right: textureRight,
  91329. up: textureUp,
  91330. down: textureDown,
  91331. size: size,
  91332. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  91333. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  91334. gammaSpace: false,
  91335. };
  91336. };
  91337. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  91338. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  91339. var textureArray = new Float32Array(buffer);
  91340. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  91341. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  91342. var dy = 1 / texSize;
  91343. var fy = 0;
  91344. for (var y = 0; y < texSize; y++) {
  91345. var xv1 = faceData[0];
  91346. var xv2 = faceData[2];
  91347. for (var x = 0; x < texSize; x++) {
  91348. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  91349. v.normalize();
  91350. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  91351. // 3 channels per pixels
  91352. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  91353. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  91354. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  91355. xv1 = xv1.add(rotDX1);
  91356. xv2 = xv2.add(rotDX2);
  91357. }
  91358. fy += dy;
  91359. }
  91360. return textureArray;
  91361. };
  91362. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  91363. var theta = Math.atan2(vDir.z, vDir.x);
  91364. var phi = Math.acos(vDir.y);
  91365. while (theta < -Math.PI) {
  91366. theta += 2 * Math.PI;
  91367. }
  91368. while (theta > Math.PI) {
  91369. theta -= 2 * Math.PI;
  91370. }
  91371. var dx = theta / Math.PI;
  91372. var dy = phi / Math.PI;
  91373. // recenter.
  91374. dx = dx * 0.5 + 0.5;
  91375. var px = Math.round(dx * inputWidth);
  91376. if (px < 0) {
  91377. px = 0;
  91378. }
  91379. else if (px >= inputWidth) {
  91380. px = inputWidth - 1;
  91381. }
  91382. var py = Math.round(dy * inputHeight);
  91383. if (py < 0) {
  91384. py = 0;
  91385. }
  91386. else if (py >= inputHeight) {
  91387. py = inputHeight - 1;
  91388. }
  91389. var inputY = (inputHeight - py - 1);
  91390. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  91391. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  91392. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  91393. return {
  91394. r: r,
  91395. g: g,
  91396. b: b
  91397. };
  91398. };
  91399. PanoramaToCubeMapTools.FACE_FRONT = [
  91400. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91401. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91402. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91403. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  91404. ];
  91405. PanoramaToCubeMapTools.FACE_BACK = [
  91406. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91407. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91408. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  91409. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  91410. ];
  91411. PanoramaToCubeMapTools.FACE_RIGHT = [
  91412. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91413. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91414. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91415. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91416. ];
  91417. PanoramaToCubeMapTools.FACE_LEFT = [
  91418. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91419. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91420. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91421. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  91422. ];
  91423. PanoramaToCubeMapTools.FACE_DOWN = [
  91424. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91425. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91426. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91427. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91428. ];
  91429. PanoramaToCubeMapTools.FACE_UP = [
  91430. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91431. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91432. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91433. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  91434. ];
  91435. return PanoramaToCubeMapTools;
  91436. }());
  91437. /***/ }),
  91438. /***/ "./Misc/andOrNotEvaluator.ts":
  91439. /*!***********************************!*\
  91440. !*** ./Misc/andOrNotEvaluator.ts ***!
  91441. \***********************************/
  91442. /*! exports provided: AndOrNotEvaluator */
  91443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91444. "use strict";
  91445. __webpack_require__.r(__webpack_exports__);
  91446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  91447. /**
  91448. * Class used to evalaute queries containing `and` and `or` operators
  91449. */
  91450. var AndOrNotEvaluator = /** @class */ (function () {
  91451. function AndOrNotEvaluator() {
  91452. }
  91453. /**
  91454. * Evaluate a query
  91455. * @param query defines the query to evaluate
  91456. * @param evaluateCallback defines the callback used to filter result
  91457. * @returns true if the query matches
  91458. */
  91459. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  91460. if (!query.match(/\([^\(\)]*\)/g)) {
  91461. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  91462. }
  91463. else {
  91464. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  91465. // remove parenthesis
  91466. r = r.slice(1, r.length - 1);
  91467. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  91468. });
  91469. }
  91470. if (query === "true") {
  91471. return true;
  91472. }
  91473. if (query === "false") {
  91474. return false;
  91475. }
  91476. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  91477. };
  91478. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  91479. evaluateCallback = evaluateCallback || (function (r) {
  91480. return r === "true" ? true : false;
  91481. });
  91482. var result;
  91483. var or = parenthesisContent.split("||");
  91484. for (var i in or) {
  91485. if (or.hasOwnProperty(i)) {
  91486. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  91487. var and = ori.split("&&");
  91488. if (and.length > 1) {
  91489. for (var j = 0; j < and.length; ++j) {
  91490. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  91491. if (andj !== "true" && andj !== "false") {
  91492. if (andj[0] === "!") {
  91493. result = !evaluateCallback(andj.substring(1));
  91494. }
  91495. else {
  91496. result = evaluateCallback(andj);
  91497. }
  91498. }
  91499. else {
  91500. result = andj === "true" ? true : false;
  91501. }
  91502. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  91503. ori = "false";
  91504. break;
  91505. }
  91506. }
  91507. }
  91508. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  91509. result = true;
  91510. break;
  91511. }
  91512. // result equals false (or undefined)
  91513. if (ori !== "true" && ori !== "false") {
  91514. if (ori[0] === "!") {
  91515. result = !evaluateCallback(ori.substring(1));
  91516. }
  91517. else {
  91518. result = evaluateCallback(ori);
  91519. }
  91520. }
  91521. else {
  91522. result = ori === "true" ? true : false;
  91523. }
  91524. }
  91525. }
  91526. // the whole parenthesis scope is replaced by 'true' or 'false'
  91527. return result ? "true" : "false";
  91528. };
  91529. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  91530. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  91531. // remove whitespaces
  91532. r = r.replace(/[\s]/g, function () { return ""; });
  91533. return r.length % 2 ? "!" : "";
  91534. });
  91535. booleanString = booleanString.trim();
  91536. if (booleanString === "!true") {
  91537. booleanString = "false";
  91538. }
  91539. else if (booleanString === "!false") {
  91540. booleanString = "true";
  91541. }
  91542. return booleanString;
  91543. };
  91544. return AndOrNotEvaluator;
  91545. }());
  91546. /***/ }),
  91547. /***/ "./Misc/arrayTools.ts":
  91548. /*!****************************!*\
  91549. !*** ./Misc/arrayTools.ts ***!
  91550. \****************************/
  91551. /*! exports provided: ArrayTools */
  91552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91553. "use strict";
  91554. __webpack_require__.r(__webpack_exports__);
  91555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  91556. /**
  91557. * Class containing a set of static utilities functions for arrays.
  91558. */
  91559. var ArrayTools = /** @class */ (function () {
  91560. function ArrayTools() {
  91561. }
  91562. /**
  91563. * Returns an array of the given size filled with element built from the given constructor and the paramters
  91564. * @param size the number of element to construct and put in the array
  91565. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  91566. * @returns a new array filled with new objects
  91567. */
  91568. ArrayTools.BuildArray = function (size, itemBuilder) {
  91569. var a = [];
  91570. for (var i = 0; i < size; ++i) {
  91571. a.push(itemBuilder());
  91572. }
  91573. return a;
  91574. };
  91575. return ArrayTools;
  91576. }());
  91577. /***/ }),
  91578. /***/ "./Misc/assetsManager.ts":
  91579. /*!*******************************!*\
  91580. !*** ./Misc/assetsManager.ts ***!
  91581. \*******************************/
  91582. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  91583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91584. "use strict";
  91585. __webpack_require__.r(__webpack_exports__);
  91586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  91587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  91588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  91589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  91590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  91591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  91592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  91593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  91594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  91595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  91596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  91597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91598. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  91599. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  91600. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  91601. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  91602. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  91603. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  91604. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91605. /**
  91606. * Defines the list of states available for a task inside a AssetsManager
  91607. */
  91608. var AssetTaskState;
  91609. (function (AssetTaskState) {
  91610. /**
  91611. * Initialization
  91612. */
  91613. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  91614. /**
  91615. * Running
  91616. */
  91617. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  91618. /**
  91619. * Done
  91620. */
  91621. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  91622. /**
  91623. * Error
  91624. */
  91625. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  91626. })(AssetTaskState || (AssetTaskState = {}));
  91627. /**
  91628. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  91629. */
  91630. var AbstractAssetTask = /** @class */ (function () {
  91631. /**
  91632. * Creates a new AssetsManager
  91633. * @param name defines the name of the task
  91634. */
  91635. function AbstractAssetTask(
  91636. /**
  91637. * Task name
  91638. */ name) {
  91639. this.name = name;
  91640. this._isCompleted = false;
  91641. this._taskState = AssetTaskState.INIT;
  91642. }
  91643. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  91644. /**
  91645. * Get if the task is completed
  91646. */
  91647. get: function () {
  91648. return this._isCompleted;
  91649. },
  91650. enumerable: true,
  91651. configurable: true
  91652. });
  91653. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  91654. /**
  91655. * Gets the current state of the task
  91656. */
  91657. get: function () {
  91658. return this._taskState;
  91659. },
  91660. enumerable: true,
  91661. configurable: true
  91662. });
  91663. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  91664. /**
  91665. * Gets the current error object (if task is in error)
  91666. */
  91667. get: function () {
  91668. return this._errorObject;
  91669. },
  91670. enumerable: true,
  91671. configurable: true
  91672. });
  91673. /**
  91674. * Internal only
  91675. * @hidden
  91676. */
  91677. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  91678. if (this._errorObject) {
  91679. return;
  91680. }
  91681. this._errorObject = {
  91682. message: message,
  91683. exception: exception
  91684. };
  91685. };
  91686. /**
  91687. * Execute the current task
  91688. * @param scene defines the scene where you want your assets to be loaded
  91689. * @param onSuccess is a callback called when the task is successfully executed
  91690. * @param onError is a callback called if an error occurs
  91691. */
  91692. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  91693. var _this = this;
  91694. this._taskState = AssetTaskState.RUNNING;
  91695. this.runTask(scene, function () {
  91696. _this.onDoneCallback(onSuccess, onError);
  91697. }, function (msg, exception) {
  91698. _this.onErrorCallback(onError, msg, exception);
  91699. });
  91700. };
  91701. /**
  91702. * Execute the current task
  91703. * @param scene defines the scene where you want your assets to be loaded
  91704. * @param onSuccess is a callback called when the task is successfully executed
  91705. * @param onError is a callback called if an error occurs
  91706. */
  91707. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91708. throw new Error("runTask is not implemented");
  91709. };
  91710. /**
  91711. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  91712. * This can be used with failed tasks that have the reason for failure fixed.
  91713. */
  91714. AbstractAssetTask.prototype.reset = function () {
  91715. this._taskState = AssetTaskState.INIT;
  91716. };
  91717. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  91718. this._taskState = AssetTaskState.ERROR;
  91719. this._errorObject = {
  91720. message: message,
  91721. exception: exception
  91722. };
  91723. if (this.onError) {
  91724. this.onError(this, message, exception);
  91725. }
  91726. onError();
  91727. };
  91728. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  91729. try {
  91730. this._taskState = AssetTaskState.DONE;
  91731. this._isCompleted = true;
  91732. if (this.onSuccess) {
  91733. this.onSuccess(this);
  91734. }
  91735. onSuccess();
  91736. }
  91737. catch (e) {
  91738. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  91739. }
  91740. };
  91741. return AbstractAssetTask;
  91742. }());
  91743. /**
  91744. * Class used to share progress information about assets loading
  91745. */
  91746. var AssetsProgressEvent = /** @class */ (function () {
  91747. /**
  91748. * Creates a AssetsProgressEvent
  91749. * @param remainingCount defines the number of remaining tasks to process
  91750. * @param totalCount defines the total number of tasks
  91751. * @param task defines the task that was just processed
  91752. */
  91753. function AssetsProgressEvent(remainingCount, totalCount, task) {
  91754. this.remainingCount = remainingCount;
  91755. this.totalCount = totalCount;
  91756. this.task = task;
  91757. }
  91758. return AssetsProgressEvent;
  91759. }());
  91760. /**
  91761. * Define a task used by AssetsManager to load meshes
  91762. */
  91763. var MeshAssetTask = /** @class */ (function (_super) {
  91764. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  91765. /**
  91766. * Creates a new MeshAssetTask
  91767. * @param name defines the name of the task
  91768. * @param meshesNames defines the list of mesh's names you want to load
  91769. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  91770. * @param sceneFilename defines the filename of the scene to load from
  91771. */
  91772. function MeshAssetTask(
  91773. /**
  91774. * Defines the name of the task
  91775. */
  91776. name,
  91777. /**
  91778. * Defines the list of mesh's names you want to load
  91779. */
  91780. meshesNames,
  91781. /**
  91782. * Defines the root url to use as a base to load your meshes and associated resources
  91783. */
  91784. rootUrl,
  91785. /**
  91786. * Defines the filename of the scene to load from
  91787. */
  91788. sceneFilename) {
  91789. var _this = _super.call(this, name) || this;
  91790. _this.name = name;
  91791. _this.meshesNames = meshesNames;
  91792. _this.rootUrl = rootUrl;
  91793. _this.sceneFilename = sceneFilename;
  91794. return _this;
  91795. }
  91796. /**
  91797. * Execute the current task
  91798. * @param scene defines the scene where you want your assets to be loaded
  91799. * @param onSuccess is a callback called when the task is successfully executed
  91800. * @param onError is a callback called if an error occurs
  91801. */
  91802. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91803. var _this = this;
  91804. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  91805. _this.loadedMeshes = meshes;
  91806. _this.loadedParticleSystems = particleSystems;
  91807. _this.loadedSkeletons = skeletons;
  91808. _this.loadedAnimationGroups = animationGroups;
  91809. onSuccess();
  91810. }, null, function (scene, message, exception) {
  91811. onError(message, exception);
  91812. });
  91813. };
  91814. return MeshAssetTask;
  91815. }(AbstractAssetTask));
  91816. /**
  91817. * Define a task used by AssetsManager to load text content
  91818. */
  91819. var TextFileAssetTask = /** @class */ (function (_super) {
  91820. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  91821. /**
  91822. * Creates a new TextFileAssetTask object
  91823. * @param name defines the name of the task
  91824. * @param url defines the location of the file to load
  91825. */
  91826. function TextFileAssetTask(
  91827. /**
  91828. * Defines the name of the task
  91829. */
  91830. name,
  91831. /**
  91832. * Defines the location of the file to load
  91833. */
  91834. url) {
  91835. var _this = _super.call(this, name) || this;
  91836. _this.name = name;
  91837. _this.url = url;
  91838. return _this;
  91839. }
  91840. /**
  91841. * Execute the current task
  91842. * @param scene defines the scene where you want your assets to be loaded
  91843. * @param onSuccess is a callback called when the task is successfully executed
  91844. * @param onError is a callback called if an error occurs
  91845. */
  91846. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91847. var _this = this;
  91848. scene._loadFile(this.url, function (data) {
  91849. _this.text = data;
  91850. onSuccess();
  91851. }, undefined, false, false, function (request, exception) {
  91852. if (request) {
  91853. onError(request.status + " " + request.statusText, exception);
  91854. }
  91855. });
  91856. };
  91857. return TextFileAssetTask;
  91858. }(AbstractAssetTask));
  91859. /**
  91860. * Define a task used by AssetsManager to load binary data
  91861. */
  91862. var BinaryFileAssetTask = /** @class */ (function (_super) {
  91863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  91864. /**
  91865. * Creates a new BinaryFileAssetTask object
  91866. * @param name defines the name of the new task
  91867. * @param url defines the location of the file to load
  91868. */
  91869. function BinaryFileAssetTask(
  91870. /**
  91871. * Defines the name of the task
  91872. */
  91873. name,
  91874. /**
  91875. * Defines the location of the file to load
  91876. */
  91877. url) {
  91878. var _this = _super.call(this, name) || this;
  91879. _this.name = name;
  91880. _this.url = url;
  91881. return _this;
  91882. }
  91883. /**
  91884. * Execute the current task
  91885. * @param scene defines the scene where you want your assets to be loaded
  91886. * @param onSuccess is a callback called when the task is successfully executed
  91887. * @param onError is a callback called if an error occurs
  91888. */
  91889. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91890. var _this = this;
  91891. scene._loadFile(this.url, function (data) {
  91892. _this.data = data;
  91893. onSuccess();
  91894. }, undefined, true, true, function (request, exception) {
  91895. if (request) {
  91896. onError(request.status + " " + request.statusText, exception);
  91897. }
  91898. });
  91899. };
  91900. return BinaryFileAssetTask;
  91901. }(AbstractAssetTask));
  91902. /**
  91903. * Define a task used by AssetsManager to load images
  91904. */
  91905. var ImageAssetTask = /** @class */ (function (_super) {
  91906. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  91907. /**
  91908. * Creates a new ImageAssetTask
  91909. * @param name defines the name of the task
  91910. * @param url defines the location of the image to load
  91911. */
  91912. function ImageAssetTask(
  91913. /**
  91914. * Defines the name of the task
  91915. */
  91916. name,
  91917. /**
  91918. * Defines the location of the image to load
  91919. */
  91920. url) {
  91921. var _this = _super.call(this, name) || this;
  91922. _this.name = name;
  91923. _this.url = url;
  91924. return _this;
  91925. }
  91926. /**
  91927. * Execute the current task
  91928. * @param scene defines the scene where you want your assets to be loaded
  91929. * @param onSuccess is a callback called when the task is successfully executed
  91930. * @param onError is a callback called if an error occurs
  91931. */
  91932. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91933. var _this = this;
  91934. var img = new Image();
  91935. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  91936. img.onload = function () {
  91937. _this.image = img;
  91938. onSuccess();
  91939. };
  91940. img.onerror = function (err) {
  91941. onError("Error loading image", err);
  91942. };
  91943. img.src = this.url;
  91944. };
  91945. return ImageAssetTask;
  91946. }(AbstractAssetTask));
  91947. /**
  91948. * Define a task used by AssetsManager to load 2D textures
  91949. */
  91950. var TextureAssetTask = /** @class */ (function (_super) {
  91951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  91952. /**
  91953. * Creates a new TextureAssetTask object
  91954. * @param name defines the name of the task
  91955. * @param url defines the location of the file to load
  91956. * @param noMipmap defines if mipmap should not be generated (default is false)
  91957. * @param invertY defines if texture must be inverted on Y axis (default is false)
  91958. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91959. */
  91960. function TextureAssetTask(
  91961. /**
  91962. * Defines the name of the task
  91963. */
  91964. name,
  91965. /**
  91966. * Defines the location of the file to load
  91967. */
  91968. url,
  91969. /**
  91970. * Defines if mipmap should not be generated (default is false)
  91971. */
  91972. noMipmap,
  91973. /**
  91974. * Defines if texture must be inverted on Y axis (default is false)
  91975. */
  91976. invertY,
  91977. /**
  91978. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91979. */
  91980. samplingMode) {
  91981. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91982. var _this = _super.call(this, name) || this;
  91983. _this.name = name;
  91984. _this.url = url;
  91985. _this.noMipmap = noMipmap;
  91986. _this.invertY = invertY;
  91987. _this.samplingMode = samplingMode;
  91988. return _this;
  91989. }
  91990. /**
  91991. * Execute the current task
  91992. * @param scene defines the scene where you want your assets to be loaded
  91993. * @param onSuccess is a callback called when the task is successfully executed
  91994. * @param onError is a callback called if an error occurs
  91995. */
  91996. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91997. var onload = function () {
  91998. onSuccess();
  91999. };
  92000. var onerror = function (message, exception) {
  92001. onError(message, exception);
  92002. };
  92003. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  92004. };
  92005. return TextureAssetTask;
  92006. }(AbstractAssetTask));
  92007. /**
  92008. * Define a task used by AssetsManager to load cube textures
  92009. */
  92010. var CubeTextureAssetTask = /** @class */ (function (_super) {
  92011. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  92012. /**
  92013. * Creates a new CubeTextureAssetTask
  92014. * @param name defines the name of the task
  92015. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92016. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92017. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92018. * @param files defines the explicit list of files (undefined by default)
  92019. */
  92020. function CubeTextureAssetTask(
  92021. /**
  92022. * Defines the name of the task
  92023. */
  92024. name,
  92025. /**
  92026. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92027. */
  92028. url,
  92029. /**
  92030. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92031. */
  92032. extensions,
  92033. /**
  92034. * Defines if mipmaps should not be generated (default is false)
  92035. */
  92036. noMipmap,
  92037. /**
  92038. * Defines the explicit list of files (undefined by default)
  92039. */
  92040. files) {
  92041. var _this = _super.call(this, name) || this;
  92042. _this.name = name;
  92043. _this.url = url;
  92044. _this.extensions = extensions;
  92045. _this.noMipmap = noMipmap;
  92046. _this.files = files;
  92047. return _this;
  92048. }
  92049. /**
  92050. * Execute the current task
  92051. * @param scene defines the scene where you want your assets to be loaded
  92052. * @param onSuccess is a callback called when the task is successfully executed
  92053. * @param onError is a callback called if an error occurs
  92054. */
  92055. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92056. var onload = function () {
  92057. onSuccess();
  92058. };
  92059. var onerror = function (message, exception) {
  92060. onError(message, exception);
  92061. };
  92062. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  92063. };
  92064. return CubeTextureAssetTask;
  92065. }(AbstractAssetTask));
  92066. /**
  92067. * Define a task used by AssetsManager to load HDR cube textures
  92068. */
  92069. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  92070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  92071. /**
  92072. * Creates a new HDRCubeTextureAssetTask object
  92073. * @param name defines the name of the task
  92074. * @param url defines the location of the file to load
  92075. * @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.
  92076. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92077. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92078. * @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)
  92079. * @param reserved Internal use only
  92080. */
  92081. function HDRCubeTextureAssetTask(
  92082. /**
  92083. * Defines the name of the task
  92084. */
  92085. name,
  92086. /**
  92087. * Defines the location of the file to load
  92088. */
  92089. url,
  92090. /**
  92091. * Defines the desired size (the more it increases the longer the generation will be)
  92092. */
  92093. size,
  92094. /**
  92095. * Defines if mipmaps should not be generated (default is false)
  92096. */
  92097. noMipmap,
  92098. /**
  92099. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92100. */
  92101. generateHarmonics,
  92102. /**
  92103. * 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)
  92104. */
  92105. gammaSpace,
  92106. /**
  92107. * Internal Use Only
  92108. */
  92109. reserved) {
  92110. if (noMipmap === void 0) { noMipmap = false; }
  92111. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92112. if (gammaSpace === void 0) { gammaSpace = false; }
  92113. if (reserved === void 0) { reserved = false; }
  92114. var _this = _super.call(this, name) || this;
  92115. _this.name = name;
  92116. _this.url = url;
  92117. _this.size = size;
  92118. _this.noMipmap = noMipmap;
  92119. _this.generateHarmonics = generateHarmonics;
  92120. _this.gammaSpace = gammaSpace;
  92121. _this.reserved = reserved;
  92122. return _this;
  92123. }
  92124. /**
  92125. * Execute the current task
  92126. * @param scene defines the scene where you want your assets to be loaded
  92127. * @param onSuccess is a callback called when the task is successfully executed
  92128. * @param onError is a callback called if an error occurs
  92129. */
  92130. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92131. var onload = function () {
  92132. onSuccess();
  92133. };
  92134. var onerror = function (message, exception) {
  92135. onError(message, exception);
  92136. };
  92137. 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);
  92138. };
  92139. return HDRCubeTextureAssetTask;
  92140. }(AbstractAssetTask));
  92141. /**
  92142. * This class can be used to easily import assets into a scene
  92143. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  92144. */
  92145. var AssetsManager = /** @class */ (function () {
  92146. /**
  92147. * Creates a new AssetsManager
  92148. * @param scene defines the scene to work on
  92149. */
  92150. function AssetsManager(scene) {
  92151. this._isLoading = false;
  92152. this._tasks = new Array();
  92153. this._waitingTasksCount = 0;
  92154. this._totalTasksCount = 0;
  92155. /**
  92156. * Observable called when all tasks are processed
  92157. */
  92158. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92159. /**
  92160. * Observable called when a task had an error
  92161. */
  92162. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92163. /**
  92164. * Observable called when a task is successful
  92165. */
  92166. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92167. /**
  92168. * Observable called when a task is done (whatever the result is)
  92169. */
  92170. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92171. /**
  92172. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  92173. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92174. */
  92175. this.useDefaultLoadingScreen = true;
  92176. this._scene = scene;
  92177. }
  92178. /**
  92179. * Add a MeshAssetTask to the list of active tasks
  92180. * @param taskName defines the name of the new task
  92181. * @param meshesNames defines the name of meshes to load
  92182. * @param rootUrl defines the root url to use to locate files
  92183. * @param sceneFilename defines the filename of the scene file
  92184. * @returns a new MeshAssetTask object
  92185. */
  92186. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  92187. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  92188. this._tasks.push(task);
  92189. return task;
  92190. };
  92191. /**
  92192. * Add a TextFileAssetTask to the list of active tasks
  92193. * @param taskName defines the name of the new task
  92194. * @param url defines the url of the file to load
  92195. * @returns a new TextFileAssetTask object
  92196. */
  92197. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  92198. var task = new TextFileAssetTask(taskName, url);
  92199. this._tasks.push(task);
  92200. return task;
  92201. };
  92202. /**
  92203. * Add a BinaryFileAssetTask to the list of active tasks
  92204. * @param taskName defines the name of the new task
  92205. * @param url defines the url of the file to load
  92206. * @returns a new BinaryFileAssetTask object
  92207. */
  92208. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  92209. var task = new BinaryFileAssetTask(taskName, url);
  92210. this._tasks.push(task);
  92211. return task;
  92212. };
  92213. /**
  92214. * Add a ImageAssetTask to the list of active tasks
  92215. * @param taskName defines the name of the new task
  92216. * @param url defines the url of the file to load
  92217. * @returns a new ImageAssetTask object
  92218. */
  92219. AssetsManager.prototype.addImageTask = function (taskName, url) {
  92220. var task = new ImageAssetTask(taskName, url);
  92221. this._tasks.push(task);
  92222. return task;
  92223. };
  92224. /**
  92225. * Add a TextureAssetTask to the list of active tasks
  92226. * @param taskName defines the name of the new task
  92227. * @param url defines the url of the file to load
  92228. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92229. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  92230. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  92231. * @returns a new TextureAssetTask object
  92232. */
  92233. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  92234. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92235. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  92236. this._tasks.push(task);
  92237. return task;
  92238. };
  92239. /**
  92240. * Add a CubeTextureAssetTask to the list of active tasks
  92241. * @param taskName defines the name of the new task
  92242. * @param url defines the url of the file to load
  92243. * @param extensions defines the extension to use to load the cube map (can be null)
  92244. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92245. * @param files defines the list of files to load (can be null)
  92246. * @returns a new CubeTextureAssetTask object
  92247. */
  92248. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  92249. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  92250. this._tasks.push(task);
  92251. return task;
  92252. };
  92253. /**
  92254. *
  92255. * Add a HDRCubeTextureAssetTask to the list of active tasks
  92256. * @param taskName defines the name of the new task
  92257. * @param url defines the url of the file to load
  92258. * @param size defines the size you want for the cubemap (can be null)
  92259. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92260. * @param generateHarmonics defines if you want to automatically generate (true by default)
  92261. * @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)
  92262. * @param reserved Internal use only
  92263. * @returns a new HDRCubeTextureAssetTask object
  92264. */
  92265. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  92266. if (noMipmap === void 0) { noMipmap = false; }
  92267. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92268. if (gammaSpace === void 0) { gammaSpace = false; }
  92269. if (reserved === void 0) { reserved = false; }
  92270. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  92271. this._tasks.push(task);
  92272. return task;
  92273. };
  92274. /**
  92275. * Remove a task from the assets manager.
  92276. * @param task the task to remove
  92277. */
  92278. AssetsManager.prototype.removeTask = function (task) {
  92279. var index = this._tasks.indexOf(task);
  92280. if (index > -1) {
  92281. this._tasks.splice(index, 1);
  92282. }
  92283. };
  92284. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  92285. this._waitingTasksCount--;
  92286. try {
  92287. if (this.onProgress) {
  92288. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  92289. }
  92290. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  92291. }
  92292. catch (e) {
  92293. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  92294. console.log(e);
  92295. }
  92296. if (this._waitingTasksCount === 0) {
  92297. try {
  92298. if (this.onFinish) {
  92299. this.onFinish(this._tasks);
  92300. }
  92301. // Let's remove successfull tasks
  92302. var currentTasks = this._tasks.slice();
  92303. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  92304. var task = currentTasks_1[_i];
  92305. if (task.taskState === AssetTaskState.DONE) {
  92306. var index = this._tasks.indexOf(task);
  92307. if (index > -1) {
  92308. this._tasks.splice(index, 1);
  92309. }
  92310. }
  92311. }
  92312. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92313. }
  92314. catch (e) {
  92315. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  92316. console.log(e);
  92317. }
  92318. this._isLoading = false;
  92319. this._scene.getEngine().hideLoadingUI();
  92320. }
  92321. };
  92322. AssetsManager.prototype._runTask = function (task) {
  92323. var _this = this;
  92324. var done = function () {
  92325. try {
  92326. if (_this.onTaskSuccess) {
  92327. _this.onTaskSuccess(task);
  92328. }
  92329. _this.onTaskSuccessObservable.notifyObservers(task);
  92330. _this._decreaseWaitingTasksCount(task);
  92331. }
  92332. catch (e) {
  92333. error("Error executing task success callbacks", e);
  92334. }
  92335. };
  92336. var error = function (message, exception) {
  92337. task._setErrorObject(message, exception);
  92338. if (_this.onTaskError) {
  92339. _this.onTaskError(task);
  92340. }
  92341. _this.onTaskErrorObservable.notifyObservers(task);
  92342. _this._decreaseWaitingTasksCount(task);
  92343. };
  92344. task.run(this._scene, done, error);
  92345. };
  92346. /**
  92347. * Reset the AssetsManager and remove all tasks
  92348. * @return the current instance of the AssetsManager
  92349. */
  92350. AssetsManager.prototype.reset = function () {
  92351. this._isLoading = false;
  92352. this._tasks = new Array();
  92353. return this;
  92354. };
  92355. /**
  92356. * Start the loading process
  92357. * @return the current instance of the AssetsManager
  92358. */
  92359. AssetsManager.prototype.load = function () {
  92360. if (this._isLoading) {
  92361. return this;
  92362. }
  92363. this._isLoading = true;
  92364. this._waitingTasksCount = this._tasks.length;
  92365. this._totalTasksCount = this._tasks.length;
  92366. if (this._waitingTasksCount === 0) {
  92367. this._isLoading = false;
  92368. if (this.onFinish) {
  92369. this.onFinish(this._tasks);
  92370. }
  92371. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92372. return this;
  92373. }
  92374. if (this.useDefaultLoadingScreen) {
  92375. this._scene.getEngine().displayLoadingUI();
  92376. }
  92377. for (var index = 0; index < this._tasks.length; index++) {
  92378. var task = this._tasks[index];
  92379. if (task.taskState === AssetTaskState.INIT) {
  92380. this._runTask(task);
  92381. }
  92382. }
  92383. return this;
  92384. };
  92385. return AssetsManager;
  92386. }());
  92387. /***/ }),
  92388. /***/ "./Misc/dds.ts":
  92389. /*!*********************!*\
  92390. !*** ./Misc/dds.ts ***!
  92391. \*********************/
  92392. /*! exports provided: DDSTools */
  92393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92394. "use strict";
  92395. __webpack_require__.r(__webpack_exports__);
  92396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  92397. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92398. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92399. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92400. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92401. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92402. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92403. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  92404. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92405. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  92406. // All values and structures referenced from:
  92407. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  92408. var DDS_MAGIC = 0x20534444;
  92409. var
  92410. //DDSD_CAPS = 0x1,
  92411. //DDSD_HEIGHT = 0x2,
  92412. //DDSD_WIDTH = 0x4,
  92413. //DDSD_PITCH = 0x8,
  92414. //DDSD_PIXELFORMAT = 0x1000,
  92415. DDSD_MIPMAPCOUNT = 0x20000;
  92416. //DDSD_LINEARSIZE = 0x80000,
  92417. //DDSD_DEPTH = 0x800000;
  92418. // var DDSCAPS_COMPLEX = 0x8,
  92419. // DDSCAPS_MIPMAP = 0x400000,
  92420. // DDSCAPS_TEXTURE = 0x1000;
  92421. var DDSCAPS2_CUBEMAP = 0x200;
  92422. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  92423. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  92424. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  92425. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  92426. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  92427. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  92428. // DDSCAPS2_VOLUME = 0x200000;
  92429. var
  92430. //DDPF_ALPHAPIXELS = 0x1,
  92431. //DDPF_ALPHA = 0x2,
  92432. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  92433. //DDPF_YUV = 0x200,
  92434. DDPF_LUMINANCE = 0x20000;
  92435. function FourCCToInt32(value) {
  92436. return value.charCodeAt(0) +
  92437. (value.charCodeAt(1) << 8) +
  92438. (value.charCodeAt(2) << 16) +
  92439. (value.charCodeAt(3) << 24);
  92440. }
  92441. function Int32ToFourCC(value) {
  92442. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  92443. }
  92444. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  92445. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  92446. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  92447. var FOURCC_DX10 = FourCCToInt32("DX10");
  92448. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  92449. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  92450. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  92451. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  92452. var headerLengthInt = 31; // The header length in 32 bit ints
  92453. // Offsets into the header array
  92454. var off_magic = 0;
  92455. var off_size = 1;
  92456. var off_flags = 2;
  92457. var off_height = 3;
  92458. var off_width = 4;
  92459. var off_mipmapCount = 7;
  92460. var off_pfFlags = 20;
  92461. var off_pfFourCC = 21;
  92462. var off_RGBbpp = 22;
  92463. var off_RMask = 23;
  92464. var off_GMask = 24;
  92465. var off_BMask = 25;
  92466. var off_AMask = 26;
  92467. // var off_caps1 = 27;
  92468. var off_caps2 = 28;
  92469. // var off_caps3 = 29;
  92470. // var off_caps4 = 30;
  92471. var off_dxgiFormat = 32;
  92472. /**
  92473. * Class used to provide DDS decompression tools
  92474. */
  92475. var DDSTools = /** @class */ (function () {
  92476. function DDSTools() {
  92477. }
  92478. /**
  92479. * Gets DDS information from an array buffer
  92480. * @param arrayBuffer defines the array buffer to read data from
  92481. * @returns the DDS information
  92482. */
  92483. DDSTools.GetDDSInfo = function (arrayBuffer) {
  92484. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92485. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  92486. var mipmapCount = 1;
  92487. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  92488. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92489. }
  92490. var fourCC = header[off_pfFourCC];
  92491. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  92492. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92493. switch (fourCC) {
  92494. case FOURCC_D3DFMT_R16G16B16A16F:
  92495. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92496. break;
  92497. case FOURCC_D3DFMT_R32G32B32A32F:
  92498. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92499. break;
  92500. case FOURCC_DX10:
  92501. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  92502. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92503. break;
  92504. }
  92505. }
  92506. return {
  92507. width: header[off_width],
  92508. height: header[off_height],
  92509. mipmapCount: mipmapCount,
  92510. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  92511. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  92512. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  92513. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  92514. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  92515. dxgiFormat: dxgiFormat,
  92516. textureType: textureType
  92517. };
  92518. };
  92519. DDSTools._ToHalfFloat = function (value) {
  92520. if (!DDSTools._FloatView) {
  92521. DDSTools._FloatView = new Float32Array(1);
  92522. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  92523. }
  92524. DDSTools._FloatView[0] = value;
  92525. var x = DDSTools._Int32View[0];
  92526. var bits = (x >> 16) & 0x8000; /* Get the sign */
  92527. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  92528. var e = (x >> 23) & 0xff; /* Using int is faster here */
  92529. /* If zero, or denormal, or exponent underflows too much for a denormal
  92530. * half, return signed zero. */
  92531. if (e < 103) {
  92532. return bits;
  92533. }
  92534. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  92535. if (e > 142) {
  92536. bits |= 0x7c00;
  92537. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  92538. * not Inf, so make sure we set one mantissa bit too. */
  92539. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  92540. return bits;
  92541. }
  92542. /* If exponent underflows but not too much, return a denormal */
  92543. if (e < 113) {
  92544. m |= 0x0800;
  92545. /* Extra rounding may overflow and set mantissa to 0 and exponent
  92546. * to 1, which is OK. */
  92547. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  92548. return bits;
  92549. }
  92550. bits |= ((e - 112) << 10) | (m >> 1);
  92551. bits += m & 1;
  92552. return bits;
  92553. };
  92554. DDSTools._FromHalfFloat = function (value) {
  92555. var s = (value & 0x8000) >> 15;
  92556. var e = (value & 0x7C00) >> 10;
  92557. var f = value & 0x03FF;
  92558. if (e === 0) {
  92559. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  92560. }
  92561. else if (e == 0x1F) {
  92562. return f ? NaN : ((s ? -1 : 1) * Infinity);
  92563. }
  92564. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  92565. };
  92566. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92567. var destArray = new Float32Array(dataLength);
  92568. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92569. var index = 0;
  92570. for (var y = 0; y < height; y++) {
  92571. for (var x = 0; x < width; x++) {
  92572. var srcPos = (x + y * width) * 4;
  92573. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  92574. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  92575. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  92576. if (DDSTools.StoreLODInAlphaChannel) {
  92577. destArray[index + 3] = lod;
  92578. }
  92579. else {
  92580. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  92581. }
  92582. index += 4;
  92583. }
  92584. }
  92585. return destArray;
  92586. };
  92587. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92588. if (DDSTools.StoreLODInAlphaChannel) {
  92589. var destArray = new Uint16Array(dataLength);
  92590. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92591. var index = 0;
  92592. for (var y = 0; y < height; y++) {
  92593. for (var x = 0; x < width; x++) {
  92594. var srcPos = (x + y * width) * 4;
  92595. destArray[index] = srcData[srcPos];
  92596. destArray[index + 1] = srcData[srcPos + 1];
  92597. destArray[index + 2] = srcData[srcPos + 2];
  92598. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  92599. index += 4;
  92600. }
  92601. }
  92602. return destArray;
  92603. }
  92604. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  92605. };
  92606. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92607. if (DDSTools.StoreLODInAlphaChannel) {
  92608. var destArray = new Float32Array(dataLength);
  92609. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92610. var index = 0;
  92611. for (var y = 0; y < height; y++) {
  92612. for (var x = 0; x < width; x++) {
  92613. var srcPos = (x + y * width) * 4;
  92614. destArray[index] = srcData[srcPos];
  92615. destArray[index + 1] = srcData[srcPos + 1];
  92616. destArray[index + 2] = srcData[srcPos + 2];
  92617. destArray[index + 3] = lod;
  92618. index += 4;
  92619. }
  92620. }
  92621. return destArray;
  92622. }
  92623. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  92624. };
  92625. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92626. var destArray = new Uint8Array(dataLength);
  92627. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92628. var index = 0;
  92629. for (var y = 0; y < height; y++) {
  92630. for (var x = 0; x < width; x++) {
  92631. var srcPos = (x + y * width) * 4;
  92632. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  92633. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  92634. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  92635. if (DDSTools.StoreLODInAlphaChannel) {
  92636. destArray[index + 3] = lod;
  92637. }
  92638. else {
  92639. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  92640. }
  92641. index += 4;
  92642. }
  92643. }
  92644. return destArray;
  92645. };
  92646. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92647. var destArray = new Uint8Array(dataLength);
  92648. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92649. var index = 0;
  92650. for (var y = 0; y < height; y++) {
  92651. for (var x = 0; x < width; x++) {
  92652. var srcPos = (x + y * width) * 4;
  92653. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  92654. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  92655. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  92656. if (DDSTools.StoreLODInAlphaChannel) {
  92657. destArray[index + 3] = lod;
  92658. }
  92659. else {
  92660. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  92661. }
  92662. index += 4;
  92663. }
  92664. }
  92665. return destArray;
  92666. };
  92667. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  92668. var byteArray = new Uint8Array(dataLength);
  92669. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92670. var index = 0;
  92671. for (var y = 0; y < height; y++) {
  92672. for (var x = 0; x < width; x++) {
  92673. var srcPos = (x + y * width) * 4;
  92674. byteArray[index] = srcData[srcPos + rOffset];
  92675. byteArray[index + 1] = srcData[srcPos + gOffset];
  92676. byteArray[index + 2] = srcData[srcPos + bOffset];
  92677. byteArray[index + 3] = srcData[srcPos + aOffset];
  92678. index += 4;
  92679. }
  92680. }
  92681. return byteArray;
  92682. };
  92683. DDSTools._ExtractLongWordOrder = function (value) {
  92684. if (value === 0 || value === 255 || value === -16777216) {
  92685. return 0;
  92686. }
  92687. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  92688. };
  92689. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  92690. var byteArray = new Uint8Array(dataLength);
  92691. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92692. var index = 0;
  92693. for (var y = 0; y < height; y++) {
  92694. for (var x = 0; x < width; x++) {
  92695. var srcPos = (x + y * width) * 3;
  92696. byteArray[index] = srcData[srcPos + rOffset];
  92697. byteArray[index + 1] = srcData[srcPos + gOffset];
  92698. byteArray[index + 2] = srcData[srcPos + bOffset];
  92699. index += 3;
  92700. }
  92701. }
  92702. return byteArray;
  92703. };
  92704. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  92705. var byteArray = new Uint8Array(dataLength);
  92706. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  92707. var index = 0;
  92708. for (var y = 0; y < height; y++) {
  92709. for (var x = 0; x < width; x++) {
  92710. var srcPos = (x + y * width);
  92711. byteArray[index] = srcData[srcPos];
  92712. index++;
  92713. }
  92714. }
  92715. return byteArray;
  92716. };
  92717. /**
  92718. * Uploads DDS Levels to a Babylon Texture
  92719. * @hidden
  92720. */
  92721. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  92722. if (lodIndex === void 0) { lodIndex = -1; }
  92723. var sphericalPolynomialFaces = null;
  92724. if (info.sphericalPolynomial) {
  92725. sphericalPolynomialFaces = new Array();
  92726. }
  92727. var ext = engine.getCaps().s3tc;
  92728. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92729. var fourCC, width, height, dataLength = 0, dataOffset;
  92730. var byteArray, mipmapCount, mip;
  92731. var internalCompressedFormat = 0;
  92732. var blockBytes = 1;
  92733. if (header[off_magic] !== DDS_MAGIC) {
  92734. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  92735. return;
  92736. }
  92737. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  92738. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  92739. return;
  92740. }
  92741. if (info.isCompressed && !ext) {
  92742. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  92743. return;
  92744. }
  92745. var bpp = header[off_RGBbpp];
  92746. dataOffset = header[off_size] + 4;
  92747. var computeFormats = false;
  92748. if (info.isFourCC) {
  92749. fourCC = header[off_pfFourCC];
  92750. switch (fourCC) {
  92751. case FOURCC_DXT1:
  92752. blockBytes = 8;
  92753. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  92754. break;
  92755. case FOURCC_DXT3:
  92756. blockBytes = 16;
  92757. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  92758. break;
  92759. case FOURCC_DXT5:
  92760. blockBytes = 16;
  92761. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  92762. break;
  92763. case FOURCC_D3DFMT_R16G16B16A16F:
  92764. computeFormats = true;
  92765. break;
  92766. case FOURCC_D3DFMT_R32G32B32A32F:
  92767. computeFormats = true;
  92768. break;
  92769. case FOURCC_DX10:
  92770. // There is an additionnal header so dataOffset need to be changed
  92771. dataOffset += 5 * 4; // 5 uints
  92772. var supported = false;
  92773. switch (info.dxgiFormat) {
  92774. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  92775. computeFormats = true;
  92776. supported = true;
  92777. break;
  92778. case DXGI_FORMAT_B8G8R8X8_UNORM:
  92779. info.isRGB = true;
  92780. info.isFourCC = false;
  92781. bpp = 32;
  92782. supported = true;
  92783. break;
  92784. }
  92785. if (supported) {
  92786. break;
  92787. }
  92788. default:
  92789. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  92790. return;
  92791. }
  92792. }
  92793. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  92794. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  92795. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  92796. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  92797. if (computeFormats) {
  92798. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  92799. }
  92800. mipmapCount = 1;
  92801. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  92802. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92803. }
  92804. for (var face = 0; face < faces; face++) {
  92805. width = header[off_width];
  92806. height = header[off_height];
  92807. for (mip = 0; mip < mipmapCount; ++mip) {
  92808. if (lodIndex === -1 || lodIndex === mip) {
  92809. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  92810. var i = (lodIndex === -1) ? mip : 0;
  92811. if (!info.isCompressed && info.isFourCC) {
  92812. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92813. dataLength = width * height * 4;
  92814. var floatArray = null;
  92815. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  92816. if (bpp === 128) {
  92817. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92818. if (sphericalPolynomialFaces && i == 0) {
  92819. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92820. }
  92821. }
  92822. else if (bpp === 64) {
  92823. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92824. if (sphericalPolynomialFaces && i == 0) {
  92825. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92826. }
  92827. }
  92828. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92829. }
  92830. else {
  92831. if (bpp === 128) {
  92832. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92833. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92834. if (sphericalPolynomialFaces && i == 0) {
  92835. sphericalPolynomialFaces.push(floatArray);
  92836. }
  92837. }
  92838. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  92839. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92840. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92841. if (sphericalPolynomialFaces && i == 0) {
  92842. sphericalPolynomialFaces.push(floatArray);
  92843. }
  92844. }
  92845. else { // 64
  92846. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92847. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92848. if (sphericalPolynomialFaces && i == 0) {
  92849. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92850. }
  92851. }
  92852. }
  92853. if (floatArray) {
  92854. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  92855. }
  92856. }
  92857. else if (info.isRGB) {
  92858. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92859. if (bpp === 24) {
  92860. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  92861. dataLength = width * height * 3;
  92862. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  92863. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92864. }
  92865. else { // 32
  92866. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92867. dataLength = width * height * 4;
  92868. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  92869. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92870. }
  92871. }
  92872. else if (info.isLuminance) {
  92873. var unpackAlignment = engine._getUnpackAlignement();
  92874. var unpaddedRowSize = width;
  92875. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  92876. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  92877. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  92878. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  92879. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92880. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92881. }
  92882. else {
  92883. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  92884. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  92885. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92886. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  92887. }
  92888. }
  92889. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  92890. width *= 0.5;
  92891. height *= 0.5;
  92892. width = Math.max(1.0, width);
  92893. height = Math.max(1.0, height);
  92894. }
  92895. if (currentFace !== undefined) {
  92896. // Loading a single face
  92897. break;
  92898. }
  92899. }
  92900. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  92901. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  92902. size: header[off_width],
  92903. right: sphericalPolynomialFaces[0],
  92904. left: sphericalPolynomialFaces[1],
  92905. up: sphericalPolynomialFaces[2],
  92906. down: sphericalPolynomialFaces[3],
  92907. front: sphericalPolynomialFaces[4],
  92908. back: sphericalPolynomialFaces[5],
  92909. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  92910. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  92911. gammaSpace: false,
  92912. });
  92913. }
  92914. else {
  92915. info.sphericalPolynomial = undefined;
  92916. }
  92917. };
  92918. /**
  92919. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  92920. */
  92921. DDSTools.StoreLODInAlphaChannel = false;
  92922. return DDSTools;
  92923. }());
  92924. /**
  92925. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  92926. * @param rootUrl defines the url where the file to load is located
  92927. * @param scene defines the current scene
  92928. * @param lodScale defines scale to apply to the mip map selection
  92929. * @param lodOffset defines offset to apply to the mip map selection
  92930. * @param onLoad defines an optional callback raised when the texture is loaded
  92931. * @param onError defines an optional callback raised if there is an issue to load the texture
  92932. * @param format defines the format of the data
  92933. * @param forcedExtension defines the extension to use to pick the right loader
  92934. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  92935. * @returns the cube texture as an InternalTexture
  92936. */
  92937. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  92938. var _this = this;
  92939. if (onLoad === void 0) { onLoad = null; }
  92940. if (onError === void 0) { onError = null; }
  92941. if (forcedExtension === void 0) { forcedExtension = null; }
  92942. if (createPolynomials === void 0) { createPolynomials = true; }
  92943. var callback = function (loadData) {
  92944. if (!loadData) {
  92945. if (onLoad) {
  92946. onLoad(null);
  92947. }
  92948. return;
  92949. }
  92950. var texture = loadData.texture;
  92951. if (!createPolynomials) {
  92952. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  92953. }
  92954. else if (loadData.info.sphericalPolynomial) {
  92955. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  92956. }
  92957. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  92958. if (_this.getCaps().textureLOD) {
  92959. // Do not add extra process if texture lod is supported.
  92960. if (onLoad) {
  92961. onLoad(texture);
  92962. }
  92963. return;
  92964. }
  92965. var mipSlices = 3;
  92966. var gl = _this._gl;
  92967. var width = loadData.width;
  92968. if (!width) {
  92969. return;
  92970. }
  92971. var textures = [];
  92972. for (var i = 0; i < mipSlices; i++) {
  92973. //compute LOD from even spacing in smoothness (matching shader calculation)
  92974. var smoothness = i / (mipSlices - 1);
  92975. var roughness = 1 - smoothness;
  92976. var minLODIndex = lodOffset; // roughness = 0
  92977. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  92978. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  92979. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  92980. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  92981. glTextureFromLod.type = texture.type;
  92982. glTextureFromLod.format = texture.format;
  92983. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  92984. glTextureFromLod.height = glTextureFromLod.width;
  92985. glTextureFromLod.isCube = true;
  92986. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  92987. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  92988. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  92989. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  92990. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  92991. if (loadData.isDDS) {
  92992. var info = loadData.info;
  92993. var data = loadData.data;
  92994. _this._unpackFlipY(info.isCompressed);
  92995. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  92996. }
  92997. else {
  92998. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  92999. }
  93000. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  93001. // Wrap in a base texture for easy binding.
  93002. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  93003. lodTexture.isCube = true;
  93004. lodTexture._texture = glTextureFromLod;
  93005. glTextureFromLod.isReady = true;
  93006. textures.push(lodTexture);
  93007. }
  93008. texture._lodTextureHigh = textures[2];
  93009. texture._lodTextureMid = textures[1];
  93010. texture._lodTextureLow = textures[0];
  93011. if (onLoad) {
  93012. onLoad(texture);
  93013. }
  93014. };
  93015. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  93016. };
  93017. /***/ }),
  93018. /***/ "./Misc/decorators.ts":
  93019. /*!****************************!*\
  93020. !*** ./Misc/decorators.ts ***!
  93021. \****************************/
  93022. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  93023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93024. "use strict";
  93025. __webpack_require__.r(__webpack_exports__);
  93026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  93027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  93028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  93029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  93030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  93031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  93032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  93033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  93034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  93035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  93036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  93037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  93038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  93039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  93040. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  93041. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93042. var __decoratorInitialStore = {};
  93043. var __mergedStore = {};
  93044. var _copySource = function (creationFunction, source, instanciate) {
  93045. var destination = creationFunction();
  93046. // Tags
  93047. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93048. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93049. }
  93050. var classStore = getMergedStore(destination);
  93051. // Properties
  93052. for (var property in classStore) {
  93053. var propertyDescriptor = classStore[property];
  93054. var sourceProperty = source[property];
  93055. var propertyType = propertyDescriptor.type;
  93056. if (sourceProperty !== undefined && sourceProperty !== null) {
  93057. switch (propertyType) {
  93058. case 0: // Value
  93059. case 6: // Mesh reference
  93060. case 11: // Camera reference
  93061. destination[property] = sourceProperty;
  93062. break;
  93063. case 1: // Texture
  93064. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  93065. break;
  93066. case 2: // Color3
  93067. case 3: // FresnelParameters
  93068. case 4: // Vector2
  93069. case 5: // Vector3
  93070. case 7: // Color Curves
  93071. case 10: // Quaternion
  93072. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  93073. break;
  93074. }
  93075. }
  93076. }
  93077. return destination;
  93078. };
  93079. function getDirectStore(target) {
  93080. var classKey = target.getClassName();
  93081. if (!__decoratorInitialStore[classKey]) {
  93082. __decoratorInitialStore[classKey] = {};
  93083. }
  93084. return __decoratorInitialStore[classKey];
  93085. }
  93086. /**
  93087. * Return the list of properties flagged as serializable
  93088. * @param target: host object
  93089. */
  93090. function getMergedStore(target) {
  93091. var classKey = target.getClassName();
  93092. if (__mergedStore[classKey]) {
  93093. return __mergedStore[classKey];
  93094. }
  93095. __mergedStore[classKey] = {};
  93096. var store = __mergedStore[classKey];
  93097. var currentTarget = target;
  93098. var currentKey = classKey;
  93099. while (currentKey) {
  93100. var initialStore = __decoratorInitialStore[currentKey];
  93101. for (var property in initialStore) {
  93102. store[property] = initialStore[property];
  93103. }
  93104. var parent_1 = void 0;
  93105. var done = false;
  93106. do {
  93107. parent_1 = Object.getPrototypeOf(currentTarget);
  93108. if (!parent_1.getClassName) {
  93109. done = true;
  93110. break;
  93111. }
  93112. if (parent_1.getClassName() !== currentKey) {
  93113. break;
  93114. }
  93115. currentTarget = parent_1;
  93116. } while (parent_1);
  93117. if (done) {
  93118. break;
  93119. }
  93120. currentKey = parent_1.getClassName();
  93121. currentTarget = parent_1;
  93122. }
  93123. return store;
  93124. }
  93125. function generateSerializableMember(type, sourceName) {
  93126. return function (target, propertyKey) {
  93127. var classStore = getDirectStore(target);
  93128. if (!classStore[propertyKey]) {
  93129. classStore[propertyKey] = { type: type, sourceName: sourceName };
  93130. }
  93131. };
  93132. }
  93133. function generateExpandMember(setCallback, targetKey) {
  93134. if (targetKey === void 0) { targetKey = null; }
  93135. return function (target, propertyKey) {
  93136. var key = targetKey || ("_" + propertyKey);
  93137. Object.defineProperty(target, propertyKey, {
  93138. get: function () {
  93139. return this[key];
  93140. },
  93141. set: function (value) {
  93142. if (this[key] === value) {
  93143. return;
  93144. }
  93145. this[key] = value;
  93146. target[setCallback].apply(this);
  93147. },
  93148. enumerable: true,
  93149. configurable: true
  93150. });
  93151. };
  93152. }
  93153. function expandToProperty(callback, targetKey) {
  93154. if (targetKey === void 0) { targetKey = null; }
  93155. return generateExpandMember(callback, targetKey);
  93156. }
  93157. function serialize(sourceName) {
  93158. return generateSerializableMember(0, sourceName); // value member
  93159. }
  93160. function serializeAsTexture(sourceName) {
  93161. return generateSerializableMember(1, sourceName); // texture member
  93162. }
  93163. function serializeAsColor3(sourceName) {
  93164. return generateSerializableMember(2, sourceName); // color3 member
  93165. }
  93166. function serializeAsFresnelParameters(sourceName) {
  93167. return generateSerializableMember(3, sourceName); // fresnel parameters member
  93168. }
  93169. function serializeAsVector2(sourceName) {
  93170. return generateSerializableMember(4, sourceName); // vector2 member
  93171. }
  93172. function serializeAsVector3(sourceName) {
  93173. return generateSerializableMember(5, sourceName); // vector3 member
  93174. }
  93175. function serializeAsMeshReference(sourceName) {
  93176. return generateSerializableMember(6, sourceName); // mesh reference member
  93177. }
  93178. function serializeAsColorCurves(sourceName) {
  93179. return generateSerializableMember(7, sourceName); // color curves
  93180. }
  93181. function serializeAsColor4(sourceName) {
  93182. return generateSerializableMember(8, sourceName); // color 4
  93183. }
  93184. function serializeAsImageProcessingConfiguration(sourceName) {
  93185. return generateSerializableMember(9, sourceName); // image processing
  93186. }
  93187. function serializeAsQuaternion(sourceName) {
  93188. return generateSerializableMember(10, sourceName); // quaternion member
  93189. }
  93190. /**
  93191. * Decorator used to define property that can be serialized as reference to a camera
  93192. * @param sourceName defines the name of the property to decorate
  93193. */
  93194. function serializeAsCameraReference(sourceName) {
  93195. return generateSerializableMember(11, sourceName); // camera reference member
  93196. }
  93197. /**
  93198. * Class used to help serialization objects
  93199. */
  93200. var SerializationHelper = /** @class */ (function () {
  93201. function SerializationHelper() {
  93202. }
  93203. /**
  93204. * Appends the serialized animations from the source animations
  93205. * @param source Source containing the animations
  93206. * @param destination Target to store the animations
  93207. */
  93208. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  93209. if (source.animations) {
  93210. destination.animations = [];
  93211. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  93212. var animation = source.animations[animationIndex];
  93213. destination.animations.push(animation.serialize());
  93214. }
  93215. }
  93216. };
  93217. /**
  93218. * Static function used to serialized a specific entity
  93219. * @param entity defines the entity to serialize
  93220. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93221. * @returns a JSON compatible object representing the serialization of the entity
  93222. */
  93223. SerializationHelper.Serialize = function (entity, serializationObject) {
  93224. if (!serializationObject) {
  93225. serializationObject = {};
  93226. }
  93227. // Tags
  93228. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93229. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  93230. }
  93231. var serializedProperties = getMergedStore(entity);
  93232. // Properties
  93233. for (var property in serializedProperties) {
  93234. var propertyDescriptor = serializedProperties[property];
  93235. var targetPropertyName = propertyDescriptor.sourceName || property;
  93236. var propertyType = propertyDescriptor.type;
  93237. var sourceProperty = entity[property];
  93238. if (sourceProperty !== undefined && sourceProperty !== null) {
  93239. switch (propertyType) {
  93240. case 0: // Value
  93241. serializationObject[targetPropertyName] = sourceProperty;
  93242. break;
  93243. case 1: // Texture
  93244. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93245. break;
  93246. case 2: // Color3
  93247. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93248. break;
  93249. case 3: // FresnelParameters
  93250. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93251. break;
  93252. case 4: // Vector2
  93253. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93254. break;
  93255. case 5: // Vector3
  93256. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93257. break;
  93258. case 6: // Mesh reference
  93259. serializationObject[targetPropertyName] = sourceProperty.id;
  93260. break;
  93261. case 7: // Color Curves
  93262. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93263. break;
  93264. case 8: // Color 4
  93265. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93266. break;
  93267. case 9: // Image Processing
  93268. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93269. break;
  93270. case 10: // Quaternion
  93271. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93272. break;
  93273. case 11: // Camera reference
  93274. serializationObject[targetPropertyName] = sourceProperty.id;
  93275. break;
  93276. }
  93277. }
  93278. }
  93279. return serializationObject;
  93280. };
  93281. /**
  93282. * Creates a new entity from a serialization data object
  93283. * @param creationFunction defines a function used to instanciated the new entity
  93284. * @param source defines the source serialization data
  93285. * @param scene defines the hosting scene
  93286. * @param rootUrl defines the root url for resources
  93287. * @returns a new entity
  93288. */
  93289. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  93290. if (rootUrl === void 0) { rootUrl = null; }
  93291. var destination = creationFunction();
  93292. if (!rootUrl) {
  93293. rootUrl = "";
  93294. }
  93295. // Tags
  93296. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93297. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93298. }
  93299. var classStore = getMergedStore(destination);
  93300. // Properties
  93301. for (var property in classStore) {
  93302. var propertyDescriptor = classStore[property];
  93303. var sourceProperty = source[propertyDescriptor.sourceName || property];
  93304. var propertyType = propertyDescriptor.type;
  93305. if (sourceProperty !== undefined && sourceProperty !== null) {
  93306. var dest = destination;
  93307. switch (propertyType) {
  93308. case 0: // Value
  93309. dest[property] = sourceProperty;
  93310. break;
  93311. case 1: // Texture
  93312. if (scene) {
  93313. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  93314. }
  93315. break;
  93316. case 2: // Color3
  93317. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  93318. break;
  93319. case 3: // FresnelParameters
  93320. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  93321. break;
  93322. case 4: // Vector2
  93323. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  93324. break;
  93325. case 5: // Vector3
  93326. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  93327. break;
  93328. case 6: // Mesh reference
  93329. if (scene) {
  93330. dest[property] = scene.getLastMeshByID(sourceProperty);
  93331. }
  93332. break;
  93333. case 7: // Color Curves
  93334. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  93335. break;
  93336. case 8: // Color 4
  93337. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  93338. break;
  93339. case 9: // Image Processing
  93340. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  93341. break;
  93342. case 10: // Quaternion
  93343. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  93344. break;
  93345. case 11: // Camera reference
  93346. if (scene) {
  93347. dest[property] = scene.getCameraByID(sourceProperty);
  93348. }
  93349. break;
  93350. }
  93351. }
  93352. }
  93353. return destination;
  93354. };
  93355. /**
  93356. * Clones an object
  93357. * @param creationFunction defines the function used to instanciate the new object
  93358. * @param source defines the source object
  93359. * @returns the cloned object
  93360. */
  93361. SerializationHelper.Clone = function (creationFunction, source) {
  93362. return _copySource(creationFunction, source, false);
  93363. };
  93364. /**
  93365. * Instanciates a new object based on a source one (some data will be shared between both object)
  93366. * @param creationFunction defines the function used to instanciate the new object
  93367. * @param source defines the source object
  93368. * @returns the new object
  93369. */
  93370. SerializationHelper.Instanciate = function (creationFunction, source) {
  93371. return _copySource(creationFunction, source, true);
  93372. };
  93373. /** hidden */
  93374. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  93375. throw "ImageProcessingConfiguration needs to be imported before being deserialized.";
  93376. };
  93377. /** hidden */
  93378. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  93379. throw "FresnelParameters needs to be imported before being deserialized.";
  93380. };
  93381. /** hidden */
  93382. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  93383. throw "ColorCurves needs to be imported before being deserialized.";
  93384. };
  93385. /** hidden */
  93386. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  93387. throw "Texture needs to be imported before being deserialized.";
  93388. };
  93389. return SerializationHelper;
  93390. }());
  93391. /***/ }),
  93392. /***/ "./Misc/deepCopier.ts":
  93393. /*!****************************!*\
  93394. !*** ./Misc/deepCopier.ts ***!
  93395. \****************************/
  93396. /*! exports provided: DeepCopier */
  93397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93398. "use strict";
  93399. __webpack_require__.r(__webpack_exports__);
  93400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  93401. var cloneValue = function (source, destinationObject) {
  93402. if (!source) {
  93403. return null;
  93404. }
  93405. if (source.getClassName && source.getClassName() === "Mesh") {
  93406. return null;
  93407. }
  93408. if (source.getClassName && source.getClassName() === "SubMesh") {
  93409. return source.clone(destinationObject);
  93410. }
  93411. else if (source.clone) {
  93412. return source.clone();
  93413. }
  93414. return null;
  93415. };
  93416. /**
  93417. * Class containing a set of static utilities functions for deep copy.
  93418. */
  93419. var DeepCopier = /** @class */ (function () {
  93420. function DeepCopier() {
  93421. }
  93422. /**
  93423. * Tries to copy an object by duplicating every property
  93424. * @param source defines the source object
  93425. * @param destination defines the target object
  93426. * @param doNotCopyList defines a list of properties to avoid
  93427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93428. */
  93429. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  93430. for (var prop in source) {
  93431. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  93432. continue;
  93433. }
  93434. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  93435. continue;
  93436. }
  93437. var sourceValue = source[prop];
  93438. var typeOfSourceValue = typeof sourceValue;
  93439. if (typeOfSourceValue === "function") {
  93440. continue;
  93441. }
  93442. try {
  93443. if (typeOfSourceValue === "object") {
  93444. if (sourceValue instanceof Array) {
  93445. destination[prop] = [];
  93446. if (sourceValue.length > 0) {
  93447. if (typeof sourceValue[0] == "object") {
  93448. for (var index = 0; index < sourceValue.length; index++) {
  93449. var clonedValue = cloneValue(sourceValue[index], destination);
  93450. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  93451. destination[prop].push(clonedValue);
  93452. }
  93453. }
  93454. }
  93455. else {
  93456. destination[prop] = sourceValue.slice(0);
  93457. }
  93458. }
  93459. }
  93460. else {
  93461. destination[prop] = cloneValue(sourceValue, destination);
  93462. }
  93463. }
  93464. else {
  93465. destination[prop] = sourceValue;
  93466. }
  93467. }
  93468. catch (e) {
  93469. // Just ignore error (it could be because of a read-only property)
  93470. }
  93471. }
  93472. };
  93473. return DeepCopier;
  93474. }());
  93475. /***/ }),
  93476. /***/ "./Misc/deferred.ts":
  93477. /*!**************************!*\
  93478. !*** ./Misc/deferred.ts ***!
  93479. \**************************/
  93480. /*! exports provided: Deferred */
  93481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93482. "use strict";
  93483. __webpack_require__.r(__webpack_exports__);
  93484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  93485. /**
  93486. * Wrapper class for promise with external resolve and reject.
  93487. */
  93488. var Deferred = /** @class */ (function () {
  93489. /**
  93490. * Constructor for this deferred object.
  93491. */
  93492. function Deferred() {
  93493. var _this = this;
  93494. this.promise = new Promise(function (resolve, reject) {
  93495. _this._resolve = resolve;
  93496. _this._reject = reject;
  93497. });
  93498. }
  93499. Object.defineProperty(Deferred.prototype, "resolve", {
  93500. /**
  93501. * The resolve method of the promise associated with this deferred object.
  93502. */
  93503. get: function () {
  93504. return this._resolve;
  93505. },
  93506. enumerable: true,
  93507. configurable: true
  93508. });
  93509. Object.defineProperty(Deferred.prototype, "reject", {
  93510. /**
  93511. * The reject method of the promise associated with this deferred object.
  93512. */
  93513. get: function () {
  93514. return this._reject;
  93515. },
  93516. enumerable: true,
  93517. configurable: true
  93518. });
  93519. return Deferred;
  93520. }());
  93521. /***/ }),
  93522. /***/ "./Misc/domManagement.ts":
  93523. /*!*******************************!*\
  93524. !*** ./Misc/domManagement.ts ***!
  93525. \*******************************/
  93526. /*! exports provided: DomManagement */
  93527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93528. "use strict";
  93529. __webpack_require__.r(__webpack_exports__);
  93530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  93531. /**
  93532. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  93533. * Babylon.js
  93534. */
  93535. var DomManagement = /** @class */ (function () {
  93536. function DomManagement() {
  93537. }
  93538. /**
  93539. * Checks if the window object exists
  93540. * @returns true if the window object exists
  93541. */
  93542. DomManagement.IsWindowObjectExist = function () {
  93543. return (typeof window) !== "undefined";
  93544. };
  93545. /**
  93546. * Extracts text content from a DOM element hierarchy
  93547. * @param element defines the root element
  93548. * @returns a string
  93549. */
  93550. DomManagement.GetDOMTextContent = function (element) {
  93551. var result = "";
  93552. var child = element.firstChild;
  93553. while (child) {
  93554. if (child.nodeType === 3) {
  93555. result += child.textContent;
  93556. }
  93557. child = (child.nextSibling);
  93558. }
  93559. return result;
  93560. };
  93561. return DomManagement;
  93562. }());
  93563. /***/ }),
  93564. /***/ "./Misc/environmentTextureTools.ts":
  93565. /*!*****************************************!*\
  93566. !*** ./Misc/environmentTextureTools.ts ***!
  93567. \*****************************************/
  93568. /*! exports provided: EnvironmentTextureTools */
  93569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93570. "use strict";
  93571. __webpack_require__.r(__webpack_exports__);
  93572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  93573. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93574. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93575. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93576. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93577. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  93578. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  93579. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93580. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93581. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  93582. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93583. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  93584. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  93585. /**
  93586. * Sets of helpers addressing the serialization and deserialization of environment texture
  93587. * stored in a BabylonJS env file.
  93588. * Those files are usually stored as .env files.
  93589. */
  93590. var EnvironmentTextureTools = /** @class */ (function () {
  93591. function EnvironmentTextureTools() {
  93592. }
  93593. /**
  93594. * Gets the environment info from an env file.
  93595. * @param data The array buffer containing the .env bytes.
  93596. * @returns the environment file info (the json header) if successfully parsed.
  93597. */
  93598. EnvironmentTextureTools.GetEnvInfo = function (data) {
  93599. var dataView = new DataView(data);
  93600. var pos = 0;
  93601. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93602. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  93603. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  93604. return null;
  93605. }
  93606. }
  93607. // Read json manifest - collect characters up to null terminator
  93608. var manifestString = '';
  93609. var charCode = 0x00;
  93610. while ((charCode = dataView.getUint8(pos++))) {
  93611. manifestString += String.fromCharCode(charCode);
  93612. }
  93613. var manifest = JSON.parse(manifestString);
  93614. if (manifest.specular) {
  93615. // Extend the header with the position of the payload.
  93616. manifest.specular.specularDataPosition = pos;
  93617. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  93618. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  93619. }
  93620. return manifest;
  93621. };
  93622. /**
  93623. * Creates an environment texture from a loaded cube texture.
  93624. * @param texture defines the cube texture to convert in env file
  93625. * @return a promise containing the environment data if succesfull.
  93626. */
  93627. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  93628. var _this = this;
  93629. var internalTexture = texture.getInternalTexture();
  93630. if (!internalTexture) {
  93631. return Promise.reject("The cube texture is invalid.");
  93632. }
  93633. if (!texture._prefiltered) {
  93634. return Promise.reject("The cube texture is invalid (not prefiltered).");
  93635. }
  93636. var engine = internalTexture.getEngine();
  93637. if (engine && engine.premultipliedAlpha) {
  93638. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  93639. }
  93640. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  93641. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  93642. }
  93643. var canvas = engine.getRenderingCanvas();
  93644. if (!canvas) {
  93645. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  93646. }
  93647. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  93648. if (!engine.getCaps().textureFloatRender) {
  93649. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93650. if (!engine.getCaps().textureHalfFloatRender) {
  93651. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  93652. }
  93653. }
  93654. var cubeWidth = internalTexture.width;
  93655. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  93656. var specularTextures = {};
  93657. var promises = [];
  93658. // Read and collect all mipmaps data from the cube.
  93659. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  93660. mipmapsCount = Math.round(mipmapsCount);
  93661. var _loop_1 = function (i) {
  93662. var faceWidth = Math.pow(2, mipmapsCount - i);
  93663. var _loop_2 = function (face) {
  93664. var data = texture.readPixels(face, i);
  93665. // Creates a temp texture with the face data.
  93666. 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);
  93667. // And rgbdEncode them.
  93668. var promise = new Promise(function (resolve, reject) {
  93669. 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);
  93670. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  93671. rgbdPostProcess.onApply = function (effect) {
  93672. effect._bindTexture("textureSampler", tempTexture);
  93673. };
  93674. // As the process needs to happen on the main canvas, keep track of the current size
  93675. var currentW = engine.getRenderWidth();
  93676. var currentH = engine.getRenderHeight();
  93677. // Set the desired size for the texture
  93678. engine.setSize(faceWidth, faceWidth);
  93679. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  93680. // Reading datas from WebGL
  93681. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  93682. var fileReader = new FileReader();
  93683. fileReader.onload = function (event) {
  93684. var arrayBuffer = event.target.result;
  93685. specularTextures[i * 6 + face] = arrayBuffer;
  93686. resolve();
  93687. };
  93688. fileReader.readAsArrayBuffer(blob);
  93689. });
  93690. // Reapply the previous canvas size
  93691. engine.setSize(currentW, currentH);
  93692. });
  93693. });
  93694. promises.push(promise);
  93695. };
  93696. // All faces of the cube.
  93697. for (var face = 0; face < 6; face++) {
  93698. _loop_2(face);
  93699. }
  93700. };
  93701. for (var i = 0; i <= mipmapsCount; i++) {
  93702. _loop_1(i);
  93703. }
  93704. // Once all the textures haves been collected as RGBD stored in PNGs
  93705. return Promise.all(promises).then(function () {
  93706. // We can delete the hosting scene keeping track of all the creation objects
  93707. hostingScene.dispose();
  93708. // Creates the json header for the env texture
  93709. var info = {
  93710. version: 1,
  93711. width: cubeWidth,
  93712. irradiance: _this._CreateEnvTextureIrradiance(texture),
  93713. specular: {
  93714. mipmaps: [],
  93715. lodGenerationScale: texture.lodGenerationScale
  93716. }
  93717. };
  93718. // Sets the specular image data information
  93719. var position = 0;
  93720. for (var i = 0; i <= mipmapsCount; i++) {
  93721. for (var face = 0; face < 6; face++) {
  93722. var byteLength = specularTextures[i * 6 + face].byteLength;
  93723. info.specular.mipmaps.push({
  93724. length: byteLength,
  93725. position: position
  93726. });
  93727. position += byteLength;
  93728. }
  93729. }
  93730. // Encode the JSON as an array buffer
  93731. var infoString = JSON.stringify(info);
  93732. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  93733. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  93734. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  93735. infoView[i] = infoString.charCodeAt(i);
  93736. }
  93737. // Ends up with a null terminator for easier parsing
  93738. infoView[infoString.length] = 0x00;
  93739. // Computes the final required size and creates the storage
  93740. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  93741. var finalBuffer = new ArrayBuffer(totalSize);
  93742. var finalBufferView = new Uint8Array(finalBuffer);
  93743. var dataView = new DataView(finalBuffer);
  93744. // Copy the magic bytes identifying the file in
  93745. var pos = 0;
  93746. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93747. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  93748. }
  93749. // Add the json info
  93750. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  93751. pos += infoBuffer.byteLength;
  93752. // Finally inserts the texture data
  93753. for (var i = 0; i <= mipmapsCount; i++) {
  93754. for (var face = 0; face < 6; face++) {
  93755. var dataBuffer = specularTextures[i * 6 + face];
  93756. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  93757. pos += dataBuffer.byteLength;
  93758. }
  93759. }
  93760. // Voila
  93761. return finalBuffer;
  93762. });
  93763. };
  93764. /**
  93765. * Creates a JSON representation of the spherical data.
  93766. * @param texture defines the texture containing the polynomials
  93767. * @return the JSON representation of the spherical info
  93768. */
  93769. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  93770. var polynmials = texture.sphericalPolynomial;
  93771. if (polynmials == null) {
  93772. return null;
  93773. }
  93774. return {
  93775. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  93776. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  93777. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  93778. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  93779. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  93780. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  93781. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  93782. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  93783. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  93784. };
  93785. };
  93786. /**
  93787. * Uploads the texture info contained in the env file to the GPU.
  93788. * @param texture defines the internal texture to upload to
  93789. * @param arrayBuffer defines the buffer cotaining the data to load
  93790. * @param info defines the texture info retrieved through the GetEnvInfo method
  93791. * @returns a promise
  93792. */
  93793. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  93794. if (info.version !== 1) {
  93795. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  93796. }
  93797. var specularInfo = info.specular;
  93798. if (!specularInfo) {
  93799. // Nothing else parsed so far
  93800. return Promise.resolve();
  93801. }
  93802. // Double checks the enclosed info
  93803. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  93804. mipmapsCount = Math.round(mipmapsCount) + 1;
  93805. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  93806. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  93807. }
  93808. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  93809. var imageData = new Array(mipmapsCount);
  93810. for (var i = 0; i < mipmapsCount; i++) {
  93811. imageData[i] = new Array(6);
  93812. for (var face = 0; face < 6; face++) {
  93813. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  93814. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  93815. }
  93816. }
  93817. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  93818. };
  93819. /**
  93820. * Uploads the levels of image data to the GPU.
  93821. * @param texture defines the internal texture to upload to
  93822. * @param imageData defines the array buffer views of image data [mipmap][face]
  93823. * @returns a promise
  93824. */
  93825. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  93826. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  93827. throw new Error("Texture size must be a power of two");
  93828. }
  93829. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  93830. // Gets everything ready.
  93831. var engine = texture.getEngine();
  93832. var expandTexture = false;
  93833. var generateNonLODTextures = false;
  93834. var rgbdPostProcess = null;
  93835. var cubeRtt = null;
  93836. var lodTextures = null;
  93837. var caps = engine.getCaps();
  93838. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  93839. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93840. texture.generateMipMaps = true;
  93841. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  93842. // Add extra process if texture lod is not supported
  93843. if (!caps.textureLOD) {
  93844. expandTexture = false;
  93845. generateNonLODTextures = true;
  93846. lodTextures = {};
  93847. }
  93848. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  93849. else if (engine.webGLVersion < 2) {
  93850. expandTexture = false;
  93851. }
  93852. // If half float available we can uncompress the texture
  93853. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  93854. expandTexture = true;
  93855. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93856. }
  93857. // If full float available we can uncompress the texture
  93858. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  93859. expandTexture = true;
  93860. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  93861. }
  93862. // Expand the texture if possible
  93863. if (expandTexture) {
  93864. // Simply run through the decode PP
  93865. 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);
  93866. texture._isRGBD = false;
  93867. texture.invertY = false;
  93868. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  93869. generateDepthBuffer: false,
  93870. generateMipMaps: true,
  93871. generateStencilBuffer: false,
  93872. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  93873. type: texture.type,
  93874. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  93875. });
  93876. }
  93877. else {
  93878. texture._isRGBD = true;
  93879. texture.invertY = true;
  93880. // In case of missing support, applies the same patch than DDS files.
  93881. if (generateNonLODTextures) {
  93882. var mipSlices = 3;
  93883. var scale = texture._lodGenerationScale;
  93884. var offset = texture._lodGenerationOffset;
  93885. for (var i = 0; i < mipSlices; i++) {
  93886. //compute LOD from even spacing in smoothness (matching shader calculation)
  93887. var smoothness = i / (mipSlices - 1);
  93888. var roughness = 1 - smoothness;
  93889. var minLODIndex = offset; // roughness = 0
  93890. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  93891. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93892. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93893. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93894. glTextureFromLod.isCube = true;
  93895. glTextureFromLod.invertY = true;
  93896. glTextureFromLod.generateMipMaps = false;
  93897. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  93898. // Wrap in a base texture for easy binding.
  93899. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  93900. lodTexture.isCube = true;
  93901. lodTexture._texture = glTextureFromLod;
  93902. lodTextures[mipmapIndex] = lodTexture;
  93903. switch (i) {
  93904. case 0:
  93905. texture._lodTextureLow = lodTexture;
  93906. break;
  93907. case 1:
  93908. texture._lodTextureMid = lodTexture;
  93909. break;
  93910. case 2:
  93911. texture._lodTextureHigh = lodTexture;
  93912. break;
  93913. }
  93914. }
  93915. }
  93916. }
  93917. var promises = [];
  93918. var _loop_3 = function (i) {
  93919. var _loop_4 = function (face) {
  93920. // Constructs an image element from image data
  93921. var bytes = imageData[i][face];
  93922. var blob = new Blob([bytes], { type: 'image/png' });
  93923. var url = URL.createObjectURL(blob);
  93924. var image = new Image();
  93925. image.src = url;
  93926. // Enqueue promise to upload to the texture.
  93927. var promise = new Promise(function (resolve, reject) {
  93928. image.onload = function () {
  93929. if (expandTexture) {
  93930. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  93931. reject(message);
  93932. }, image);
  93933. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  93934. // Uncompress the data to a RTT
  93935. rgbdPostProcess.onApply = function (effect) {
  93936. effect._bindTexture("textureSampler", tempTexture_1);
  93937. effect.setFloat2("scale", 1, 1);
  93938. };
  93939. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  93940. // Cleanup
  93941. engine.restoreDefaultFramebuffer();
  93942. tempTexture_1.dispose();
  93943. window.URL.revokeObjectURL(url);
  93944. resolve();
  93945. });
  93946. }
  93947. else {
  93948. engine._uploadImageToTexture(texture, image, face, i);
  93949. // Upload the face to the non lod texture support
  93950. if (generateNonLODTextures) {
  93951. var lodTexture = lodTextures[i];
  93952. if (lodTexture) {
  93953. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  93954. }
  93955. }
  93956. resolve();
  93957. }
  93958. };
  93959. image.onerror = function (error) {
  93960. reject(error);
  93961. };
  93962. });
  93963. promises.push(promise);
  93964. };
  93965. // All faces
  93966. for (var face = 0; face < 6; face++) {
  93967. _loop_4(face);
  93968. }
  93969. };
  93970. // All mipmaps up to provided number of images
  93971. for (var i = 0; i < imageData.length; i++) {
  93972. _loop_3(i);
  93973. }
  93974. // Fill remaining mipmaps with black textures.
  93975. if (imageData.length < mipmapsCount) {
  93976. var data = void 0;
  93977. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  93978. var dataLength = size * size * 4;
  93979. switch (texture.type) {
  93980. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  93981. data = new Uint8Array(dataLength);
  93982. break;
  93983. }
  93984. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  93985. data = new Uint16Array(dataLength);
  93986. break;
  93987. }
  93988. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  93989. data = new Float32Array(dataLength);
  93990. break;
  93991. }
  93992. }
  93993. for (var i = imageData.length; i < mipmapsCount; i++) {
  93994. for (var face = 0; face < 6; face++) {
  93995. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  93996. }
  93997. }
  93998. }
  93999. // Once all done, finishes the cleanup and return
  94000. return Promise.all(promises).then(function () {
  94001. // Release temp RTT.
  94002. if (cubeRtt) {
  94003. engine._releaseFramebufferObjects(cubeRtt);
  94004. cubeRtt._swapAndDie(texture);
  94005. }
  94006. // Release temp Post Process.
  94007. if (rgbdPostProcess) {
  94008. rgbdPostProcess.dispose();
  94009. }
  94010. // Flag internal texture as ready in case they are in use.
  94011. if (generateNonLODTextures) {
  94012. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  94013. texture._lodTextureHigh._texture.isReady = true;
  94014. }
  94015. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  94016. texture._lodTextureMid._texture.isReady = true;
  94017. }
  94018. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  94019. texture._lodTextureLow._texture.isReady = true;
  94020. }
  94021. }
  94022. });
  94023. };
  94024. /**
  94025. * Uploads spherical polynomials information to the texture.
  94026. * @param texture defines the texture we are trying to upload the information to
  94027. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  94028. */
  94029. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  94030. if (info.version !== 1) {
  94031. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  94032. }
  94033. var irradianceInfo = info.irradiance;
  94034. if (!irradianceInfo) {
  94035. return;
  94036. }
  94037. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  94038. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  94039. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  94040. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  94041. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  94042. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  94043. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  94044. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  94045. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  94046. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  94047. texture._sphericalPolynomial = sp;
  94048. };
  94049. /** @hidden */
  94050. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  94051. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  94052. internalTexture._bufferViewArrayArray = data;
  94053. internalTexture._lodGenerationScale = lodScale;
  94054. internalTexture._lodGenerationOffset = lodOffset;
  94055. internalTexture._sphericalPolynomial = sphericalPolynomial;
  94056. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  94057. internalTexture.isReady = true;
  94058. });
  94059. };
  94060. /**
  94061. * Magic number identifying the env file.
  94062. */
  94063. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  94064. return EnvironmentTextureTools;
  94065. }());
  94066. // References the dependencies.
  94067. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  94068. /***/ }),
  94069. /***/ "./Misc/filesInput.ts":
  94070. /*!****************************!*\
  94071. !*** ./Misc/filesInput.ts ***!
  94072. \****************************/
  94073. /*! exports provided: FilesInput */
  94074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94075. "use strict";
  94076. __webpack_require__.r(__webpack_exports__);
  94077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  94078. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94079. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94080. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94081. /**
  94082. * Class used to help managing file picking and drag'n'drop
  94083. */
  94084. var FilesInput = /** @class */ (function () {
  94085. /**
  94086. * Creates a new FilesInput
  94087. * @param engine defines the rendering engine
  94088. * @param scene defines the hosting scene
  94089. * @param sceneLoadedCallback callback called when scene is loaded
  94090. * @param progressCallback callback called to track progress
  94091. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  94092. * @param textureLoadingCallback callback called when a texture is loading
  94093. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  94094. * @param onReloadCallback callback called when a reload is requested
  94095. * @param errorCallback callback call if an error occurs
  94096. */
  94097. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  94098. /**
  94099. * Callback called when a file is processed
  94100. */
  94101. this.onProcessFileCallback = function () { return true; };
  94102. this._engine = engine;
  94103. this._currentScene = scene;
  94104. this._sceneLoadedCallback = sceneLoadedCallback;
  94105. this._progressCallback = progressCallback;
  94106. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  94107. this._textureLoadingCallback = textureLoadingCallback;
  94108. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  94109. this._onReloadCallback = onReloadCallback;
  94110. this._errorCallback = errorCallback;
  94111. }
  94112. Object.defineProperty(FilesInput, "FilesToLoad", {
  94113. /**
  94114. * List of files ready to be loaded
  94115. */
  94116. get: function () {
  94117. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  94118. },
  94119. enumerable: true,
  94120. configurable: true
  94121. });
  94122. /**
  94123. * Calls this function to listen to drag'n'drop events on a specific DOM element
  94124. * @param elementToMonitor defines the DOM element to track
  94125. */
  94126. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  94127. var _this = this;
  94128. if (elementToMonitor) {
  94129. this._elementToMonitor = elementToMonitor;
  94130. this._dragEnterHandler = function (e) { _this.drag(e); };
  94131. this._dragOverHandler = function (e) { _this.drag(e); };
  94132. this._dropHandler = function (e) { _this.drop(e); };
  94133. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  94134. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  94135. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  94136. }
  94137. };
  94138. /**
  94139. * Release all associated resources
  94140. */
  94141. FilesInput.prototype.dispose = function () {
  94142. if (!this._elementToMonitor) {
  94143. return;
  94144. }
  94145. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  94146. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  94147. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  94148. };
  94149. FilesInput.prototype.renderFunction = function () {
  94150. if (this._additionalRenderLoopLogicCallback) {
  94151. this._additionalRenderLoopLogicCallback();
  94152. }
  94153. if (this._currentScene) {
  94154. if (this._textureLoadingCallback) {
  94155. var remaining = this._currentScene.getWaitingItemsCount();
  94156. if (remaining > 0) {
  94157. this._textureLoadingCallback(remaining);
  94158. }
  94159. }
  94160. this._currentScene.render();
  94161. }
  94162. };
  94163. FilesInput.prototype.drag = function (e) {
  94164. e.stopPropagation();
  94165. e.preventDefault();
  94166. };
  94167. FilesInput.prototype.drop = function (eventDrop) {
  94168. eventDrop.stopPropagation();
  94169. eventDrop.preventDefault();
  94170. this.loadFiles(eventDrop);
  94171. };
  94172. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  94173. var _this = this;
  94174. var reader = folder.createReader();
  94175. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  94176. reader.readEntries(function (entries) {
  94177. remaining.count += entries.length;
  94178. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  94179. var entry = entries_1[_i];
  94180. if (entry.isFile) {
  94181. entry.file(function (file) {
  94182. file.correctName = relativePath + file.name;
  94183. files.push(file);
  94184. if (--remaining.count === 0) {
  94185. callback();
  94186. }
  94187. });
  94188. }
  94189. else if (entry.isDirectory) {
  94190. _this._traverseFolder(entry, files, remaining, callback);
  94191. }
  94192. }
  94193. if (--remaining.count) {
  94194. callback();
  94195. }
  94196. });
  94197. };
  94198. FilesInput.prototype._processFiles = function (files) {
  94199. for (var i = 0; i < files.length; i++) {
  94200. var name = files[i].correctName.toLowerCase();
  94201. var extension = name.split('.').pop();
  94202. if (!this.onProcessFileCallback(files[i], name, extension)) {
  94203. continue;
  94204. }
  94205. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  94206. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  94207. this._sceneFileToLoad = files[i];
  94208. }
  94209. FilesInput.FilesToLoad[name] = files[i];
  94210. }
  94211. };
  94212. /**
  94213. * Load files from a drop event
  94214. * @param event defines the drop event to use as source
  94215. */
  94216. FilesInput.prototype.loadFiles = function (event) {
  94217. var _this = this;
  94218. // Handling data transfer via drag'n'drop
  94219. if (event && event.dataTransfer && event.dataTransfer.files) {
  94220. this._filesToLoad = event.dataTransfer.files;
  94221. }
  94222. // Handling files from input files
  94223. if (event && event.target && event.target.files) {
  94224. this._filesToLoad = event.target.files;
  94225. }
  94226. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  94227. return;
  94228. }
  94229. if (this._startingProcessingFilesCallback) {
  94230. this._startingProcessingFilesCallback(this._filesToLoad);
  94231. }
  94232. if (this._filesToLoad && this._filesToLoad.length > 0) {
  94233. var files_1 = new Array();
  94234. var folders = [];
  94235. var items = event.dataTransfer ? event.dataTransfer.items : null;
  94236. for (var i = 0; i < this._filesToLoad.length; i++) {
  94237. var fileToLoad = this._filesToLoad[i];
  94238. var name_1 = fileToLoad.name.toLowerCase();
  94239. var entry = void 0;
  94240. fileToLoad.correctName = name_1;
  94241. if (items) {
  94242. var item = items[i];
  94243. if (item.getAsEntry) {
  94244. entry = item.getAsEntry();
  94245. }
  94246. else if (item.webkitGetAsEntry) {
  94247. entry = item.webkitGetAsEntry();
  94248. }
  94249. }
  94250. if (!entry) {
  94251. files_1.push(fileToLoad);
  94252. }
  94253. else {
  94254. if (entry.isDirectory) {
  94255. folders.push(entry);
  94256. }
  94257. else {
  94258. files_1.push(fileToLoad);
  94259. }
  94260. }
  94261. }
  94262. if (folders.length === 0) {
  94263. this._processFiles(files_1);
  94264. this._processReload();
  94265. }
  94266. else {
  94267. var remaining = { count: folders.length };
  94268. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  94269. var folder = folders_1[_i];
  94270. this._traverseFolder(folder, files_1, remaining, function () {
  94271. _this._processFiles(files_1);
  94272. if (remaining.count === 0) {
  94273. _this._processReload();
  94274. }
  94275. });
  94276. }
  94277. }
  94278. }
  94279. };
  94280. FilesInput.prototype._processReload = function () {
  94281. if (this._onReloadCallback) {
  94282. this._onReloadCallback(this._sceneFileToLoad);
  94283. }
  94284. else {
  94285. this.reload();
  94286. }
  94287. };
  94288. /**
  94289. * Reload the current scene from the loaded files
  94290. */
  94291. FilesInput.prototype.reload = function () {
  94292. var _this = this;
  94293. // If a scene file has been provided
  94294. if (this._sceneFileToLoad) {
  94295. if (this._currentScene) {
  94296. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  94297. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  94298. }
  94299. this._engine.stopRenderLoop();
  94300. }
  94301. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  94302. if (_this._progressCallback) {
  94303. _this._progressCallback(progress);
  94304. }
  94305. }).then(function (scene) {
  94306. if (_this._currentScene) {
  94307. _this._currentScene.dispose();
  94308. }
  94309. _this._currentScene = scene;
  94310. if (_this._sceneLoadedCallback) {
  94311. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  94312. }
  94313. // Wait for textures and shaders to be ready
  94314. _this._currentScene.executeWhenReady(function () {
  94315. _this._engine.runRenderLoop(function () {
  94316. _this.renderFunction();
  94317. });
  94318. });
  94319. }).catch(function (error) {
  94320. if (_this._errorCallback) {
  94321. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  94322. }
  94323. });
  94324. }
  94325. else {
  94326. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  94327. }
  94328. };
  94329. return FilesInput;
  94330. }());
  94331. /***/ }),
  94332. /***/ "./Misc/filesInputStore.ts":
  94333. /*!*********************************!*\
  94334. !*** ./Misc/filesInputStore.ts ***!
  94335. \*********************************/
  94336. /*! exports provided: FilesInputStore */
  94337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94338. "use strict";
  94339. __webpack_require__.r(__webpack_exports__);
  94340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  94341. /**
  94342. * Class used to help managing file picking and drag'n'drop
  94343. * File Storage
  94344. */
  94345. var FilesInputStore = /** @class */ (function () {
  94346. function FilesInputStore() {
  94347. }
  94348. /**
  94349. * List of files ready to be loaded
  94350. */
  94351. FilesInputStore.FilesToLoad = {};
  94352. return FilesInputStore;
  94353. }());
  94354. /***/ }),
  94355. /***/ "./Misc/index.ts":
  94356. /*!***********************!*\
  94357. !*** ./Misc/index.ts ***!
  94358. \***********************/
  94359. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, 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, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  94360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94361. "use strict";
  94362. __webpack_require__.r(__webpack_exports__);
  94363. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  94364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  94365. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  94366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  94367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  94368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  94369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  94370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  94371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  94372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  94373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  94374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  94375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  94376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  94377. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  94378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  94379. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  94380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  94381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  94382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  94383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  94384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  94385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  94386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  94387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  94388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  94389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  94390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  94391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  94392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  94393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  94394. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  94395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  94396. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  94397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  94398. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  94399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  94400. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  94401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  94402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  94403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  94404. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  94405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  94406. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  94408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  94409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  94410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  94411. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  94412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  94413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  94414. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  94415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  94416. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  94417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  94418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  94419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  94420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  94421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  94422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  94423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  94424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  94425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  94426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  94427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  94428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  94429. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  94430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  94431. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  94432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  94433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  94434. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  94435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  94436. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  94437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  94438. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  94439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  94440. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  94441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  94442. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  94444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  94445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  94446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  94447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  94448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  94449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  94450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  94451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  94452. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  94453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  94454. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  94455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  94456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  94457. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  94458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  94459. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  94460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  94461. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  94462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  94463. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  94465. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  94466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  94467. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  94468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  94469. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  94471. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  94472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  94473. /* empty/unused harmony star reexport */
  94474. /***/ }),
  94475. /***/ "./Misc/khronosTextureContainer.ts":
  94476. /*!*****************************************!*\
  94477. !*** ./Misc/khronosTextureContainer.ts ***!
  94478. \*****************************************/
  94479. /*! exports provided: KhronosTextureContainer */
  94480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94481. "use strict";
  94482. __webpack_require__.r(__webpack_exports__);
  94483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  94484. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94485. /**
  94486. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94487. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94488. */
  94489. var KhronosTextureContainer = /** @class */ (function () {
  94490. /**
  94491. * Creates a new KhronosTextureContainer
  94492. * @param arrayBuffer contents of the KTX container file
  94493. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  94494. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  94495. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  94496. */
  94497. function KhronosTextureContainer(
  94498. /** contents of the KTX container file */
  94499. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  94500. this.arrayBuffer = arrayBuffer;
  94501. /**
  94502. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  94503. */
  94504. this.isInvalid = false;
  94505. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  94506. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  94507. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  94508. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  94509. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  94510. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  94511. this.isInvalid = true;
  94512. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  94513. return;
  94514. }
  94515. // load the reset of the header in native 32 bit uint
  94516. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  94517. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  94518. var endianness = headerDataView.getUint32(0, true);
  94519. var littleEndian = endianness === 0x04030201;
  94520. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  94521. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  94522. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  94523. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  94524. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  94525. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  94526. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  94527. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  94528. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  94529. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  94530. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  94531. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  94532. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  94533. if (this.glType !== 0) {
  94534. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  94535. return;
  94536. }
  94537. else {
  94538. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  94539. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  94540. }
  94541. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  94542. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  94543. return;
  94544. }
  94545. if (this.numberOfArrayElements !== 0) {
  94546. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  94547. return;
  94548. }
  94549. if (this.numberOfFaces !== facesExpected) {
  94550. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  94551. return;
  94552. }
  94553. // we now have a completely validated file, so could use existence of loadType as success
  94554. // would need to make this more elaborate & adjust checks above to support more than one load type
  94555. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  94556. }
  94557. /**
  94558. * Uploads KTX content to a Babylon Texture.
  94559. * It is assumed that the texture has already been created & is currently bound
  94560. * @hidden
  94561. */
  94562. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  94563. switch (this.loadType) {
  94564. case KhronosTextureContainer.COMPRESSED_2D:
  94565. this._upload2DCompressedLevels(texture, loadMipmaps);
  94566. break;
  94567. case KhronosTextureContainer.TEX_2D:
  94568. case KhronosTextureContainer.COMPRESSED_3D:
  94569. case KhronosTextureContainer.TEX_3D:
  94570. }
  94571. };
  94572. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  94573. // initialize width & height for level 1
  94574. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  94575. var width = this.pixelWidth;
  94576. var height = this.pixelHeight;
  94577. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  94578. for (var level = 0; level < mipmapCount; level++) {
  94579. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  94580. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  94581. for (var face = 0; face < this.numberOfFaces; face++) {
  94582. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  94583. var engine = texture.getEngine();
  94584. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  94585. dataOffset += imageSize; // add size of the image for the next face/mipmap
  94586. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  94587. }
  94588. width = Math.max(1.0, width * 0.5);
  94589. height = Math.max(1.0, height * 0.5);
  94590. }
  94591. };
  94592. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  94593. // load types
  94594. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  94595. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  94596. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  94597. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  94598. return KhronosTextureContainer;
  94599. }());
  94600. /***/ }),
  94601. /***/ "./Misc/logger.ts":
  94602. /*!************************!*\
  94603. !*** ./Misc/logger.ts ***!
  94604. \************************/
  94605. /*! exports provided: Logger */
  94606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94607. "use strict";
  94608. __webpack_require__.r(__webpack_exports__);
  94609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  94610. /**
  94611. * Logger used througouht the application to allow configuration of
  94612. * the log level required for the messages.
  94613. */
  94614. var Logger = /** @class */ (function () {
  94615. function Logger() {
  94616. }
  94617. Logger._AddLogEntry = function (entry) {
  94618. Logger._LogCache = entry + Logger._LogCache;
  94619. if (Logger.OnNewCacheEntry) {
  94620. Logger.OnNewCacheEntry(entry);
  94621. }
  94622. };
  94623. Logger._FormatMessage = function (message) {
  94624. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  94625. var date = new Date();
  94626. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  94627. };
  94628. Logger._LogDisabled = function (message) {
  94629. // nothing to do
  94630. };
  94631. Logger._LogEnabled = function (message) {
  94632. var formattedMessage = Logger._FormatMessage(message);
  94633. console.log("BJS - " + formattedMessage);
  94634. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  94635. Logger._AddLogEntry(entry);
  94636. };
  94637. Logger._WarnDisabled = function (message) {
  94638. // nothing to do
  94639. };
  94640. Logger._WarnEnabled = function (message) {
  94641. var formattedMessage = Logger._FormatMessage(message);
  94642. console.warn("BJS - " + formattedMessage);
  94643. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  94644. Logger._AddLogEntry(entry);
  94645. };
  94646. Logger._ErrorDisabled = function (message) {
  94647. // nothing to do
  94648. };
  94649. Logger._ErrorEnabled = function (message) {
  94650. Logger.errorsCount++;
  94651. var formattedMessage = Logger._FormatMessage(message);
  94652. console.error("BJS - " + formattedMessage);
  94653. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  94654. Logger._AddLogEntry(entry);
  94655. };
  94656. Object.defineProperty(Logger, "LogCache", {
  94657. /**
  94658. * Gets current log cache (list of logs)
  94659. */
  94660. get: function () {
  94661. return Logger._LogCache;
  94662. },
  94663. enumerable: true,
  94664. configurable: true
  94665. });
  94666. /**
  94667. * Clears the log cache
  94668. */
  94669. Logger.ClearLogCache = function () {
  94670. Logger._LogCache = "";
  94671. Logger.errorsCount = 0;
  94672. };
  94673. Object.defineProperty(Logger, "LogLevels", {
  94674. /**
  94675. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94676. */
  94677. set: function (level) {
  94678. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  94679. Logger.Log = Logger._LogEnabled;
  94680. }
  94681. else {
  94682. Logger.Log = Logger._LogDisabled;
  94683. }
  94684. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  94685. Logger.Warn = Logger._WarnEnabled;
  94686. }
  94687. else {
  94688. Logger.Warn = Logger._WarnDisabled;
  94689. }
  94690. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  94691. Logger.Error = Logger._ErrorEnabled;
  94692. }
  94693. else {
  94694. Logger.Error = Logger._ErrorDisabled;
  94695. }
  94696. },
  94697. enumerable: true,
  94698. configurable: true
  94699. });
  94700. /**
  94701. * No log
  94702. */
  94703. Logger.NoneLogLevel = 0;
  94704. /**
  94705. * Only message logs
  94706. */
  94707. Logger.MessageLogLevel = 1;
  94708. /**
  94709. * Only warning logs
  94710. */
  94711. Logger.WarningLogLevel = 2;
  94712. /**
  94713. * Only error logs
  94714. */
  94715. Logger.ErrorLogLevel = 4;
  94716. /**
  94717. * All logs
  94718. */
  94719. Logger.AllLogLevel = 7;
  94720. Logger._LogCache = "";
  94721. /**
  94722. * Gets a value indicating the number of loading errors
  94723. * @ignorenaming
  94724. */
  94725. Logger.errorsCount = 0;
  94726. /**
  94727. * Log a message to the console
  94728. */
  94729. Logger.Log = Logger._LogEnabled;
  94730. /**
  94731. * Write a warning message to the console
  94732. */
  94733. Logger.Warn = Logger._WarnEnabled;
  94734. /**
  94735. * Write an error message to the console
  94736. */
  94737. Logger.Error = Logger._ErrorEnabled;
  94738. return Logger;
  94739. }());
  94740. /***/ }),
  94741. /***/ "./Misc/observable.ts":
  94742. /*!****************************!*\
  94743. !*** ./Misc/observable.ts ***!
  94744. \****************************/
  94745. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  94746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94747. "use strict";
  94748. __webpack_require__.r(__webpack_exports__);
  94749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  94750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  94751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  94752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  94753. /**
  94754. * A class serves as a medium between the observable and its observers
  94755. */
  94756. var EventState = /** @class */ (function () {
  94757. /**
  94758. * Create a new EventState
  94759. * @param mask defines the mask associated with this state
  94760. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  94761. * @param target defines the original target of the state
  94762. * @param currentTarget defines the current target of the state
  94763. */
  94764. function EventState(mask, skipNextObservers, target, currentTarget) {
  94765. if (skipNextObservers === void 0) { skipNextObservers = false; }
  94766. this.initalize(mask, skipNextObservers, target, currentTarget);
  94767. }
  94768. /**
  94769. * Initialize the current event state
  94770. * @param mask defines the mask associated with this state
  94771. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  94772. * @param target defines the original target of the state
  94773. * @param currentTarget defines the current target of the state
  94774. * @returns the current event state
  94775. */
  94776. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  94777. if (skipNextObservers === void 0) { skipNextObservers = false; }
  94778. this.mask = mask;
  94779. this.skipNextObservers = skipNextObservers;
  94780. this.target = target;
  94781. this.currentTarget = currentTarget;
  94782. return this;
  94783. };
  94784. return EventState;
  94785. }());
  94786. /**
  94787. * Represent an Observer registered to a given Observable object.
  94788. */
  94789. var Observer = /** @class */ (function () {
  94790. /**
  94791. * Creates a new observer
  94792. * @param callback defines the callback to call when the observer is notified
  94793. * @param mask defines the mask of the observer (used to filter notifications)
  94794. * @param scope defines the current scope used to restore the JS context
  94795. */
  94796. function Observer(
  94797. /**
  94798. * Defines the callback to call when the observer is notified
  94799. */
  94800. callback,
  94801. /**
  94802. * Defines the mask of the observer (used to filter notifications)
  94803. */
  94804. mask,
  94805. /**
  94806. * Defines the current scope used to restore the JS context
  94807. */
  94808. scope) {
  94809. if (scope === void 0) { scope = null; }
  94810. this.callback = callback;
  94811. this.mask = mask;
  94812. this.scope = scope;
  94813. /** @hidden */
  94814. this._willBeUnregistered = false;
  94815. /**
  94816. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  94817. */
  94818. this.unregisterOnNextCall = false;
  94819. }
  94820. return Observer;
  94821. }());
  94822. /**
  94823. * Represent a list of observers registered to multiple Observables object.
  94824. */
  94825. var MultiObserver = /** @class */ (function () {
  94826. function MultiObserver() {
  94827. }
  94828. /**
  94829. * Release associated resources
  94830. */
  94831. MultiObserver.prototype.dispose = function () {
  94832. if (this._observers && this._observables) {
  94833. for (var index = 0; index < this._observers.length; index++) {
  94834. this._observables[index].remove(this._observers[index]);
  94835. }
  94836. }
  94837. this._observers = null;
  94838. this._observables = null;
  94839. };
  94840. /**
  94841. * Raise a callback when one of the observable will notify
  94842. * @param observables defines a list of observables to watch
  94843. * @param callback defines the callback to call on notification
  94844. * @param mask defines the mask used to filter notifications
  94845. * @param scope defines the current scope used to restore the JS context
  94846. * @returns the new MultiObserver
  94847. */
  94848. MultiObserver.Watch = function (observables, callback, mask, scope) {
  94849. if (mask === void 0) { mask = -1; }
  94850. if (scope === void 0) { scope = null; }
  94851. var result = new MultiObserver();
  94852. result._observers = new Array();
  94853. result._observables = observables;
  94854. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  94855. var observable = observables_1[_i];
  94856. var observer = observable.add(callback, mask, false, scope);
  94857. if (observer) {
  94858. result._observers.push(observer);
  94859. }
  94860. }
  94861. return result;
  94862. };
  94863. return MultiObserver;
  94864. }());
  94865. /**
  94866. * The Observable class is a simple implementation of the Observable pattern.
  94867. *
  94868. * 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.
  94869. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  94870. * 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).
  94871. * 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.
  94872. */
  94873. var Observable = /** @class */ (function () {
  94874. /**
  94875. * Creates a new observable
  94876. * @param onObserverAdded defines a callback to call when a new observer is added
  94877. */
  94878. function Observable(onObserverAdded) {
  94879. this._observers = new Array();
  94880. this._eventState = new EventState(0);
  94881. if (onObserverAdded) {
  94882. this._onObserverAdded = onObserverAdded;
  94883. }
  94884. }
  94885. /**
  94886. * Create a new Observer with the specified callback
  94887. * @param callback the callback that will be executed for that Observer
  94888. * @param mask the mask used to filter observers
  94889. * @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.
  94890. * @param scope optional scope for the callback to be called from
  94891. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  94892. * @returns the new observer created for the callback
  94893. */
  94894. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  94895. if (mask === void 0) { mask = -1; }
  94896. if (insertFirst === void 0) { insertFirst = false; }
  94897. if (scope === void 0) { scope = null; }
  94898. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  94899. if (!callback) {
  94900. return null;
  94901. }
  94902. var observer = new Observer(callback, mask, scope);
  94903. observer.unregisterOnNextCall = unregisterOnFirstCall;
  94904. if (insertFirst) {
  94905. this._observers.unshift(observer);
  94906. }
  94907. else {
  94908. this._observers.push(observer);
  94909. }
  94910. if (this._onObserverAdded) {
  94911. this._onObserverAdded(observer);
  94912. }
  94913. return observer;
  94914. };
  94915. /**
  94916. * Create a new Observer with the specified callback and unregisters after the next notification
  94917. * @param callback the callback that will be executed for that Observer
  94918. * @returns the new observer created for the callback
  94919. */
  94920. Observable.prototype.addOnce = function (callback) {
  94921. return this.add(callback, undefined, undefined, undefined, true);
  94922. };
  94923. /**
  94924. * Remove an Observer from the Observable object
  94925. * @param observer the instance of the Observer to remove
  94926. * @returns false if it doesn't belong to this Observable
  94927. */
  94928. Observable.prototype.remove = function (observer) {
  94929. if (!observer) {
  94930. return false;
  94931. }
  94932. var index = this._observers.indexOf(observer);
  94933. if (index !== -1) {
  94934. this._deferUnregister(observer);
  94935. return true;
  94936. }
  94937. return false;
  94938. };
  94939. /**
  94940. * Remove a callback from the Observable object
  94941. * @param callback the callback to remove
  94942. * @param scope optional scope. If used only the callbacks with this scope will be removed
  94943. * @returns false if it doesn't belong to this Observable
  94944. */
  94945. Observable.prototype.removeCallback = function (callback, scope) {
  94946. for (var index = 0; index < this._observers.length; index++) {
  94947. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  94948. this._deferUnregister(this._observers[index]);
  94949. return true;
  94950. }
  94951. }
  94952. return false;
  94953. };
  94954. Observable.prototype._deferUnregister = function (observer) {
  94955. var _this = this;
  94956. observer.unregisterOnNextCall = false;
  94957. observer._willBeUnregistered = true;
  94958. setTimeout(function () {
  94959. _this._remove(observer);
  94960. }, 0);
  94961. };
  94962. // This should only be called when not iterating over _observers to avoid callback skipping.
  94963. // Removes an observer from the _observer Array.
  94964. Observable.prototype._remove = function (observer) {
  94965. if (!observer) {
  94966. return false;
  94967. }
  94968. var index = this._observers.indexOf(observer);
  94969. if (index !== -1) {
  94970. this._observers.splice(index, 1);
  94971. return true;
  94972. }
  94973. return false;
  94974. };
  94975. /**
  94976. * Notify all Observers by calling their respective callback with the given data
  94977. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  94978. * @param eventData defines the data to send to all observers
  94979. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  94980. * @param target defines the original target of the state
  94981. * @param currentTarget defines the current target of the state
  94982. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  94983. */
  94984. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  94985. if (mask === void 0) { mask = -1; }
  94986. if (!this._observers.length) {
  94987. return true;
  94988. }
  94989. var state = this._eventState;
  94990. state.mask = mask;
  94991. state.target = target;
  94992. state.currentTarget = currentTarget;
  94993. state.skipNextObservers = false;
  94994. state.lastReturnValue = eventData;
  94995. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94996. var obs = _a[_i];
  94997. if (obs._willBeUnregistered) {
  94998. continue;
  94999. }
  95000. if (obs.mask & mask) {
  95001. if (obs.scope) {
  95002. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  95003. }
  95004. else {
  95005. state.lastReturnValue = obs.callback(eventData, state);
  95006. }
  95007. if (obs.unregisterOnNextCall) {
  95008. this._deferUnregister(obs);
  95009. }
  95010. }
  95011. if (state.skipNextObservers) {
  95012. return false;
  95013. }
  95014. }
  95015. return true;
  95016. };
  95017. /**
  95018. * Calling this will execute each callback, expecting it to be a promise or return a value.
  95019. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  95020. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  95021. * and it is crucial that all callbacks will be executed.
  95022. * The order of the callbacks is kept, callbacks are not executed parallel.
  95023. *
  95024. * @param eventData The data to be sent to each callback
  95025. * @param mask is used to filter observers defaults to -1
  95026. * @param target defines the callback target (see EventState)
  95027. * @param currentTarget defines he current object in the bubbling phase
  95028. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  95029. */
  95030. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  95031. var _this = this;
  95032. if (mask === void 0) { mask = -1; }
  95033. // create an empty promise
  95034. var p = Promise.resolve(eventData);
  95035. // no observers? return this promise.
  95036. if (!this._observers.length) {
  95037. return p;
  95038. }
  95039. var state = this._eventState;
  95040. state.mask = mask;
  95041. state.target = target;
  95042. state.currentTarget = currentTarget;
  95043. state.skipNextObservers = false;
  95044. // execute one callback after another (not using Promise.all, the order is important)
  95045. this._observers.forEach(function (obs) {
  95046. if (state.skipNextObservers) {
  95047. return;
  95048. }
  95049. if (obs._willBeUnregistered) {
  95050. return;
  95051. }
  95052. if (obs.mask & mask) {
  95053. if (obs.scope) {
  95054. p = p.then(function (lastReturnedValue) {
  95055. state.lastReturnValue = lastReturnedValue;
  95056. return obs.callback.apply(obs.scope, [eventData, state]);
  95057. });
  95058. }
  95059. else {
  95060. p = p.then(function (lastReturnedValue) {
  95061. state.lastReturnValue = lastReturnedValue;
  95062. return obs.callback(eventData, state);
  95063. });
  95064. }
  95065. if (obs.unregisterOnNextCall) {
  95066. _this._deferUnregister(obs);
  95067. }
  95068. }
  95069. });
  95070. // return the eventData
  95071. return p.then(function () { return eventData; });
  95072. };
  95073. /**
  95074. * Notify a specific observer
  95075. * @param observer defines the observer to notify
  95076. * @param eventData defines the data to be sent to each callback
  95077. * @param mask is used to filter observers defaults to -1
  95078. */
  95079. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  95080. if (mask === void 0) { mask = -1; }
  95081. var state = this._eventState;
  95082. state.mask = mask;
  95083. state.skipNextObservers = false;
  95084. observer.callback(eventData, state);
  95085. };
  95086. /**
  95087. * Gets a boolean indicating if the observable has at least one observer
  95088. * @returns true is the Observable has at least one Observer registered
  95089. */
  95090. Observable.prototype.hasObservers = function () {
  95091. return this._observers.length > 0;
  95092. };
  95093. /**
  95094. * Clear the list of observers
  95095. */
  95096. Observable.prototype.clear = function () {
  95097. this._observers = new Array();
  95098. this._onObserverAdded = null;
  95099. };
  95100. /**
  95101. * Clone the current observable
  95102. * @returns a new observable
  95103. */
  95104. Observable.prototype.clone = function () {
  95105. var result = new Observable();
  95106. result._observers = this._observers.slice(0);
  95107. return result;
  95108. };
  95109. /**
  95110. * Does this observable handles observer registered with a given mask
  95111. * @param mask defines the mask to be tested
  95112. * @return whether or not one observer registered with the given mask is handeled
  95113. **/
  95114. Observable.prototype.hasSpecificMask = function (mask) {
  95115. if (mask === void 0) { mask = -1; }
  95116. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95117. var obs = _a[_i];
  95118. if (obs.mask & mask || obs.mask === mask) {
  95119. return true;
  95120. }
  95121. }
  95122. return false;
  95123. };
  95124. return Observable;
  95125. }());
  95126. /***/ }),
  95127. /***/ "./Misc/performanceMonitor.ts":
  95128. /*!************************************!*\
  95129. !*** ./Misc/performanceMonitor.ts ***!
  95130. \************************************/
  95131. /*! exports provided: PerformanceMonitor, RollingAverage */
  95132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95133. "use strict";
  95134. __webpack_require__.r(__webpack_exports__);
  95135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  95136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  95137. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  95138. /**
  95139. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  95140. */
  95141. var PerformanceMonitor = /** @class */ (function () {
  95142. /**
  95143. * constructor
  95144. * @param frameSampleSize The number of samples required to saturate the sliding window
  95145. */
  95146. function PerformanceMonitor(frameSampleSize) {
  95147. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  95148. this._enabled = true;
  95149. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  95150. }
  95151. /**
  95152. * Samples current frame
  95153. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  95154. */
  95155. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  95156. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  95157. if (!this._enabled) {
  95158. return;
  95159. }
  95160. if (this._lastFrameTimeMs != null) {
  95161. var dt = timeMs - this._lastFrameTimeMs;
  95162. this._rollingFrameTime.add(dt);
  95163. }
  95164. this._lastFrameTimeMs = timeMs;
  95165. };
  95166. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  95167. /**
  95168. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95169. */
  95170. get: function () {
  95171. return this._rollingFrameTime.average;
  95172. },
  95173. enumerable: true,
  95174. configurable: true
  95175. });
  95176. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  95177. /**
  95178. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95179. */
  95180. get: function () {
  95181. return this._rollingFrameTime.variance;
  95182. },
  95183. enumerable: true,
  95184. configurable: true
  95185. });
  95186. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  95187. /**
  95188. * Returns the frame time of the most recent frame
  95189. */
  95190. get: function () {
  95191. return this._rollingFrameTime.history(0);
  95192. },
  95193. enumerable: true,
  95194. configurable: true
  95195. });
  95196. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  95197. /**
  95198. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  95199. */
  95200. get: function () {
  95201. return 1000.0 / this._rollingFrameTime.average;
  95202. },
  95203. enumerable: true,
  95204. configurable: true
  95205. });
  95206. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  95207. /**
  95208. * Returns the average framerate in frames per second using the most recent frame time
  95209. */
  95210. get: function () {
  95211. var history = this._rollingFrameTime.history(0);
  95212. if (history === 0) {
  95213. return 0;
  95214. }
  95215. return 1000.0 / history;
  95216. },
  95217. enumerable: true,
  95218. configurable: true
  95219. });
  95220. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  95221. /**
  95222. * Returns true if enough samples have been taken to completely fill the sliding window
  95223. */
  95224. get: function () {
  95225. return this._rollingFrameTime.isSaturated();
  95226. },
  95227. enumerable: true,
  95228. configurable: true
  95229. });
  95230. /**
  95231. * Enables contributions to the sliding window sample set
  95232. */
  95233. PerformanceMonitor.prototype.enable = function () {
  95234. this._enabled = true;
  95235. };
  95236. /**
  95237. * Disables contributions to the sliding window sample set
  95238. * Samples will not be interpolated over the disabled period
  95239. */
  95240. PerformanceMonitor.prototype.disable = function () {
  95241. this._enabled = false;
  95242. //clear last sample to avoid interpolating over the disabled period when next enabled
  95243. this._lastFrameTimeMs = null;
  95244. };
  95245. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  95246. /**
  95247. * Returns true if sampling is enabled
  95248. */
  95249. get: function () {
  95250. return this._enabled;
  95251. },
  95252. enumerable: true,
  95253. configurable: true
  95254. });
  95255. /**
  95256. * Resets performance monitor
  95257. */
  95258. PerformanceMonitor.prototype.reset = function () {
  95259. //clear last sample to avoid interpolating over the disabled period when next enabled
  95260. this._lastFrameTimeMs = null;
  95261. //wipe record
  95262. this._rollingFrameTime.reset();
  95263. };
  95264. return PerformanceMonitor;
  95265. }());
  95266. /**
  95267. * RollingAverage
  95268. *
  95269. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  95270. */
  95271. var RollingAverage = /** @class */ (function () {
  95272. /**
  95273. * constructor
  95274. * @param length The number of samples required to saturate the sliding window
  95275. */
  95276. function RollingAverage(length) {
  95277. this._samples = new Array(length);
  95278. this.reset();
  95279. }
  95280. /**
  95281. * Adds a sample to the sample set
  95282. * @param v The sample value
  95283. */
  95284. RollingAverage.prototype.add = function (v) {
  95285. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  95286. var delta;
  95287. //we need to check if we've already wrapped round
  95288. if (this.isSaturated()) {
  95289. //remove bottom of stack from mean
  95290. var bottomValue = this._samples[this._pos];
  95291. delta = bottomValue - this.average;
  95292. this.average -= delta / (this._sampleCount - 1);
  95293. this._m2 -= delta * (bottomValue - this.average);
  95294. }
  95295. else {
  95296. this._sampleCount++;
  95297. }
  95298. //add new value to mean
  95299. delta = v - this.average;
  95300. this.average += delta / (this._sampleCount);
  95301. this._m2 += delta * (v - this.average);
  95302. //set the new variance
  95303. this.variance = this._m2 / (this._sampleCount - 1);
  95304. this._samples[this._pos] = v;
  95305. this._pos++;
  95306. this._pos %= this._samples.length; //positive wrap around
  95307. };
  95308. /**
  95309. * Returns previously added values or null if outside of history or outside the sliding window domain
  95310. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  95311. * @return Value previously recorded with add() or null if outside of range
  95312. */
  95313. RollingAverage.prototype.history = function (i) {
  95314. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  95315. return 0;
  95316. }
  95317. var i0 = this._wrapPosition(this._pos - 1.0);
  95318. return this._samples[this._wrapPosition(i0 - i)];
  95319. };
  95320. /**
  95321. * Returns true if enough samples have been taken to completely fill the sliding window
  95322. * @return true if sample-set saturated
  95323. */
  95324. RollingAverage.prototype.isSaturated = function () {
  95325. return this._sampleCount >= this._samples.length;
  95326. };
  95327. /**
  95328. * Resets the rolling average (equivalent to 0 samples taken so far)
  95329. */
  95330. RollingAverage.prototype.reset = function () {
  95331. this.average = 0;
  95332. this.variance = 0;
  95333. this._sampleCount = 0;
  95334. this._pos = 0;
  95335. this._m2 = 0;
  95336. };
  95337. /**
  95338. * Wraps a value around the sample range boundaries
  95339. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  95340. * @return Wrapped position in sample range
  95341. */
  95342. RollingAverage.prototype._wrapPosition = function (i) {
  95343. var max = this._samples.length;
  95344. return ((i % max) + max) % max;
  95345. };
  95346. return RollingAverage;
  95347. }());
  95348. /***/ }),
  95349. /***/ "./Misc/pivotTools.ts":
  95350. /*!****************************!*\
  95351. !*** ./Misc/pivotTools.ts ***!
  95352. \****************************/
  95353. /*! exports provided: PivotTools */
  95354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95355. "use strict";
  95356. __webpack_require__.r(__webpack_exports__);
  95357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  95358. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95359. /**
  95360. * Class containing a set of static utilities functions for managing Pivots
  95361. * @hidden
  95362. */
  95363. var PivotTools = /** @class */ (function () {
  95364. function PivotTools() {
  95365. }
  95366. /** @hidden */
  95367. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  95368. if (mesh && PivotTools._PivotCached === 0) {
  95369. // Save old pivot and set pivot to 0,0,0
  95370. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  95371. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  95372. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  95373. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  95374. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95375. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95376. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95377. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  95378. }
  95379. }
  95380. PivotTools._PivotCached++;
  95381. };
  95382. /** @hidden */
  95383. PivotTools._RestorePivotPoint = function (mesh) {
  95384. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  95385. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  95386. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95387. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95388. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95389. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  95390. }
  95391. this._PivotCached--;
  95392. };
  95393. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  95394. // store/remove pivot point should only be applied during their outermost calls
  95395. PivotTools._PivotCached = 0;
  95396. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95397. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95398. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95399. return PivotTools;
  95400. }());
  95401. /***/ }),
  95402. /***/ "./Misc/precisionDate.ts":
  95403. /*!*******************************!*\
  95404. !*** ./Misc/precisionDate.ts ***!
  95405. \*******************************/
  95406. /*! exports provided: PrecisionDate */
  95407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95408. "use strict";
  95409. __webpack_require__.r(__webpack_exports__);
  95410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  95411. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  95412. /**
  95413. * Class containing a set of static utilities functions for precision date
  95414. */
  95415. var PrecisionDate = /** @class */ (function () {
  95416. function PrecisionDate() {
  95417. }
  95418. Object.defineProperty(PrecisionDate, "Now", {
  95419. /**
  95420. * Gets either window.performance.now() if supported or Date.now() else
  95421. */
  95422. get: function () {
  95423. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  95424. return window.performance.now();
  95425. }
  95426. return Date.now();
  95427. },
  95428. enumerable: true,
  95429. configurable: true
  95430. });
  95431. return PrecisionDate;
  95432. }());
  95433. /***/ }),
  95434. /***/ "./Misc/promise.ts":
  95435. /*!*************************!*\
  95436. !*** ./Misc/promise.ts ***!
  95437. \*************************/
  95438. /*! exports provided: PromisePolyfill */
  95439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95440. "use strict";
  95441. __webpack_require__.r(__webpack_exports__);
  95442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  95443. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95444. var PromiseStates;
  95445. (function (PromiseStates) {
  95446. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  95447. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  95448. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  95449. })(PromiseStates || (PromiseStates = {}));
  95450. var FulFillmentAgregator = /** @class */ (function () {
  95451. function FulFillmentAgregator() {
  95452. this.count = 0;
  95453. this.target = 0;
  95454. this.results = [];
  95455. }
  95456. return FulFillmentAgregator;
  95457. }());
  95458. var InternalPromise = /** @class */ (function () {
  95459. function InternalPromise(resolver) {
  95460. var _this = this;
  95461. this._state = PromiseStates.Pending;
  95462. this._children = new Array();
  95463. this._rejectWasConsumed = false;
  95464. if (!resolver) {
  95465. return;
  95466. }
  95467. try {
  95468. resolver(function (value) {
  95469. _this._resolve(value);
  95470. }, function (reason) {
  95471. _this._reject(reason);
  95472. });
  95473. }
  95474. catch (e) {
  95475. this._reject(e);
  95476. }
  95477. }
  95478. Object.defineProperty(InternalPromise.prototype, "_result", {
  95479. get: function () {
  95480. return this._resultValue;
  95481. },
  95482. set: function (value) {
  95483. this._resultValue = value;
  95484. if (this._parent && this._parent._result === undefined) {
  95485. this._parent._result = value;
  95486. }
  95487. },
  95488. enumerable: true,
  95489. configurable: true
  95490. });
  95491. InternalPromise.prototype.catch = function (onRejected) {
  95492. return this.then(undefined, onRejected);
  95493. };
  95494. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  95495. var _this = this;
  95496. var newPromise = new InternalPromise();
  95497. newPromise._onFulfilled = onFulfilled;
  95498. newPromise._onRejected = onRejected;
  95499. // Composition
  95500. this._children.push(newPromise);
  95501. newPromise._parent = this;
  95502. if (this._state !== PromiseStates.Pending) {
  95503. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  95504. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  95505. var returnedValue = newPromise._resolve(_this._result);
  95506. if (returnedValue !== undefined && returnedValue !== null) {
  95507. if (returnedValue._state !== undefined) {
  95508. var returnedPromise = returnedValue;
  95509. newPromise._children.push(returnedPromise);
  95510. returnedPromise._parent = newPromise;
  95511. newPromise = returnedPromise;
  95512. }
  95513. else {
  95514. newPromise._result = returnedValue;
  95515. }
  95516. }
  95517. }
  95518. else {
  95519. newPromise._reject(_this._reason);
  95520. }
  95521. });
  95522. }
  95523. return newPromise;
  95524. };
  95525. InternalPromise.prototype._moveChildren = function (children) {
  95526. var _this = this;
  95527. var _a;
  95528. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  95529. this._children.forEach(function (child) {
  95530. child._parent = _this;
  95531. });
  95532. if (this._state === PromiseStates.Fulfilled) {
  95533. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  95534. var child = _b[_i];
  95535. child._resolve(this._result);
  95536. }
  95537. }
  95538. else if (this._state === PromiseStates.Rejected) {
  95539. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  95540. var child = _d[_c];
  95541. child._reject(this._reason);
  95542. }
  95543. }
  95544. };
  95545. InternalPromise.prototype._resolve = function (value) {
  95546. try {
  95547. this._state = PromiseStates.Fulfilled;
  95548. var returnedValue = null;
  95549. if (this._onFulfilled) {
  95550. returnedValue = this._onFulfilled(value);
  95551. }
  95552. if (returnedValue !== undefined && returnedValue !== null) {
  95553. if (returnedValue._state !== undefined) {
  95554. // Transmit children
  95555. var returnedPromise = returnedValue;
  95556. returnedPromise._parent = this;
  95557. returnedPromise._moveChildren(this._children);
  95558. value = returnedPromise._result;
  95559. }
  95560. else {
  95561. value = returnedValue;
  95562. }
  95563. }
  95564. this._result = value;
  95565. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95566. var child = _a[_i];
  95567. child._resolve(value);
  95568. }
  95569. this._children.length = 0;
  95570. delete this._onFulfilled;
  95571. delete this._onRejected;
  95572. }
  95573. catch (e) {
  95574. this._reject(e, true);
  95575. }
  95576. };
  95577. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  95578. if (onLocalThrow === void 0) { onLocalThrow = false; }
  95579. this._state = PromiseStates.Rejected;
  95580. this._reason = reason;
  95581. if (this._onRejected && !onLocalThrow) {
  95582. try {
  95583. this._onRejected(reason);
  95584. this._rejectWasConsumed = true;
  95585. }
  95586. catch (e) {
  95587. reason = e;
  95588. }
  95589. }
  95590. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95591. var child = _a[_i];
  95592. if (this._rejectWasConsumed) {
  95593. child._resolve(null);
  95594. }
  95595. else {
  95596. child._reject(reason);
  95597. }
  95598. }
  95599. this._children.length = 0;
  95600. delete this._onFulfilled;
  95601. delete this._onRejected;
  95602. };
  95603. InternalPromise.resolve = function (value) {
  95604. var newPromise = new InternalPromise();
  95605. newPromise._resolve(value);
  95606. return newPromise;
  95607. };
  95608. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  95609. promise.then(function (value) {
  95610. agregator.results[index] = value;
  95611. agregator.count++;
  95612. if (agregator.count === agregator.target) {
  95613. agregator.rootPromise._resolve(agregator.results);
  95614. }
  95615. return null;
  95616. }, function (reason) {
  95617. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  95618. agregator.rootPromise._reject(reason);
  95619. }
  95620. });
  95621. };
  95622. InternalPromise.all = function (promises) {
  95623. var newPromise = new InternalPromise();
  95624. var agregator = new FulFillmentAgregator();
  95625. agregator.target = promises.length;
  95626. agregator.rootPromise = newPromise;
  95627. if (promises.length) {
  95628. for (var index = 0; index < promises.length; index++) {
  95629. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  95630. }
  95631. }
  95632. else {
  95633. newPromise._resolve([]);
  95634. }
  95635. return newPromise;
  95636. };
  95637. InternalPromise.race = function (promises) {
  95638. var newPromise = new InternalPromise();
  95639. if (promises.length) {
  95640. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  95641. var promise = promises_1[_i];
  95642. promise.then(function (value) {
  95643. if (newPromise) {
  95644. newPromise._resolve(value);
  95645. newPromise = null;
  95646. }
  95647. return null;
  95648. }, function (reason) {
  95649. if (newPromise) {
  95650. newPromise._reject(reason);
  95651. newPromise = null;
  95652. }
  95653. });
  95654. }
  95655. }
  95656. return newPromise;
  95657. };
  95658. return InternalPromise;
  95659. }());
  95660. /**
  95661. * Helper class that provides a small promise polyfill
  95662. */
  95663. var PromisePolyfill = /** @class */ (function () {
  95664. function PromisePolyfill() {
  95665. }
  95666. /**
  95667. * Static function used to check if the polyfill is required
  95668. * If this is the case then the function will inject the polyfill to window.Promise
  95669. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95670. */
  95671. PromisePolyfill.Apply = function (force) {
  95672. if (force === void 0) { force = false; }
  95673. if (force || typeof Promise === 'undefined') {
  95674. var root = window;
  95675. root.Promise = InternalPromise;
  95676. }
  95677. };
  95678. return PromisePolyfill;
  95679. }());
  95680. /***/ }),
  95681. /***/ "./Misc/sceneOptimizer.ts":
  95682. /*!********************************!*\
  95683. !*** ./Misc/sceneOptimizer.ts ***!
  95684. \********************************/
  95685. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  95686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95687. "use strict";
  95688. __webpack_require__.r(__webpack_exports__);
  95689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  95690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  95691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  95692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  95693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  95694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  95695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  95696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  95697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  95698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  95699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  95700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  95701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  95702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  95703. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95704. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  95705. /**
  95706. * Defines the root class used to create scene optimization to use with SceneOptimizer
  95707. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95708. */
  95709. var SceneOptimization = /** @class */ (function () {
  95710. /**
  95711. * Creates the SceneOptimization object
  95712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95713. * @param desc defines the description associated with the optimization
  95714. */
  95715. function SceneOptimization(
  95716. /**
  95717. * Defines the priority of this optimization (0 by default which means first in the list)
  95718. */
  95719. priority) {
  95720. if (priority === void 0) { priority = 0; }
  95721. this.priority = priority;
  95722. }
  95723. /**
  95724. * Gets a string describing the action executed by the current optimization
  95725. * @returns description string
  95726. */
  95727. SceneOptimization.prototype.getDescription = function () {
  95728. return "";
  95729. };
  95730. /**
  95731. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95732. * @param scene defines the current scene where to apply this optimization
  95733. * @param optimizer defines the current optimizer
  95734. * @returns true if everything that can be done was applied
  95735. */
  95736. SceneOptimization.prototype.apply = function (scene, optimizer) {
  95737. return true;
  95738. };
  95739. return SceneOptimization;
  95740. }());
  95741. /**
  95742. * Defines an optimization used to reduce the size of render target textures
  95743. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95744. */
  95745. var TextureOptimization = /** @class */ (function (_super) {
  95746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  95747. /**
  95748. * Creates the TextureOptimization object
  95749. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95750. * @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
  95751. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  95752. */
  95753. function TextureOptimization(
  95754. /**
  95755. * Defines the priority of this optimization (0 by default which means first in the list)
  95756. */
  95757. priority,
  95758. /**
  95759. * 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
  95760. */
  95761. maximumSize,
  95762. /**
  95763. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  95764. */
  95765. step) {
  95766. if (priority === void 0) { priority = 0; }
  95767. if (maximumSize === void 0) { maximumSize = 1024; }
  95768. if (step === void 0) { step = 0.5; }
  95769. var _this = _super.call(this, priority) || this;
  95770. _this.priority = priority;
  95771. _this.maximumSize = maximumSize;
  95772. _this.step = step;
  95773. return _this;
  95774. }
  95775. /**
  95776. * Gets a string describing the action executed by the current optimization
  95777. * @returns description string
  95778. */
  95779. TextureOptimization.prototype.getDescription = function () {
  95780. return "Reducing render target texture size to " + this.maximumSize;
  95781. };
  95782. /**
  95783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95784. * @param scene defines the current scene where to apply this optimization
  95785. * @param optimizer defines the current optimizer
  95786. * @returns true if everything that can be done was applied
  95787. */
  95788. TextureOptimization.prototype.apply = function (scene, optimizer) {
  95789. var allDone = true;
  95790. for (var index = 0; index < scene.textures.length; index++) {
  95791. var texture = scene.textures[index];
  95792. if (!texture.canRescale || texture.getContext) {
  95793. continue;
  95794. }
  95795. var currentSize = texture.getSize();
  95796. var maxDimension = Math.max(currentSize.width, currentSize.height);
  95797. if (maxDimension > this.maximumSize) {
  95798. texture.scale(this.step);
  95799. allDone = false;
  95800. }
  95801. }
  95802. return allDone;
  95803. };
  95804. return TextureOptimization;
  95805. }(SceneOptimization));
  95806. /**
  95807. * Defines an optimization used to increase or decrease the rendering resolution
  95808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95809. */
  95810. var HardwareScalingOptimization = /** @class */ (function (_super) {
  95811. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  95812. /**
  95813. * Creates the HardwareScalingOptimization object
  95814. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95815. * @param maximumScale defines the maximum scale to use (2 by default)
  95816. * @param step defines the step to use between two passes (0.5 by default)
  95817. */
  95818. function HardwareScalingOptimization(
  95819. /**
  95820. * Defines the priority of this optimization (0 by default which means first in the list)
  95821. */
  95822. priority,
  95823. /**
  95824. * Defines the maximum scale to use (2 by default)
  95825. */
  95826. maximumScale,
  95827. /**
  95828. * Defines the step to use between two passes (0.5 by default)
  95829. */
  95830. step) {
  95831. if (priority === void 0) { priority = 0; }
  95832. if (maximumScale === void 0) { maximumScale = 2; }
  95833. if (step === void 0) { step = 0.25; }
  95834. var _this = _super.call(this, priority) || this;
  95835. _this.priority = priority;
  95836. _this.maximumScale = maximumScale;
  95837. _this.step = step;
  95838. _this._currentScale = -1;
  95839. _this._directionOffset = 1;
  95840. return _this;
  95841. }
  95842. /**
  95843. * Gets a string describing the action executed by the current optimization
  95844. * @return description string
  95845. */
  95846. HardwareScalingOptimization.prototype.getDescription = function () {
  95847. return "Setting hardware scaling level to " + this._currentScale;
  95848. };
  95849. /**
  95850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95851. * @param scene defines the current scene where to apply this optimization
  95852. * @param optimizer defines the current optimizer
  95853. * @returns true if everything that can be done was applied
  95854. */
  95855. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  95856. if (this._currentScale === -1) {
  95857. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  95858. if (this._currentScale > this.maximumScale) {
  95859. this._directionOffset = -1;
  95860. }
  95861. }
  95862. this._currentScale += this._directionOffset * this.step;
  95863. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  95864. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  95865. };
  95866. return HardwareScalingOptimization;
  95867. }(SceneOptimization));
  95868. /**
  95869. * Defines an optimization used to remove shadows
  95870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95871. */
  95872. var ShadowsOptimization = /** @class */ (function (_super) {
  95873. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  95874. function ShadowsOptimization() {
  95875. return _super !== null && _super.apply(this, arguments) || this;
  95876. }
  95877. /**
  95878. * Gets a string describing the action executed by the current optimization
  95879. * @return description string
  95880. */
  95881. ShadowsOptimization.prototype.getDescription = function () {
  95882. return "Turning shadows on/off";
  95883. };
  95884. /**
  95885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95886. * @param scene defines the current scene where to apply this optimization
  95887. * @param optimizer defines the current optimizer
  95888. * @returns true if everything that can be done was applied
  95889. */
  95890. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  95891. scene.shadowsEnabled = optimizer.isInImprovementMode;
  95892. return true;
  95893. };
  95894. return ShadowsOptimization;
  95895. }(SceneOptimization));
  95896. /**
  95897. * Defines an optimization used to turn post-processes off
  95898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95899. */
  95900. var PostProcessesOptimization = /** @class */ (function (_super) {
  95901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  95902. function PostProcessesOptimization() {
  95903. return _super !== null && _super.apply(this, arguments) || this;
  95904. }
  95905. /**
  95906. * Gets a string describing the action executed by the current optimization
  95907. * @return description string
  95908. */
  95909. PostProcessesOptimization.prototype.getDescription = function () {
  95910. return "Turning post-processes on/off";
  95911. };
  95912. /**
  95913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95914. * @param scene defines the current scene where to apply this optimization
  95915. * @param optimizer defines the current optimizer
  95916. * @returns true if everything that can be done was applied
  95917. */
  95918. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  95919. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  95920. return true;
  95921. };
  95922. return PostProcessesOptimization;
  95923. }(SceneOptimization));
  95924. /**
  95925. * Defines an optimization used to turn lens flares off
  95926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95927. */
  95928. var LensFlaresOptimization = /** @class */ (function (_super) {
  95929. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  95930. function LensFlaresOptimization() {
  95931. return _super !== null && _super.apply(this, arguments) || this;
  95932. }
  95933. /**
  95934. * Gets a string describing the action executed by the current optimization
  95935. * @return description string
  95936. */
  95937. LensFlaresOptimization.prototype.getDescription = function () {
  95938. return "Turning lens flares on/off";
  95939. };
  95940. /**
  95941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95942. * @param scene defines the current scene where to apply this optimization
  95943. * @param optimizer defines the current optimizer
  95944. * @returns true if everything that can be done was applied
  95945. */
  95946. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  95947. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  95948. return true;
  95949. };
  95950. return LensFlaresOptimization;
  95951. }(SceneOptimization));
  95952. /**
  95953. * Defines an optimization based on user defined callback.
  95954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95955. */
  95956. var CustomOptimization = /** @class */ (function (_super) {
  95957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  95958. function CustomOptimization() {
  95959. return _super !== null && _super.apply(this, arguments) || this;
  95960. }
  95961. /**
  95962. * Gets a string describing the action executed by the current optimization
  95963. * @returns description string
  95964. */
  95965. CustomOptimization.prototype.getDescription = function () {
  95966. if (this.onGetDescription) {
  95967. return this.onGetDescription();
  95968. }
  95969. return "Running user defined callback";
  95970. };
  95971. /**
  95972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95973. * @param scene defines the current scene where to apply this optimization
  95974. * @param optimizer defines the current optimizer
  95975. * @returns true if everything that can be done was applied
  95976. */
  95977. CustomOptimization.prototype.apply = function (scene, optimizer) {
  95978. if (this.onApply) {
  95979. return this.onApply(scene, optimizer);
  95980. }
  95981. return true;
  95982. };
  95983. return CustomOptimization;
  95984. }(SceneOptimization));
  95985. /**
  95986. * Defines an optimization used to turn particles off
  95987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95988. */
  95989. var ParticlesOptimization = /** @class */ (function (_super) {
  95990. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  95991. function ParticlesOptimization() {
  95992. return _super !== null && _super.apply(this, arguments) || this;
  95993. }
  95994. /**
  95995. * Gets a string describing the action executed by the current optimization
  95996. * @return description string
  95997. */
  95998. ParticlesOptimization.prototype.getDescription = function () {
  95999. return "Turning particles on/off";
  96000. };
  96001. /**
  96002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96003. * @param scene defines the current scene where to apply this optimization
  96004. * @param optimizer defines the current optimizer
  96005. * @returns true if everything that can be done was applied
  96006. */
  96007. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  96008. scene.particlesEnabled = optimizer.isInImprovementMode;
  96009. return true;
  96010. };
  96011. return ParticlesOptimization;
  96012. }(SceneOptimization));
  96013. /**
  96014. * Defines an optimization used to turn render targets off
  96015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96016. */
  96017. var RenderTargetsOptimization = /** @class */ (function (_super) {
  96018. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  96019. function RenderTargetsOptimization() {
  96020. return _super !== null && _super.apply(this, arguments) || this;
  96021. }
  96022. /**
  96023. * Gets a string describing the action executed by the current optimization
  96024. * @return description string
  96025. */
  96026. RenderTargetsOptimization.prototype.getDescription = function () {
  96027. return "Turning render targets off";
  96028. };
  96029. /**
  96030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96031. * @param scene defines the current scene where to apply this optimization
  96032. * @param optimizer defines the current optimizer
  96033. * @returns true if everything that can be done was applied
  96034. */
  96035. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  96036. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  96037. return true;
  96038. };
  96039. return RenderTargetsOptimization;
  96040. }(SceneOptimization));
  96041. /**
  96042. * Defines an optimization used to merge meshes with compatible materials
  96043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96044. */
  96045. var MergeMeshesOptimization = /** @class */ (function (_super) {
  96046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  96047. function MergeMeshesOptimization() {
  96048. var _this = _super !== null && _super.apply(this, arguments) || this;
  96049. _this._canBeMerged = function (abstractMesh) {
  96050. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  96051. return false;
  96052. }
  96053. var mesh = abstractMesh;
  96054. if (mesh.isDisposed()) {
  96055. return false;
  96056. }
  96057. if (!mesh.isVisible || !mesh.isEnabled()) {
  96058. return false;
  96059. }
  96060. if (mesh.instances.length > 0) {
  96061. return false;
  96062. }
  96063. if (mesh.skeleton || mesh.hasLODLevels) {
  96064. return false;
  96065. }
  96066. return true;
  96067. };
  96068. return _this;
  96069. }
  96070. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  96071. /**
  96072. * Gets or sets a boolean which defines if optimization octree has to be updated
  96073. */
  96074. get: function () {
  96075. return MergeMeshesOptimization._UpdateSelectionTree;
  96076. },
  96077. /**
  96078. * Gets or sets a boolean which defines if optimization octree has to be updated
  96079. */
  96080. set: function (value) {
  96081. MergeMeshesOptimization._UpdateSelectionTree = value;
  96082. },
  96083. enumerable: true,
  96084. configurable: true
  96085. });
  96086. /**
  96087. * Gets a string describing the action executed by the current optimization
  96088. * @return description string
  96089. */
  96090. MergeMeshesOptimization.prototype.getDescription = function () {
  96091. return "Merging similar meshes together";
  96092. };
  96093. /**
  96094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96095. * @param scene defines the current scene where to apply this optimization
  96096. * @param optimizer defines the current optimizer
  96097. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  96098. * @returns true if everything that can be done was applied
  96099. */
  96100. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  96101. var globalPool = scene.meshes.slice(0);
  96102. var globalLength = globalPool.length;
  96103. for (var index = 0; index < globalLength; index++) {
  96104. var currentPool = new Array();
  96105. var current = globalPool[index];
  96106. // Checks
  96107. if (!this._canBeMerged(current)) {
  96108. continue;
  96109. }
  96110. currentPool.push(current);
  96111. // Find compatible meshes
  96112. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  96113. var otherMesh = globalPool[subIndex];
  96114. if (!this._canBeMerged(otherMesh)) {
  96115. continue;
  96116. }
  96117. if (otherMesh.material !== current.material) {
  96118. continue;
  96119. }
  96120. if (otherMesh.checkCollisions !== current.checkCollisions) {
  96121. continue;
  96122. }
  96123. currentPool.push(otherMesh);
  96124. globalLength--;
  96125. globalPool.splice(subIndex, 1);
  96126. subIndex--;
  96127. }
  96128. if (currentPool.length < 2) {
  96129. continue;
  96130. }
  96131. // Merge meshes
  96132. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  96133. }
  96134. // Call the octree system optimization if it is defined.
  96135. var sceneAsAny = scene;
  96136. if (sceneAsAny.createOrUpdateSelectionOctree) {
  96137. if (updateSelectionTree != undefined) {
  96138. if (updateSelectionTree) {
  96139. sceneAsAny.createOrUpdateSelectionOctree();
  96140. }
  96141. }
  96142. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  96143. sceneAsAny.createOrUpdateSelectionOctree();
  96144. }
  96145. }
  96146. return true;
  96147. };
  96148. MergeMeshesOptimization._UpdateSelectionTree = false;
  96149. return MergeMeshesOptimization;
  96150. }(SceneOptimization));
  96151. /**
  96152. * Defines a list of options used by SceneOptimizer
  96153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96154. */
  96155. var SceneOptimizerOptions = /** @class */ (function () {
  96156. /**
  96157. * Creates a new list of options used by SceneOptimizer
  96158. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  96159. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  96160. */
  96161. function SceneOptimizerOptions(
  96162. /**
  96163. * Defines the target frame rate to reach (60 by default)
  96164. */
  96165. targetFrameRate,
  96166. /**
  96167. * Defines the interval between two checkes (2000ms by default)
  96168. */
  96169. trackerDuration) {
  96170. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  96171. if (trackerDuration === void 0) { trackerDuration = 2000; }
  96172. this.targetFrameRate = targetFrameRate;
  96173. this.trackerDuration = trackerDuration;
  96174. /**
  96175. * Gets the list of optimizations to apply
  96176. */
  96177. this.optimizations = new Array();
  96178. }
  96179. /**
  96180. * Add a new optimization
  96181. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  96182. * @returns the current SceneOptimizerOptions
  96183. */
  96184. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  96185. this.optimizations.push(optimization);
  96186. return this;
  96187. };
  96188. /**
  96189. * Add a new custom optimization
  96190. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  96191. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  96192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96193. * @returns the current SceneOptimizerOptions
  96194. */
  96195. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  96196. if (priority === void 0) { priority = 0; }
  96197. var optimization = new CustomOptimization(priority);
  96198. optimization.onApply = onApply;
  96199. optimization.onGetDescription = onGetDescription;
  96200. this.optimizations.push(optimization);
  96201. return this;
  96202. };
  96203. /**
  96204. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  96205. * @param targetFrameRate defines the target frame rate (60 by default)
  96206. * @returns a SceneOptimizerOptions object
  96207. */
  96208. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  96209. var result = new SceneOptimizerOptions(targetFrameRate);
  96210. var priority = 0;
  96211. result.addOptimization(new MergeMeshesOptimization(priority));
  96212. result.addOptimization(new ShadowsOptimization(priority));
  96213. result.addOptimization(new LensFlaresOptimization(priority));
  96214. // Next priority
  96215. priority++;
  96216. result.addOptimization(new PostProcessesOptimization(priority));
  96217. result.addOptimization(new ParticlesOptimization(priority));
  96218. // Next priority
  96219. priority++;
  96220. result.addOptimization(new TextureOptimization(priority, 1024));
  96221. return result;
  96222. };
  96223. /**
  96224. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  96225. * @param targetFrameRate defines the target frame rate (60 by default)
  96226. * @returns a SceneOptimizerOptions object
  96227. */
  96228. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  96229. var result = new SceneOptimizerOptions(targetFrameRate);
  96230. var priority = 0;
  96231. result.addOptimization(new MergeMeshesOptimization(priority));
  96232. result.addOptimization(new ShadowsOptimization(priority));
  96233. result.addOptimization(new LensFlaresOptimization(priority));
  96234. // Next priority
  96235. priority++;
  96236. result.addOptimization(new PostProcessesOptimization(priority));
  96237. result.addOptimization(new ParticlesOptimization(priority));
  96238. // Next priority
  96239. priority++;
  96240. result.addOptimization(new TextureOptimization(priority, 512));
  96241. // Next priority
  96242. priority++;
  96243. result.addOptimization(new RenderTargetsOptimization(priority));
  96244. // Next priority
  96245. priority++;
  96246. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  96247. return result;
  96248. };
  96249. /**
  96250. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  96251. * @param targetFrameRate defines the target frame rate (60 by default)
  96252. * @returns a SceneOptimizerOptions object
  96253. */
  96254. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  96255. var result = new SceneOptimizerOptions(targetFrameRate);
  96256. var priority = 0;
  96257. result.addOptimization(new MergeMeshesOptimization(priority));
  96258. result.addOptimization(new ShadowsOptimization(priority));
  96259. result.addOptimization(new LensFlaresOptimization(priority));
  96260. // Next priority
  96261. priority++;
  96262. result.addOptimization(new PostProcessesOptimization(priority));
  96263. result.addOptimization(new ParticlesOptimization(priority));
  96264. // Next priority
  96265. priority++;
  96266. result.addOptimization(new TextureOptimization(priority, 256));
  96267. // Next priority
  96268. priority++;
  96269. result.addOptimization(new RenderTargetsOptimization(priority));
  96270. // Next priority
  96271. priority++;
  96272. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  96273. return result;
  96274. };
  96275. return SceneOptimizerOptions;
  96276. }());
  96277. /**
  96278. * Class used to run optimizations in order to reach a target frame rate
  96279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96280. */
  96281. var SceneOptimizer = /** @class */ (function () {
  96282. /**
  96283. * Creates a new SceneOptimizer
  96284. * @param scene defines the scene to work on
  96285. * @param options defines the options to use with the SceneOptimizer
  96286. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  96287. * @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)
  96288. */
  96289. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  96290. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  96291. if (improvementMode === void 0) { improvementMode = false; }
  96292. var _this = this;
  96293. this._isRunning = false;
  96294. this._currentPriorityLevel = 0;
  96295. this._targetFrameRate = 60;
  96296. this._trackerDuration = 2000;
  96297. this._currentFrameRate = 0;
  96298. this._improvementMode = false;
  96299. /**
  96300. * Defines an observable called when the optimizer reaches the target frame rate
  96301. */
  96302. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96303. /**
  96304. * Defines an observable called when the optimizer enables an optimization
  96305. */
  96306. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96307. /**
  96308. * Defines an observable called when the optimizer is not able to reach the target frame rate
  96309. */
  96310. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96311. if (!options) {
  96312. this._options = new SceneOptimizerOptions();
  96313. }
  96314. else {
  96315. this._options = options;
  96316. }
  96317. if (this._options.targetFrameRate) {
  96318. this._targetFrameRate = this._options.targetFrameRate;
  96319. }
  96320. if (this._options.trackerDuration) {
  96321. this._trackerDuration = this._options.trackerDuration;
  96322. }
  96323. if (autoGeneratePriorities) {
  96324. var priority = 0;
  96325. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  96326. var optim = _a[_i];
  96327. optim.priority = priority++;
  96328. }
  96329. }
  96330. this._improvementMode = improvementMode;
  96331. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  96332. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  96333. _this._sceneDisposeObserver = null;
  96334. _this.dispose();
  96335. });
  96336. }
  96337. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  96338. /**
  96339. * Gets a boolean indicating if the optimizer is in improvement mode
  96340. */
  96341. get: function () {
  96342. return this._improvementMode;
  96343. },
  96344. enumerable: true,
  96345. configurable: true
  96346. });
  96347. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  96348. /**
  96349. * Gets the current priority level (0 at start)
  96350. */
  96351. get: function () {
  96352. return this._currentPriorityLevel;
  96353. },
  96354. enumerable: true,
  96355. configurable: true
  96356. });
  96357. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  96358. /**
  96359. * Gets the current frame rate checked by the SceneOptimizer
  96360. */
  96361. get: function () {
  96362. return this._currentFrameRate;
  96363. },
  96364. enumerable: true,
  96365. configurable: true
  96366. });
  96367. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  96368. /**
  96369. * Gets or sets the current target frame rate (60 by default)
  96370. */
  96371. get: function () {
  96372. return this._targetFrameRate;
  96373. },
  96374. /**
  96375. * Gets or sets the current target frame rate (60 by default)
  96376. */
  96377. set: function (value) {
  96378. this._targetFrameRate = value;
  96379. },
  96380. enumerable: true,
  96381. configurable: true
  96382. });
  96383. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  96384. /**
  96385. * Gets or sets the current interval between two checks (every 2000ms by default)
  96386. */
  96387. get: function () {
  96388. return this._trackerDuration;
  96389. },
  96390. /**
  96391. * Gets or sets the current interval between two checks (every 2000ms by default)
  96392. */
  96393. set: function (value) {
  96394. this._trackerDuration = value;
  96395. },
  96396. enumerable: true,
  96397. configurable: true
  96398. });
  96399. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  96400. /**
  96401. * Gets the list of active optimizations
  96402. */
  96403. get: function () {
  96404. return this._options.optimizations;
  96405. },
  96406. enumerable: true,
  96407. configurable: true
  96408. });
  96409. /**
  96410. * Stops the current optimizer
  96411. */
  96412. SceneOptimizer.prototype.stop = function () {
  96413. this._isRunning = false;
  96414. };
  96415. /**
  96416. * Reset the optimizer to initial step (current priority level = 0)
  96417. */
  96418. SceneOptimizer.prototype.reset = function () {
  96419. this._currentPriorityLevel = 0;
  96420. };
  96421. /**
  96422. * Start the optimizer. By default it will try to reach a specific framerate
  96423. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  96424. */
  96425. SceneOptimizer.prototype.start = function () {
  96426. var _this = this;
  96427. if (this._isRunning) {
  96428. return;
  96429. }
  96430. this._isRunning = true;
  96431. // Let's wait for the scene to be ready before running our check
  96432. this._scene.executeWhenReady(function () {
  96433. setTimeout(function () {
  96434. _this._checkCurrentState();
  96435. }, _this._trackerDuration);
  96436. });
  96437. };
  96438. SceneOptimizer.prototype._checkCurrentState = function () {
  96439. var _this = this;
  96440. if (!this._isRunning) {
  96441. return;
  96442. }
  96443. var scene = this._scene;
  96444. var options = this._options;
  96445. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  96446. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  96447. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  96448. this._isRunning = false;
  96449. this.onSuccessObservable.notifyObservers(this);
  96450. return;
  96451. }
  96452. // Apply current level of optimizations
  96453. var allDone = true;
  96454. var noOptimizationApplied = true;
  96455. for (var index = 0; index < options.optimizations.length; index++) {
  96456. var optimization = options.optimizations[index];
  96457. if (optimization.priority === this._currentPriorityLevel) {
  96458. noOptimizationApplied = false;
  96459. allDone = allDone && optimization.apply(scene, this);
  96460. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  96461. }
  96462. }
  96463. // If no optimization was applied, this is a failure :(
  96464. if (noOptimizationApplied) {
  96465. this._isRunning = false;
  96466. this.onFailureObservable.notifyObservers(this);
  96467. return;
  96468. }
  96469. // If all optimizations were done, move to next level
  96470. if (allDone) {
  96471. this._currentPriorityLevel++;
  96472. }
  96473. // Let's the system running for a specific amount of time before checking FPS
  96474. scene.executeWhenReady(function () {
  96475. setTimeout(function () {
  96476. _this._checkCurrentState();
  96477. }, _this._trackerDuration);
  96478. });
  96479. };
  96480. /**
  96481. * Release all resources
  96482. */
  96483. SceneOptimizer.prototype.dispose = function () {
  96484. this.stop();
  96485. this.onSuccessObservable.clear();
  96486. this.onFailureObservable.clear();
  96487. this.onNewOptimizationAppliedObservable.clear();
  96488. if (this._sceneDisposeObserver) {
  96489. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  96490. }
  96491. };
  96492. /**
  96493. * Helper function to create a SceneOptimizer with one single line of code
  96494. * @param scene defines the scene to work on
  96495. * @param options defines the options to use with the SceneOptimizer
  96496. * @param onSuccess defines a callback to call on success
  96497. * @param onFailure defines a callback to call on failure
  96498. * @returns the new SceneOptimizer object
  96499. */
  96500. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  96501. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  96502. if (onSuccess) {
  96503. optimizer.onSuccessObservable.add(function () {
  96504. onSuccess();
  96505. });
  96506. }
  96507. if (onFailure) {
  96508. optimizer.onFailureObservable.add(function () {
  96509. onFailure();
  96510. });
  96511. }
  96512. optimizer.start();
  96513. return optimizer;
  96514. };
  96515. return SceneOptimizer;
  96516. }());
  96517. /***/ }),
  96518. /***/ "./Misc/sceneSerializer.ts":
  96519. /*!*********************************!*\
  96520. !*** ./Misc/sceneSerializer.ts ***!
  96521. \*********************************/
  96522. /*! exports provided: SceneSerializer */
  96523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96524. "use strict";
  96525. __webpack_require__.r(__webpack_exports__);
  96526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  96527. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96528. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96529. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  96530. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96531. var serializedGeometries = [];
  96532. var serializeGeometry = function (geometry, serializationGeometries) {
  96533. if (serializedGeometries[geometry.id]) {
  96534. return;
  96535. }
  96536. if (geometry.doNotSerialize) {
  96537. return;
  96538. }
  96539. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  96540. serializedGeometries[geometry.id] = true;
  96541. };
  96542. var serializeMesh = function (mesh, serializationScene) {
  96543. var serializationObject = {};
  96544. // Geometry
  96545. var geometry = mesh._geometry;
  96546. if (geometry) {
  96547. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  96548. // 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
  96549. serializeGeometry(geometry, serializationScene.geometries);
  96550. }
  96551. }
  96552. // Custom
  96553. if (mesh.serialize) {
  96554. mesh.serialize(serializationObject);
  96555. }
  96556. return serializationObject;
  96557. };
  96558. var finalizeSingleMesh = function (mesh, serializationObject) {
  96559. //only works if the mesh is already loaded
  96560. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96561. //serialize material
  96562. if (mesh.material) {
  96563. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  96564. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  96565. serializationObject.materials = serializationObject.materials || [];
  96566. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96567. serializationObject.multiMaterials.push(mesh.material.serialize());
  96568. var _loop_1 = function (submaterial) {
  96569. if (submaterial) {
  96570. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  96571. serializationObject.materials.push(submaterial.serialize());
  96572. }
  96573. }
  96574. };
  96575. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  96576. var submaterial = _a[_i];
  96577. _loop_1(submaterial);
  96578. }
  96579. }
  96580. }
  96581. else {
  96582. serializationObject.materials = serializationObject.materials || [];
  96583. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96584. serializationObject.materials.push(mesh.material.serialize());
  96585. }
  96586. }
  96587. }
  96588. //serialize geometry
  96589. var geometry = mesh._geometry;
  96590. if (geometry) {
  96591. if (!serializationObject.geometries) {
  96592. serializationObject.geometries = {};
  96593. serializationObject.geometries.boxes = [];
  96594. serializationObject.geometries.spheres = [];
  96595. serializationObject.geometries.cylinders = [];
  96596. serializationObject.geometries.toruses = [];
  96597. serializationObject.geometries.grounds = [];
  96598. serializationObject.geometries.planes = [];
  96599. serializationObject.geometries.torusKnots = [];
  96600. serializationObject.geometries.vertexData = [];
  96601. }
  96602. serializeGeometry(geometry, serializationObject.geometries);
  96603. }
  96604. // Skeletons
  96605. if (mesh.skeleton) {
  96606. serializationObject.skeletons = serializationObject.skeletons || [];
  96607. serializationObject.skeletons.push(mesh.skeleton.serialize());
  96608. }
  96609. //serialize the actual mesh
  96610. serializationObject.meshes = serializationObject.meshes || [];
  96611. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96612. }
  96613. };
  96614. /**
  96615. * Class used to serialize a scene into a string
  96616. */
  96617. var SceneSerializer = /** @class */ (function () {
  96618. function SceneSerializer() {
  96619. }
  96620. /**
  96621. * Clear cache used by a previous serialization
  96622. */
  96623. SceneSerializer.ClearCache = function () {
  96624. serializedGeometries = [];
  96625. };
  96626. /**
  96627. * Serialize a scene into a JSON compatible object
  96628. * @param scene defines the scene to serialize
  96629. * @returns a JSON compatible object
  96630. */
  96631. SceneSerializer.Serialize = function (scene) {
  96632. var serializationObject = {};
  96633. SceneSerializer.ClearCache();
  96634. // Scene
  96635. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  96636. serializationObject.autoClear = scene.autoClear;
  96637. serializationObject.clearColor = scene.clearColor.asArray();
  96638. serializationObject.ambientColor = scene.ambientColor.asArray();
  96639. serializationObject.gravity = scene.gravity.asArray();
  96640. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  96641. // Fog
  96642. if (scene.fogMode && scene.fogMode !== 0) {
  96643. serializationObject.fogMode = scene.fogMode;
  96644. serializationObject.fogColor = scene.fogColor.asArray();
  96645. serializationObject.fogStart = scene.fogStart;
  96646. serializationObject.fogEnd = scene.fogEnd;
  96647. serializationObject.fogDensity = scene.fogDensity;
  96648. }
  96649. //Physics
  96650. if (scene.isPhysicsEnabled()) {
  96651. var physicEngine = scene.getPhysicsEngine();
  96652. if (physicEngine) {
  96653. serializationObject.physicsEnabled = true;
  96654. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  96655. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  96656. }
  96657. }
  96658. // Metadata
  96659. if (scene.metadata) {
  96660. serializationObject.metadata = scene.metadata;
  96661. }
  96662. // Morph targets
  96663. serializationObject.morphTargetManagers = [];
  96664. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  96665. var abstractMesh = _a[_i];
  96666. var manager = abstractMesh.morphTargetManager;
  96667. if (manager) {
  96668. serializationObject.morphTargetManagers.push(manager.serialize());
  96669. }
  96670. }
  96671. // Lights
  96672. serializationObject.lights = [];
  96673. var index;
  96674. var light;
  96675. for (index = 0; index < scene.lights.length; index++) {
  96676. light = scene.lights[index];
  96677. if (!light.doNotSerialize) {
  96678. serializationObject.lights.push(light.serialize());
  96679. }
  96680. }
  96681. // Cameras
  96682. serializationObject.cameras = [];
  96683. for (index = 0; index < scene.cameras.length; index++) {
  96684. var camera = scene.cameras[index];
  96685. if (!camera.doNotSerialize) {
  96686. serializationObject.cameras.push(camera.serialize());
  96687. }
  96688. }
  96689. if (scene.activeCamera) {
  96690. serializationObject.activeCameraID = scene.activeCamera.id;
  96691. }
  96692. // Animations
  96693. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  96694. // Reflection probes
  96695. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  96696. serializationObject.reflectionProbes = [];
  96697. for (index = 0; index < scene.reflectionProbes.length; index++) {
  96698. var reflectionProbe = scene.reflectionProbes[index];
  96699. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  96700. }
  96701. }
  96702. // Materials
  96703. serializationObject.materials = [];
  96704. serializationObject.multiMaterials = [];
  96705. var material;
  96706. for (index = 0; index < scene.materials.length; index++) {
  96707. material = scene.materials[index];
  96708. if (!material.doNotSerialize) {
  96709. serializationObject.materials.push(material.serialize());
  96710. }
  96711. }
  96712. // MultiMaterials
  96713. serializationObject.multiMaterials = [];
  96714. for (index = 0; index < scene.multiMaterials.length; index++) {
  96715. var multiMaterial = scene.multiMaterials[index];
  96716. serializationObject.multiMaterials.push(multiMaterial.serialize());
  96717. }
  96718. // Environment texture
  96719. if (scene.environmentTexture) {
  96720. serializationObject.environmentTexture = scene.environmentTexture.name;
  96721. }
  96722. // Skeletons
  96723. serializationObject.skeletons = [];
  96724. for (index = 0; index < scene.skeletons.length; index++) {
  96725. var skeleton = scene.skeletons[index];
  96726. if (!skeleton.doNotSerialize) {
  96727. serializationObject.skeletons.push(skeleton.serialize());
  96728. }
  96729. }
  96730. // Transform nodes
  96731. serializationObject.transformNodes = [];
  96732. for (index = 0; index < scene.transformNodes.length; index++) {
  96733. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  96734. }
  96735. // Geometries
  96736. serializationObject.geometries = {};
  96737. serializationObject.geometries.boxes = [];
  96738. serializationObject.geometries.spheres = [];
  96739. serializationObject.geometries.cylinders = [];
  96740. serializationObject.geometries.toruses = [];
  96741. serializationObject.geometries.grounds = [];
  96742. serializationObject.geometries.planes = [];
  96743. serializationObject.geometries.torusKnots = [];
  96744. serializationObject.geometries.vertexData = [];
  96745. serializedGeometries = [];
  96746. var geometries = scene.getGeometries();
  96747. for (index = 0; index < geometries.length; index++) {
  96748. var geometry = geometries[index];
  96749. if (geometry.isReady()) {
  96750. serializeGeometry(geometry, serializationObject.geometries);
  96751. }
  96752. }
  96753. // Meshes
  96754. serializationObject.meshes = [];
  96755. for (index = 0; index < scene.meshes.length; index++) {
  96756. var abstractMesh = scene.meshes[index];
  96757. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  96758. var mesh = abstractMesh;
  96759. if (!mesh.doNotSerialize) {
  96760. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96761. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96762. }
  96763. }
  96764. }
  96765. }
  96766. // Particles Systems
  96767. serializationObject.particleSystems = [];
  96768. for (index = 0; index < scene.particleSystems.length; index++) {
  96769. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  96770. }
  96771. // Action Manager
  96772. if (scene.actionManager) {
  96773. serializationObject.actions = scene.actionManager.serialize("scene");
  96774. }
  96775. // Components
  96776. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  96777. var component = _c[_b];
  96778. component.serialize(serializationObject);
  96779. }
  96780. return serializationObject;
  96781. };
  96782. /**
  96783. * Serialize a mesh into a JSON compatible object
  96784. * @param toSerialize defines the mesh to serialize
  96785. * @param withParents defines if parents must be serialized as well
  96786. * @param withChildren defines if children must be serialized as well
  96787. * @returns a JSON compatible object
  96788. */
  96789. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  96790. if (withParents === void 0) { withParents = false; }
  96791. if (withChildren === void 0) { withChildren = false; }
  96792. var serializationObject = {};
  96793. SceneSerializer.ClearCache();
  96794. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  96795. if (withParents || withChildren) {
  96796. //deliberate for loop! not for each, appended should be processed as well.
  96797. for (var i = 0; i < toSerialize.length; ++i) {
  96798. if (withChildren) {
  96799. toSerialize[i].getDescendants().forEach(function (node) {
  96800. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  96801. toSerialize.push(node);
  96802. }
  96803. });
  96804. }
  96805. //make sure the array doesn't contain the object already
  96806. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  96807. toSerialize.push(toSerialize[i].parent);
  96808. }
  96809. }
  96810. }
  96811. toSerialize.forEach(function (mesh) {
  96812. finalizeSingleMesh(mesh, serializationObject);
  96813. });
  96814. return serializationObject;
  96815. };
  96816. return SceneSerializer;
  96817. }());
  96818. /***/ }),
  96819. /***/ "./Misc/screenshotTools.ts":
  96820. /*!*********************************!*\
  96821. !*** ./Misc/screenshotTools.ts ***!
  96822. \*********************************/
  96823. /*! exports provided: ScreenshotTools */
  96824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96825. "use strict";
  96826. __webpack_require__.r(__webpack_exports__);
  96827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  96828. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96829. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  96830. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  96831. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96832. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  96833. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96834. // Screenshots
  96835. var screenshotCanvas;
  96836. /**
  96837. * Class containing a set of static utilities functions for screenshots
  96838. */
  96839. var ScreenshotTools = /** @class */ (function () {
  96840. function ScreenshotTools() {
  96841. }
  96842. /**
  96843. * Captures a screenshot of the current rendering
  96844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96845. * @param engine defines the rendering engine
  96846. * @param camera defines the source camera
  96847. * @param size This parameter can be set to a single number or to an object with the
  96848. * following (optional) properties: precision, width, height. If a single number is passed,
  96849. * it will be used for both width and height. If an object is passed, the screenshot size
  96850. * will be derived from the parameters. The precision property is a multiplier allowing
  96851. * rendering at a higher or lower resolution
  96852. * @param successCallback defines the callback receives a single parameter which contains the
  96853. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96854. * src parameter of an <img> to display it
  96855. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96856. * Check your browser for supported MIME types
  96857. */
  96858. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  96859. if (mimeType === void 0) { mimeType = "image/png"; }
  96860. var width;
  96861. var height;
  96862. // If a precision value is specified
  96863. if (size.precision) {
  96864. width = Math.round(engine.getRenderWidth() * size.precision);
  96865. height = Math.round(width / engine.getAspectRatio(camera));
  96866. }
  96867. else if (size.width && size.height) {
  96868. width = size.width;
  96869. height = size.height;
  96870. }
  96871. //If passing only width, computing height to keep display canvas ratio.
  96872. else if (size.width && !size.height) {
  96873. width = size.width;
  96874. height = Math.round(width / engine.getAspectRatio(camera));
  96875. }
  96876. //If passing only height, computing width to keep display canvas ratio.
  96877. else if (size.height && !size.width) {
  96878. height = size.height;
  96879. width = Math.round(height * engine.getAspectRatio(camera));
  96880. }
  96881. //Assuming here that "size" parameter is a number
  96882. else if (!isNaN(size)) {
  96883. height = size;
  96884. width = size;
  96885. }
  96886. else {
  96887. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96888. return;
  96889. }
  96890. if (!screenshotCanvas) {
  96891. screenshotCanvas = document.createElement('canvas');
  96892. }
  96893. screenshotCanvas.width = width;
  96894. screenshotCanvas.height = height;
  96895. var renderContext = screenshotCanvas.getContext("2d");
  96896. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  96897. var newWidth = width;
  96898. var newHeight = newWidth / ratio;
  96899. if (newHeight > height) {
  96900. newHeight = height;
  96901. newWidth = newHeight * ratio;
  96902. }
  96903. var offsetX = Math.max(0, width - newWidth) / 2;
  96904. var offsetY = Math.max(0, height - newHeight) / 2;
  96905. var renderingCanvas = engine.getRenderingCanvas();
  96906. if (renderContext && renderingCanvas) {
  96907. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  96908. }
  96909. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  96910. };
  96911. /**
  96912. * Generates an image screenshot from the specified camera.
  96913. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96914. * @param engine The engine to use for rendering
  96915. * @param camera The camera to use for rendering
  96916. * @param size This parameter can be set to a single number or to an object with the
  96917. * following (optional) properties: precision, width, height. If a single number is passed,
  96918. * it will be used for both width and height. If an object is passed, the screenshot size
  96919. * will be derived from the parameters. The precision property is a multiplier allowing
  96920. * rendering at a higher or lower resolution
  96921. * @param successCallback The callback receives a single parameter which contains the
  96922. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96923. * src parameter of an <img> to display it
  96924. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96925. * Check your browser for supported MIME types
  96926. * @param samples Texture samples (default: 1)
  96927. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96928. * @param fileName A name for for the downloaded file.
  96929. */
  96930. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  96931. if (mimeType === void 0) { mimeType = "image/png"; }
  96932. if (samples === void 0) { samples = 1; }
  96933. if (antialiasing === void 0) { antialiasing = false; }
  96934. var width;
  96935. var height;
  96936. //If a precision value is specified
  96937. if (size.precision) {
  96938. width = Math.round(engine.getRenderWidth() * size.precision);
  96939. height = Math.round(width / engine.getAspectRatio(camera));
  96940. size = { width: width, height: height };
  96941. }
  96942. else if (size.width && size.height) {
  96943. width = size.width;
  96944. height = size.height;
  96945. }
  96946. //If passing only width, computing height to keep display canvas ratio.
  96947. else if (size.width && !size.height) {
  96948. width = size.width;
  96949. height = Math.round(width / engine.getAspectRatio(camera));
  96950. size = { width: width, height: height };
  96951. }
  96952. //If passing only height, computing width to keep display canvas ratio.
  96953. else if (size.height && !size.width) {
  96954. height = size.height;
  96955. width = Math.round(height * engine.getAspectRatio(camera));
  96956. size = { width: width, height: height };
  96957. }
  96958. //Assuming here that "size" parameter is a number
  96959. else if (!isNaN(size)) {
  96960. height = size;
  96961. width = size;
  96962. }
  96963. else {
  96964. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96965. return;
  96966. }
  96967. var scene = camera.getScene();
  96968. var previousCamera = null;
  96969. if (scene.activeCamera !== camera) {
  96970. previousCamera = scene.activeCamera;
  96971. scene.activeCamera = camera;
  96972. }
  96973. var renderCanvas = engine.getRenderingCanvas();
  96974. if (!renderCanvas) {
  96975. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  96976. return;
  96977. }
  96978. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  96979. engine.setSize(width, height);
  96980. scene.render();
  96981. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  96982. 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);
  96983. texture.renderList = null;
  96984. texture.samples = samples;
  96985. if (antialiasing) {
  96986. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  96987. }
  96988. texture.onAfterRenderObservable.add(function () {
  96989. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  96990. });
  96991. scene.incrementRenderId();
  96992. scene.resetCachedMaterial();
  96993. texture.render(true);
  96994. texture.dispose();
  96995. if (previousCamera) {
  96996. scene.activeCamera = previousCamera;
  96997. }
  96998. engine.setSize(originalSize.width, originalSize.height);
  96999. camera.getProjectionMatrix(true); // Force cache refresh;
  97000. };
  97001. return ScreenshotTools;
  97002. }());
  97003. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  97004. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  97005. /***/ }),
  97006. /***/ "./Misc/smartArray.ts":
  97007. /*!****************************!*\
  97008. !*** ./Misc/smartArray.ts ***!
  97009. \****************************/
  97010. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  97011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97012. "use strict";
  97013. __webpack_require__.r(__webpack_exports__);
  97014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  97015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  97016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97017. /**
  97018. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97019. */
  97020. var SmartArray = /** @class */ (function () {
  97021. /**
  97022. * Instantiates a Smart Array.
  97023. * @param capacity defines the default capacity of the array.
  97024. */
  97025. function SmartArray(capacity) {
  97026. /**
  97027. * The active length of the array.
  97028. */
  97029. this.length = 0;
  97030. this.data = new Array(capacity);
  97031. this._id = SmartArray._GlobalId++;
  97032. }
  97033. /**
  97034. * Pushes a value at the end of the active data.
  97035. * @param value defines the object to push in the array.
  97036. */
  97037. SmartArray.prototype.push = function (value) {
  97038. this.data[this.length++] = value;
  97039. if (this.length > this.data.length) {
  97040. this.data.length *= 2;
  97041. }
  97042. };
  97043. /**
  97044. * Iterates over the active data and apply the lambda to them.
  97045. * @param func defines the action to apply on each value.
  97046. */
  97047. SmartArray.prototype.forEach = function (func) {
  97048. for (var index = 0; index < this.length; index++) {
  97049. func(this.data[index]);
  97050. }
  97051. };
  97052. /**
  97053. * Sorts the full sets of data.
  97054. * @param compareFn defines the comparison function to apply.
  97055. */
  97056. SmartArray.prototype.sort = function (compareFn) {
  97057. this.data.sort(compareFn);
  97058. };
  97059. /**
  97060. * Resets the active data to an empty array.
  97061. */
  97062. SmartArray.prototype.reset = function () {
  97063. this.length = 0;
  97064. };
  97065. /**
  97066. * Releases all the data from the array as well as the array.
  97067. */
  97068. SmartArray.prototype.dispose = function () {
  97069. this.reset();
  97070. if (this.data) {
  97071. this.data.length = 0;
  97072. this.data = [];
  97073. }
  97074. };
  97075. /**
  97076. * Concats the active data with a given array.
  97077. * @param array defines the data to concatenate with.
  97078. */
  97079. SmartArray.prototype.concat = function (array) {
  97080. if (array.length === 0) {
  97081. return;
  97082. }
  97083. if (this.length + array.length > this.data.length) {
  97084. this.data.length = (this.length + array.length) * 2;
  97085. }
  97086. for (var index = 0; index < array.length; index++) {
  97087. this.data[this.length++] = (array.data || array)[index];
  97088. }
  97089. };
  97090. /**
  97091. * Returns the position of a value in the active data.
  97092. * @param value defines the value to find the index for
  97093. * @returns the index if found in the active data otherwise -1
  97094. */
  97095. SmartArray.prototype.indexOf = function (value) {
  97096. var position = this.data.indexOf(value);
  97097. if (position >= this.length) {
  97098. return -1;
  97099. }
  97100. return position;
  97101. };
  97102. /**
  97103. * Returns whether an element is part of the active data.
  97104. * @param value defines the value to look for
  97105. * @returns true if found in the active data otherwise false
  97106. */
  97107. SmartArray.prototype.contains = function (value) {
  97108. return this.indexOf(value) !== -1;
  97109. };
  97110. // Statics
  97111. SmartArray._GlobalId = 0;
  97112. return SmartArray;
  97113. }());
  97114. /**
  97115. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97116. * The data in this array can only be present once
  97117. */
  97118. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  97119. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  97120. function SmartArrayNoDuplicate() {
  97121. var _this = _super !== null && _super.apply(this, arguments) || this;
  97122. _this._duplicateId = 0;
  97123. return _this;
  97124. }
  97125. /**
  97126. * Pushes a value at the end of the active data.
  97127. * THIS DOES NOT PREVENT DUPPLICATE DATA
  97128. * @param value defines the object to push in the array.
  97129. */
  97130. SmartArrayNoDuplicate.prototype.push = function (value) {
  97131. _super.prototype.push.call(this, value);
  97132. if (!value.__smartArrayFlags) {
  97133. value.__smartArrayFlags = {};
  97134. }
  97135. value.__smartArrayFlags[this._id] = this._duplicateId;
  97136. };
  97137. /**
  97138. * Pushes a value at the end of the active data.
  97139. * If the data is already present, it won t be added again
  97140. * @param value defines the object to push in the array.
  97141. * @returns true if added false if it was already present
  97142. */
  97143. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  97144. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  97145. return false;
  97146. }
  97147. this.push(value);
  97148. return true;
  97149. };
  97150. /**
  97151. * Resets the active data to an empty array.
  97152. */
  97153. SmartArrayNoDuplicate.prototype.reset = function () {
  97154. _super.prototype.reset.call(this);
  97155. this._duplicateId++;
  97156. };
  97157. /**
  97158. * Concats the active data with a given array.
  97159. * This ensures no dupplicate will be present in the result.
  97160. * @param array defines the data to concatenate with.
  97161. */
  97162. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  97163. if (array.length === 0) {
  97164. return;
  97165. }
  97166. if (this.length + array.length > this.data.length) {
  97167. this.data.length = (this.length + array.length) * 2;
  97168. }
  97169. for (var index = 0; index < array.length; index++) {
  97170. var item = (array.data || array)[index];
  97171. this.pushNoDuplicate(item);
  97172. }
  97173. };
  97174. return SmartArrayNoDuplicate;
  97175. }(SmartArray));
  97176. /***/ }),
  97177. /***/ "./Misc/stringDictionary.ts":
  97178. /*!**********************************!*\
  97179. !*** ./Misc/stringDictionary.ts ***!
  97180. \**********************************/
  97181. /*! exports provided: StringDictionary */
  97182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97183. "use strict";
  97184. __webpack_require__.r(__webpack_exports__);
  97185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  97186. /**
  97187. * This class implement a typical dictionary using a string as key and the generic type T as value.
  97188. * The underlying implementation relies on an associative array to ensure the best performances.
  97189. * The value can be anything including 'null' but except 'undefined'
  97190. */
  97191. var StringDictionary = /** @class */ (function () {
  97192. function StringDictionary() {
  97193. this._count = 0;
  97194. this._data = {};
  97195. }
  97196. /**
  97197. * This will clear this dictionary and copy the content from the 'source' one.
  97198. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  97199. * @param source the dictionary to take the content from and copy to this dictionary
  97200. */
  97201. StringDictionary.prototype.copyFrom = function (source) {
  97202. var _this = this;
  97203. this.clear();
  97204. source.forEach(function (t, v) { return _this.add(t, v); });
  97205. };
  97206. /**
  97207. * Get a value based from its key
  97208. * @param key the given key to get the matching value from
  97209. * @return the value if found, otherwise undefined is returned
  97210. */
  97211. StringDictionary.prototype.get = function (key) {
  97212. var val = this._data[key];
  97213. if (val !== undefined) {
  97214. return val;
  97215. }
  97216. return undefined;
  97217. };
  97218. /**
  97219. * Get a value from its key or add it if it doesn't exist.
  97220. * This method will ensure you that a given key/data will be present in the dictionary.
  97221. * @param key the given key to get the matching value from
  97222. * @param factory the factory that will create the value if the key is not present in the dictionary.
  97223. * The factory will only be invoked if there's no data for the given key.
  97224. * @return the value corresponding to the key.
  97225. */
  97226. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  97227. var val = this.get(key);
  97228. if (val !== undefined) {
  97229. return val;
  97230. }
  97231. val = factory(key);
  97232. if (val) {
  97233. this.add(key, val);
  97234. }
  97235. return val;
  97236. };
  97237. /**
  97238. * Get a value from its key if present in the dictionary otherwise add it
  97239. * @param key the key to get the value from
  97240. * @param val if there's no such key/value pair in the dictionary add it with this value
  97241. * @return the value corresponding to the key
  97242. */
  97243. StringDictionary.prototype.getOrAdd = function (key, val) {
  97244. var curVal = this.get(key);
  97245. if (curVal !== undefined) {
  97246. return curVal;
  97247. }
  97248. this.add(key, val);
  97249. return val;
  97250. };
  97251. /**
  97252. * Check if there's a given key in the dictionary
  97253. * @param key the key to check for
  97254. * @return true if the key is present, false otherwise
  97255. */
  97256. StringDictionary.prototype.contains = function (key) {
  97257. return this._data[key] !== undefined;
  97258. };
  97259. /**
  97260. * Add a new key and its corresponding value
  97261. * @param key the key to add
  97262. * @param value the value corresponding to the key
  97263. * @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
  97264. */
  97265. StringDictionary.prototype.add = function (key, value) {
  97266. if (this._data[key] !== undefined) {
  97267. return false;
  97268. }
  97269. this._data[key] = value;
  97270. ++this._count;
  97271. return true;
  97272. };
  97273. /**
  97274. * Update a specific value associated to a key
  97275. * @param key defines the key to use
  97276. * @param value defines the value to store
  97277. * @returns true if the value was updated (or false if the key was not found)
  97278. */
  97279. StringDictionary.prototype.set = function (key, value) {
  97280. if (this._data[key] === undefined) {
  97281. return false;
  97282. }
  97283. this._data[key] = value;
  97284. return true;
  97285. };
  97286. /**
  97287. * Get the element of the given key and remove it from the dictionary
  97288. * @param key defines the key to search
  97289. * @returns the value associated with the key or null if not found
  97290. */
  97291. StringDictionary.prototype.getAndRemove = function (key) {
  97292. var val = this.get(key);
  97293. if (val !== undefined) {
  97294. delete this._data[key];
  97295. --this._count;
  97296. return val;
  97297. }
  97298. return null;
  97299. };
  97300. /**
  97301. * Remove a key/value from the dictionary.
  97302. * @param key the key to remove
  97303. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  97304. */
  97305. StringDictionary.prototype.remove = function (key) {
  97306. if (this.contains(key)) {
  97307. delete this._data[key];
  97308. --this._count;
  97309. return true;
  97310. }
  97311. return false;
  97312. };
  97313. /**
  97314. * Clear the whole content of the dictionary
  97315. */
  97316. StringDictionary.prototype.clear = function () {
  97317. this._data = {};
  97318. this._count = 0;
  97319. };
  97320. Object.defineProperty(StringDictionary.prototype, "count", {
  97321. /**
  97322. * Gets the current count
  97323. */
  97324. get: function () {
  97325. return this._count;
  97326. },
  97327. enumerable: true,
  97328. configurable: true
  97329. });
  97330. /**
  97331. * Execute a callback on each key/val of the dictionary.
  97332. * Note that you can remove any element in this dictionary in the callback implementation
  97333. * @param callback the callback to execute on a given key/value pair
  97334. */
  97335. StringDictionary.prototype.forEach = function (callback) {
  97336. for (var cur in this._data) {
  97337. var val = this._data[cur];
  97338. callback(cur, val);
  97339. }
  97340. };
  97341. /**
  97342. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  97343. * If the callback returns null or undefined the method will iterate to the next key/value pair
  97344. * Note that you can remove any element in this dictionary in the callback implementation
  97345. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  97346. * @returns the first item
  97347. */
  97348. StringDictionary.prototype.first = function (callback) {
  97349. for (var cur in this._data) {
  97350. var val = this._data[cur];
  97351. var res = callback(cur, val);
  97352. if (res) {
  97353. return res;
  97354. }
  97355. }
  97356. return null;
  97357. };
  97358. return StringDictionary;
  97359. }());
  97360. /***/ }),
  97361. /***/ "./Misc/tags.ts":
  97362. /*!**********************!*\
  97363. !*** ./Misc/tags.ts ***!
  97364. \**********************/
  97365. /*! exports provided: Tags */
  97366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97367. "use strict";
  97368. __webpack_require__.r(__webpack_exports__);
  97369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  97370. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97371. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97372. /**
  97373. * Class used to store custom tags
  97374. */
  97375. var Tags = /** @class */ (function () {
  97376. function Tags() {
  97377. }
  97378. /**
  97379. * Adds support for tags on the given object
  97380. * @param obj defines the object to use
  97381. */
  97382. Tags.EnableFor = function (obj) {
  97383. obj._tags = obj._tags || {};
  97384. obj.hasTags = function () {
  97385. return Tags.HasTags(obj);
  97386. };
  97387. obj.addTags = function (tagsString) {
  97388. return Tags.AddTagsTo(obj, tagsString);
  97389. };
  97390. obj.removeTags = function (tagsString) {
  97391. return Tags.RemoveTagsFrom(obj, tagsString);
  97392. };
  97393. obj.matchesTagsQuery = function (tagsQuery) {
  97394. return Tags.MatchesQuery(obj, tagsQuery);
  97395. };
  97396. };
  97397. /**
  97398. * Removes tags support
  97399. * @param obj defines the object to use
  97400. */
  97401. Tags.DisableFor = function (obj) {
  97402. delete obj._tags;
  97403. delete obj.hasTags;
  97404. delete obj.addTags;
  97405. delete obj.removeTags;
  97406. delete obj.matchesTagsQuery;
  97407. };
  97408. /**
  97409. * Gets a boolean indicating if the given object has tags
  97410. * @param obj defines the object to use
  97411. * @returns a boolean
  97412. */
  97413. Tags.HasTags = function (obj) {
  97414. if (!obj._tags) {
  97415. return false;
  97416. }
  97417. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  97418. };
  97419. /**
  97420. * Gets the tags available on a given object
  97421. * @param obj defines the object to use
  97422. * @param asString defines if the tags must be returned as a string instead of an array of strings
  97423. * @returns the tags
  97424. */
  97425. Tags.GetTags = function (obj, asString) {
  97426. if (asString === void 0) { asString = true; }
  97427. if (!obj._tags) {
  97428. return null;
  97429. }
  97430. if (asString) {
  97431. var tagsArray = [];
  97432. for (var tag in obj._tags) {
  97433. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  97434. tagsArray.push(tag);
  97435. }
  97436. }
  97437. return tagsArray.join(" ");
  97438. }
  97439. else {
  97440. return obj._tags;
  97441. }
  97442. };
  97443. /**
  97444. * Adds tags to an object
  97445. * @param obj defines the object to use
  97446. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  97447. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  97448. */
  97449. Tags.AddTagsTo = function (obj, tagsString) {
  97450. if (!tagsString) {
  97451. return;
  97452. }
  97453. if (typeof tagsString !== "string") {
  97454. return;
  97455. }
  97456. var tags = tagsString.split(" ");
  97457. tags.forEach(function (tag, index, array) {
  97458. Tags._AddTagTo(obj, tag);
  97459. });
  97460. };
  97461. /**
  97462. * @hidden
  97463. */
  97464. Tags._AddTagTo = function (obj, tag) {
  97465. tag = tag.trim();
  97466. if (tag === "" || tag === "true" || tag === "false") {
  97467. return;
  97468. }
  97469. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  97470. return;
  97471. }
  97472. Tags.EnableFor(obj);
  97473. obj._tags[tag] = true;
  97474. };
  97475. /**
  97476. * Removes specific tags from a specific object
  97477. * @param obj defines the object to use
  97478. * @param tagsString defines the tags to remove
  97479. */
  97480. Tags.RemoveTagsFrom = function (obj, tagsString) {
  97481. if (!Tags.HasTags(obj)) {
  97482. return;
  97483. }
  97484. var tags = tagsString.split(" ");
  97485. for (var t in tags) {
  97486. Tags._RemoveTagFrom(obj, tags[t]);
  97487. }
  97488. };
  97489. /**
  97490. * @hidden
  97491. */
  97492. Tags._RemoveTagFrom = function (obj, tag) {
  97493. delete obj._tags[tag];
  97494. };
  97495. /**
  97496. * Defines if tags hosted on an object match a given query
  97497. * @param obj defines the object to use
  97498. * @param tagsQuery defines the tag query
  97499. * @returns a boolean
  97500. */
  97501. Tags.MatchesQuery = function (obj, tagsQuery) {
  97502. if (tagsQuery === undefined) {
  97503. return true;
  97504. }
  97505. if (tagsQuery === "") {
  97506. return Tags.HasTags(obj);
  97507. }
  97508. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  97509. };
  97510. return Tags;
  97511. }());
  97512. /***/ }),
  97513. /***/ "./Misc/textureTools.ts":
  97514. /*!******************************!*\
  97515. !*** ./Misc/textureTools.ts ***!
  97516. \******************************/
  97517. /*! exports provided: TextureTools */
  97518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97519. "use strict";
  97520. __webpack_require__.r(__webpack_exports__);
  97521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  97522. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97523. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97524. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  97525. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97526. /**
  97527. * Class used to host texture specific utilities
  97528. */
  97529. var TextureTools = /** @class */ (function () {
  97530. function TextureTools() {
  97531. }
  97532. /**
  97533. * Uses the GPU to create a copy texture rescaled at a given size
  97534. * @param texture Texture to copy from
  97535. * @param width defines the desired width
  97536. * @param height defines the desired height
  97537. * @param useBilinearMode defines if bilinear mode has to be used
  97538. * @return the generated texture
  97539. */
  97540. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  97541. if (useBilinearMode === void 0) { useBilinearMode = true; }
  97542. var scene = texture.getScene();
  97543. var engine = scene.getEngine();
  97544. 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);
  97545. rtt.wrapU = texture.wrapU;
  97546. rtt.wrapV = texture.wrapV;
  97547. rtt.uOffset = texture.uOffset;
  97548. rtt.vOffset = texture.vOffset;
  97549. rtt.uScale = texture.uScale;
  97550. rtt.vScale = texture.vScale;
  97551. rtt.uAng = texture.uAng;
  97552. rtt.vAng = texture.vAng;
  97553. rtt.wAng = texture.wAng;
  97554. rtt.coordinatesIndex = texture.coordinatesIndex;
  97555. rtt.level = texture.level;
  97556. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  97557. rtt._texture.isReady = false;
  97558. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97559. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97560. 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);
  97561. passPostProcess.getEffect().executeWhenCompiled(function () {
  97562. passPostProcess.onApply = function (effect) {
  97563. effect.setTexture("textureSampler", texture);
  97564. };
  97565. var internalTexture = rtt.getInternalTexture();
  97566. if (internalTexture) {
  97567. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  97568. engine.unBindFramebuffer(internalTexture);
  97569. rtt.disposeFramebufferObjects();
  97570. passPostProcess.dispose();
  97571. internalTexture.isReady = true;
  97572. }
  97573. });
  97574. return rtt;
  97575. };
  97576. /**
  97577. * Gets an environment BRDF texture for a given scene
  97578. * @param scene defines the hosting scene
  97579. * @returns the environment BRDF texture
  97580. */
  97581. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97582. if (!scene._environmentBRDFTexture) {
  97583. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  97584. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97585. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97586. scene._environmentBRDFTexture = texture;
  97587. }
  97588. return scene._environmentBRDFTexture;
  97589. };
  97590. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=";
  97591. return TextureTools;
  97592. }());
  97593. /***/ }),
  97594. /***/ "./Misc/tga.ts":
  97595. /*!*********************!*\
  97596. !*** ./Misc/tga.ts ***!
  97597. \*********************/
  97598. /*! exports provided: TGATools */
  97599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97600. "use strict";
  97601. __webpack_require__.r(__webpack_exports__);
  97602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  97603. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97604. /**
  97605. * Based on jsTGALoader - Javascript loader for TGA file
  97606. * By Vincent Thibault
  97607. * @see http://blog.robrowser.com/javascript-tga-loader.html
  97608. */
  97609. var TGATools = /** @class */ (function () {
  97610. function TGATools() {
  97611. }
  97612. /**
  97613. * Gets the header of a TGA file
  97614. * @param data defines the TGA data
  97615. * @returns the header
  97616. */
  97617. TGATools.GetTGAHeader = function (data) {
  97618. var offset = 0;
  97619. var header = {
  97620. id_length: data[offset++],
  97621. colormap_type: data[offset++],
  97622. image_type: data[offset++],
  97623. colormap_index: data[offset++] | data[offset++] << 8,
  97624. colormap_length: data[offset++] | data[offset++] << 8,
  97625. colormap_size: data[offset++],
  97626. origin: [
  97627. data[offset++] | data[offset++] << 8,
  97628. data[offset++] | data[offset++] << 8
  97629. ],
  97630. width: data[offset++] | data[offset++] << 8,
  97631. height: data[offset++] | data[offset++] << 8,
  97632. pixel_size: data[offset++],
  97633. flags: data[offset++]
  97634. };
  97635. return header;
  97636. };
  97637. /**
  97638. * Uploads TGA content to a Babylon Texture
  97639. * @hidden
  97640. */
  97641. TGATools.UploadContent = function (texture, data) {
  97642. // Not enough data to contain header ?
  97643. if (data.length < 19) {
  97644. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  97645. return;
  97646. }
  97647. // Read Header
  97648. var offset = 18;
  97649. var header = TGATools.GetTGAHeader(data);
  97650. // Assume it's a valid Targa file.
  97651. if (header.id_length + offset > data.length) {
  97652. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  97653. return;
  97654. }
  97655. // Skip not needed data
  97656. offset += header.id_length;
  97657. var use_rle = false;
  97658. var use_pal = false;
  97659. var use_grey = false;
  97660. // Get some informations.
  97661. switch (header.image_type) {
  97662. case TGATools._TYPE_RLE_INDEXED:
  97663. use_rle = true;
  97664. case TGATools._TYPE_INDEXED:
  97665. use_pal = true;
  97666. break;
  97667. case TGATools._TYPE_RLE_RGB:
  97668. use_rle = true;
  97669. case TGATools._TYPE_RGB:
  97670. // use_rgb = true;
  97671. break;
  97672. case TGATools._TYPE_RLE_GREY:
  97673. use_rle = true;
  97674. case TGATools._TYPE_GREY:
  97675. use_grey = true;
  97676. break;
  97677. }
  97678. var pixel_data;
  97679. // var numAlphaBits = header.flags & 0xf;
  97680. var pixel_size = header.pixel_size >> 3;
  97681. var pixel_total = header.width * header.height * pixel_size;
  97682. // Read palettes
  97683. var palettes;
  97684. if (use_pal) {
  97685. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  97686. }
  97687. // Read LRE
  97688. if (use_rle) {
  97689. pixel_data = new Uint8Array(pixel_total);
  97690. var c, count, i;
  97691. var localOffset = 0;
  97692. var pixels = new Uint8Array(pixel_size);
  97693. while (offset < pixel_total && localOffset < pixel_total) {
  97694. c = data[offset++];
  97695. count = (c & 0x7f) + 1;
  97696. // RLE pixels
  97697. if (c & 0x80) {
  97698. // Bind pixel tmp array
  97699. for (i = 0; i < pixel_size; ++i) {
  97700. pixels[i] = data[offset++];
  97701. }
  97702. // Copy pixel array
  97703. for (i = 0; i < count; ++i) {
  97704. pixel_data.set(pixels, localOffset + i * pixel_size);
  97705. }
  97706. localOffset += pixel_size * count;
  97707. }
  97708. // Raw pixels
  97709. else {
  97710. count *= pixel_size;
  97711. for (i = 0; i < count; ++i) {
  97712. pixel_data[localOffset + i] = data[offset++];
  97713. }
  97714. localOffset += count;
  97715. }
  97716. }
  97717. }
  97718. // RAW Pixels
  97719. else {
  97720. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  97721. }
  97722. // Load to texture
  97723. var x_start, y_start, x_step, y_step, y_end, x_end;
  97724. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  97725. default:
  97726. case TGATools._ORIGIN_UL:
  97727. x_start = 0;
  97728. x_step = 1;
  97729. x_end = header.width;
  97730. y_start = 0;
  97731. y_step = 1;
  97732. y_end = header.height;
  97733. break;
  97734. case TGATools._ORIGIN_BL:
  97735. x_start = 0;
  97736. x_step = 1;
  97737. x_end = header.width;
  97738. y_start = header.height - 1;
  97739. y_step = -1;
  97740. y_end = -1;
  97741. break;
  97742. case TGATools._ORIGIN_UR:
  97743. x_start = header.width - 1;
  97744. x_step = -1;
  97745. x_end = -1;
  97746. y_start = 0;
  97747. y_step = 1;
  97748. y_end = header.height;
  97749. break;
  97750. case TGATools._ORIGIN_BR:
  97751. x_start = header.width - 1;
  97752. x_step = -1;
  97753. x_end = -1;
  97754. y_start = header.height - 1;
  97755. y_step = -1;
  97756. y_end = -1;
  97757. break;
  97758. }
  97759. // Load the specify method
  97760. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  97761. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  97762. var engine = texture.getEngine();
  97763. engine._uploadDataToTextureDirectly(texture, imageData);
  97764. };
  97765. /** @hidden */
  97766. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97767. var image = pixel_data, colormap = palettes;
  97768. var width = header.width, height = header.height;
  97769. var color, i = 0, x, y;
  97770. var imageData = new Uint8Array(width * height * 4);
  97771. for (y = y_start; y !== y_end; y += y_step) {
  97772. for (x = x_start; x !== x_end; x += x_step, i++) {
  97773. color = image[i];
  97774. imageData[(x + width * y) * 4 + 3] = 255;
  97775. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  97776. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  97777. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  97778. }
  97779. }
  97780. return imageData;
  97781. };
  97782. /** @hidden */
  97783. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97784. var image = pixel_data;
  97785. var width = header.width, height = header.height;
  97786. var color, i = 0, x, y;
  97787. var imageData = new Uint8Array(width * height * 4);
  97788. for (y = y_start; y !== y_end; y += y_step) {
  97789. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97790. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  97791. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  97792. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  97793. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  97794. imageData[(x + width * y) * 4 + 0] = r;
  97795. imageData[(x + width * y) * 4 + 1] = g;
  97796. imageData[(x + width * y) * 4 + 2] = b;
  97797. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  97798. }
  97799. }
  97800. return imageData;
  97801. };
  97802. /** @hidden */
  97803. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97804. var image = pixel_data;
  97805. var width = header.width, height = header.height;
  97806. var i = 0, x, y;
  97807. var imageData = new Uint8Array(width * height * 4);
  97808. for (y = y_start; y !== y_end; y += y_step) {
  97809. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  97810. imageData[(x + width * y) * 4 + 3] = 255;
  97811. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97812. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  97813. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  97814. }
  97815. }
  97816. return imageData;
  97817. };
  97818. /** @hidden */
  97819. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97820. var image = pixel_data;
  97821. var width = header.width, height = header.height;
  97822. var i = 0, x, y;
  97823. var imageData = new Uint8Array(width * height * 4);
  97824. for (y = y_start; y !== y_end; y += y_step) {
  97825. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  97826. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97827. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  97828. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  97829. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  97830. }
  97831. }
  97832. return imageData;
  97833. };
  97834. /** @hidden */
  97835. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97836. var image = pixel_data;
  97837. var width = header.width, height = header.height;
  97838. var color, i = 0, x, y;
  97839. var imageData = new Uint8Array(width * height * 4);
  97840. for (y = y_start; y !== y_end; y += y_step) {
  97841. for (x = x_start; x !== x_end; x += x_step, i++) {
  97842. color = image[i];
  97843. imageData[(x + width * y) * 4 + 0] = color;
  97844. imageData[(x + width * y) * 4 + 1] = color;
  97845. imageData[(x + width * y) * 4 + 2] = color;
  97846. imageData[(x + width * y) * 4 + 3] = 255;
  97847. }
  97848. }
  97849. return imageData;
  97850. };
  97851. /** @hidden */
  97852. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97853. var image = pixel_data;
  97854. var width = header.width, height = header.height;
  97855. var i = 0, x, y;
  97856. var imageData = new Uint8Array(width * height * 4);
  97857. for (y = y_start; y !== y_end; y += y_step) {
  97858. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97859. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  97860. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  97861. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97862. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  97863. }
  97864. }
  97865. return imageData;
  97866. };
  97867. //private static _TYPE_NO_DATA = 0;
  97868. TGATools._TYPE_INDEXED = 1;
  97869. TGATools._TYPE_RGB = 2;
  97870. TGATools._TYPE_GREY = 3;
  97871. TGATools._TYPE_RLE_INDEXED = 9;
  97872. TGATools._TYPE_RLE_RGB = 10;
  97873. TGATools._TYPE_RLE_GREY = 11;
  97874. TGATools._ORIGIN_MASK = 0x30;
  97875. TGATools._ORIGIN_SHIFT = 0x04;
  97876. TGATools._ORIGIN_BL = 0x00;
  97877. TGATools._ORIGIN_BR = 0x01;
  97878. TGATools._ORIGIN_UL = 0x02;
  97879. TGATools._ORIGIN_UR = 0x03;
  97880. return TGATools;
  97881. }());
  97882. /***/ }),
  97883. /***/ "./Misc/tools.ts":
  97884. /*!***********************!*\
  97885. !*** ./Misc/tools.ts ***!
  97886. \***********************/
  97887. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  97888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97889. "use strict";
  97890. __webpack_require__.r(__webpack_exports__);
  97891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  97892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  97893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  97894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  97895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  97896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  97897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  97898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  97899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  97900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97901. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97902. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97903. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  97904. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97905. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97906. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  97907. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97908. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  97909. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  97910. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97911. /** Class used to store color4 gradient */
  97912. var ColorGradient = /** @class */ (function () {
  97913. function ColorGradient() {
  97914. }
  97915. /**
  97916. * Will get a color picked randomly between color1 and color2.
  97917. * If color2 is undefined then color1 will be used
  97918. * @param result defines the target Color4 to store the result in
  97919. */
  97920. ColorGradient.prototype.getColorToRef = function (result) {
  97921. if (!this.color2) {
  97922. result.copyFrom(this.color1);
  97923. return;
  97924. }
  97925. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  97926. };
  97927. return ColorGradient;
  97928. }());
  97929. /** Class used to store color 3 gradient */
  97930. var Color3Gradient = /** @class */ (function () {
  97931. function Color3Gradient() {
  97932. }
  97933. return Color3Gradient;
  97934. }());
  97935. /** Class used to store factor gradient */
  97936. var FactorGradient = /** @class */ (function () {
  97937. function FactorGradient() {
  97938. }
  97939. /**
  97940. * Will get a number picked randomly between factor1 and factor2.
  97941. * If factor2 is undefined then factor1 will be used
  97942. * @returns the picked number
  97943. */
  97944. FactorGradient.prototype.getFactor = function () {
  97945. if (this.factor2 === undefined) {
  97946. return this.factor1;
  97947. }
  97948. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  97949. };
  97950. return FactorGradient;
  97951. }());
  97952. /**
  97953. * @ignore
  97954. * Application error to support additional information when loading a file
  97955. */
  97956. var LoadFileError = /** @class */ (function (_super) {
  97957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  97958. /**
  97959. * Creates a new LoadFileError
  97960. * @param message defines the message of the error
  97961. * @param request defines the optional XHR request
  97962. */
  97963. function LoadFileError(message,
  97964. /** defines the optional XHR request */
  97965. request) {
  97966. var _this = _super.call(this, message) || this;
  97967. _this.request = request;
  97968. _this.name = "LoadFileError";
  97969. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  97970. return _this;
  97971. }
  97972. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  97973. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  97974. // Polyfill for Object.setPrototypeOf if necessary.
  97975. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  97976. return LoadFileError;
  97977. }(Error));
  97978. /**
  97979. * Class used to define a retry strategy when error happens while loading assets
  97980. */
  97981. var RetryStrategy = /** @class */ (function () {
  97982. function RetryStrategy() {
  97983. }
  97984. /**
  97985. * Function used to defines an exponential back off strategy
  97986. * @param maxRetries defines the maximum number of retries (3 by default)
  97987. * @param baseInterval defines the interval between retries
  97988. * @returns the strategy function to use
  97989. */
  97990. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  97991. if (maxRetries === void 0) { maxRetries = 3; }
  97992. if (baseInterval === void 0) { baseInterval = 500; }
  97993. return function (url, request, retryIndex) {
  97994. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  97995. return -1;
  97996. }
  97997. return Math.pow(2, retryIndex) * baseInterval;
  97998. };
  97999. };
  98000. return RetryStrategy;
  98001. }());
  98002. // Screenshots
  98003. var screenshotCanvas;
  98004. /**
  98005. * Class containing a set of static utilities functions
  98006. */
  98007. var Tools = /** @class */ (function () {
  98008. function Tools() {
  98009. }
  98010. /**
  98011. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98012. * @param u defines the coordinate on X axis
  98013. * @param v defines the coordinate on Y axis
  98014. * @param width defines the width of the source data
  98015. * @param height defines the height of the source data
  98016. * @param pixels defines the source byte array
  98017. * @param color defines the output color
  98018. */
  98019. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  98020. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  98021. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  98022. var position = (wrappedU + wrappedV * width) * 4;
  98023. color.r = pixels[position] / 255;
  98024. color.g = pixels[position + 1] / 255;
  98025. color.b = pixels[position + 2] / 255;
  98026. color.a = pixels[position + 3] / 255;
  98027. };
  98028. /**
  98029. * Interpolates between a and b via alpha
  98030. * @param a The lower value (returned when alpha = 0)
  98031. * @param b The upper value (returned when alpha = 1)
  98032. * @param alpha The interpolation-factor
  98033. * @return The mixed value
  98034. */
  98035. Tools.Mix = function (a, b, alpha) {
  98036. return a * (1 - alpha) + b * alpha;
  98037. };
  98038. /**
  98039. * Tries to instantiate a new object from a given class name
  98040. * @param className defines the class name to instantiate
  98041. * @returns the new object or null if the system was not able to do the instantiation
  98042. */
  98043. Tools.Instantiate = function (className) {
  98044. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  98045. return Tools.RegisteredExternalClasses[className];
  98046. }
  98047. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  98048. if (internalClass) {
  98049. return internalClass;
  98050. }
  98051. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  98052. var arr = className.split(".");
  98053. var fn = (window || this);
  98054. for (var i = 0, len = arr.length; i < len; i++) {
  98055. fn = fn[arr[i]];
  98056. }
  98057. if (typeof fn !== "function") {
  98058. return null;
  98059. }
  98060. return fn;
  98061. };
  98062. /**
  98063. * Provides a slice function that will work even on IE
  98064. * @param data defines the array to slice
  98065. * @param start defines the start of the data (optional)
  98066. * @param end defines the end of the data (optional)
  98067. * @returns the new sliced array
  98068. */
  98069. Tools.Slice = function (data, start, end) {
  98070. if (data.slice) {
  98071. return data.slice(start, end);
  98072. }
  98073. return Array.prototype.slice.call(data, start, end);
  98074. };
  98075. /**
  98076. * Polyfill for setImmediate
  98077. * @param action defines the action to execute after the current execution block
  98078. */
  98079. Tools.SetImmediate = function (action) {
  98080. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  98081. window.setImmediate(action);
  98082. }
  98083. else {
  98084. setTimeout(action, 1);
  98085. }
  98086. };
  98087. /**
  98088. * Function indicating if a number is an exponent of 2
  98089. * @param value defines the value to test
  98090. * @returns true if the value is an exponent of 2
  98091. */
  98092. Tools.IsExponentOfTwo = function (value) {
  98093. var count = 1;
  98094. do {
  98095. count *= 2;
  98096. } while (count < value);
  98097. return count === value;
  98098. };
  98099. /**
  98100. * Returns the nearest 32-bit single precision float representation of a Number
  98101. * @param value A Number. If the parameter is of a different type, it will get converted
  98102. * to a number or to NaN if it cannot be converted
  98103. * @returns number
  98104. */
  98105. Tools.FloatRound = function (value) {
  98106. if (Math.fround) {
  98107. return Math.fround(value);
  98108. }
  98109. return (Tools._tmpFloatArray[0] = value);
  98110. };
  98111. /**
  98112. * Find the next highest power of two.
  98113. * @param x Number to start search from.
  98114. * @return Next highest power of two.
  98115. */
  98116. Tools.CeilingPOT = function (x) {
  98117. x--;
  98118. x |= x >> 1;
  98119. x |= x >> 2;
  98120. x |= x >> 4;
  98121. x |= x >> 8;
  98122. x |= x >> 16;
  98123. x++;
  98124. return x;
  98125. };
  98126. /**
  98127. * Find the next lowest power of two.
  98128. * @param x Number to start search from.
  98129. * @return Next lowest power of two.
  98130. */
  98131. Tools.FloorPOT = function (x) {
  98132. x = x | (x >> 1);
  98133. x = x | (x >> 2);
  98134. x = x | (x >> 4);
  98135. x = x | (x >> 8);
  98136. x = x | (x >> 16);
  98137. return x - (x >> 1);
  98138. };
  98139. /**
  98140. * Find the nearest power of two.
  98141. * @param x Number to start search from.
  98142. * @return Next nearest power of two.
  98143. */
  98144. Tools.NearestPOT = function (x) {
  98145. var c = Tools.CeilingPOT(x);
  98146. var f = Tools.FloorPOT(x);
  98147. return (c - x) > (x - f) ? f : c;
  98148. };
  98149. /**
  98150. * Get the closest exponent of two
  98151. * @param value defines the value to approximate
  98152. * @param max defines the maximum value to return
  98153. * @param mode defines how to define the closest value
  98154. * @returns closest exponent of two of the given value
  98155. */
  98156. Tools.GetExponentOfTwo = function (value, max, mode) {
  98157. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  98158. var pot;
  98159. switch (mode) {
  98160. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  98161. pot = Tools.FloorPOT(value);
  98162. break;
  98163. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  98164. pot = Tools.NearestPOT(value);
  98165. break;
  98166. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  98167. default:
  98168. pot = Tools.CeilingPOT(value);
  98169. break;
  98170. }
  98171. return Math.min(pot, max);
  98172. };
  98173. /**
  98174. * Extracts the filename from a path
  98175. * @param path defines the path to use
  98176. * @returns the filename
  98177. */
  98178. Tools.GetFilename = function (path) {
  98179. var index = path.lastIndexOf("/");
  98180. if (index < 0) {
  98181. return path;
  98182. }
  98183. return path.substring(index + 1);
  98184. };
  98185. /**
  98186. * Extracts the "folder" part of a path (everything before the filename).
  98187. * @param uri The URI to extract the info from
  98188. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98189. * @returns The "folder" part of the path
  98190. */
  98191. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  98192. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  98193. var index = uri.lastIndexOf("/");
  98194. if (index < 0) {
  98195. if (returnUnchangedIfNoSlash) {
  98196. return uri;
  98197. }
  98198. return "";
  98199. }
  98200. return uri.substring(0, index + 1);
  98201. };
  98202. /**
  98203. * Convert an angle in radians to degrees
  98204. * @param angle defines the angle to convert
  98205. * @returns the angle in degrees
  98206. */
  98207. Tools.ToDegrees = function (angle) {
  98208. return angle * 180 / Math.PI;
  98209. };
  98210. /**
  98211. * Convert an angle in degrees to radians
  98212. * @param angle defines the angle to convert
  98213. * @returns the angle in radians
  98214. */
  98215. Tools.ToRadians = function (angle) {
  98216. return angle * Math.PI / 180;
  98217. };
  98218. /**
  98219. * Encode a buffer to a base64 string
  98220. * @param buffer defines the buffer to encode
  98221. * @returns the encoded string
  98222. */
  98223. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  98224. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  98225. var output = "";
  98226. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  98227. var i = 0;
  98228. var bytes = new Uint8Array(buffer);
  98229. while (i < bytes.length) {
  98230. chr1 = bytes[i++];
  98231. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  98232. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  98233. enc1 = chr1 >> 2;
  98234. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  98235. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  98236. enc4 = chr3 & 63;
  98237. if (isNaN(chr2)) {
  98238. enc3 = enc4 = 64;
  98239. }
  98240. else if (isNaN(chr3)) {
  98241. enc4 = 64;
  98242. }
  98243. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  98244. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  98245. }
  98246. return "data:image/png;base64," + output;
  98247. };
  98248. /**
  98249. * Extracts minimum and maximum values from a list of indexed positions
  98250. * @param positions defines the positions to use
  98251. * @param indices defines the indices to the positions
  98252. * @param indexStart defines the start index
  98253. * @param indexCount defines the end index
  98254. * @param bias defines bias value to add to the result
  98255. * @return minimum and maximum values
  98256. */
  98257. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  98258. if (bias === void 0) { bias = null; }
  98259. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98260. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98261. for (var index = indexStart; index < indexStart + indexCount; index++) {
  98262. var offset = indices[index] * 3;
  98263. var x = positions[offset];
  98264. var y = positions[offset + 1];
  98265. var z = positions[offset + 2];
  98266. minimum.minimizeInPlaceFromFloats(x, y, z);
  98267. maximum.maximizeInPlaceFromFloats(x, y, z);
  98268. }
  98269. if (bias) {
  98270. minimum.x -= minimum.x * bias.x + bias.y;
  98271. minimum.y -= minimum.y * bias.x + bias.y;
  98272. minimum.z -= minimum.z * bias.x + bias.y;
  98273. maximum.x += maximum.x * bias.x + bias.y;
  98274. maximum.y += maximum.y * bias.x + bias.y;
  98275. maximum.z += maximum.z * bias.x + bias.y;
  98276. }
  98277. return {
  98278. minimum: minimum,
  98279. maximum: maximum
  98280. };
  98281. };
  98282. /**
  98283. * Extracts minimum and maximum values from a list of positions
  98284. * @param positions defines the positions to use
  98285. * @param start defines the start index in the positions array
  98286. * @param count defines the number of positions to handle
  98287. * @param bias defines bias value to add to the result
  98288. * @param stride defines the stride size to use (distance between two positions in the positions array)
  98289. * @return minimum and maximum values
  98290. */
  98291. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  98292. if (bias === void 0) { bias = null; }
  98293. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98294. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98295. if (!stride) {
  98296. stride = 3;
  98297. }
  98298. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  98299. var x = positions[offset];
  98300. var y = positions[offset + 1];
  98301. var z = positions[offset + 2];
  98302. minimum.minimizeInPlaceFromFloats(x, y, z);
  98303. maximum.maximizeInPlaceFromFloats(x, y, z);
  98304. }
  98305. if (bias) {
  98306. minimum.x -= minimum.x * bias.x + bias.y;
  98307. minimum.y -= minimum.y * bias.x + bias.y;
  98308. minimum.z -= minimum.z * bias.x + bias.y;
  98309. maximum.x += maximum.x * bias.x + bias.y;
  98310. maximum.y += maximum.y * bias.x + bias.y;
  98311. maximum.z += maximum.z * bias.x + bias.y;
  98312. }
  98313. return {
  98314. minimum: minimum,
  98315. maximum: maximum
  98316. };
  98317. };
  98318. /**
  98319. * Returns an array if obj is not an array
  98320. * @param obj defines the object to evaluate as an array
  98321. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98322. * @returns either obj directly if obj is an array or a new array containing obj
  98323. */
  98324. Tools.MakeArray = function (obj, allowsNullUndefined) {
  98325. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  98326. return null;
  98327. }
  98328. return Array.isArray(obj) ? obj : [obj];
  98329. };
  98330. /**
  98331. * Gets the pointer prefix to use
  98332. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98333. */
  98334. Tools.GetPointerPrefix = function () {
  98335. var eventPrefix = "pointer";
  98336. // Check if pointer events are supported
  98337. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  98338. eventPrefix = "mouse";
  98339. }
  98340. return eventPrefix;
  98341. };
  98342. /**
  98343. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98344. * @param func - the function to be called
  98345. * @param requester - the object that will request the next frame. Falls back to window.
  98346. * @returns frame number
  98347. */
  98348. Tools.QueueNewFrame = function (func, requester) {
  98349. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98350. return setTimeout(func, 16);
  98351. }
  98352. if (!requester) {
  98353. requester = window;
  98354. }
  98355. if (requester.requestAnimationFrame) {
  98356. return requester.requestAnimationFrame(func);
  98357. }
  98358. else if (requester.msRequestAnimationFrame) {
  98359. return requester.msRequestAnimationFrame(func);
  98360. }
  98361. else if (requester.webkitRequestAnimationFrame) {
  98362. return requester.webkitRequestAnimationFrame(func);
  98363. }
  98364. else if (requester.mozRequestAnimationFrame) {
  98365. return requester.mozRequestAnimationFrame(func);
  98366. }
  98367. else if (requester.oRequestAnimationFrame) {
  98368. return requester.oRequestAnimationFrame(func);
  98369. }
  98370. else {
  98371. return window.setTimeout(func, 16);
  98372. }
  98373. };
  98374. /**
  98375. * Ask the browser to promote the current element to fullscreen rendering mode
  98376. * @param element defines the DOM element to promote
  98377. */
  98378. Tools.RequestFullscreen = function (element) {
  98379. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  98380. if (!requestFunction) {
  98381. return;
  98382. }
  98383. requestFunction.call(element);
  98384. };
  98385. /**
  98386. * Asks the browser to exit fullscreen mode
  98387. */
  98388. Tools.ExitFullscreen = function () {
  98389. if (document.exitFullscreen) {
  98390. document.exitFullscreen();
  98391. }
  98392. else if (document.mozCancelFullScreen) {
  98393. document.mozCancelFullScreen();
  98394. }
  98395. else if (document.webkitCancelFullScreen) {
  98396. document.webkitCancelFullScreen();
  98397. }
  98398. else if (document.msCancelFullScreen) {
  98399. document.msCancelFullScreen();
  98400. }
  98401. };
  98402. /**
  98403. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98404. * @param url define the url we are trying
  98405. * @param element define the dom element where to configure the cors policy
  98406. */
  98407. Tools.SetCorsBehavior = function (url, element) {
  98408. if (url && url.indexOf("data:") === 0) {
  98409. return;
  98410. }
  98411. if (Tools.CorsBehavior) {
  98412. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  98413. element.crossOrigin = Tools.CorsBehavior;
  98414. }
  98415. else {
  98416. var result = Tools.CorsBehavior(url);
  98417. if (result) {
  98418. element.crossOrigin = result;
  98419. }
  98420. }
  98421. }
  98422. };
  98423. // External files
  98424. /**
  98425. * Removes unwanted characters from an url
  98426. * @param url defines the url to clean
  98427. * @returns the cleaned url
  98428. */
  98429. Tools.CleanUrl = function (url) {
  98430. url = url.replace(/#/mg, "%23");
  98431. return url;
  98432. };
  98433. /**
  98434. * Loads an image as an HTMLImageElement.
  98435. * @param input url string, ArrayBuffer, or Blob to load
  98436. * @param onLoad callback called when the image successfully loads
  98437. * @param onError callback called when the image fails to load
  98438. * @param offlineProvider offline provider for caching
  98439. * @returns the HTMLImageElement of the loaded image
  98440. */
  98441. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  98442. var url;
  98443. var usingObjectURL = false;
  98444. if (input instanceof ArrayBuffer) {
  98445. url = URL.createObjectURL(new Blob([input]));
  98446. usingObjectURL = true;
  98447. }
  98448. else if (input instanceof Blob) {
  98449. url = URL.createObjectURL(input);
  98450. usingObjectURL = true;
  98451. }
  98452. else {
  98453. url = Tools.CleanUrl(input);
  98454. url = Tools.PreprocessUrl(input);
  98455. }
  98456. var img = new Image();
  98457. Tools.SetCorsBehavior(url, img);
  98458. var loadHandler = function () {
  98459. if (usingObjectURL && img.src) {
  98460. URL.revokeObjectURL(img.src);
  98461. }
  98462. img.removeEventListener("load", loadHandler);
  98463. img.removeEventListener("error", errorHandler);
  98464. onLoad(img);
  98465. };
  98466. var errorHandler = function (err) {
  98467. if (usingObjectURL && img.src) {
  98468. URL.revokeObjectURL(img.src);
  98469. }
  98470. img.removeEventListener("load", loadHandler);
  98471. img.removeEventListener("error", errorHandler);
  98472. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  98473. if (onError) {
  98474. onError("Error while trying to load image: " + input, err);
  98475. }
  98476. };
  98477. img.addEventListener("load", loadHandler);
  98478. img.addEventListener("error", errorHandler);
  98479. var noOfflineSupport = function () {
  98480. img.src = url;
  98481. };
  98482. var loadFromOfflineSupport = function () {
  98483. if (offlineProvider) {
  98484. offlineProvider.loadImage(url, img);
  98485. }
  98486. };
  98487. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  98488. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  98489. }
  98490. else {
  98491. if (url.indexOf("file:") !== -1) {
  98492. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  98493. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  98494. try {
  98495. var blobURL;
  98496. try {
  98497. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98498. }
  98499. catch (ex) {
  98500. // Chrome doesn't support oneTimeOnly parameter
  98501. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98502. }
  98503. img.src = blobURL;
  98504. usingObjectURL = true;
  98505. }
  98506. catch (e) {
  98507. img.src = "";
  98508. }
  98509. return img;
  98510. }
  98511. }
  98512. noOfflineSupport();
  98513. }
  98514. return img;
  98515. };
  98516. /**
  98517. * Loads a file
  98518. * @param url url string, ArrayBuffer, or Blob to load
  98519. * @param onSuccess callback called when the file successfully loads
  98520. * @param onProgress callback called while file is loading (if the server supports this mode)
  98521. * @param offlineProvider defines the offline provider for caching
  98522. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98523. * @param onError callback called when the file fails to load
  98524. * @returns a file request object
  98525. */
  98526. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  98527. url = Tools.CleanUrl(url);
  98528. url = Tools.PreprocessUrl(url);
  98529. // If file and file input are set
  98530. if (url.indexOf("file:") !== -1) {
  98531. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  98532. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  98533. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  98534. }
  98535. }
  98536. var loadUrl = Tools.BaseUrl + url;
  98537. var aborted = false;
  98538. var fileRequest = {
  98539. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98540. abort: function () { return aborted = true; },
  98541. };
  98542. var requestFile = function () {
  98543. var request = new XMLHttpRequest();
  98544. var retryHandle = null;
  98545. fileRequest.abort = function () {
  98546. aborted = true;
  98547. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  98548. request.abort();
  98549. }
  98550. if (retryHandle !== null) {
  98551. clearTimeout(retryHandle);
  98552. retryHandle = null;
  98553. }
  98554. };
  98555. var retryLoop = function (retryIndex) {
  98556. request.open('GET', loadUrl, true);
  98557. if (useArrayBuffer) {
  98558. request.responseType = "arraybuffer";
  98559. }
  98560. if (onProgress) {
  98561. request.addEventListener("progress", onProgress);
  98562. }
  98563. var onLoadEnd = function () {
  98564. request.removeEventListener("loadend", onLoadEnd);
  98565. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98566. fileRequest.onCompleteObservable.clear();
  98567. };
  98568. request.addEventListener("loadend", onLoadEnd);
  98569. var onReadyStateChange = function () {
  98570. if (aborted) {
  98571. return;
  98572. }
  98573. // In case of undefined state in some browsers.
  98574. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  98575. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  98576. request.removeEventListener("readystatechange", onReadyStateChange);
  98577. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  98578. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  98579. return;
  98580. }
  98581. var retryStrategy = Tools.DefaultRetryStrategy;
  98582. if (retryStrategy) {
  98583. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  98584. if (waitTime !== -1) {
  98585. // Prevent the request from completing for retry.
  98586. request.removeEventListener("loadend", onLoadEnd);
  98587. request = new XMLHttpRequest();
  98588. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  98589. return;
  98590. }
  98591. }
  98592. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  98593. if (onError) {
  98594. onError(request, e);
  98595. }
  98596. else {
  98597. throw e;
  98598. }
  98599. }
  98600. };
  98601. request.addEventListener("readystatechange", onReadyStateChange);
  98602. if (Tools.UseCustomRequestHeaders) {
  98603. Tools.InjectCustomRequestHeaders(request);
  98604. }
  98605. request.send();
  98606. };
  98607. retryLoop(0);
  98608. };
  98609. // Caching all files
  98610. if (offlineProvider && offlineProvider.enableSceneOffline) {
  98611. var noOfflineSupport_1 = function (request) {
  98612. if (request && request.status > 400) {
  98613. if (onError) {
  98614. onError(request);
  98615. }
  98616. }
  98617. else {
  98618. if (!aborted) {
  98619. requestFile();
  98620. }
  98621. }
  98622. };
  98623. var loadFromOfflineSupport = function () {
  98624. // TODO: database needs to support aborting and should return a IFileRequest
  98625. if (aborted) {
  98626. return;
  98627. }
  98628. if (offlineProvider) {
  98629. offlineProvider.loadFile(url, function (data) {
  98630. if (!aborted) {
  98631. onSuccess(data);
  98632. }
  98633. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98634. }, onProgress ? function (event) {
  98635. if (!aborted) {
  98636. onProgress(event);
  98637. }
  98638. } : undefined, noOfflineSupport_1, useArrayBuffer);
  98639. }
  98640. };
  98641. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  98642. }
  98643. else {
  98644. requestFile();
  98645. }
  98646. return fileRequest;
  98647. };
  98648. /**
  98649. * Load a script (identified by an url). When the url returns, the
  98650. * content of this file is added into a new script element, attached to the DOM (body element)
  98651. * @param scriptUrl defines the url of the script to laod
  98652. * @param onSuccess defines the callback called when the script is loaded
  98653. * @param onError defines the callback to call if an error occurs
  98654. */
  98655. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  98656. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98657. return;
  98658. }
  98659. var head = document.getElementsByTagName('head')[0];
  98660. var script = document.createElement('script');
  98661. script.type = 'text/javascript';
  98662. script.src = scriptUrl;
  98663. script.onload = function () {
  98664. if (onSuccess) {
  98665. onSuccess();
  98666. }
  98667. };
  98668. script.onerror = function (e) {
  98669. if (onError) {
  98670. onError("Unable to load script '" + scriptUrl + "'", e);
  98671. }
  98672. };
  98673. head.appendChild(script);
  98674. };
  98675. /**
  98676. * Loads a file from a blob
  98677. * @param fileToLoad defines the blob to use
  98678. * @param callback defines the callback to call when data is loaded
  98679. * @param progressCallback defines the callback to call during loading process
  98680. * @returns a file request object
  98681. */
  98682. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  98683. var reader = new FileReader();
  98684. var request = {
  98685. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98686. abort: function () { return reader.abort(); },
  98687. };
  98688. reader.onloadend = function (e) {
  98689. request.onCompleteObservable.notifyObservers(request);
  98690. };
  98691. reader.onload = function (e) {
  98692. //target doesn't have result from ts 1.3
  98693. callback(e.target['result']);
  98694. };
  98695. reader.onprogress = progressCallback;
  98696. reader.readAsDataURL(fileToLoad);
  98697. return request;
  98698. };
  98699. /**
  98700. * Loads a file
  98701. * @param fileToLoad defines the file to load
  98702. * @param callback defines the callback to call when data is loaded
  98703. * @param progressCallBack defines the callback to call during loading process
  98704. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98705. * @returns a file request object
  98706. */
  98707. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  98708. var reader = new FileReader();
  98709. var request = {
  98710. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98711. abort: function () { return reader.abort(); },
  98712. };
  98713. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  98714. reader.onerror = function (e) {
  98715. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  98716. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  98717. };
  98718. reader.onload = function (e) {
  98719. //target doesn't have result from ts 1.3
  98720. callback(e.target['result']);
  98721. };
  98722. if (progressCallBack) {
  98723. reader.onprogress = progressCallBack;
  98724. }
  98725. if (!useArrayBuffer) {
  98726. // Asynchronous read
  98727. reader.readAsText(fileToLoad);
  98728. }
  98729. else {
  98730. reader.readAsArrayBuffer(fileToLoad);
  98731. }
  98732. return request;
  98733. };
  98734. /**
  98735. * Creates a data url from a given string content
  98736. * @param content defines the content to convert
  98737. * @returns the new data url link
  98738. */
  98739. Tools.FileAsURL = function (content) {
  98740. var fileBlob = new Blob([content]);
  98741. var url = window.URL || window.webkitURL;
  98742. var link = url.createObjectURL(fileBlob);
  98743. return link;
  98744. };
  98745. /**
  98746. * Format the given number to a specific decimal format
  98747. * @param value defines the number to format
  98748. * @param decimals defines the number of decimals to use
  98749. * @returns the formatted string
  98750. */
  98751. Tools.Format = function (value, decimals) {
  98752. if (decimals === void 0) { decimals = 2; }
  98753. return value.toFixed(decimals);
  98754. };
  98755. /**
  98756. * Checks if a given vector is inside a specific range
  98757. * @param v defines the vector to test
  98758. * @param min defines the minimum range
  98759. * @param max defines the maximum range
  98760. */
  98761. Tools.CheckExtends = function (v, min, max) {
  98762. min.minimizeInPlace(v);
  98763. max.maximizeInPlace(v);
  98764. };
  98765. /**
  98766. * Tries to copy an object by duplicating every property
  98767. * @param source defines the source object
  98768. * @param destination defines the target object
  98769. * @param doNotCopyList defines a list of properties to avoid
  98770. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98771. */
  98772. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98773. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  98774. };
  98775. /**
  98776. * Gets a boolean indicating if the given object has no own property
  98777. * @param obj defines the object to test
  98778. * @returns true if object has no own property
  98779. */
  98780. Tools.IsEmpty = function (obj) {
  98781. for (var i in obj) {
  98782. if (obj.hasOwnProperty(i)) {
  98783. return false;
  98784. }
  98785. }
  98786. return true;
  98787. };
  98788. /**
  98789. * Function used to register events at window level
  98790. * @param events defines the events to register
  98791. */
  98792. Tools.RegisterTopRootEvents = function (events) {
  98793. for (var index = 0; index < events.length; index++) {
  98794. var event = events[index];
  98795. window.addEventListener(event.name, event.handler, false);
  98796. try {
  98797. if (window.parent) {
  98798. window.parent.addEventListener(event.name, event.handler, false);
  98799. }
  98800. }
  98801. catch (e) {
  98802. // Silently fails...
  98803. }
  98804. }
  98805. };
  98806. /**
  98807. * Function used to unregister events from window level
  98808. * @param events defines the events to unregister
  98809. */
  98810. Tools.UnregisterTopRootEvents = function (events) {
  98811. for (var index = 0; index < events.length; index++) {
  98812. var event = events[index];
  98813. window.removeEventListener(event.name, event.handler);
  98814. try {
  98815. if (window.parent) {
  98816. window.parent.removeEventListener(event.name, event.handler);
  98817. }
  98818. }
  98819. catch (e) {
  98820. // Silently fails...
  98821. }
  98822. }
  98823. };
  98824. /**
  98825. * Dumps the current bound framebuffer
  98826. * @param width defines the rendering width
  98827. * @param height defines the rendering height
  98828. * @param engine defines the hosting engine
  98829. * @param successCallback defines the callback triggered once the data are available
  98830. * @param mimeType defines the mime type of the result
  98831. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98832. */
  98833. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  98834. if (mimeType === void 0) { mimeType = "image/png"; }
  98835. // Read the contents of the framebuffer
  98836. var numberOfChannelsByLine = width * 4;
  98837. var halfHeight = height / 2;
  98838. //Reading datas from WebGL
  98839. var data = engine.readPixels(0, 0, width, height);
  98840. //To flip image on Y axis.
  98841. for (var i = 0; i < halfHeight; i++) {
  98842. for (var j = 0; j < numberOfChannelsByLine; j++) {
  98843. var currentCell = j + i * numberOfChannelsByLine;
  98844. var targetLine = height - i - 1;
  98845. var targetCell = j + targetLine * numberOfChannelsByLine;
  98846. var temp = data[currentCell];
  98847. data[currentCell] = data[targetCell];
  98848. data[targetCell] = temp;
  98849. }
  98850. }
  98851. // Create a 2D canvas to store the result
  98852. if (!screenshotCanvas) {
  98853. screenshotCanvas = document.createElement('canvas');
  98854. }
  98855. screenshotCanvas.width = width;
  98856. screenshotCanvas.height = height;
  98857. var context = screenshotCanvas.getContext('2d');
  98858. if (context) {
  98859. // Copy the pixels to a 2D canvas
  98860. var imageData = context.createImageData(width, height);
  98861. var castData = (imageData.data);
  98862. castData.set(data);
  98863. context.putImageData(imageData, 0, 0);
  98864. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  98865. }
  98866. };
  98867. /**
  98868. * Converts the canvas data to blob.
  98869. * This acts as a polyfill for browsers not supporting the to blob function.
  98870. * @param canvas Defines the canvas to extract the data from
  98871. * @param successCallback Defines the callback triggered once the data are available
  98872. * @param mimeType Defines the mime type of the result
  98873. */
  98874. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  98875. if (mimeType === void 0) { mimeType = "image/png"; }
  98876. // We need HTMLCanvasElement.toBlob for HD screenshots
  98877. if (!canvas.toBlob) {
  98878. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  98879. canvas.toBlob = function (callback, type, quality) {
  98880. var _this = this;
  98881. setTimeout(function () {
  98882. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  98883. for (var i = 0; i < len; i++) {
  98884. arr[i] = binStr.charCodeAt(i);
  98885. }
  98886. callback(new Blob([arr]));
  98887. });
  98888. };
  98889. }
  98890. canvas.toBlob(function (blob) {
  98891. successCallback(blob);
  98892. }, mimeType);
  98893. };
  98894. /**
  98895. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98896. * @param successCallback defines the callback triggered once the data are available
  98897. * @param mimeType defines the mime type of the result
  98898. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98899. */
  98900. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  98901. if (mimeType === void 0) { mimeType = "image/png"; }
  98902. if (successCallback) {
  98903. var base64Image = screenshotCanvas.toDataURL(mimeType);
  98904. successCallback(base64Image);
  98905. }
  98906. else {
  98907. this.ToBlob(screenshotCanvas, function (blob) {
  98908. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  98909. if (("download" in document.createElement("a"))) {
  98910. if (!fileName) {
  98911. var date = new Date();
  98912. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  98913. fileName = "screenshot_" + stringDate + ".png";
  98914. }
  98915. Tools.Download(blob, fileName);
  98916. }
  98917. else {
  98918. var url = URL.createObjectURL(blob);
  98919. var newWindow = window.open("");
  98920. if (!newWindow) {
  98921. return;
  98922. }
  98923. var img = newWindow.document.createElement("img");
  98924. img.onload = function () {
  98925. // no longer need to read the blob so it's revoked
  98926. URL.revokeObjectURL(url);
  98927. };
  98928. img.src = url;
  98929. newWindow.document.body.appendChild(img);
  98930. }
  98931. }, mimeType);
  98932. }
  98933. };
  98934. /**
  98935. * Downloads a blob in the browser
  98936. * @param blob defines the blob to download
  98937. * @param fileName defines the name of the downloaded file
  98938. */
  98939. Tools.Download = function (blob, fileName) {
  98940. if (navigator && navigator.msSaveBlob) {
  98941. navigator.msSaveBlob(blob, fileName);
  98942. return;
  98943. }
  98944. var url = window.URL.createObjectURL(blob);
  98945. var a = document.createElement("a");
  98946. document.body.appendChild(a);
  98947. a.style.display = "none";
  98948. a.href = url;
  98949. a.download = fileName;
  98950. a.addEventListener("click", function () {
  98951. if (a.parentElement) {
  98952. a.parentElement.removeChild(a);
  98953. }
  98954. });
  98955. a.click();
  98956. window.URL.revokeObjectURL(url);
  98957. };
  98958. /**
  98959. * Captures a screenshot of the current rendering
  98960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98961. * @param engine defines the rendering engine
  98962. * @param camera defines the source camera
  98963. * @param size This parameter can be set to a single number or to an object with the
  98964. * following (optional) properties: precision, width, height. If a single number is passed,
  98965. * it will be used for both width and height. If an object is passed, the screenshot size
  98966. * will be derived from the parameters. The precision property is a multiplier allowing
  98967. * rendering at a higher or lower resolution
  98968. * @param successCallback defines the callback receives a single parameter which contains the
  98969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98970. * src parameter of an <img> to display it
  98971. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98972. * Check your browser for supported MIME types
  98973. */
  98974. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  98975. if (mimeType === void 0) { mimeType = "image/png"; }
  98976. throw "Import ScreenshotTools before creating screenshot.";
  98977. };
  98978. /**
  98979. * Generates an image screenshot from the specified camera.
  98980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98981. * @param engine The engine to use for rendering
  98982. * @param camera The camera to use for rendering
  98983. * @param size This parameter can be set to a single number or to an object with the
  98984. * following (optional) properties: precision, width, height. If a single number is passed,
  98985. * it will be used for both width and height. If an object is passed, the screenshot size
  98986. * will be derived from the parameters. The precision property is a multiplier allowing
  98987. * rendering at a higher or lower resolution
  98988. * @param successCallback The callback receives a single parameter which contains the
  98989. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98990. * src parameter of an <img> to display it
  98991. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98992. * Check your browser for supported MIME types
  98993. * @param samples Texture samples (default: 1)
  98994. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98995. * @param fileName A name for for the downloaded file.
  98996. */
  98997. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  98998. if (mimeType === void 0) { mimeType = "image/png"; }
  98999. if (samples === void 0) { samples = 1; }
  99000. if (antialiasing === void 0) { antialiasing = false; }
  99001. throw "Import ScreenshotTools before creating screenshot.";
  99002. };
  99003. /**
  99004. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99005. * Be aware Math.random() could cause collisions, but:
  99006. * "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"
  99007. * @returns a pseudo random id
  99008. */
  99009. Tools.RandomId = function () {
  99010. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  99011. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  99012. return v.toString(16);
  99013. });
  99014. };
  99015. /**
  99016. * Test if the given uri is a base64 string
  99017. * @param uri The uri to test
  99018. * @return True if the uri is a base64 string or false otherwise
  99019. */
  99020. Tools.IsBase64 = function (uri) {
  99021. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  99022. };
  99023. /**
  99024. * Decode the given base64 uri.
  99025. * @param uri The uri to decode
  99026. * @return The decoded base64 data.
  99027. */
  99028. Tools.DecodeBase64 = function (uri) {
  99029. var decodedString = atob(uri.split(",")[1]);
  99030. var bufferLength = decodedString.length;
  99031. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  99032. for (var i = 0; i < bufferLength; i++) {
  99033. bufferView[i] = decodedString.charCodeAt(i);
  99034. }
  99035. return bufferView.buffer;
  99036. };
  99037. Object.defineProperty(Tools, "errorsCount", {
  99038. /**
  99039. * Gets a value indicating the number of loading errors
  99040. * @ignorenaming
  99041. */
  99042. get: function () {
  99043. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  99044. },
  99045. enumerable: true,
  99046. configurable: true
  99047. });
  99048. /**
  99049. * Log a message to the console
  99050. * @param message defines the message to log
  99051. */
  99052. Tools.Log = function (message) {
  99053. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  99054. };
  99055. /**
  99056. * Write a warning message to the console
  99057. * @param message defines the message to log
  99058. */
  99059. Tools.Warn = function (message) {
  99060. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  99061. };
  99062. /**
  99063. * Write an error message to the console
  99064. * @param message defines the message to log
  99065. */
  99066. Tools.Error = function (message) {
  99067. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  99068. };
  99069. Object.defineProperty(Tools, "LogCache", {
  99070. /**
  99071. * Gets current log cache (list of logs)
  99072. */
  99073. get: function () {
  99074. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  99075. },
  99076. enumerable: true,
  99077. configurable: true
  99078. });
  99079. /**
  99080. * Clears the log cache
  99081. */
  99082. Tools.ClearLogCache = function () {
  99083. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  99084. };
  99085. Object.defineProperty(Tools, "LogLevels", {
  99086. /**
  99087. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99088. */
  99089. set: function (level) {
  99090. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  99091. },
  99092. enumerable: true,
  99093. configurable: true
  99094. });
  99095. /**
  99096. * Checks if the loaded document was accessed via `file:`-Protocol.
  99097. * @returns boolean
  99098. */
  99099. Tools.IsFileURL = function () {
  99100. return location.protocol === "file:";
  99101. };
  99102. Object.defineProperty(Tools, "PerformanceLogLevel", {
  99103. /**
  99104. * Sets the current performance log level
  99105. */
  99106. set: function (level) {
  99107. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  99108. Tools.StartPerformanceCounter = Tools._StartUserMark;
  99109. Tools.EndPerformanceCounter = Tools._EndUserMark;
  99110. return;
  99111. }
  99112. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  99113. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  99114. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  99115. return;
  99116. }
  99117. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99118. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99119. },
  99120. enumerable: true,
  99121. configurable: true
  99122. });
  99123. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  99124. };
  99125. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  99126. };
  99127. Tools._StartUserMark = function (counterName, condition) {
  99128. if (condition === void 0) { condition = true; }
  99129. if (!Tools._performance) {
  99130. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99131. return;
  99132. }
  99133. Tools._performance = window.performance;
  99134. }
  99135. if (!condition || !Tools._performance.mark) {
  99136. return;
  99137. }
  99138. Tools._performance.mark(counterName + "-Begin");
  99139. };
  99140. Tools._EndUserMark = function (counterName, condition) {
  99141. if (condition === void 0) { condition = true; }
  99142. if (!condition || !Tools._performance.mark) {
  99143. return;
  99144. }
  99145. Tools._performance.mark(counterName + "-End");
  99146. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  99147. };
  99148. Tools._StartPerformanceConsole = function (counterName, condition) {
  99149. if (condition === void 0) { condition = true; }
  99150. if (!condition) {
  99151. return;
  99152. }
  99153. Tools._StartUserMark(counterName, condition);
  99154. if (console.time) {
  99155. console.time(counterName);
  99156. }
  99157. };
  99158. Tools._EndPerformanceConsole = function (counterName, condition) {
  99159. if (condition === void 0) { condition = true; }
  99160. if (!condition) {
  99161. return;
  99162. }
  99163. Tools._EndUserMark(counterName, condition);
  99164. if (console.time) {
  99165. console.timeEnd(counterName);
  99166. }
  99167. };
  99168. /**
  99169. * Injects the @see CustomRequestHeaders into the given request
  99170. * @param request the request that should be used for injection
  99171. */
  99172. Tools.InjectCustomRequestHeaders = function (request) {
  99173. for (var key in Tools.CustomRequestHeaders) {
  99174. var val = Tools.CustomRequestHeaders[key];
  99175. if (val) {
  99176. request.setRequestHeader(key, val);
  99177. }
  99178. }
  99179. };
  99180. Object.defineProperty(Tools, "Now", {
  99181. /**
  99182. * Gets either window.performance.now() if supported or Date.now() else
  99183. */
  99184. get: function () {
  99185. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99186. },
  99187. enumerable: true,
  99188. configurable: true
  99189. });
  99190. /**
  99191. * This method will return the name of the class used to create the instance of the given object.
  99192. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99193. * @param object the object to get the class name from
  99194. * @param isType defines if the object is actually a type
  99195. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99196. */
  99197. Tools.GetClassName = function (object, isType) {
  99198. if (isType === void 0) { isType = false; }
  99199. var name = null;
  99200. if (!isType && object.getClassName) {
  99201. name = object.getClassName();
  99202. }
  99203. else {
  99204. if (object instanceof Object) {
  99205. var classObj = isType ? object : Object.getPrototypeOf(object);
  99206. name = classObj.constructor["__bjsclassName__"];
  99207. }
  99208. if (!name) {
  99209. name = typeof object;
  99210. }
  99211. }
  99212. return name;
  99213. };
  99214. /**
  99215. * Gets the first element of an array satisfying a given predicate
  99216. * @param array defines the array to browse
  99217. * @param predicate defines the predicate to use
  99218. * @returns null if not found or the element
  99219. */
  99220. Tools.First = function (array, predicate) {
  99221. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  99222. var el = array_1[_i];
  99223. if (predicate(el)) {
  99224. return el;
  99225. }
  99226. }
  99227. return null;
  99228. };
  99229. /**
  99230. * This method will return the name of the full name of the class, including its owning module (if any).
  99231. * 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).
  99232. * @param object the object to get the class name from
  99233. * @param isType defines if the object is actually a type
  99234. * @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.
  99235. * @ignorenaming
  99236. */
  99237. Tools.getFullClassName = function (object, isType) {
  99238. if (isType === void 0) { isType = false; }
  99239. var className = null;
  99240. var moduleName = null;
  99241. if (!isType && object.getClassName) {
  99242. className = object.getClassName();
  99243. }
  99244. else {
  99245. if (object instanceof Object) {
  99246. var classObj = isType ? object : Object.getPrototypeOf(object);
  99247. className = classObj.constructor["__bjsclassName__"];
  99248. moduleName = classObj.constructor["__bjsmoduleName__"];
  99249. }
  99250. if (!className) {
  99251. className = typeof object;
  99252. }
  99253. }
  99254. if (!className) {
  99255. return null;
  99256. }
  99257. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  99258. };
  99259. /**
  99260. * Returns a promise that resolves after the given amount of time.
  99261. * @param delay Number of milliseconds to delay
  99262. * @returns Promise that resolves after the given amount of time
  99263. */
  99264. Tools.DelayAsync = function (delay) {
  99265. return new Promise(function (resolve) {
  99266. setTimeout(function () {
  99267. resolve();
  99268. }, delay);
  99269. });
  99270. };
  99271. /**
  99272. * Gets the current gradient from an array of IValueGradient
  99273. * @param ratio defines the current ratio to get
  99274. * @param gradients defines the array of IValueGradient
  99275. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99276. */
  99277. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  99278. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  99279. var currentGradient = gradients[gradientIndex];
  99280. var nextGradient = gradients[gradientIndex + 1];
  99281. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  99282. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  99283. updateFunc(currentGradient, nextGradient, scale);
  99284. return;
  99285. }
  99286. }
  99287. // Use last index if over
  99288. var lastIndex = gradients.length - 1;
  99289. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  99290. };
  99291. /**
  99292. * Gets or sets the base URL to use to load assets
  99293. */
  99294. Tools.BaseUrl = "";
  99295. /**
  99296. * Enable/Disable Custom HTTP Request Headers globally.
  99297. * default = false
  99298. * @see CustomRequestHeaders
  99299. */
  99300. Tools.UseCustomRequestHeaders = false;
  99301. /**
  99302. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99303. * i.e. when loading files, where the server/service expects an Authorization header.
  99304. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  99305. */
  99306. Tools.CustomRequestHeaders = {};
  99307. /**
  99308. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99309. */
  99310. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  99311. /**
  99312. * Default behaviour for cors in the application.
  99313. * It can be a string if the expected behavior is identical in the entire app.
  99314. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99315. */
  99316. Tools.CorsBehavior = "anonymous";
  99317. /**
  99318. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99319. * @ignorenaming
  99320. */
  99321. Tools.UseFallbackTexture = true;
  99322. /**
  99323. * Use this object to register external classes like custom textures or material
  99324. * to allow the laoders to instantiate them
  99325. */
  99326. Tools.RegisteredExternalClasses = {};
  99327. /**
  99328. * Texture content used if a texture cannot loaded
  99329. * @ignorenaming
  99330. */
  99331. 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";
  99332. Tools._tmpFloatArray = new Float32Array(1);
  99333. /**
  99334. * Extracts text content from a DOM element hierarchy
  99335. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99336. */
  99337. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  99338. /**
  99339. * Gets or sets a function used to pre-process url before using them to load assets
  99340. */
  99341. Tools.PreprocessUrl = function (url) {
  99342. return url;
  99343. };
  99344. // Logs
  99345. /**
  99346. * No log
  99347. */
  99348. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  99349. /**
  99350. * Only message logs
  99351. */
  99352. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  99353. /**
  99354. * Only warning logs
  99355. */
  99356. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  99357. /**
  99358. * Only error logs
  99359. */
  99360. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  99361. /**
  99362. * All logs
  99363. */
  99364. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  99365. /**
  99366. * Checks if the window object exists
  99367. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99368. */
  99369. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  99370. // Performances
  99371. /**
  99372. * No performance log
  99373. */
  99374. Tools.PerformanceNoneLogLevel = 0;
  99375. /**
  99376. * Use user marks to log performance
  99377. */
  99378. Tools.PerformanceUserMarkLogLevel = 1;
  99379. /**
  99380. * Log performance to the console
  99381. */
  99382. Tools.PerformanceConsoleLogLevel = 2;
  99383. /**
  99384. * Starts a performance counter
  99385. */
  99386. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99387. /**
  99388. * Ends a specific performance coutner
  99389. */
  99390. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99391. return Tools;
  99392. }());
  99393. /**
  99394. * This class is used to track a performance counter which is number based.
  99395. * The user has access to many properties which give statistics of different nature.
  99396. *
  99397. * The implementer can track two kinds of Performance Counter: time and count.
  99398. * 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.
  99399. * 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.
  99400. */
  99401. var PerfCounter = /** @class */ (function () {
  99402. /**
  99403. * Creates a new counter
  99404. */
  99405. function PerfCounter() {
  99406. this._startMonitoringTime = 0;
  99407. this._min = 0;
  99408. this._max = 0;
  99409. this._average = 0;
  99410. this._lastSecAverage = 0;
  99411. this._current = 0;
  99412. this._totalValueCount = 0;
  99413. this._totalAccumulated = 0;
  99414. this._lastSecAccumulated = 0;
  99415. this._lastSecTime = 0;
  99416. this._lastSecValueCount = 0;
  99417. }
  99418. Object.defineProperty(PerfCounter.prototype, "min", {
  99419. /**
  99420. * Returns the smallest value ever
  99421. */
  99422. get: function () {
  99423. return this._min;
  99424. },
  99425. enumerable: true,
  99426. configurable: true
  99427. });
  99428. Object.defineProperty(PerfCounter.prototype, "max", {
  99429. /**
  99430. * Returns the biggest value ever
  99431. */
  99432. get: function () {
  99433. return this._max;
  99434. },
  99435. enumerable: true,
  99436. configurable: true
  99437. });
  99438. Object.defineProperty(PerfCounter.prototype, "average", {
  99439. /**
  99440. * Returns the average value since the performance counter is running
  99441. */
  99442. get: function () {
  99443. return this._average;
  99444. },
  99445. enumerable: true,
  99446. configurable: true
  99447. });
  99448. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  99449. /**
  99450. * Returns the average value of the last second the counter was monitored
  99451. */
  99452. get: function () {
  99453. return this._lastSecAverage;
  99454. },
  99455. enumerable: true,
  99456. configurable: true
  99457. });
  99458. Object.defineProperty(PerfCounter.prototype, "current", {
  99459. /**
  99460. * Returns the current value
  99461. */
  99462. get: function () {
  99463. return this._current;
  99464. },
  99465. enumerable: true,
  99466. configurable: true
  99467. });
  99468. Object.defineProperty(PerfCounter.prototype, "total", {
  99469. /**
  99470. * Gets the accumulated total
  99471. */
  99472. get: function () {
  99473. return this._totalAccumulated;
  99474. },
  99475. enumerable: true,
  99476. configurable: true
  99477. });
  99478. Object.defineProperty(PerfCounter.prototype, "count", {
  99479. /**
  99480. * Gets the total value count
  99481. */
  99482. get: function () {
  99483. return this._totalValueCount;
  99484. },
  99485. enumerable: true,
  99486. configurable: true
  99487. });
  99488. /**
  99489. * Call this method to start monitoring a new frame.
  99490. * 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.
  99491. */
  99492. PerfCounter.prototype.fetchNewFrame = function () {
  99493. this._totalValueCount++;
  99494. this._current = 0;
  99495. this._lastSecValueCount++;
  99496. };
  99497. /**
  99498. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99499. * @param newCount the count value to add to the monitored count
  99500. * @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.
  99501. */
  99502. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  99503. if (!PerfCounter.Enabled) {
  99504. return;
  99505. }
  99506. this._current += newCount;
  99507. if (fetchResult) {
  99508. this._fetchResult();
  99509. }
  99510. };
  99511. /**
  99512. * Start monitoring this performance counter
  99513. */
  99514. PerfCounter.prototype.beginMonitoring = function () {
  99515. if (!PerfCounter.Enabled) {
  99516. return;
  99517. }
  99518. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99519. };
  99520. /**
  99521. * Compute the time lapsed since the previous beginMonitoring() call.
  99522. * @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
  99523. */
  99524. PerfCounter.prototype.endMonitoring = function (newFrame) {
  99525. if (newFrame === void 0) { newFrame = true; }
  99526. if (!PerfCounter.Enabled) {
  99527. return;
  99528. }
  99529. if (newFrame) {
  99530. this.fetchNewFrame();
  99531. }
  99532. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99533. this._current = currentTime - this._startMonitoringTime;
  99534. if (newFrame) {
  99535. this._fetchResult();
  99536. }
  99537. };
  99538. PerfCounter.prototype._fetchResult = function () {
  99539. this._totalAccumulated += this._current;
  99540. this._lastSecAccumulated += this._current;
  99541. // Min/Max update
  99542. this._min = Math.min(this._min, this._current);
  99543. this._max = Math.max(this._max, this._current);
  99544. this._average = this._totalAccumulated / this._totalValueCount;
  99545. // Reset last sec?
  99546. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99547. if ((now - this._lastSecTime) > 1000) {
  99548. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  99549. this._lastSecTime = now;
  99550. this._lastSecAccumulated = 0;
  99551. this._lastSecValueCount = 0;
  99552. }
  99553. };
  99554. /**
  99555. * Gets or sets a global boolean to turn on and off all the counters
  99556. */
  99557. PerfCounter.Enabled = true;
  99558. return PerfCounter;
  99559. }());
  99560. /**
  99561. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99562. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99563. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99564. * @param name The name of the class, case should be preserved
  99565. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99566. */
  99567. function className(name, module) {
  99568. return function (target) {
  99569. target["__bjsclassName__"] = name;
  99570. target["__bjsmoduleName__"] = (module != null) ? module : null;
  99571. };
  99572. }
  99573. /**
  99574. * An implementation of a loop for asynchronous functions.
  99575. */
  99576. var AsyncLoop = /** @class */ (function () {
  99577. /**
  99578. * Constructor.
  99579. * @param iterations the number of iterations.
  99580. * @param func the function to run each iteration
  99581. * @param successCallback the callback that will be called upon succesful execution
  99582. * @param offset starting offset.
  99583. */
  99584. function AsyncLoop(
  99585. /**
  99586. * Defines the number of iterations for the loop
  99587. */
  99588. iterations, func, successCallback, offset) {
  99589. if (offset === void 0) { offset = 0; }
  99590. this.iterations = iterations;
  99591. this.index = offset - 1;
  99592. this._done = false;
  99593. this._fn = func;
  99594. this._successCallback = successCallback;
  99595. }
  99596. /**
  99597. * Execute the next iteration. Must be called after the last iteration was finished.
  99598. */
  99599. AsyncLoop.prototype.executeNext = function () {
  99600. if (!this._done) {
  99601. if (this.index + 1 < this.iterations) {
  99602. ++this.index;
  99603. this._fn(this);
  99604. }
  99605. else {
  99606. this.breakLoop();
  99607. }
  99608. }
  99609. };
  99610. /**
  99611. * Break the loop and run the success callback.
  99612. */
  99613. AsyncLoop.prototype.breakLoop = function () {
  99614. this._done = true;
  99615. this._successCallback();
  99616. };
  99617. /**
  99618. * Create and run an async loop.
  99619. * @param iterations the number of iterations.
  99620. * @param fn the function to run each iteration
  99621. * @param successCallback the callback that will be called upon succesful execution
  99622. * @param offset starting offset.
  99623. * @returns the created async loop object
  99624. */
  99625. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  99626. if (offset === void 0) { offset = 0; }
  99627. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  99628. loop.executeNext();
  99629. return loop;
  99630. };
  99631. /**
  99632. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99633. * @param iterations total number of iterations
  99634. * @param syncedIterations number of synchronous iterations in each async iteration.
  99635. * @param fn the function to call each iteration.
  99636. * @param callback a success call back that will be called when iterating stops.
  99637. * @param breakFunction a break condition (optional)
  99638. * @param timeout timeout settings for the setTimeout function. default - 0.
  99639. * @returns the created async loop object
  99640. */
  99641. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  99642. if (timeout === void 0) { timeout = 0; }
  99643. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  99644. if (breakFunction && breakFunction()) {
  99645. loop.breakLoop();
  99646. }
  99647. else {
  99648. setTimeout(function () {
  99649. for (var i = 0; i < syncedIterations; ++i) {
  99650. var iteration = (loop.index * syncedIterations) + i;
  99651. if (iteration >= iterations) {
  99652. break;
  99653. }
  99654. fn(iteration);
  99655. if (breakFunction && breakFunction()) {
  99656. loop.breakLoop();
  99657. break;
  99658. }
  99659. }
  99660. loop.executeNext();
  99661. }, timeout);
  99662. }
  99663. }, callback);
  99664. };
  99665. return AsyncLoop;
  99666. }());
  99667. /***/ }),
  99668. /***/ "./Misc/typeStore.ts":
  99669. /*!***************************!*\
  99670. !*** ./Misc/typeStore.ts ***!
  99671. \***************************/
  99672. /*! exports provided: _TypeStore */
  99673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99674. "use strict";
  99675. __webpack_require__.r(__webpack_exports__);
  99676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  99677. /** @hidden */
  99678. var _TypeStore = /** @class */ (function () {
  99679. function _TypeStore() {
  99680. }
  99681. /** @hidden */
  99682. _TypeStore.GetClass = function (fqdn) {
  99683. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  99684. return this.RegisteredTypes[fqdn];
  99685. }
  99686. return null;
  99687. };
  99688. /** @hidden */
  99689. _TypeStore.RegisteredTypes = {};
  99690. return _TypeStore;
  99691. }());
  99692. /***/ }),
  99693. /***/ "./Misc/videoRecorder.ts":
  99694. /*!*******************************!*\
  99695. !*** ./Misc/videoRecorder.ts ***!
  99696. \*******************************/
  99697. /*! exports provided: VideoRecorder */
  99698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99699. "use strict";
  99700. __webpack_require__.r(__webpack_exports__);
  99701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  99702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99703. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99704. /**
  99705. * This can helps recording videos from BabylonJS.
  99706. * This is based on the available WebRTC functionalities of the browser.
  99707. *
  99708. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  99709. */
  99710. var VideoRecorder = /** @class */ (function () {
  99711. /**
  99712. * Create a new VideoCapture object which can help converting what you see in Babylon to
  99713. * a video file.
  99714. * @param engine Defines the BabylonJS Engine you wish to record
  99715. * @param options Defines options that can be used to customized the capture
  99716. */
  99717. function VideoRecorder(engine, options) {
  99718. if (options === void 0) { options = null; }
  99719. if (!VideoRecorder.IsSupported(engine)) {
  99720. throw "Your browser does not support recording so far.";
  99721. }
  99722. var canvas = engine.getRenderingCanvas();
  99723. if (!canvas) {
  99724. throw "The babylon engine must have a canvas to be recorded";
  99725. }
  99726. this._canvas = canvas;
  99727. this._canvas.isRecording = false;
  99728. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  99729. var stream = this._canvas.captureStream(this._options.fps);
  99730. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  99731. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  99732. this._mediaRecorder.onerror = this._handleError.bind(this);
  99733. this._mediaRecorder.onstop = this._handleStop.bind(this);
  99734. }
  99735. /**
  99736. * Returns wehther or not the VideoRecorder is available in your browser.
  99737. * @param engine Defines the Babylon Engine to check the support for
  99738. * @returns true if supported otherwise false
  99739. */
  99740. VideoRecorder.IsSupported = function (engine) {
  99741. var canvas = engine.getRenderingCanvas();
  99742. return (!!canvas && typeof canvas.captureStream === "function");
  99743. };
  99744. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  99745. /**
  99746. * True wether a recording is already in progress.
  99747. */
  99748. get: function () {
  99749. return !!this._canvas && this._canvas.isRecording;
  99750. },
  99751. enumerable: true,
  99752. configurable: true
  99753. });
  99754. /**
  99755. * Stops the current recording before the default capture timeout passed in the startRecording
  99756. * functions.
  99757. */
  99758. VideoRecorder.prototype.stopRecording = function () {
  99759. if (!this._canvas || !this._mediaRecorder) {
  99760. return;
  99761. }
  99762. if (!this.isRecording) {
  99763. return;
  99764. }
  99765. this._canvas.isRecording = false;
  99766. this._mediaRecorder.stop();
  99767. };
  99768. /**
  99769. * Starts recording the canvas for a max duration specified in parameters.
  99770. * @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.
  99771. * @param maxDuration Defines the maximum recording time in seconds.
  99772. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  99773. * @return a promise callback at the end of the recording with the video data in Blob.
  99774. */
  99775. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  99776. var _this = this;
  99777. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  99778. if (maxDuration === void 0) { maxDuration = 7; }
  99779. if (!this._canvas || !this._mediaRecorder) {
  99780. throw "Recorder has already been disposed";
  99781. }
  99782. if (this.isRecording) {
  99783. throw "Recording already in progress";
  99784. }
  99785. if (maxDuration > 0) {
  99786. setTimeout(function () {
  99787. _this.stopRecording();
  99788. }, maxDuration * 1000);
  99789. }
  99790. this._fileName = fileName;
  99791. this._recordedChunks = [];
  99792. this._resolve = null;
  99793. this._reject = null;
  99794. this._canvas.isRecording = true;
  99795. this._mediaRecorder.start(this._options.recordChunckSize);
  99796. return new Promise(function (resolve, reject) {
  99797. _this._resolve = resolve;
  99798. _this._reject = reject;
  99799. });
  99800. };
  99801. /**
  99802. * Releases internal resources used during the recording.
  99803. */
  99804. VideoRecorder.prototype.dispose = function () {
  99805. this._canvas = null;
  99806. this._mediaRecorder = null;
  99807. this._recordedChunks = [];
  99808. this._fileName = null;
  99809. this._resolve = null;
  99810. this._reject = null;
  99811. };
  99812. VideoRecorder.prototype._handleDataAvailable = function (event) {
  99813. if (event.data.size > 0) {
  99814. this._recordedChunks.push(event.data);
  99815. }
  99816. };
  99817. VideoRecorder.prototype._handleError = function (event) {
  99818. this.stopRecording();
  99819. if (this._reject) {
  99820. this._reject(event.error);
  99821. }
  99822. else {
  99823. throw new event.error();
  99824. }
  99825. };
  99826. VideoRecorder.prototype._handleStop = function () {
  99827. this.stopRecording();
  99828. var superBuffer = new Blob(this._recordedChunks);
  99829. if (this._resolve) {
  99830. this._resolve(superBuffer);
  99831. }
  99832. window.URL.createObjectURL(superBuffer);
  99833. if (this._fileName) {
  99834. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  99835. }
  99836. };
  99837. VideoRecorder._defaultOptions = {
  99838. mimeType: "video/webm",
  99839. fps: 25,
  99840. recordChunckSize: 3000
  99841. };
  99842. return VideoRecorder;
  99843. }());
  99844. /***/ }),
  99845. /***/ "./Misc/virtualJoystick.ts":
  99846. /*!*********************************!*\
  99847. !*** ./Misc/virtualJoystick.ts ***!
  99848. \*********************************/
  99849. /*! exports provided: JoystickAxis, VirtualJoystick */
  99850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99851. "use strict";
  99852. __webpack_require__.r(__webpack_exports__);
  99853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  99854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  99855. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99856. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  99857. // Mainly based on these 2 articles :
  99858. // 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
  99859. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  99860. /**
  99861. * Defines the potential axis of a Joystick
  99862. */
  99863. var JoystickAxis;
  99864. (function (JoystickAxis) {
  99865. /** X axis */
  99866. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  99867. /** Y axis */
  99868. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  99869. /** Z axis */
  99870. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  99871. })(JoystickAxis || (JoystickAxis = {}));
  99872. /**
  99873. * Class used to define virtual joystick (used in touch mode)
  99874. */
  99875. var VirtualJoystick = /** @class */ (function () {
  99876. /**
  99877. * Creates a new virtual joystick
  99878. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99879. */
  99880. function VirtualJoystick(leftJoystick) {
  99881. var _this = this;
  99882. if (leftJoystick) {
  99883. this._leftJoystick = true;
  99884. }
  99885. else {
  99886. this._leftJoystick = false;
  99887. }
  99888. VirtualJoystick._globalJoystickIndex++;
  99889. // By default left & right arrow keys are moving the X
  99890. // and up & down keys are moving the Y
  99891. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  99892. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  99893. this.reverseLeftRight = false;
  99894. this.reverseUpDown = false;
  99895. // collections of pointers
  99896. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  99897. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99898. this._joystickSensibility = 25;
  99899. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99900. this._onResize = function (evt) {
  99901. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  99902. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99903. if (VirtualJoystick.Canvas) {
  99904. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  99905. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  99906. }
  99907. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  99908. };
  99909. // injecting a canvas element on top of the canvas 3D game
  99910. if (!VirtualJoystick.Canvas) {
  99911. window.addEventListener("resize", this._onResize, false);
  99912. VirtualJoystick.Canvas = document.createElement("canvas");
  99913. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  99914. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99915. VirtualJoystick.Canvas.width = window.innerWidth;
  99916. VirtualJoystick.Canvas.height = window.innerHeight;
  99917. VirtualJoystick.Canvas.style.width = "100%";
  99918. VirtualJoystick.Canvas.style.height = "100%";
  99919. VirtualJoystick.Canvas.style.position = "absolute";
  99920. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  99921. VirtualJoystick.Canvas.style.top = "0px";
  99922. VirtualJoystick.Canvas.style.left = "0px";
  99923. VirtualJoystick.Canvas.style.zIndex = "5";
  99924. VirtualJoystick.Canvas.style.msTouchAction = "none";
  99925. // Support for jQuery PEP polyfill
  99926. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  99927. var context = VirtualJoystick.Canvas.getContext('2d');
  99928. if (!context) {
  99929. throw new Error("Unable to create canvas for virtual joystick");
  99930. }
  99931. VirtualJoystick.vjCanvasContext = context;
  99932. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  99933. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99934. document.body.appendChild(VirtualJoystick.Canvas);
  99935. }
  99936. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  99937. this.pressed = false;
  99938. // default joystick color
  99939. this._joystickColor = "cyan";
  99940. this._joystickPointerID = -1;
  99941. // current joystick position
  99942. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99943. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99944. // origin joystick position
  99945. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99946. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99947. this._onPointerDownHandlerRef = function (evt) {
  99948. _this._onPointerDown(evt);
  99949. };
  99950. this._onPointerMoveHandlerRef = function (evt) {
  99951. _this._onPointerMove(evt);
  99952. };
  99953. this._onPointerUpHandlerRef = function (evt) {
  99954. _this._onPointerUp(evt);
  99955. };
  99956. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  99957. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  99958. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  99959. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  99960. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  99961. evt.preventDefault(); // Disables system menu
  99962. }, false);
  99963. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99964. }
  99965. /**
  99966. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99967. * @param newJoystickSensibility defines the new sensibility
  99968. */
  99969. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  99970. this._joystickSensibility = newJoystickSensibility;
  99971. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99972. };
  99973. VirtualJoystick.prototype._onPointerDown = function (e) {
  99974. var positionOnScreenCondition;
  99975. e.preventDefault();
  99976. if (this._leftJoystick === true) {
  99977. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  99978. }
  99979. else {
  99980. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  99981. }
  99982. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  99983. // First contact will be dedicated to the virtual joystick
  99984. this._joystickPointerID = e.pointerId;
  99985. this._joystickPointerStartPos.x = e.clientX;
  99986. this._joystickPointerStartPos.y = e.clientY;
  99987. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  99988. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  99989. this._deltaJoystickVector.x = 0;
  99990. this._deltaJoystickVector.y = 0;
  99991. this.pressed = true;
  99992. this._touches.add(e.pointerId.toString(), e);
  99993. }
  99994. else {
  99995. // You can only trigger the action buttons with a joystick declared
  99996. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  99997. this._action();
  99998. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  99999. }
  100000. }
  100001. };
  100002. VirtualJoystick.prototype._onPointerMove = function (e) {
  100003. // If the current pointer is the one associated to the joystick (first touch contact)
  100004. if (this._joystickPointerID == e.pointerId) {
  100005. this._joystickPointerPos.x = e.clientX;
  100006. this._joystickPointerPos.y = e.clientY;
  100007. this._deltaJoystickVector = this._joystickPointerPos.clone();
  100008. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  100009. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  100010. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  100011. switch (this._axisTargetedByLeftAndRight) {
  100012. case JoystickAxis.X:
  100013. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  100014. break;
  100015. case JoystickAxis.Y:
  100016. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  100017. break;
  100018. case JoystickAxis.Z:
  100019. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  100020. break;
  100021. }
  100022. var directionUpDown = this.reverseUpDown ? 1 : -1;
  100023. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  100024. switch (this._axisTargetedByUpAndDown) {
  100025. case JoystickAxis.X:
  100026. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  100027. break;
  100028. case JoystickAxis.Y:
  100029. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  100030. break;
  100031. case JoystickAxis.Z:
  100032. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  100033. break;
  100034. }
  100035. }
  100036. else {
  100037. var data = this._touches.get(e.pointerId.toString());
  100038. if (data) {
  100039. data.x = e.clientX;
  100040. data.y = e.clientY;
  100041. }
  100042. }
  100043. };
  100044. VirtualJoystick.prototype._onPointerUp = function (e) {
  100045. if (this._joystickPointerID == e.pointerId) {
  100046. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  100047. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  100048. this._joystickPointerID = -1;
  100049. this.pressed = false;
  100050. }
  100051. else {
  100052. var touch = this._touches.get(e.pointerId.toString());
  100053. if (touch) {
  100054. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100055. }
  100056. }
  100057. this._deltaJoystickVector.x = 0;
  100058. this._deltaJoystickVector.y = 0;
  100059. this._touches.remove(e.pointerId.toString());
  100060. };
  100061. /**
  100062. * Change the color of the virtual joystick
  100063. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100064. */
  100065. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  100066. this._joystickColor = newColor;
  100067. };
  100068. /**
  100069. * Defines a callback to call when the joystick is touched
  100070. * @param action defines the callback
  100071. */
  100072. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  100073. this._action = action;
  100074. };
  100075. /**
  100076. * Defines which axis you'd like to control for left & right
  100077. * @param axis defines the axis to use
  100078. */
  100079. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  100080. switch (axis) {
  100081. case JoystickAxis.X:
  100082. case JoystickAxis.Y:
  100083. case JoystickAxis.Z:
  100084. this._axisTargetedByLeftAndRight = axis;
  100085. break;
  100086. default:
  100087. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100088. break;
  100089. }
  100090. };
  100091. /**
  100092. * Defines which axis you'd like to control for up & down
  100093. * @param axis defines the axis to use
  100094. */
  100095. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  100096. switch (axis) {
  100097. case JoystickAxis.X:
  100098. case JoystickAxis.Y:
  100099. case JoystickAxis.Z:
  100100. this._axisTargetedByUpAndDown = axis;
  100101. break;
  100102. default:
  100103. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100104. break;
  100105. }
  100106. };
  100107. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  100108. var _this = this;
  100109. if (this.pressed) {
  100110. this._touches.forEach(function (key, touch) {
  100111. if (touch.pointerId === _this._joystickPointerID) {
  100112. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  100113. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  100114. VirtualJoystick.vjCanvasContext.beginPath();
  100115. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100116. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100117. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  100118. VirtualJoystick.vjCanvasContext.stroke();
  100119. VirtualJoystick.vjCanvasContext.closePath();
  100120. VirtualJoystick.vjCanvasContext.beginPath();
  100121. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100122. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100123. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  100124. VirtualJoystick.vjCanvasContext.stroke();
  100125. VirtualJoystick.vjCanvasContext.closePath();
  100126. VirtualJoystick.vjCanvasContext.beginPath();
  100127. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100128. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  100129. VirtualJoystick.vjCanvasContext.stroke();
  100130. VirtualJoystick.vjCanvasContext.closePath();
  100131. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  100132. }
  100133. else {
  100134. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100135. VirtualJoystick.vjCanvasContext.beginPath();
  100136. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  100137. VirtualJoystick.vjCanvasContext.beginPath();
  100138. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  100139. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100140. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  100141. VirtualJoystick.vjCanvasContext.stroke();
  100142. VirtualJoystick.vjCanvasContext.closePath();
  100143. touch.prevX = touch.x;
  100144. touch.prevY = touch.y;
  100145. }
  100146. });
  100147. }
  100148. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100149. };
  100150. /**
  100151. * Release internal HTML canvas
  100152. */
  100153. VirtualJoystick.prototype.releaseCanvas = function () {
  100154. if (VirtualJoystick.Canvas) {
  100155. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  100156. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  100157. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  100158. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  100159. window.removeEventListener("resize", this._onResize);
  100160. document.body.removeChild(VirtualJoystick.Canvas);
  100161. VirtualJoystick.Canvas = null;
  100162. }
  100163. };
  100164. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  100165. VirtualJoystick._globalJoystickIndex = 0;
  100166. return VirtualJoystick;
  100167. }());
  100168. /***/ }),
  100169. /***/ "./Misc/workerPool.ts":
  100170. /*!****************************!*\
  100171. !*** ./Misc/workerPool.ts ***!
  100172. \****************************/
  100173. /*! exports provided: WorkerPool */
  100174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100175. "use strict";
  100176. __webpack_require__.r(__webpack_exports__);
  100177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  100178. /**
  100179. * Helper class to push actions to a pool of workers.
  100180. */
  100181. var WorkerPool = /** @class */ (function () {
  100182. /**
  100183. * Constructor
  100184. * @param workers Array of workers to use for actions
  100185. */
  100186. function WorkerPool(workers) {
  100187. this._pendingActions = new Array();
  100188. this._workerInfos = workers.map(function (worker) { return ({
  100189. worker: worker,
  100190. active: false
  100191. }); });
  100192. }
  100193. /**
  100194. * Terminates all workers and clears any pending actions.
  100195. */
  100196. WorkerPool.prototype.dispose = function () {
  100197. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100198. var workerInfo = _a[_i];
  100199. workerInfo.worker.terminate();
  100200. }
  100201. delete this._workerInfos;
  100202. delete this._pendingActions;
  100203. };
  100204. /**
  100205. * Pushes an action to the worker pool. If all the workers are active, the action will be
  100206. * pended until a worker has completed its action.
  100207. * @param action The action to perform. Call onComplete when the action is complete.
  100208. */
  100209. WorkerPool.prototype.push = function (action) {
  100210. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100211. var workerInfo = _a[_i];
  100212. if (!workerInfo.active) {
  100213. this._execute(workerInfo, action);
  100214. return;
  100215. }
  100216. }
  100217. this._pendingActions.push(action);
  100218. };
  100219. WorkerPool.prototype._execute = function (workerInfo, action) {
  100220. var _this = this;
  100221. workerInfo.active = true;
  100222. action(workerInfo.worker, function () {
  100223. workerInfo.active = false;
  100224. var nextAction = _this._pendingActions.shift();
  100225. if (nextAction) {
  100226. _this._execute(workerInfo, nextAction);
  100227. }
  100228. });
  100229. };
  100230. return WorkerPool;
  100231. }());
  100232. /***/ }),
  100233. /***/ "./Morph/index.ts":
  100234. /*!************************!*\
  100235. !*** ./Morph/index.ts ***!
  100236. \************************/
  100237. /*! exports provided: MorphTarget, MorphTargetManager */
  100238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100239. "use strict";
  100240. __webpack_require__.r(__webpack_exports__);
  100241. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  100243. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  100244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  100245. /***/ }),
  100246. /***/ "./Morph/morphTarget.ts":
  100247. /*!******************************!*\
  100248. !*** ./Morph/morphTarget.ts ***!
  100249. \******************************/
  100250. /*! exports provided: MorphTarget */
  100251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100252. "use strict";
  100253. __webpack_require__.r(__webpack_exports__);
  100254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  100255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100256. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  100257. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100258. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  100259. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  100260. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  100261. /**
  100262. * Defines a target to use with MorphTargetManager
  100263. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100264. */
  100265. var MorphTarget = /** @class */ (function () {
  100266. /**
  100267. * Creates a new MorphTarget
  100268. * @param name defines the name of the target
  100269. * @param influence defines the influence to use
  100270. * @param scene defines the scene the morphtarget belongs to
  100271. */
  100272. function MorphTarget(
  100273. /** defines the name of the target */
  100274. name, influence, scene) {
  100275. if (influence === void 0) { influence = 0; }
  100276. if (scene === void 0) { scene = null; }
  100277. this.name = name;
  100278. /**
  100279. * Gets or sets the list of animations
  100280. */
  100281. this.animations = new Array();
  100282. this._positions = null;
  100283. this._normals = null;
  100284. this._tangents = null;
  100285. /**
  100286. * Observable raised when the influence changes
  100287. */
  100288. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100289. /** @hidden */
  100290. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100291. this._animationPropertiesOverride = null;
  100292. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100293. this.influence = influence;
  100294. }
  100295. Object.defineProperty(MorphTarget.prototype, "influence", {
  100296. /**
  100297. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  100298. */
  100299. get: function () {
  100300. return this._influence;
  100301. },
  100302. set: function (influence) {
  100303. if (this._influence === influence) {
  100304. return;
  100305. }
  100306. var previous = this._influence;
  100307. this._influence = influence;
  100308. if (this.onInfluenceChanged.hasObservers) {
  100309. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  100310. }
  100311. },
  100312. enumerable: true,
  100313. configurable: true
  100314. });
  100315. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  100316. /**
  100317. * Gets or sets the animation properties override
  100318. */
  100319. get: function () {
  100320. if (!this._animationPropertiesOverride && this._scene) {
  100321. return this._scene.animationPropertiesOverride;
  100322. }
  100323. return this._animationPropertiesOverride;
  100324. },
  100325. set: function (value) {
  100326. this._animationPropertiesOverride = value;
  100327. },
  100328. enumerable: true,
  100329. configurable: true
  100330. });
  100331. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  100332. /**
  100333. * Gets a boolean defining if the target contains position data
  100334. */
  100335. get: function () {
  100336. return !!this._positions;
  100337. },
  100338. enumerable: true,
  100339. configurable: true
  100340. });
  100341. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  100342. /**
  100343. * Gets a boolean defining if the target contains normal data
  100344. */
  100345. get: function () {
  100346. return !!this._normals;
  100347. },
  100348. enumerable: true,
  100349. configurable: true
  100350. });
  100351. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  100352. /**
  100353. * Gets a boolean defining if the target contains tangent data
  100354. */
  100355. get: function () {
  100356. return !!this._tangents;
  100357. },
  100358. enumerable: true,
  100359. configurable: true
  100360. });
  100361. /**
  100362. * Affects position data to this target
  100363. * @param data defines the position data to use
  100364. */
  100365. MorphTarget.prototype.setPositions = function (data) {
  100366. var hadPositions = this.hasPositions;
  100367. this._positions = data;
  100368. if (hadPositions !== this.hasPositions) {
  100369. this._onDataLayoutChanged.notifyObservers(undefined);
  100370. }
  100371. };
  100372. /**
  100373. * Gets the position data stored in this target
  100374. * @returns a FloatArray containing the position data (or null if not present)
  100375. */
  100376. MorphTarget.prototype.getPositions = function () {
  100377. return this._positions;
  100378. };
  100379. /**
  100380. * Affects normal data to this target
  100381. * @param data defines the normal data to use
  100382. */
  100383. MorphTarget.prototype.setNormals = function (data) {
  100384. var hadNormals = this.hasNormals;
  100385. this._normals = data;
  100386. if (hadNormals !== this.hasNormals) {
  100387. this._onDataLayoutChanged.notifyObservers(undefined);
  100388. }
  100389. };
  100390. /**
  100391. * Gets the normal data stored in this target
  100392. * @returns a FloatArray containing the normal data (or null if not present)
  100393. */
  100394. MorphTarget.prototype.getNormals = function () {
  100395. return this._normals;
  100396. };
  100397. /**
  100398. * Affects tangent data to this target
  100399. * @param data defines the tangent data to use
  100400. */
  100401. MorphTarget.prototype.setTangents = function (data) {
  100402. var hadTangents = this.hasTangents;
  100403. this._tangents = data;
  100404. if (hadTangents !== this.hasTangents) {
  100405. this._onDataLayoutChanged.notifyObservers(undefined);
  100406. }
  100407. };
  100408. /**
  100409. * Gets the tangent data stored in this target
  100410. * @returns a FloatArray containing the tangent data (or null if not present)
  100411. */
  100412. MorphTarget.prototype.getTangents = function () {
  100413. return this._tangents;
  100414. };
  100415. /**
  100416. * Serializes the current target into a Serialization object
  100417. * @returns the serialized object
  100418. */
  100419. MorphTarget.prototype.serialize = function () {
  100420. var serializationObject = {};
  100421. serializationObject.name = this.name;
  100422. serializationObject.influence = this.influence;
  100423. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  100424. if (this.id != null) {
  100425. serializationObject.id = this.id;
  100426. }
  100427. if (this.hasNormals) {
  100428. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  100429. }
  100430. if (this.hasTangents) {
  100431. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  100432. }
  100433. // Animations
  100434. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  100435. return serializationObject;
  100436. };
  100437. /**
  100438. * Returns the string "MorphTarget"
  100439. * @returns "MorphTarget"
  100440. */
  100441. MorphTarget.prototype.getClassName = function () {
  100442. return "MorphTarget";
  100443. };
  100444. // Statics
  100445. /**
  100446. * Creates a new target from serialized data
  100447. * @param serializationObject defines the serialized data to use
  100448. * @returns a new MorphTarget
  100449. */
  100450. MorphTarget.Parse = function (serializationObject) {
  100451. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  100452. result.setPositions(serializationObject.positions);
  100453. if (serializationObject.id != null) {
  100454. result.id = serializationObject.id;
  100455. }
  100456. if (serializationObject.normals) {
  100457. result.setNormals(serializationObject.normals);
  100458. }
  100459. if (serializationObject.tangents) {
  100460. result.setTangents(serializationObject.tangents);
  100461. }
  100462. // Animations
  100463. if (serializationObject.animations) {
  100464. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  100465. var parsedAnimation = serializationObject.animations[animationIndex];
  100466. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  100467. if (internalClass) {
  100468. result.animations.push(internalClass.Parse(parsedAnimation));
  100469. }
  100470. }
  100471. }
  100472. return result;
  100473. };
  100474. /**
  100475. * Creates a MorphTarget from mesh data
  100476. * @param mesh defines the source mesh
  100477. * @param name defines the name to use for the new target
  100478. * @param influence defines the influence to attach to the target
  100479. * @returns a new MorphTarget
  100480. */
  100481. MorphTarget.FromMesh = function (mesh, name, influence) {
  100482. if (!name) {
  100483. name = mesh.name;
  100484. }
  100485. var result = new MorphTarget(name, influence, mesh.getScene());
  100486. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  100487. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  100488. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  100489. }
  100490. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  100491. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  100492. }
  100493. return result;
  100494. };
  100495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  100496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  100497. ], MorphTarget.prototype, "id", void 0);
  100498. return MorphTarget;
  100499. }());
  100500. /***/ }),
  100501. /***/ "./Morph/morphTargetManager.ts":
  100502. /*!*************************************!*\
  100503. !*** ./Morph/morphTargetManager.ts ***!
  100504. \*************************************/
  100505. /*! exports provided: MorphTargetManager */
  100506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100507. "use strict";
  100508. __webpack_require__.r(__webpack_exports__);
  100509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  100510. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  100511. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100512. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100513. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100514. /**
  100515. * This class is used to deform meshes using morphing between different targets
  100516. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100517. */
  100518. var MorphTargetManager = /** @class */ (function () {
  100519. /**
  100520. * Creates a new MorphTargetManager
  100521. * @param scene defines the current scene
  100522. */
  100523. function MorphTargetManager(scene) {
  100524. if (scene === void 0) { scene = null; }
  100525. this._targets = new Array();
  100526. this._targetInfluenceChangedObservers = new Array();
  100527. this._targetDataLayoutChangedObservers = new Array();
  100528. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  100529. this._supportsNormals = false;
  100530. this._supportsTangents = false;
  100531. this._vertexCount = 0;
  100532. this._uniqueId = 0;
  100533. this._tempInfluences = new Array();
  100534. if (!scene) {
  100535. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100536. }
  100537. this._scene = scene;
  100538. if (this._scene) {
  100539. this._scene.morphTargetManagers.push(this);
  100540. this._uniqueId = this._scene.getUniqueId();
  100541. }
  100542. }
  100543. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  100544. /**
  100545. * Gets the unique ID of this manager
  100546. */
  100547. get: function () {
  100548. return this._uniqueId;
  100549. },
  100550. enumerable: true,
  100551. configurable: true
  100552. });
  100553. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  100554. /**
  100555. * Gets the number of vertices handled by this manager
  100556. */
  100557. get: function () {
  100558. return this._vertexCount;
  100559. },
  100560. enumerable: true,
  100561. configurable: true
  100562. });
  100563. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  100564. /**
  100565. * Gets a boolean indicating if this manager supports morphing of normals
  100566. */
  100567. get: function () {
  100568. return this._supportsNormals;
  100569. },
  100570. enumerable: true,
  100571. configurable: true
  100572. });
  100573. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  100574. /**
  100575. * Gets a boolean indicating if this manager supports morphing of tangents
  100576. */
  100577. get: function () {
  100578. return this._supportsTangents;
  100579. },
  100580. enumerable: true,
  100581. configurable: true
  100582. });
  100583. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  100584. /**
  100585. * Gets the number of targets stored in this manager
  100586. */
  100587. get: function () {
  100588. return this._targets.length;
  100589. },
  100590. enumerable: true,
  100591. configurable: true
  100592. });
  100593. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  100594. /**
  100595. * Gets the number of influencers (ie. the number of targets with influences > 0)
  100596. */
  100597. get: function () {
  100598. return this._activeTargets.length;
  100599. },
  100600. enumerable: true,
  100601. configurable: true
  100602. });
  100603. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  100604. /**
  100605. * Gets the list of influences (one per target)
  100606. */
  100607. get: function () {
  100608. return this._influences;
  100609. },
  100610. enumerable: true,
  100611. configurable: true
  100612. });
  100613. /**
  100614. * Gets the active target at specified index. An active target is a target with an influence > 0
  100615. * @param index defines the index to check
  100616. * @returns the requested target
  100617. */
  100618. MorphTargetManager.prototype.getActiveTarget = function (index) {
  100619. return this._activeTargets.data[index];
  100620. };
  100621. /**
  100622. * Gets the target at specified index
  100623. * @param index defines the index to check
  100624. * @returns the requested target
  100625. */
  100626. MorphTargetManager.prototype.getTarget = function (index) {
  100627. return this._targets[index];
  100628. };
  100629. /**
  100630. * Add a new target to this manager
  100631. * @param target defines the target to add
  100632. */
  100633. MorphTargetManager.prototype.addTarget = function (target) {
  100634. var _this = this;
  100635. this._targets.push(target);
  100636. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  100637. _this._syncActiveTargets(needUpdate);
  100638. }));
  100639. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  100640. _this._syncActiveTargets(true);
  100641. }));
  100642. this._syncActiveTargets(true);
  100643. };
  100644. /**
  100645. * Removes a target from the manager
  100646. * @param target defines the target to remove
  100647. */
  100648. MorphTargetManager.prototype.removeTarget = function (target) {
  100649. var index = this._targets.indexOf(target);
  100650. if (index >= 0) {
  100651. this._targets.splice(index, 1);
  100652. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  100653. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  100654. this._syncActiveTargets(true);
  100655. }
  100656. };
  100657. /**
  100658. * Serializes the current manager into a Serialization object
  100659. * @returns the serialized object
  100660. */
  100661. MorphTargetManager.prototype.serialize = function () {
  100662. var serializationObject = {};
  100663. serializationObject.id = this.uniqueId;
  100664. serializationObject.targets = [];
  100665. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  100666. var target = _a[_i];
  100667. serializationObject.targets.push(target.serialize());
  100668. }
  100669. return serializationObject;
  100670. };
  100671. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  100672. var influenceCount = 0;
  100673. this._activeTargets.reset();
  100674. this._supportsNormals = true;
  100675. this._supportsTangents = true;
  100676. this._vertexCount = 0;
  100677. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  100678. var target = _a[_i];
  100679. if (target.influence === 0) {
  100680. continue;
  100681. }
  100682. this._activeTargets.push(target);
  100683. this._tempInfluences[influenceCount++] = target.influence;
  100684. this._supportsNormals = this._supportsNormals && target.hasNormals;
  100685. this._supportsTangents = this._supportsTangents && target.hasTangents;
  100686. var positions = target.getPositions();
  100687. if (positions) {
  100688. var vertexCount = positions.length / 3;
  100689. if (this._vertexCount === 0) {
  100690. this._vertexCount = vertexCount;
  100691. }
  100692. else if (this._vertexCount !== vertexCount) {
  100693. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  100694. return;
  100695. }
  100696. }
  100697. }
  100698. if (!this._influences || this._influences.length !== influenceCount) {
  100699. this._influences = new Float32Array(influenceCount);
  100700. }
  100701. for (var index = 0; index < influenceCount; index++) {
  100702. this._influences[index] = this._tempInfluences[index];
  100703. }
  100704. if (needUpdate) {
  100705. this.synchronize();
  100706. }
  100707. };
  100708. /**
  100709. * Syncrhonize the targets with all the meshes using this morph target manager
  100710. */
  100711. MorphTargetManager.prototype.synchronize = function () {
  100712. if (!this._scene) {
  100713. return;
  100714. }
  100715. // Flag meshes as dirty to resync with the active targets
  100716. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  100717. var mesh = _a[_i];
  100718. if (mesh.morphTargetManager === this) {
  100719. mesh._syncGeometryWithMorphTargetManager();
  100720. }
  100721. }
  100722. };
  100723. // Statics
  100724. /**
  100725. * Creates a new MorphTargetManager from serialized data
  100726. * @param serializationObject defines the serialized data
  100727. * @param scene defines the hosting scene
  100728. * @returns the new MorphTargetManager
  100729. */
  100730. MorphTargetManager.Parse = function (serializationObject, scene) {
  100731. var result = new MorphTargetManager(scene);
  100732. result._uniqueId = serializationObject.id;
  100733. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  100734. var targetData = _a[_i];
  100735. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  100736. }
  100737. return result;
  100738. };
  100739. return MorphTargetManager;
  100740. }());
  100741. /***/ }),
  100742. /***/ "./Offline/database.ts":
  100743. /*!*****************************!*\
  100744. !*** ./Offline/database.ts ***!
  100745. \*****************************/
  100746. /*! exports provided: Database */
  100747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100748. "use strict";
  100749. __webpack_require__.r(__webpack_exports__);
  100750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  100751. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  100752. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100753. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  100754. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  100755. // Sets the default offline provider to Babylon.js
  100756. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  100757. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100758. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  100759. };
  100760. /**
  100761. * Class used to enable access to IndexedDB
  100762. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100763. */
  100764. var Database = /** @class */ (function () {
  100765. /**
  100766. * Creates a new Database
  100767. * @param urlToScene defines the url to load the scene
  100768. * @param callbackManifestChecked defines the callback to use when manifest is checked
  100769. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  100770. */
  100771. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  100772. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100773. var _this = this;
  100774. // Handling various flavors of prefixed version of IndexedDB
  100775. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  100776. this._callbackManifestChecked = callbackManifestChecked;
  100777. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  100778. this._db = null;
  100779. this._enableSceneOffline = false;
  100780. this._enableTexturesOffline = false;
  100781. this._manifestVersionFound = 0;
  100782. this._mustUpdateRessources = false;
  100783. this._hasReachedQuota = false;
  100784. if (!Database.IDBStorageEnabled) {
  100785. this._callbackManifestChecked(true);
  100786. }
  100787. else {
  100788. if (disableManifestCheck) {
  100789. this._enableSceneOffline = true;
  100790. this._enableTexturesOffline = true;
  100791. this._manifestVersionFound = 1;
  100792. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100793. _this._callbackManifestChecked(true);
  100794. });
  100795. }
  100796. else {
  100797. this._checkManifestFile();
  100798. }
  100799. }
  100800. }
  100801. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  100802. /**
  100803. * Gets a boolean indicating if scene must be saved in the database
  100804. */
  100805. get: function () {
  100806. return this._enableSceneOffline;
  100807. },
  100808. enumerable: true,
  100809. configurable: true
  100810. });
  100811. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  100812. /**
  100813. * Gets a boolean indicating if textures must be saved in the database
  100814. */
  100815. get: function () {
  100816. return this._enableTexturesOffline;
  100817. },
  100818. enumerable: true,
  100819. configurable: true
  100820. });
  100821. Database.prototype._checkManifestFile = function () {
  100822. var _this = this;
  100823. var noManifestFile = function () {
  100824. _this._enableSceneOffline = false;
  100825. _this._enableTexturesOffline = false;
  100826. _this._callbackManifestChecked(false);
  100827. };
  100828. var timeStampUsed = false;
  100829. var manifestURL = this._currentSceneUrl + ".manifest";
  100830. var xhr = new XMLHttpRequest();
  100831. if (navigator.onLine) {
  100832. // Adding a timestamp to by-pass browsers' cache
  100833. timeStampUsed = true;
  100834. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  100835. }
  100836. xhr.open("GET", manifestURL, true);
  100837. xhr.addEventListener("load", function () {
  100838. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  100839. try {
  100840. var manifestFile = JSON.parse(xhr.response);
  100841. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  100842. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  100843. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  100844. _this._manifestVersionFound = manifestFile.version;
  100845. }
  100846. if (_this._callbackManifestChecked) {
  100847. _this._callbackManifestChecked(true);
  100848. }
  100849. }
  100850. catch (ex) {
  100851. noManifestFile();
  100852. }
  100853. }
  100854. else {
  100855. noManifestFile();
  100856. }
  100857. }, false);
  100858. xhr.addEventListener("error", function () {
  100859. if (timeStampUsed) {
  100860. timeStampUsed = false;
  100861. // Let's retry without the timeStamp
  100862. // It could fail when coupled with HTML5 Offline API
  100863. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  100864. xhr.open("GET", retryManifestURL, true);
  100865. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100866. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100867. }
  100868. xhr.send();
  100869. }
  100870. else {
  100871. noManifestFile();
  100872. }
  100873. }, false);
  100874. try {
  100875. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100876. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100877. }
  100878. xhr.send();
  100879. }
  100880. catch (ex) {
  100881. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  100882. this._callbackManifestChecked(false);
  100883. }
  100884. };
  100885. /**
  100886. * Open the database and make it available
  100887. * @param successCallback defines the callback to call on success
  100888. * @param errorCallback defines the callback to call on error
  100889. */
  100890. Database.prototype.open = function (successCallback, errorCallback) {
  100891. var _this = this;
  100892. var handleError = function () {
  100893. _this._isSupported = false;
  100894. if (errorCallback) {
  100895. errorCallback();
  100896. }
  100897. };
  100898. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  100899. // Your browser doesn't support IndexedDB
  100900. this._isSupported = false;
  100901. if (errorCallback) {
  100902. errorCallback();
  100903. }
  100904. }
  100905. else {
  100906. // If the DB hasn't been opened or created yet
  100907. if (!this._db) {
  100908. this._hasReachedQuota = false;
  100909. this._isSupported = true;
  100910. var request = this._idbFactory.open("babylonjs", 1);
  100911. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  100912. request.onerror = function () {
  100913. handleError();
  100914. };
  100915. // executes when a version change transaction cannot complete due to other active transactions
  100916. request.onblocked = function () {
  100917. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  100918. handleError();
  100919. };
  100920. // DB has been opened successfully
  100921. request.onsuccess = function () {
  100922. _this._db = request.result;
  100923. successCallback();
  100924. };
  100925. // Initialization of the DB. Creating Scenes & Textures stores
  100926. request.onupgradeneeded = function (event) {
  100927. _this._db = (event.target).result;
  100928. if (_this._db) {
  100929. try {
  100930. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  100931. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  100932. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  100933. }
  100934. catch (ex) {
  100935. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  100936. handleError();
  100937. }
  100938. }
  100939. };
  100940. }
  100941. // DB has already been created and opened
  100942. else {
  100943. if (successCallback) {
  100944. successCallback();
  100945. }
  100946. }
  100947. }
  100948. };
  100949. /**
  100950. * Loads an image from the database
  100951. * @param url defines the url to load from
  100952. * @param image defines the target DOM image
  100953. */
  100954. Database.prototype.loadImage = function (url, image) {
  100955. var _this = this;
  100956. var completeURL = Database._ReturnFullUrlLocation(url);
  100957. var saveAndLoadImage = function () {
  100958. if (!_this._hasReachedQuota && _this._db !== null) {
  100959. // the texture is not yet in the DB, let's try to save it
  100960. _this._saveImageIntoDBAsync(completeURL, image);
  100961. }
  100962. // If the texture is not in the DB and we've reached the DB quota limit
  100963. // let's load it directly from the web
  100964. else {
  100965. image.src = url;
  100966. }
  100967. };
  100968. if (!this._mustUpdateRessources) {
  100969. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  100970. }
  100971. // First time we're download the images or update requested in the manifest file by a version change
  100972. else {
  100973. saveAndLoadImage();
  100974. }
  100975. };
  100976. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  100977. if (this._isSupported && this._db !== null) {
  100978. var texture;
  100979. var transaction = this._db.transaction(["textures"]);
  100980. transaction.onabort = function () {
  100981. image.src = url;
  100982. };
  100983. transaction.oncomplete = function () {
  100984. var blobTextureURL;
  100985. if (texture) {
  100986. var URL = window.URL || window.webkitURL;
  100987. blobTextureURL = URL.createObjectURL(texture.data);
  100988. image.onerror = function () {
  100989. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  100990. image.src = url;
  100991. };
  100992. image.src = blobTextureURL;
  100993. }
  100994. else {
  100995. notInDBCallback();
  100996. }
  100997. };
  100998. var getRequest = transaction.objectStore("textures").get(url);
  100999. getRequest.onsuccess = function (event) {
  101000. texture = (event.target).result;
  101001. };
  101002. getRequest.onerror = function () {
  101003. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  101004. image.src = url;
  101005. };
  101006. }
  101007. else {
  101008. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101009. image.src = url;
  101010. }
  101011. };
  101012. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  101013. var _this = this;
  101014. if (this._isSupported) {
  101015. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  101016. var generateBlobUrl = function () {
  101017. var blobTextureURL;
  101018. if (blob) {
  101019. var URL = window.URL || window.webkitURL;
  101020. try {
  101021. blobTextureURL = URL.createObjectURL(blob);
  101022. }
  101023. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  101024. catch (ex) {
  101025. blobTextureURL = URL.createObjectURL(blob);
  101026. }
  101027. }
  101028. if (blobTextureURL) {
  101029. image.src = blobTextureURL;
  101030. }
  101031. };
  101032. if (Database.IsUASupportingBlobStorage) { // Create XHR
  101033. var xhr = new XMLHttpRequest(), blob;
  101034. xhr.open("GET", url, true);
  101035. xhr.responseType = "blob";
  101036. xhr.addEventListener("load", function () {
  101037. if (xhr.status === 200 && _this._db) {
  101038. // Blob as response (XHR2)
  101039. blob = xhr.response;
  101040. var transaction = _this._db.transaction(["textures"], "readwrite");
  101041. // the transaction could abort because of a QuotaExceededError error
  101042. transaction.onabort = function (event) {
  101043. try {
  101044. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101045. var srcElement = (event.srcElement || event.target);
  101046. var error = srcElement.error;
  101047. if (error && error.name === "QuotaExceededError") {
  101048. _this._hasReachedQuota = true;
  101049. }
  101050. }
  101051. catch (ex) { }
  101052. generateBlobUrl();
  101053. };
  101054. transaction.oncomplete = function () {
  101055. generateBlobUrl();
  101056. };
  101057. var newTexture = { textureUrl: url, data: blob };
  101058. try {
  101059. // Put the blob into the dabase
  101060. var addRequest = transaction.objectStore("textures").put(newTexture);
  101061. addRequest.onsuccess = function () {
  101062. };
  101063. addRequest.onerror = function () {
  101064. generateBlobUrl();
  101065. };
  101066. }
  101067. catch (ex) {
  101068. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  101069. if (ex.code === 25) {
  101070. Database.IsUASupportingBlobStorage = false;
  101071. _this._enableTexturesOffline = false;
  101072. }
  101073. image.src = url;
  101074. }
  101075. }
  101076. else {
  101077. image.src = url;
  101078. }
  101079. }, false);
  101080. xhr.addEventListener("error", function () {
  101081. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  101082. image.src = url;
  101083. }, false);
  101084. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  101085. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101086. }
  101087. xhr.send();
  101088. }
  101089. else {
  101090. image.src = url;
  101091. }
  101092. }
  101093. else {
  101094. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101095. image.src = url;
  101096. }
  101097. };
  101098. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  101099. var _this = this;
  101100. var updateVersion = function () {
  101101. // the version is not yet in the DB or we need to update it
  101102. _this._saveVersionIntoDBAsync(url, versionLoaded);
  101103. };
  101104. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  101105. };
  101106. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  101107. var _this = this;
  101108. if (this._isSupported && this._db) {
  101109. var version;
  101110. try {
  101111. var transaction = this._db.transaction(["versions"]);
  101112. transaction.oncomplete = function () {
  101113. if (version) {
  101114. // If the version in the JSON file is different from the version in DB
  101115. if (_this._manifestVersionFound !== version.data) {
  101116. _this._mustUpdateRessources = true;
  101117. updateInDBCallback();
  101118. }
  101119. else {
  101120. callback(version.data);
  101121. }
  101122. }
  101123. // version was not found in DB
  101124. else {
  101125. _this._mustUpdateRessources = true;
  101126. updateInDBCallback();
  101127. }
  101128. };
  101129. transaction.onabort = function () {
  101130. callback(-1);
  101131. };
  101132. var getRequest = transaction.objectStore("versions").get(url);
  101133. getRequest.onsuccess = function (event) {
  101134. version = (event.target).result;
  101135. };
  101136. getRequest.onerror = function () {
  101137. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  101138. callback(-1);
  101139. };
  101140. }
  101141. catch (ex) {
  101142. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  101143. callback(-1);
  101144. }
  101145. }
  101146. else {
  101147. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101148. callback(-1);
  101149. }
  101150. };
  101151. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  101152. var _this = this;
  101153. if (this._isSupported && !this._hasReachedQuota && this._db) {
  101154. try {
  101155. // Open a transaction to the database
  101156. var transaction = this._db.transaction(["versions"], "readwrite");
  101157. // the transaction could abort because of a QuotaExceededError error
  101158. transaction.onabort = function (event) {
  101159. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101160. var error = event.srcElement['error'];
  101161. if (error && error.name === "QuotaExceededError") {
  101162. _this._hasReachedQuota = true;
  101163. }
  101164. }
  101165. catch (ex) { }
  101166. callback(-1);
  101167. };
  101168. transaction.oncomplete = function () {
  101169. callback(_this._manifestVersionFound);
  101170. };
  101171. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  101172. // Put the scene into the database
  101173. var addRequest = transaction.objectStore("versions").put(newVersion);
  101174. addRequest.onsuccess = function () {
  101175. };
  101176. addRequest.onerror = function () {
  101177. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  101178. };
  101179. }
  101180. catch (ex) {
  101181. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  101182. callback(-1);
  101183. }
  101184. }
  101185. else {
  101186. callback(-1);
  101187. }
  101188. };
  101189. /**
  101190. * Loads a file from database
  101191. * @param url defines the URL to load from
  101192. * @param sceneLoaded defines a callback to call on success
  101193. * @param progressCallBack defines a callback to call when progress changed
  101194. * @param errorCallback defines a callback to call on error
  101195. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  101196. */
  101197. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  101198. var _this = this;
  101199. var completeUrl = Database._ReturnFullUrlLocation(url);
  101200. var saveAndLoadFile = function () {
  101201. // the scene is not yet in the DB, let's try to save it
  101202. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101203. };
  101204. this._checkVersionFromDB(completeUrl, function (version) {
  101205. if (version !== -1) {
  101206. if (!_this._mustUpdateRessources) {
  101207. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  101208. }
  101209. else {
  101210. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101211. }
  101212. }
  101213. else {
  101214. if (errorCallback) {
  101215. errorCallback();
  101216. }
  101217. }
  101218. });
  101219. };
  101220. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  101221. if (this._isSupported && this._db) {
  101222. var targetStore;
  101223. if (url.indexOf(".babylon") !== -1) {
  101224. targetStore = "scenes";
  101225. }
  101226. else {
  101227. targetStore = "textures";
  101228. }
  101229. var file;
  101230. var transaction = this._db.transaction([targetStore]);
  101231. transaction.oncomplete = function () {
  101232. if (file) {
  101233. callback(file.data);
  101234. }
  101235. // file was not found in DB
  101236. else {
  101237. notInDBCallback();
  101238. }
  101239. };
  101240. transaction.onabort = function () {
  101241. notInDBCallback();
  101242. };
  101243. var getRequest = transaction.objectStore(targetStore).get(url);
  101244. getRequest.onsuccess = function (event) {
  101245. file = (event.target).result;
  101246. };
  101247. getRequest.onerror = function () {
  101248. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  101249. notInDBCallback();
  101250. };
  101251. }
  101252. else {
  101253. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101254. callback();
  101255. }
  101256. };
  101257. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  101258. var _this = this;
  101259. if (this._isSupported) {
  101260. var targetStore;
  101261. if (url.indexOf(".babylon") !== -1) {
  101262. targetStore = "scenes";
  101263. }
  101264. else {
  101265. targetStore = "textures";
  101266. }
  101267. // Create XHR
  101268. var xhr = new XMLHttpRequest();
  101269. var fileData;
  101270. xhr.open("GET", url + "?" + Date.now(), true);
  101271. if (useArrayBuffer) {
  101272. xhr.responseType = "arraybuffer";
  101273. }
  101274. if (progressCallback) {
  101275. xhr.onprogress = progressCallback;
  101276. }
  101277. xhr.addEventListener("load", function () {
  101278. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  101279. // Blob as response (XHR2)
  101280. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  101281. if (!_this._hasReachedQuota && _this._db) {
  101282. // Open a transaction to the database
  101283. var transaction = _this._db.transaction([targetStore], "readwrite");
  101284. // the transaction could abort because of a QuotaExceededError error
  101285. transaction.onabort = function (event) {
  101286. try {
  101287. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101288. var error = event.srcElement['error'];
  101289. if (error && error.name === "QuotaExceededError") {
  101290. _this._hasReachedQuota = true;
  101291. }
  101292. }
  101293. catch (ex) { }
  101294. callback(fileData);
  101295. };
  101296. transaction.oncomplete = function () {
  101297. callback(fileData);
  101298. };
  101299. var newFile;
  101300. if (targetStore === "scenes") {
  101301. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  101302. }
  101303. else {
  101304. newFile = { textureUrl: url, data: fileData };
  101305. }
  101306. try {
  101307. // Put the scene into the database
  101308. var addRequest = transaction.objectStore(targetStore).put(newFile);
  101309. addRequest.onsuccess = function () {
  101310. };
  101311. addRequest.onerror = function () {
  101312. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  101313. };
  101314. }
  101315. catch (ex) {
  101316. callback(fileData);
  101317. }
  101318. }
  101319. else {
  101320. callback(fileData);
  101321. }
  101322. }
  101323. else {
  101324. if (xhr.status >= 400 && errorCallback) {
  101325. errorCallback(xhr);
  101326. }
  101327. else {
  101328. callback();
  101329. }
  101330. }
  101331. }, false);
  101332. xhr.addEventListener("error", function () {
  101333. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  101334. callback();
  101335. }, false);
  101336. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101337. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101338. }
  101339. xhr.send();
  101340. }
  101341. else {
  101342. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  101343. callback();
  101344. }
  101345. };
  101346. /**
  101347. * Validates if xhr data is correct
  101348. * @param xhr defines the request to validate
  101349. * @param dataType defines the expected data type
  101350. * @returns true if data is correct
  101351. */
  101352. Database._ValidateXHRData = function (xhr, dataType) {
  101353. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  101354. if (dataType === void 0) { dataType = 7; }
  101355. try {
  101356. if (dataType & 1) {
  101357. if (xhr.responseText && xhr.responseText.length > 0) {
  101358. return true;
  101359. }
  101360. else if (dataType === 1) {
  101361. return false;
  101362. }
  101363. }
  101364. if (dataType & 2) {
  101365. // Check header width and height since there is no "TGA" magic number
  101366. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  101367. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  101368. return true;
  101369. }
  101370. else if (dataType === 2) {
  101371. return false;
  101372. }
  101373. }
  101374. if (dataType & 4) {
  101375. // Check for the "DDS" magic number
  101376. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  101377. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  101378. return true;
  101379. }
  101380. else {
  101381. return false;
  101382. }
  101383. }
  101384. }
  101385. catch (e) {
  101386. // Global protection
  101387. }
  101388. return false;
  101389. };
  101390. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  101391. Database.IsUASupportingBlobStorage = true;
  101392. /**
  101393. * Gets a boolean indicating if Database storate is enabled (off by default)
  101394. */
  101395. Database.IDBStorageEnabled = false;
  101396. Database._ParseURL = function (url) {
  101397. var a = document.createElement('a');
  101398. a.href = url;
  101399. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  101400. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  101401. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  101402. return absLocation;
  101403. };
  101404. Database._ReturnFullUrlLocation = function (url) {
  101405. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  101406. return (Database._ParseURL(window.location.href) + url);
  101407. }
  101408. else {
  101409. return url;
  101410. }
  101411. };
  101412. return Database;
  101413. }());
  101414. /***/ }),
  101415. /***/ "./Offline/index.ts":
  101416. /*!**************************!*\
  101417. !*** ./Offline/index.ts ***!
  101418. \**************************/
  101419. /*! exports provided: Database */
  101420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101421. "use strict";
  101422. __webpack_require__.r(__webpack_exports__);
  101423. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  101424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  101425. /***/ }),
  101426. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  101427. /*!******************************************************!*\
  101428. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  101429. \******************************************************/
  101430. /*! exports provided: BoxParticleEmitter */
  101431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101432. "use strict";
  101433. __webpack_require__.r(__webpack_exports__);
  101434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  101435. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101436. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101437. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101438. /**
  101439. * Particle emitter emitting particles from the inside of a box.
  101440. * It emits the particles randomly between 2 given directions.
  101441. */
  101442. var BoxParticleEmitter = /** @class */ (function () {
  101443. /**
  101444. * Creates a new instance BoxParticleEmitter
  101445. */
  101446. function BoxParticleEmitter() {
  101447. /**
  101448. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101449. */
  101450. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101451. /**
  101452. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101453. */
  101454. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101455. /**
  101456. * 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.
  101457. */
  101458. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  101459. /**
  101460. * 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.
  101461. */
  101462. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  101463. }
  101464. /**
  101465. * Called by the particle System when the direction is computed for the created particle.
  101466. * @param worldMatrix is the world matrix of the particle system
  101467. * @param directionToUpdate is the direction vector to update with the result
  101468. * @param particle is the particle we are computed the direction for
  101469. */
  101470. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101471. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101472. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101473. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101474. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101475. };
  101476. /**
  101477. * Called by the particle System when the position is computed for the created particle.
  101478. * @param worldMatrix is the world matrix of the particle system
  101479. * @param positionToUpdate is the position vector to update with the result
  101480. * @param particle is the particle we are computed the position for
  101481. */
  101482. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101483. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  101484. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  101485. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  101486. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101487. };
  101488. /**
  101489. * Clones the current emitter and returns a copy of it
  101490. * @returns the new emitter
  101491. */
  101492. BoxParticleEmitter.prototype.clone = function () {
  101493. var newOne = new BoxParticleEmitter();
  101494. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101495. return newOne;
  101496. };
  101497. /**
  101498. * Called by the GPUParticleSystem to setup the update shader
  101499. * @param effect defines the update shader
  101500. */
  101501. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  101502. effect.setVector3("direction1", this.direction1);
  101503. effect.setVector3("direction2", this.direction2);
  101504. effect.setVector3("minEmitBox", this.minEmitBox);
  101505. effect.setVector3("maxEmitBox", this.maxEmitBox);
  101506. };
  101507. /**
  101508. * Returns a string to use to update the GPU particles update shader
  101509. * @returns a string containng the defines string
  101510. */
  101511. BoxParticleEmitter.prototype.getEffectDefines = function () {
  101512. return "#define BOXEMITTER";
  101513. };
  101514. /**
  101515. * Returns the string "BoxParticleEmitter"
  101516. * @returns a string containing the class name
  101517. */
  101518. BoxParticleEmitter.prototype.getClassName = function () {
  101519. return "BoxParticleEmitter";
  101520. };
  101521. /**
  101522. * Serializes the particle system to a JSON object.
  101523. * @returns the JSON object
  101524. */
  101525. BoxParticleEmitter.prototype.serialize = function () {
  101526. var serializationObject = {};
  101527. serializationObject.type = this.getClassName();
  101528. serializationObject.direction1 = this.direction1.asArray();
  101529. serializationObject.direction2 = this.direction2.asArray();
  101530. serializationObject.minEmitBox = this.minEmitBox.asArray();
  101531. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  101532. return serializationObject;
  101533. };
  101534. /**
  101535. * Parse properties from a JSON object
  101536. * @param serializationObject defines the JSON object
  101537. */
  101538. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  101539. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101540. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101541. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  101542. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  101543. };
  101544. return BoxParticleEmitter;
  101545. }());
  101546. /***/ }),
  101547. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  101548. /*!*******************************************************!*\
  101549. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  101550. \*******************************************************/
  101551. /*! exports provided: ConeParticleEmitter */
  101552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101553. "use strict";
  101554. __webpack_require__.r(__webpack_exports__);
  101555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  101556. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101557. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101558. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101559. /**
  101560. * Particle emitter emitting particles from the inside of a cone.
  101561. * It emits the particles alongside the cone volume from the base to the particle.
  101562. * The emission direction might be randomized.
  101563. */
  101564. var ConeParticleEmitter = /** @class */ (function () {
  101565. /**
  101566. * Creates a new instance ConeParticleEmitter
  101567. * @param radius the radius of the emission cone (1 by default)
  101568. * @param angle the cone base angle (PI by default)
  101569. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101570. */
  101571. function ConeParticleEmitter(radius, angle,
  101572. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101573. directionRandomizer) {
  101574. if (radius === void 0) { radius = 1; }
  101575. if (angle === void 0) { angle = Math.PI; }
  101576. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101577. this.directionRandomizer = directionRandomizer;
  101578. /**
  101579. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101580. */
  101581. this.radiusRange = 1;
  101582. /**
  101583. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101584. */
  101585. this.heightRange = 1;
  101586. /**
  101587. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101588. */
  101589. this.emitFromSpawnPointOnly = false;
  101590. this.angle = angle;
  101591. this.radius = radius;
  101592. }
  101593. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  101594. /**
  101595. * Gets or sets the radius of the emission cone
  101596. */
  101597. get: function () {
  101598. return this._radius;
  101599. },
  101600. set: function (value) {
  101601. this._radius = value;
  101602. this._buildHeight();
  101603. },
  101604. enumerable: true,
  101605. configurable: true
  101606. });
  101607. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  101608. /**
  101609. * Gets or sets the angle of the emission cone
  101610. */
  101611. get: function () {
  101612. return this._angle;
  101613. },
  101614. set: function (value) {
  101615. this._angle = value;
  101616. this._buildHeight();
  101617. },
  101618. enumerable: true,
  101619. configurable: true
  101620. });
  101621. ConeParticleEmitter.prototype._buildHeight = function () {
  101622. if (this._angle !== 0) {
  101623. this._height = this._radius / Math.tan(this._angle / 2);
  101624. }
  101625. else {
  101626. this._height = 1;
  101627. }
  101628. };
  101629. /**
  101630. * Called by the particle System when the direction is computed for the created particle.
  101631. * @param worldMatrix is the world matrix of the particle system
  101632. * @param directionToUpdate is the direction vector to update with the result
  101633. * @param particle is the particle we are computed the direction for
  101634. */
  101635. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101636. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  101637. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  101638. }
  101639. else {
  101640. // measure the direction Vector from the emitter to the particle.
  101641. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101642. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101643. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101644. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101645. direction.x += randX;
  101646. direction.y += randY;
  101647. direction.z += randZ;
  101648. direction.normalize();
  101649. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101650. }
  101651. };
  101652. /**
  101653. * Called by the particle System when the position is computed for the created particle.
  101654. * @param worldMatrix is the world matrix of the particle system
  101655. * @param positionToUpdate is the position vector to update with the result
  101656. * @param particle is the particle we are computed the position for
  101657. */
  101658. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101659. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  101660. var h;
  101661. if (!this.emitFromSpawnPointOnly) {
  101662. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  101663. // Better distribution in a cone at normal angles.
  101664. h = 1 - h * h;
  101665. }
  101666. else {
  101667. h = 0.0001;
  101668. }
  101669. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  101670. radius = radius * h;
  101671. var randX = radius * Math.sin(s);
  101672. var randZ = radius * Math.cos(s);
  101673. var randY = h * this._height;
  101674. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101675. };
  101676. /**
  101677. * Clones the current emitter and returns a copy of it
  101678. * @returns the new emitter
  101679. */
  101680. ConeParticleEmitter.prototype.clone = function () {
  101681. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  101682. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101683. return newOne;
  101684. };
  101685. /**
  101686. * Called by the GPUParticleSystem to setup the update shader
  101687. * @param effect defines the update shader
  101688. */
  101689. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  101690. effect.setFloat2("radius", this._radius, this.radiusRange);
  101691. effect.setFloat("coneAngle", this._angle);
  101692. effect.setFloat2("height", this._height, this.heightRange);
  101693. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101694. };
  101695. /**
  101696. * Returns a string to use to update the GPU particles update shader
  101697. * @returns a string containng the defines string
  101698. */
  101699. ConeParticleEmitter.prototype.getEffectDefines = function () {
  101700. var defines = "#define CONEEMITTER";
  101701. if (this.emitFromSpawnPointOnly) {
  101702. defines += "\n#define CONEEMITTERSPAWNPOINT";
  101703. }
  101704. return defines;
  101705. };
  101706. /**
  101707. * Returns the string "ConeParticleEmitter"
  101708. * @returns a string containing the class name
  101709. */
  101710. ConeParticleEmitter.prototype.getClassName = function () {
  101711. return "ConeParticleEmitter";
  101712. };
  101713. /**
  101714. * Serializes the particle system to a JSON object.
  101715. * @returns the JSON object
  101716. */
  101717. ConeParticleEmitter.prototype.serialize = function () {
  101718. var serializationObject = {};
  101719. serializationObject.type = this.getClassName();
  101720. serializationObject.radius = this._radius;
  101721. serializationObject.angle = this._angle;
  101722. serializationObject.directionRandomizer = this.directionRandomizer;
  101723. return serializationObject;
  101724. };
  101725. /**
  101726. * Parse properties from a JSON object
  101727. * @param serializationObject defines the JSON object
  101728. */
  101729. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  101730. this.radius = serializationObject.radius;
  101731. this.angle = serializationObject.angle;
  101732. this.directionRandomizer = serializationObject.directionRandomizer;
  101733. };
  101734. return ConeParticleEmitter;
  101735. }());
  101736. /***/ }),
  101737. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  101738. /*!***********************************************************!*\
  101739. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  101740. \***********************************************************/
  101741. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  101742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101743. "use strict";
  101744. __webpack_require__.r(__webpack_exports__);
  101745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  101746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  101747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101748. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101749. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101750. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101751. /**
  101752. * Particle emitter emitting particles from the inside of a cylinder.
  101753. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  101754. */
  101755. var CylinderParticleEmitter = /** @class */ (function () {
  101756. /**
  101757. * Creates a new instance CylinderParticleEmitter
  101758. * @param radius the radius of the emission cylinder (1 by default)
  101759. * @param height the height of the emission cylinder (1 by default)
  101760. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101761. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101762. */
  101763. function CylinderParticleEmitter(
  101764. /**
  101765. * The radius of the emission cylinder.
  101766. */
  101767. radius,
  101768. /**
  101769. * The height of the emission cylinder.
  101770. */
  101771. height,
  101772. /**
  101773. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101774. */
  101775. radiusRange,
  101776. /**
  101777. * How much to randomize the particle direction [0-1].
  101778. */
  101779. directionRandomizer) {
  101780. if (radius === void 0) { radius = 1; }
  101781. if (height === void 0) { height = 1; }
  101782. if (radiusRange === void 0) { radiusRange = 1; }
  101783. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101784. this.radius = radius;
  101785. this.height = height;
  101786. this.radiusRange = radiusRange;
  101787. this.directionRandomizer = directionRandomizer;
  101788. }
  101789. /**
  101790. * Called by the particle System when the direction is computed for the created particle.
  101791. * @param worldMatrix is the world matrix of the particle system
  101792. * @param directionToUpdate is the direction vector to update with the result
  101793. * @param particle is the particle we are computed the direction for
  101794. */
  101795. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101796. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101797. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  101798. var angle = Math.atan2(direction.x, direction.z);
  101799. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  101800. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  101801. direction.x = Math.sin(angle);
  101802. direction.z = Math.cos(angle);
  101803. direction.normalize();
  101804. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101805. };
  101806. /**
  101807. * Called by the particle System when the position is computed for the created particle.
  101808. * @param worldMatrix is the world matrix of the particle system
  101809. * @param positionToUpdate is the position vector to update with the result
  101810. * @param particle is the particle we are computed the position for
  101811. */
  101812. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101813. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  101814. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101815. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  101816. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  101817. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  101818. var xPos = positionRadius * Math.cos(angle);
  101819. var zPos = positionRadius * Math.sin(angle);
  101820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  101821. };
  101822. /**
  101823. * Clones the current emitter and returns a copy of it
  101824. * @returns the new emitter
  101825. */
  101826. CylinderParticleEmitter.prototype.clone = function () {
  101827. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  101828. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101829. return newOne;
  101830. };
  101831. /**
  101832. * Called by the GPUParticleSystem to setup the update shader
  101833. * @param effect defines the update shader
  101834. */
  101835. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  101836. effect.setFloat("radius", this.radius);
  101837. effect.setFloat("height", this.height);
  101838. effect.setFloat("radiusRange", this.radiusRange);
  101839. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101840. };
  101841. /**
  101842. * Returns a string to use to update the GPU particles update shader
  101843. * @returns a string containng the defines string
  101844. */
  101845. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  101846. return "#define CYLINDEREMITTER";
  101847. };
  101848. /**
  101849. * Returns the string "CylinderParticleEmitter"
  101850. * @returns a string containing the class name
  101851. */
  101852. CylinderParticleEmitter.prototype.getClassName = function () {
  101853. return "CylinderParticleEmitter";
  101854. };
  101855. /**
  101856. * Serializes the particle system to a JSON object.
  101857. * @returns the JSON object
  101858. */
  101859. CylinderParticleEmitter.prototype.serialize = function () {
  101860. var serializationObject = {};
  101861. serializationObject.type = this.getClassName();
  101862. serializationObject.radius = this.radius;
  101863. serializationObject.height = this.height;
  101864. serializationObject.radiusRange = this.radiusRange;
  101865. serializationObject.directionRandomizer = this.directionRandomizer;
  101866. return serializationObject;
  101867. };
  101868. /**
  101869. * Parse properties from a JSON object
  101870. * @param serializationObject defines the JSON object
  101871. */
  101872. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  101873. this.radius = serializationObject.radius;
  101874. this.height = serializationObject.height;
  101875. this.radiusRange = serializationObject.radiusRange;
  101876. this.directionRandomizer = serializationObject.directionRandomizer;
  101877. };
  101878. return CylinderParticleEmitter;
  101879. }());
  101880. /**
  101881. * Particle emitter emitting particles from the inside of a cylinder.
  101882. * It emits the particles randomly between two vectors.
  101883. */
  101884. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  101885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  101886. /**
  101887. * Creates a new instance CylinderDirectedParticleEmitter
  101888. * @param radius the radius of the emission cylinder (1 by default)
  101889. * @param height the height of the emission cylinder (1 by default)
  101890. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101891. * @param direction1 the min limit of the emission direction (up vector by default)
  101892. * @param direction2 the max limit of the emission direction (up vector by default)
  101893. */
  101894. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  101895. /**
  101896. * The min limit of the emission direction.
  101897. */
  101898. direction1,
  101899. /**
  101900. * The max limit of the emission direction.
  101901. */
  101902. direction2) {
  101903. if (radius === void 0) { radius = 1; }
  101904. if (height === void 0) { height = 1; }
  101905. if (radiusRange === void 0) { radiusRange = 1; }
  101906. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101907. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101908. var _this = _super.call(this, radius, height, radiusRange) || this;
  101909. _this.direction1 = direction1;
  101910. _this.direction2 = direction2;
  101911. return _this;
  101912. }
  101913. /**
  101914. * Called by the particle System when the direction is computed for the created particle.
  101915. * @param worldMatrix is the world matrix of the particle system
  101916. * @param directionToUpdate is the direction vector to update with the result
  101917. * @param particle is the particle we are computed the direction for
  101918. */
  101919. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101920. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101921. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101922. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101923. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101924. };
  101925. /**
  101926. * Clones the current emitter and returns a copy of it
  101927. * @returns the new emitter
  101928. */
  101929. CylinderDirectedParticleEmitter.prototype.clone = function () {
  101930. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  101931. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101932. return newOne;
  101933. };
  101934. /**
  101935. * Called by the GPUParticleSystem to setup the update shader
  101936. * @param effect defines the update shader
  101937. */
  101938. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101939. effect.setFloat("radius", this.radius);
  101940. effect.setFloat("height", this.height);
  101941. effect.setFloat("radiusRange", this.radiusRange);
  101942. effect.setVector3("direction1", this.direction1);
  101943. effect.setVector3("direction2", this.direction2);
  101944. };
  101945. /**
  101946. * Returns a string to use to update the GPU particles update shader
  101947. * @returns a string containng the defines string
  101948. */
  101949. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101950. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  101951. };
  101952. /**
  101953. * Returns the string "CylinderDirectedParticleEmitter"
  101954. * @returns a string containing the class name
  101955. */
  101956. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  101957. return "CylinderDirectedParticleEmitter";
  101958. };
  101959. /**
  101960. * Serializes the particle system to a JSON object.
  101961. * @returns the JSON object
  101962. */
  101963. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  101964. var serializationObject = _super.prototype.serialize.call(this);
  101965. serializationObject.direction1 = this.direction1.asArray();
  101966. serializationObject.direction2 = this.direction2.asArray();
  101967. return serializationObject;
  101968. };
  101969. /**
  101970. * Parse properties from a JSON object
  101971. * @param serializationObject defines the JSON object
  101972. */
  101973. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101974. _super.prototype.parse.call(this, serializationObject);
  101975. this.direction1.copyFrom(serializationObject.direction1);
  101976. this.direction2.copyFrom(serializationObject.direction2);
  101977. };
  101978. return CylinderDirectedParticleEmitter;
  101979. }(CylinderParticleEmitter));
  101980. /***/ }),
  101981. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  101982. /*!**************************************************************!*\
  101983. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  101984. \**************************************************************/
  101985. /*! exports provided: HemisphericParticleEmitter */
  101986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101987. "use strict";
  101988. __webpack_require__.r(__webpack_exports__);
  101989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  101990. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101991. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101992. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101993. /**
  101994. * Particle emitter emitting particles from the inside of a hemisphere.
  101995. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101996. */
  101997. var HemisphericParticleEmitter = /** @class */ (function () {
  101998. /**
  101999. * Creates a new instance HemisphericParticleEmitter
  102000. * @param radius the radius of the emission hemisphere (1 by default)
  102001. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102002. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102003. */
  102004. function HemisphericParticleEmitter(
  102005. /**
  102006. * The radius of the emission hemisphere.
  102007. */
  102008. radius,
  102009. /**
  102010. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102011. */
  102012. radiusRange,
  102013. /**
  102014. * How much to randomize the particle direction [0-1].
  102015. */
  102016. directionRandomizer) {
  102017. if (radius === void 0) { radius = 1; }
  102018. if (radiusRange === void 0) { radiusRange = 1; }
  102019. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102020. this.radius = radius;
  102021. this.radiusRange = radiusRange;
  102022. this.directionRandomizer = directionRandomizer;
  102023. }
  102024. /**
  102025. * Called by the particle System when the direction is computed for the created particle.
  102026. * @param worldMatrix is the world matrix of the particle system
  102027. * @param directionToUpdate is the direction vector to update with the result
  102028. * @param particle is the particle we are computed the direction for
  102029. */
  102030. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102031. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102032. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102033. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102034. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102035. direction.x += randX;
  102036. direction.y += randY;
  102037. direction.z += randZ;
  102038. direction.normalize();
  102039. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102040. };
  102041. /**
  102042. * Called by the particle System when the position is computed for the created particle.
  102043. * @param worldMatrix is the world matrix of the particle system
  102044. * @param positionToUpdate is the position vector to update with the result
  102045. * @param particle is the particle we are computed the position for
  102046. */
  102047. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102048. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102049. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102050. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102051. var theta = Math.acos(2 * v - 1);
  102052. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102053. var randY = randRadius * Math.cos(theta);
  102054. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  102056. };
  102057. /**
  102058. * Clones the current emitter and returns a copy of it
  102059. * @returns the new emitter
  102060. */
  102061. HemisphericParticleEmitter.prototype.clone = function () {
  102062. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  102063. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102064. return newOne;
  102065. };
  102066. /**
  102067. * Called by the GPUParticleSystem to setup the update shader
  102068. * @param effect defines the update shader
  102069. */
  102070. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  102071. effect.setFloat("radius", this.radius);
  102072. effect.setFloat("radiusRange", this.radiusRange);
  102073. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102074. };
  102075. /**
  102076. * Returns a string to use to update the GPU particles update shader
  102077. * @returns a string containng the defines string
  102078. */
  102079. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  102080. return "#define HEMISPHERICEMITTER";
  102081. };
  102082. /**
  102083. * Returns the string "HemisphericParticleEmitter"
  102084. * @returns a string containing the class name
  102085. */
  102086. HemisphericParticleEmitter.prototype.getClassName = function () {
  102087. return "HemisphericParticleEmitter";
  102088. };
  102089. /**
  102090. * Serializes the particle system to a JSON object.
  102091. * @returns the JSON object
  102092. */
  102093. HemisphericParticleEmitter.prototype.serialize = function () {
  102094. var serializationObject = {};
  102095. serializationObject.type = this.getClassName();
  102096. serializationObject.radius = this.radius;
  102097. serializationObject.radiusRange = this.radiusRange;
  102098. serializationObject.directionRandomizer = this.directionRandomizer;
  102099. return serializationObject;
  102100. };
  102101. /**
  102102. * Parse properties from a JSON object
  102103. * @param serializationObject defines the JSON object
  102104. */
  102105. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  102106. this.radius = serializationObject.radius;
  102107. this.radiusRange = serializationObject.radiusRange;
  102108. this.directionRandomizer = serializationObject.directionRandomizer;
  102109. };
  102110. return HemisphericParticleEmitter;
  102111. }());
  102112. /***/ }),
  102113. /***/ "./Particles/EmitterTypes/index.ts":
  102114. /*!*****************************************!*\
  102115. !*** ./Particles/EmitterTypes/index.ts ***!
  102116. \*****************************************/
  102117. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  102118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102119. "use strict";
  102120. __webpack_require__.r(__webpack_exports__);
  102121. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  102123. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  102124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  102125. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  102126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  102127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  102128. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  102129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  102130. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  102131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  102132. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  102133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  102134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  102135. /***/ }),
  102136. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  102137. /*!********************************************************!*\
  102138. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  102139. \********************************************************/
  102140. /*! exports provided: PointParticleEmitter */
  102141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102142. "use strict";
  102143. __webpack_require__.r(__webpack_exports__);
  102144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  102145. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102146. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102147. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102148. /**
  102149. * Particle emitter emitting particles from a point.
  102150. * It emits the particles randomly between 2 given directions.
  102151. */
  102152. var PointParticleEmitter = /** @class */ (function () {
  102153. /**
  102154. * Creates a new instance PointParticleEmitter
  102155. */
  102156. function PointParticleEmitter() {
  102157. /**
  102158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102159. */
  102160. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102161. /**
  102162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102163. */
  102164. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102165. }
  102166. /**
  102167. * Called by the particle System when the direction is computed for the created particle.
  102168. * @param worldMatrix is the world matrix of the particle system
  102169. * @param directionToUpdate is the direction vector to update with the result
  102170. * @param particle is the particle we are computed the direction for
  102171. */
  102172. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102173. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102174. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102175. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102176. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102177. };
  102178. /**
  102179. * Called by the particle System when the position is computed for the created particle.
  102180. * @param worldMatrix is the world matrix of the particle system
  102181. * @param positionToUpdate is the position vector to update with the result
  102182. * @param particle is the particle we are computed the position for
  102183. */
  102184. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102185. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  102186. };
  102187. /**
  102188. * Clones the current emitter and returns a copy of it
  102189. * @returns the new emitter
  102190. */
  102191. PointParticleEmitter.prototype.clone = function () {
  102192. var newOne = new PointParticleEmitter();
  102193. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102194. return newOne;
  102195. };
  102196. /**
  102197. * Called by the GPUParticleSystem to setup the update shader
  102198. * @param effect defines the update shader
  102199. */
  102200. PointParticleEmitter.prototype.applyToShader = function (effect) {
  102201. effect.setVector3("direction1", this.direction1);
  102202. effect.setVector3("direction2", this.direction2);
  102203. };
  102204. /**
  102205. * Returns a string to use to update the GPU particles update shader
  102206. * @returns a string containng the defines string
  102207. */
  102208. PointParticleEmitter.prototype.getEffectDefines = function () {
  102209. return "#define POINTEMITTER";
  102210. };
  102211. /**
  102212. * Returns the string "PointParticleEmitter"
  102213. * @returns a string containing the class name
  102214. */
  102215. PointParticleEmitter.prototype.getClassName = function () {
  102216. return "PointParticleEmitter";
  102217. };
  102218. /**
  102219. * Serializes the particle system to a JSON object.
  102220. * @returns the JSON object
  102221. */
  102222. PointParticleEmitter.prototype.serialize = function () {
  102223. var serializationObject = {};
  102224. serializationObject.type = this.getClassName();
  102225. serializationObject.direction1 = this.direction1.asArray();
  102226. serializationObject.direction2 = this.direction2.asArray();
  102227. return serializationObject;
  102228. };
  102229. /**
  102230. * Parse properties from a JSON object
  102231. * @param serializationObject defines the JSON object
  102232. */
  102233. PointParticleEmitter.prototype.parse = function (serializationObject) {
  102234. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  102235. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  102236. };
  102237. return PointParticleEmitter;
  102238. }());
  102239. /***/ }),
  102240. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  102241. /*!*********************************************************!*\
  102242. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  102243. \*********************************************************/
  102244. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  102245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102246. "use strict";
  102247. __webpack_require__.r(__webpack_exports__);
  102248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  102249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  102250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102251. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102252. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102253. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102254. /**
  102255. * Particle emitter emitting particles from the inside of a sphere.
  102256. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  102257. */
  102258. var SphereParticleEmitter = /** @class */ (function () {
  102259. /**
  102260. * Creates a new instance SphereParticleEmitter
  102261. * @param radius the radius of the emission sphere (1 by default)
  102262. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102263. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102264. */
  102265. function SphereParticleEmitter(
  102266. /**
  102267. * The radius of the emission sphere.
  102268. */
  102269. radius,
  102270. /**
  102271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102272. */
  102273. radiusRange,
  102274. /**
  102275. * How much to randomize the particle direction [0-1].
  102276. */
  102277. directionRandomizer) {
  102278. if (radius === void 0) { radius = 1; }
  102279. if (radiusRange === void 0) { radiusRange = 1; }
  102280. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102281. this.radius = radius;
  102282. this.radiusRange = radiusRange;
  102283. this.directionRandomizer = directionRandomizer;
  102284. }
  102285. /**
  102286. * Called by the particle System when the direction is computed for the created particle.
  102287. * @param worldMatrix is the world matrix of the particle system
  102288. * @param directionToUpdate is the direction vector to update with the result
  102289. * @param particle is the particle we are computed the direction for
  102290. */
  102291. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102292. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102293. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102294. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102295. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102296. direction.x += randX;
  102297. direction.y += randY;
  102298. direction.z += randZ;
  102299. direction.normalize();
  102300. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102301. };
  102302. /**
  102303. * Called by the particle System when the position is computed for the created particle.
  102304. * @param worldMatrix is the world matrix of the particle system
  102305. * @param positionToUpdate is the position vector to update with the result
  102306. * @param particle is the particle we are computed the position for
  102307. */
  102308. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102309. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102310. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102311. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102312. var theta = Math.acos(2 * v - 1);
  102313. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102314. var randY = randRadius * Math.cos(theta);
  102315. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102316. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102317. };
  102318. /**
  102319. * Clones the current emitter and returns a copy of it
  102320. * @returns the new emitter
  102321. */
  102322. SphereParticleEmitter.prototype.clone = function () {
  102323. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  102324. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102325. return newOne;
  102326. };
  102327. /**
  102328. * Called by the GPUParticleSystem to setup the update shader
  102329. * @param effect defines the update shader
  102330. */
  102331. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  102332. effect.setFloat("radius", this.radius);
  102333. effect.setFloat("radiusRange", this.radiusRange);
  102334. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102335. };
  102336. /**
  102337. * Returns a string to use to update the GPU particles update shader
  102338. * @returns a string containng the defines string
  102339. */
  102340. SphereParticleEmitter.prototype.getEffectDefines = function () {
  102341. return "#define SPHEREEMITTER";
  102342. };
  102343. /**
  102344. * Returns the string "SphereParticleEmitter"
  102345. * @returns a string containing the class name
  102346. */
  102347. SphereParticleEmitter.prototype.getClassName = function () {
  102348. return "SphereParticleEmitter";
  102349. };
  102350. /**
  102351. * Serializes the particle system to a JSON object.
  102352. * @returns the JSON object
  102353. */
  102354. SphereParticleEmitter.prototype.serialize = function () {
  102355. var serializationObject = {};
  102356. serializationObject.type = this.getClassName();
  102357. serializationObject.radius = this.radius;
  102358. serializationObject.radiusRange = this.radiusRange;
  102359. serializationObject.directionRandomizer = this.directionRandomizer;
  102360. return serializationObject;
  102361. };
  102362. /**
  102363. * Parse properties from a JSON object
  102364. * @param serializationObject defines the JSON object
  102365. */
  102366. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  102367. this.radius = serializationObject.radius;
  102368. this.radiusRange = serializationObject.radiusRange;
  102369. this.directionRandomizer = serializationObject.directionRandomizer;
  102370. };
  102371. return SphereParticleEmitter;
  102372. }());
  102373. /**
  102374. * Particle emitter emitting particles from the inside of a sphere.
  102375. * It emits the particles randomly between two vectors.
  102376. */
  102377. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  102378. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  102379. /**
  102380. * Creates a new instance SphereDirectedParticleEmitter
  102381. * @param radius the radius of the emission sphere (1 by default)
  102382. * @param direction1 the min limit of the emission direction (up vector by default)
  102383. * @param direction2 the max limit of the emission direction (up vector by default)
  102384. */
  102385. function SphereDirectedParticleEmitter(radius,
  102386. /**
  102387. * The min limit of the emission direction.
  102388. */
  102389. direction1,
  102390. /**
  102391. * The max limit of the emission direction.
  102392. */
  102393. direction2) {
  102394. if (radius === void 0) { radius = 1; }
  102395. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102396. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102397. var _this = _super.call(this, radius) || this;
  102398. _this.direction1 = direction1;
  102399. _this.direction2 = direction2;
  102400. return _this;
  102401. }
  102402. /**
  102403. * Called by the particle System when the direction is computed for the created particle.
  102404. * @param worldMatrix is the world matrix of the particle system
  102405. * @param directionToUpdate is the direction vector to update with the result
  102406. * @param particle is the particle we are computed the direction for
  102407. */
  102408. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102409. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102410. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102411. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102412. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102413. };
  102414. /**
  102415. * Clones the current emitter and returns a copy of it
  102416. * @returns the new emitter
  102417. */
  102418. SphereDirectedParticleEmitter.prototype.clone = function () {
  102419. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  102420. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102421. return newOne;
  102422. };
  102423. /**
  102424. * Called by the GPUParticleSystem to setup the update shader
  102425. * @param effect defines the update shader
  102426. */
  102427. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102428. effect.setFloat("radius", this.radius);
  102429. effect.setFloat("radiusRange", this.radiusRange);
  102430. effect.setVector3("direction1", this.direction1);
  102431. effect.setVector3("direction2", this.direction2);
  102432. };
  102433. /**
  102434. * Returns a string to use to update the GPU particles update shader
  102435. * @returns a string containng the defines string
  102436. */
  102437. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102438. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  102439. };
  102440. /**
  102441. * Returns the string "SphereDirectedParticleEmitter"
  102442. * @returns a string containing the class name
  102443. */
  102444. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  102445. return "SphereDirectedParticleEmitter";
  102446. };
  102447. /**
  102448. * Serializes the particle system to a JSON object.
  102449. * @returns the JSON object
  102450. */
  102451. SphereDirectedParticleEmitter.prototype.serialize = function () {
  102452. var serializationObject = _super.prototype.serialize.call(this);
  102453. serializationObject.direction1 = this.direction1.asArray();
  102454. serializationObject.direction2 = this.direction2.asArray();
  102455. return serializationObject;
  102456. };
  102457. /**
  102458. * Parse properties from a JSON object
  102459. * @param serializationObject defines the JSON object
  102460. */
  102461. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102462. _super.prototype.parse.call(this, serializationObject);
  102463. this.direction1.copyFrom(serializationObject.direction1);
  102464. this.direction2.copyFrom(serializationObject.direction2);
  102465. };
  102466. return SphereDirectedParticleEmitter;
  102467. }(SphereParticleEmitter));
  102468. /***/ }),
  102469. /***/ "./Particles/baseParticleSystem.ts":
  102470. /*!*****************************************!*\
  102471. !*** ./Particles/baseParticleSystem.ts ***!
  102472. \*****************************************/
  102473. /*! exports provided: BaseParticleSystem */
  102474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102475. "use strict";
  102476. __webpack_require__.r(__webpack_exports__);
  102477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  102478. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102479. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102480. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  102481. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102482. /**
  102483. * This represents the base class for particle system in Babylon.
  102484. * 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.
  102485. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  102486. * @example https://doc.babylonjs.com/babylon101/particles
  102487. */
  102488. var BaseParticleSystem = /** @class */ (function () {
  102489. /**
  102490. * Instantiates a particle system.
  102491. * 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.
  102492. * @param name The name of the particle system
  102493. */
  102494. function BaseParticleSystem(name) {
  102495. /**
  102496. * List of animations used by the particle system.
  102497. */
  102498. this.animations = [];
  102499. /**
  102500. * The rendering group used by the Particle system to chose when to render.
  102501. */
  102502. this.renderingGroupId = 0;
  102503. /**
  102504. * The emitter represents the Mesh or position we are attaching the particle system to.
  102505. */
  102506. this.emitter = null;
  102507. /**
  102508. * The maximum number of particles to emit per frame
  102509. */
  102510. this.emitRate = 10;
  102511. /**
  102512. * If you want to launch only a few particles at once, that can be done, as well.
  102513. */
  102514. this.manualEmitCount = -1;
  102515. /**
  102516. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102517. */
  102518. this.updateSpeed = 0.01;
  102519. /**
  102520. * The amount of time the particle system is running (depends of the overall update speed).
  102521. */
  102522. this.targetStopDuration = 0;
  102523. /**
  102524. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102525. */
  102526. this.disposeOnStop = false;
  102527. /**
  102528. * Minimum power of emitting particles.
  102529. */
  102530. this.minEmitPower = 1;
  102531. /**
  102532. * Maximum power of emitting particles.
  102533. */
  102534. this.maxEmitPower = 1;
  102535. /**
  102536. * Minimum life time of emitting particles.
  102537. */
  102538. this.minLifeTime = 1;
  102539. /**
  102540. * Maximum life time of emitting particles.
  102541. */
  102542. this.maxLifeTime = 1;
  102543. /**
  102544. * Minimum Size of emitting particles.
  102545. */
  102546. this.minSize = 1;
  102547. /**
  102548. * Maximum Size of emitting particles.
  102549. */
  102550. this.maxSize = 1;
  102551. /**
  102552. * Minimum scale of emitting particles on X axis.
  102553. */
  102554. this.minScaleX = 1;
  102555. /**
  102556. * Maximum scale of emitting particles on X axis.
  102557. */
  102558. this.maxScaleX = 1;
  102559. /**
  102560. * Minimum scale of emitting particles on Y axis.
  102561. */
  102562. this.minScaleY = 1;
  102563. /**
  102564. * Maximum scale of emitting particles on Y axis.
  102565. */
  102566. this.maxScaleY = 1;
  102567. /**
  102568. * Gets or sets the minimal initial rotation in radians.
  102569. */
  102570. this.minInitialRotation = 0;
  102571. /**
  102572. * Gets or sets the maximal initial rotation in radians.
  102573. */
  102574. this.maxInitialRotation = 0;
  102575. /**
  102576. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102577. */
  102578. this.minAngularSpeed = 0;
  102579. /**
  102580. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102581. */
  102582. this.maxAngularSpeed = 0;
  102583. /**
  102584. * The layer mask we are rendering the particles through.
  102585. */
  102586. this.layerMask = 0x0FFFFFFF;
  102587. /**
  102588. * This can help using your own shader to render the particle system.
  102589. * The according effect will be created
  102590. */
  102591. this.customShader = null;
  102592. /**
  102593. * By default particle system starts as soon as they are created. This prevents the
  102594. * automatic start to happen and let you decide when to start emitting particles.
  102595. */
  102596. this.preventAutoStart = false;
  102597. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102598. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  102599. /**
  102600. * Callback triggered when the particle animation is ending.
  102601. */
  102602. this.onAnimationEnd = null;
  102603. /**
  102604. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  102605. */
  102606. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  102607. /**
  102608. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102609. * to override the particles.
  102610. */
  102611. this.forceDepthWrite = false;
  102612. /** 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 */
  102613. this.preWarmCycles = 0;
  102614. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  102615. this.preWarmStepOffset = 1;
  102616. /**
  102617. * 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)
  102618. */
  102619. this.spriteCellChangeSpeed = 1;
  102620. /**
  102621. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102622. */
  102623. this.startSpriteCellID = 0;
  102624. /**
  102625. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102626. */
  102627. this.endSpriteCellID = 0;
  102628. /**
  102629. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102630. */
  102631. this.spriteCellWidth = 0;
  102632. /**
  102633. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102634. */
  102635. this.spriteCellHeight = 0;
  102636. /**
  102637. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  102638. */
  102639. this.spriteRandomStartCell = false;
  102640. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  102641. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  102642. /**
  102643. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  102644. */
  102645. this.beginAnimationOnStart = false;
  102646. /**
  102647. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  102648. */
  102649. this.beginAnimationFrom = 0;
  102650. /**
  102651. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  102652. */
  102653. this.beginAnimationTo = 60;
  102654. /**
  102655. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  102656. */
  102657. this.beginAnimationLoop = false;
  102658. /**
  102659. * You can use gravity if you want to give an orientation to your particles.
  102660. */
  102661. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102662. this._colorGradients = null;
  102663. this._sizeGradients = null;
  102664. this._lifeTimeGradients = null;
  102665. this._angularSpeedGradients = null;
  102666. this._velocityGradients = null;
  102667. this._limitVelocityGradients = null;
  102668. this._dragGradients = null;
  102669. this._emitRateGradients = null;
  102670. this._startSizeGradients = null;
  102671. this._rampGradients = null;
  102672. this._colorRemapGradients = null;
  102673. this._alphaRemapGradients = null;
  102674. /**
  102675. * Defines the delay in milliseconds before starting the system (0 by default)
  102676. */
  102677. this.startDelay = 0;
  102678. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  102679. this.limitVelocityDamping = 0.4;
  102680. /**
  102681. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  102682. */
  102683. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102684. /**
  102685. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  102686. */
  102687. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102688. /**
  102689. * Color the particle will have at the end of its lifetime
  102690. */
  102691. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  102692. /**
  102693. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  102694. */
  102695. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  102696. /** @hidden */
  102697. this._isSubEmitter = false;
  102698. /**
  102699. * Gets or sets the billboard mode to use when isBillboardBased = true.
  102700. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  102701. */
  102702. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  102703. this._isBillboardBased = true;
  102704. /**
  102705. * Local cache of defines for image processing.
  102706. */
  102707. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  102708. this.id = name;
  102709. this.name = name;
  102710. }
  102711. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  102712. /**
  102713. * Gets or sets a texture used to add random noise to particle positions
  102714. */
  102715. get: function () {
  102716. return this._noiseTexture;
  102717. },
  102718. set: function (value) {
  102719. if (this._noiseTexture === value) {
  102720. return;
  102721. }
  102722. this._noiseTexture = value;
  102723. this._reset();
  102724. },
  102725. enumerable: true,
  102726. configurable: true
  102727. });
  102728. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  102729. /**
  102730. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  102731. */
  102732. get: function () {
  102733. return this._isAnimationSheetEnabled;
  102734. },
  102735. set: function (value) {
  102736. if (this._isAnimationSheetEnabled == value) {
  102737. return;
  102738. }
  102739. this._isAnimationSheetEnabled = value;
  102740. this._reset();
  102741. },
  102742. enumerable: true,
  102743. configurable: true
  102744. });
  102745. /**
  102746. * Get hosting scene
  102747. * @returns the scene
  102748. */
  102749. BaseParticleSystem.prototype.getScene = function () {
  102750. return this._scene;
  102751. };
  102752. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  102753. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  102754. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  102755. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  102756. };
  102757. /**
  102758. * Gets the current list of drag gradients.
  102759. * You must use addDragGradient and removeDragGradient to udpate this list
  102760. * @returns the list of drag gradients
  102761. */
  102762. BaseParticleSystem.prototype.getDragGradients = function () {
  102763. return this._dragGradients;
  102764. };
  102765. /**
  102766. * Gets the current list of limit velocity gradients.
  102767. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  102768. * @returns the list of limit velocity gradients
  102769. */
  102770. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  102771. return this._limitVelocityGradients;
  102772. };
  102773. /**
  102774. * Gets the current list of color gradients.
  102775. * You must use addColorGradient and removeColorGradient to udpate this list
  102776. * @returns the list of color gradients
  102777. */
  102778. BaseParticleSystem.prototype.getColorGradients = function () {
  102779. return this._colorGradients;
  102780. };
  102781. /**
  102782. * Gets the current list of size gradients.
  102783. * You must use addSizeGradient and removeSizeGradient to udpate this list
  102784. * @returns the list of size gradients
  102785. */
  102786. BaseParticleSystem.prototype.getSizeGradients = function () {
  102787. return this._sizeGradients;
  102788. };
  102789. /**
  102790. * Gets the current list of color remap gradients.
  102791. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102792. * @returns the list of color remap gradients
  102793. */
  102794. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  102795. return this._colorRemapGradients;
  102796. };
  102797. /**
  102798. * Gets the current list of alpha remap gradients.
  102799. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102800. * @returns the list of alpha remap gradients
  102801. */
  102802. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  102803. return this._alphaRemapGradients;
  102804. };
  102805. /**
  102806. * Gets the current list of life time gradients.
  102807. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  102808. * @returns the list of life time gradients
  102809. */
  102810. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  102811. return this._lifeTimeGradients;
  102812. };
  102813. /**
  102814. * Gets the current list of angular speed gradients.
  102815. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  102816. * @returns the list of angular speed gradients
  102817. */
  102818. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  102819. return this._angularSpeedGradients;
  102820. };
  102821. /**
  102822. * Gets the current list of velocity gradients.
  102823. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  102824. * @returns the list of velocity gradients
  102825. */
  102826. BaseParticleSystem.prototype.getVelocityGradients = function () {
  102827. return this._velocityGradients;
  102828. };
  102829. /**
  102830. * Gets the current list of start size gradients.
  102831. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  102832. * @returns the list of start size gradients
  102833. */
  102834. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  102835. return this._startSizeGradients;
  102836. };
  102837. /**
  102838. * Gets the current list of emit rate gradients.
  102839. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  102840. * @returns the list of emit rate gradients
  102841. */
  102842. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  102843. return this._emitRateGradients;
  102844. };
  102845. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  102846. /**
  102847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102849. */
  102850. get: function () {
  102851. if (this.particleEmitterType.direction1) {
  102852. return this.particleEmitterType.direction1;
  102853. }
  102854. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102855. },
  102856. set: function (value) {
  102857. if (this.particleEmitterType.direction1) {
  102858. this.particleEmitterType.direction1 = value;
  102859. }
  102860. },
  102861. enumerable: true,
  102862. configurable: true
  102863. });
  102864. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  102865. /**
  102866. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102868. */
  102869. get: function () {
  102870. if (this.particleEmitterType.direction2) {
  102871. return this.particleEmitterType.direction2;
  102872. }
  102873. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102874. },
  102875. set: function (value) {
  102876. if (this.particleEmitterType.direction2) {
  102877. this.particleEmitterType.direction2 = value;
  102878. }
  102879. },
  102880. enumerable: true,
  102881. configurable: true
  102882. });
  102883. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  102884. /**
  102885. * 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.
  102886. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102887. */
  102888. get: function () {
  102889. if (this.particleEmitterType.minEmitBox) {
  102890. return this.particleEmitterType.minEmitBox;
  102891. }
  102892. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102893. },
  102894. set: function (value) {
  102895. if (this.particleEmitterType.minEmitBox) {
  102896. this.particleEmitterType.minEmitBox = value;
  102897. }
  102898. },
  102899. enumerable: true,
  102900. configurable: true
  102901. });
  102902. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  102903. /**
  102904. * 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.
  102905. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102906. */
  102907. get: function () {
  102908. if (this.particleEmitterType.maxEmitBox) {
  102909. return this.particleEmitterType.maxEmitBox;
  102910. }
  102911. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102912. },
  102913. set: function (value) {
  102914. if (this.particleEmitterType.maxEmitBox) {
  102915. this.particleEmitterType.maxEmitBox = value;
  102916. }
  102917. },
  102918. enumerable: true,
  102919. configurable: true
  102920. });
  102921. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  102922. /**
  102923. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  102924. */
  102925. get: function () {
  102926. return this._isBillboardBased;
  102927. },
  102928. set: function (value) {
  102929. if (this._isBillboardBased === value) {
  102930. return;
  102931. }
  102932. this._isBillboardBased = value;
  102933. this._reset();
  102934. },
  102935. enumerable: true,
  102936. configurable: true
  102937. });
  102938. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  102939. /**
  102940. * Gets the image processing configuration used either in this material.
  102941. */
  102942. get: function () {
  102943. return this._imageProcessingConfiguration;
  102944. },
  102945. /**
  102946. * Sets the Default image processing configuration used either in the this material.
  102947. *
  102948. * If sets to null, the scene one is in use.
  102949. */
  102950. set: function (value) {
  102951. this._attachImageProcessingConfiguration(value);
  102952. },
  102953. enumerable: true,
  102954. configurable: true
  102955. });
  102956. /**
  102957. * Attaches a new image processing configuration to the Standard Material.
  102958. * @param configuration
  102959. */
  102960. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  102961. if (configuration === this._imageProcessingConfiguration) {
  102962. return;
  102963. }
  102964. // Pick the scene configuration if needed.
  102965. if (!configuration) {
  102966. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  102967. }
  102968. else {
  102969. this._imageProcessingConfiguration = configuration;
  102970. }
  102971. };
  102972. /** @hidden */
  102973. BaseParticleSystem.prototype._reset = function () {
  102974. };
  102975. /** @hidden */
  102976. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102977. if (!gradients) {
  102978. return this;
  102979. }
  102980. var index = 0;
  102981. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  102982. var valueGradient = gradients_1[_i];
  102983. if (valueGradient.gradient === gradient) {
  102984. gradients.splice(index, 1);
  102985. break;
  102986. }
  102987. index++;
  102988. }
  102989. if (texture) {
  102990. texture.dispose();
  102991. }
  102992. return this;
  102993. };
  102994. /**
  102995. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102996. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102997. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102998. * @returns the emitter
  102999. */
  103000. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  103001. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  103002. particleEmitter.direction1 = direction1;
  103003. particleEmitter.direction2 = direction2;
  103004. this.particleEmitterType = particleEmitter;
  103005. return particleEmitter;
  103006. };
  103007. /**
  103008. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  103009. * @param radius The radius of the hemisphere to emit from
  103010. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103011. * @returns the emitter
  103012. */
  103013. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  103014. if (radius === void 0) { radius = 1; }
  103015. if (radiusRange === void 0) { radiusRange = 1; }
  103016. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  103017. this.particleEmitterType = particleEmitter;
  103018. return particleEmitter;
  103019. };
  103020. /**
  103021. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  103022. * @param radius The radius of the sphere to emit from
  103023. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103024. * @returns the emitter
  103025. */
  103026. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  103027. if (radius === void 0) { radius = 1; }
  103028. if (radiusRange === void 0) { radiusRange = 1; }
  103029. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  103030. this.particleEmitterType = particleEmitter;
  103031. return particleEmitter;
  103032. };
  103033. /**
  103034. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  103035. * @param radius The radius of the sphere to emit from
  103036. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  103037. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  103038. * @returns the emitter
  103039. */
  103040. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  103041. if (radius === void 0) { radius = 1; }
  103042. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103043. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103044. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  103045. this.particleEmitterType = particleEmitter;
  103046. return particleEmitter;
  103047. };
  103048. /**
  103049. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  103050. * @param radius The radius of the emission cylinder
  103051. * @param height The height of the emission cylinder
  103052. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  103053. * @param directionRandomizer How much to randomize the particle direction [0-1]
  103054. * @returns the emitter
  103055. */
  103056. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  103057. if (radius === void 0) { radius = 1; }
  103058. if (height === void 0) { height = 1; }
  103059. if (radiusRange === void 0) { radiusRange = 1; }
  103060. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103061. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  103062. this.particleEmitterType = particleEmitter;
  103063. return particleEmitter;
  103064. };
  103065. /**
  103066. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  103067. * @param radius The radius of the cylinder to emit from
  103068. * @param height The height of the emission cylinder
  103069. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  103071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  103072. * @returns the emitter
  103073. */
  103074. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  103075. if (radius === void 0) { radius = 1; }
  103076. if (height === void 0) { height = 1; }
  103077. if (radiusRange === void 0) { radiusRange = 1; }
  103078. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103079. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103080. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  103081. this.particleEmitterType = particleEmitter;
  103082. return particleEmitter;
  103083. };
  103084. /**
  103085. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103086. * @param radius The radius of the cone to emit from
  103087. * @param angle The base angle of the cone
  103088. * @returns the emitter
  103089. */
  103090. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  103091. if (radius === void 0) { radius = 1; }
  103092. if (angle === void 0) { angle = Math.PI / 4; }
  103093. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  103094. this.particleEmitterType = particleEmitter;
  103095. return particleEmitter;
  103096. };
  103097. /**
  103098. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  103099. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103100. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103101. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103102. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103103. * @returns the emitter
  103104. */
  103105. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  103106. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  103107. this.particleEmitterType = particleEmitter;
  103108. this.direction1 = direction1;
  103109. this.direction2 = direction2;
  103110. this.minEmitBox = minEmitBox;
  103111. this.maxEmitBox = maxEmitBox;
  103112. return particleEmitter;
  103113. };
  103114. /**
  103115. * Source color is added to the destination color without alpha affecting the result
  103116. */
  103117. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  103118. /**
  103119. * Blend current color and particle color using particle’s alpha
  103120. */
  103121. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  103122. /**
  103123. * Add current color and particle color multiplied by particle’s alpha
  103124. */
  103125. BaseParticleSystem.BLENDMODE_ADD = 2;
  103126. /**
  103127. * Multiply current color with particle color
  103128. */
  103129. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  103130. /**
  103131. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  103132. */
  103133. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  103134. return BaseParticleSystem;
  103135. }());
  103136. /***/ }),
  103137. /***/ "./Particles/gpuParticleSystem.ts":
  103138. /*!****************************************!*\
  103139. !*** ./Particles/gpuParticleSystem.ts ***!
  103140. \****************************************/
  103141. /*! exports provided: GPUParticleSystem */
  103142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103143. "use strict";
  103144. __webpack_require__.r(__webpack_exports__);
  103145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  103146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103147. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103148. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103149. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103150. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103151. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103152. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103153. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103154. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  103155. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  103156. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  103157. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  103158. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103159. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103160. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  103161. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103162. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103163. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103164. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  103165. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  103166. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  103167. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  103168. /**
  103169. * This represents a GPU particle system in Babylon
  103170. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  103171. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  103172. */
  103173. var GPUParticleSystem = /** @class */ (function (_super) {
  103174. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  103175. /**
  103176. * Instantiates a GPU particle system.
  103177. * 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.
  103178. * @param name The name of the particle system
  103179. * @param options The options used to create the system
  103180. * @param scene The scene the particle system belongs to
  103181. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103182. */
  103183. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  103184. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  103185. var _this = _super.call(this, name) || this;
  103186. /**
  103187. * The layer mask we are rendering the particles through.
  103188. */
  103189. _this.layerMask = 0x0FFFFFFF;
  103190. _this._accumulatedCount = 0;
  103191. _this._targetIndex = 0;
  103192. _this._currentRenderId = -1;
  103193. _this._started = false;
  103194. _this._stopped = false;
  103195. _this._timeDelta = 0;
  103196. _this._actualFrame = 0;
  103197. _this._rawTextureWidth = 256;
  103198. /**
  103199. * An event triggered when the system is disposed.
  103200. */
  103201. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  103202. /**
  103203. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103204. * to override the particles.
  103205. */
  103206. _this.forceDepthWrite = false;
  103207. _this._preWarmDone = false;
  103208. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  103209. // Setup the default processing configuration to the scene.
  103210. _this._attachImageProcessingConfiguration(null);
  103211. _this._engine = _this._scene.getEngine();
  103212. if (!options.randomTextureSize) {
  103213. delete options.randomTextureSize;
  103214. }
  103215. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  103216. var optionsAsNumber = options;
  103217. if (isFinite(optionsAsNumber)) {
  103218. fullOptions.capacity = optionsAsNumber;
  103219. }
  103220. _this._capacity = fullOptions.capacity;
  103221. _this._activeCount = fullOptions.capacity;
  103222. _this._currentActiveCount = 0;
  103223. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  103224. _this._scene.particleSystems.push(_this);
  103225. _this._updateEffectOptions = {
  103226. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  103227. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  103228. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  103229. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  103230. uniformBuffersNames: [],
  103231. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  103232. defines: "",
  103233. fallbacks: null,
  103234. onCompiled: null,
  103235. onError: null,
  103236. indexParameters: null,
  103237. maxSimultaneousLights: 0,
  103238. transformFeedbackVaryings: []
  103239. };
  103240. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  103241. // Random data
  103242. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  103243. var d = [];
  103244. for (var i = 0; i < maxTextureSize; ++i) {
  103245. d.push(Math.random());
  103246. d.push(Math.random());
  103247. d.push(Math.random());
  103248. d.push(Math.random());
  103249. }
  103250. _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);
  103251. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103252. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103253. d = [];
  103254. for (var i = 0; i < maxTextureSize; ++i) {
  103255. d.push(Math.random());
  103256. d.push(Math.random());
  103257. d.push(Math.random());
  103258. d.push(Math.random());
  103259. }
  103260. _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);
  103261. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103262. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103263. _this._randomTextureSize = maxTextureSize;
  103264. return _this;
  103265. }
  103266. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  103267. /**
  103268. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  103269. */
  103270. get: function () {
  103271. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  103272. return false;
  103273. }
  103274. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  103275. },
  103276. enumerable: true,
  103277. configurable: true
  103278. });
  103279. /**
  103280. * Gets the maximum number of particles active at the same time.
  103281. * @returns The max number of active particles.
  103282. */
  103283. GPUParticleSystem.prototype.getCapacity = function () {
  103284. return this._capacity;
  103285. };
  103286. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  103287. /**
  103288. * Gets or set the number of active particles
  103289. */
  103290. get: function () {
  103291. return this._activeCount;
  103292. },
  103293. set: function (value) {
  103294. this._activeCount = Math.min(value, this._capacity);
  103295. },
  103296. enumerable: true,
  103297. configurable: true
  103298. });
  103299. /**
  103300. * Is this system ready to be used/rendered
  103301. * @return true if the system is ready
  103302. */
  103303. GPUParticleSystem.prototype.isReady = function () {
  103304. if (!this._updateEffect) {
  103305. this._recreateUpdateEffect();
  103306. this._recreateRenderEffect();
  103307. return false;
  103308. }
  103309. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  103310. return false;
  103311. }
  103312. return true;
  103313. };
  103314. /**
  103315. * Gets if the system has been started. (Note: this will still be true after stop is called)
  103316. * @returns True if it has been started, otherwise false.
  103317. */
  103318. GPUParticleSystem.prototype.isStarted = function () {
  103319. return this._started;
  103320. };
  103321. /**
  103322. * Starts the particle system and begins to emit
  103323. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  103324. */
  103325. GPUParticleSystem.prototype.start = function (delay) {
  103326. var _this = this;
  103327. if (delay === void 0) { delay = this.startDelay; }
  103328. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  103329. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  103330. }
  103331. if (delay) {
  103332. setTimeout(function () {
  103333. _this.start(0);
  103334. }, delay);
  103335. return;
  103336. }
  103337. this._started = true;
  103338. this._stopped = false;
  103339. this._preWarmDone = false;
  103340. // Animations
  103341. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  103342. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  103343. }
  103344. };
  103345. /**
  103346. * Stops the particle system.
  103347. */
  103348. GPUParticleSystem.prototype.stop = function () {
  103349. this._stopped = true;
  103350. };
  103351. /**
  103352. * Remove all active particles
  103353. */
  103354. GPUParticleSystem.prototype.reset = function () {
  103355. this._releaseBuffers();
  103356. this._releaseVAOs();
  103357. this._currentActiveCount = 0;
  103358. this._targetIndex = 0;
  103359. };
  103360. /**
  103361. * Returns the string "GPUParticleSystem"
  103362. * @returns a string containing the class name
  103363. */
  103364. GPUParticleSystem.prototype.getClassName = function () {
  103365. return "GPUParticleSystem";
  103366. };
  103367. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103368. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  103369. this._releaseBuffers();
  103370. return this;
  103371. };
  103372. /**
  103373. * Adds a new color gradient
  103374. * @param gradient defines the gradient to use (between 0 and 1)
  103375. * @param color1 defines the color to affect to the specified gradient
  103376. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  103377. * @returns the current particle system
  103378. */
  103379. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  103380. if (!this._colorGradients) {
  103381. this._colorGradients = [];
  103382. }
  103383. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  103384. colorGradient.gradient = gradient;
  103385. colorGradient.color1 = color1;
  103386. this._colorGradients.push(colorGradient);
  103387. this._colorGradients.sort(function (a, b) {
  103388. if (a.gradient < b.gradient) {
  103389. return -1;
  103390. }
  103391. else if (a.gradient > b.gradient) {
  103392. return 1;
  103393. }
  103394. return 0;
  103395. });
  103396. if (this._colorGradientsTexture) {
  103397. this._colorGradientsTexture.dispose();
  103398. this._colorGradientsTexture = null;
  103399. }
  103400. this._releaseBuffers();
  103401. return this;
  103402. };
  103403. /**
  103404. * Remove a specific color gradient
  103405. * @param gradient defines the gradient to remove
  103406. * @returns the current particle system
  103407. */
  103408. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  103409. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  103410. this._colorGradientsTexture = null;
  103411. return this;
  103412. };
  103413. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  103414. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  103415. valueGradient.gradient = gradient;
  103416. valueGradient.factor1 = factor;
  103417. factorGradients.push(valueGradient);
  103418. factorGradients.sort(function (a, b) {
  103419. if (a.gradient < b.gradient) {
  103420. return -1;
  103421. }
  103422. else if (a.gradient > b.gradient) {
  103423. return 1;
  103424. }
  103425. return 0;
  103426. });
  103427. this._releaseBuffers();
  103428. };
  103429. /**
  103430. * Adds a new size gradient
  103431. * @param gradient defines the gradient to use (between 0 and 1)
  103432. * @param factor defines the size factor to affect to the specified gradient
  103433. * @returns the current particle system
  103434. */
  103435. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  103436. if (!this._sizeGradients) {
  103437. this._sizeGradients = [];
  103438. }
  103439. this._addFactorGradient(this._sizeGradients, gradient, factor);
  103440. if (this._sizeGradientsTexture) {
  103441. this._sizeGradientsTexture.dispose();
  103442. this._sizeGradientsTexture = null;
  103443. }
  103444. this._releaseBuffers();
  103445. return this;
  103446. };
  103447. /**
  103448. * Remove a specific size gradient
  103449. * @param gradient defines the gradient to remove
  103450. * @returns the current particle system
  103451. */
  103452. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  103453. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  103454. this._sizeGradientsTexture = null;
  103455. return this;
  103456. };
  103457. /**
  103458. * Adds a new angular speed gradient
  103459. * @param gradient defines the gradient to use (between 0 and 1)
  103460. * @param factor defines the angular speed to affect to the specified gradient
  103461. * @returns the current particle system
  103462. */
  103463. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  103464. if (!this._angularSpeedGradients) {
  103465. this._angularSpeedGradients = [];
  103466. }
  103467. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  103468. if (this._angularSpeedGradientsTexture) {
  103469. this._angularSpeedGradientsTexture.dispose();
  103470. this._angularSpeedGradientsTexture = null;
  103471. }
  103472. this._releaseBuffers();
  103473. return this;
  103474. };
  103475. /**
  103476. * Remove a specific angular speed gradient
  103477. * @param gradient defines the gradient to remove
  103478. * @returns the current particle system
  103479. */
  103480. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  103481. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  103482. this._angularSpeedGradientsTexture = null;
  103483. return this;
  103484. };
  103485. /**
  103486. * Adds a new velocity gradient
  103487. * @param gradient defines the gradient to use (between 0 and 1)
  103488. * @param factor defines the velocity to affect to the specified gradient
  103489. * @returns the current particle system
  103490. */
  103491. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  103492. if (!this._velocityGradients) {
  103493. this._velocityGradients = [];
  103494. }
  103495. this._addFactorGradient(this._velocityGradients, gradient, factor);
  103496. if (this._velocityGradientsTexture) {
  103497. this._velocityGradientsTexture.dispose();
  103498. this._velocityGradientsTexture = null;
  103499. }
  103500. this._releaseBuffers();
  103501. return this;
  103502. };
  103503. /**
  103504. * Remove a specific velocity gradient
  103505. * @param gradient defines the gradient to remove
  103506. * @returns the current particle system
  103507. */
  103508. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  103509. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  103510. this._velocityGradientsTexture = null;
  103511. return this;
  103512. };
  103513. /**
  103514. * Adds a new limit velocity gradient
  103515. * @param gradient defines the gradient to use (between 0 and 1)
  103516. * @param factor defines the limit velocity value to affect to the specified gradient
  103517. * @returns the current particle system
  103518. */
  103519. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  103520. if (!this._limitVelocityGradients) {
  103521. this._limitVelocityGradients = [];
  103522. }
  103523. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  103524. if (this._limitVelocityGradientsTexture) {
  103525. this._limitVelocityGradientsTexture.dispose();
  103526. this._limitVelocityGradientsTexture = null;
  103527. }
  103528. this._releaseBuffers();
  103529. return this;
  103530. };
  103531. /**
  103532. * Remove a specific limit velocity gradient
  103533. * @param gradient defines the gradient to remove
  103534. * @returns the current particle system
  103535. */
  103536. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  103537. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  103538. this._limitVelocityGradientsTexture = null;
  103539. return this;
  103540. };
  103541. /**
  103542. * Adds a new drag gradient
  103543. * @param gradient defines the gradient to use (between 0 and 1)
  103544. * @param factor defines the drag value to affect to the specified gradient
  103545. * @returns the current particle system
  103546. */
  103547. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  103548. if (!this._dragGradients) {
  103549. this._dragGradients = [];
  103550. }
  103551. this._addFactorGradient(this._dragGradients, gradient, factor);
  103552. if (this._dragGradientsTexture) {
  103553. this._dragGradientsTexture.dispose();
  103554. this._dragGradientsTexture = null;
  103555. }
  103556. this._releaseBuffers();
  103557. return this;
  103558. };
  103559. /**
  103560. * Remove a specific drag gradient
  103561. * @param gradient defines the gradient to remove
  103562. * @returns the current particle system
  103563. */
  103564. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  103565. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  103566. this._dragGradientsTexture = null;
  103567. return this;
  103568. };
  103569. /**
  103570. * Not supported by GPUParticleSystem
  103571. * @param gradient defines the gradient to use (between 0 and 1)
  103572. * @param factor defines the emit rate value to affect to the specified gradient
  103573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103574. * @returns the current particle system
  103575. */
  103576. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  103577. // Do nothing as emit rate is not supported by GPUParticleSystem
  103578. return this;
  103579. };
  103580. /**
  103581. * Not supported by GPUParticleSystem
  103582. * @param gradient defines the gradient to remove
  103583. * @returns the current particle system
  103584. */
  103585. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  103586. // Do nothing as emit rate is not supported by GPUParticleSystem
  103587. return this;
  103588. };
  103589. /**
  103590. * Not supported by GPUParticleSystem
  103591. * @param gradient defines the gradient to use (between 0 and 1)
  103592. * @param factor defines the start size value to affect to the specified gradient
  103593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103594. * @returns the current particle system
  103595. */
  103596. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  103597. // Do nothing as start size is not supported by GPUParticleSystem
  103598. return this;
  103599. };
  103600. /**
  103601. * Not supported by GPUParticleSystem
  103602. * @param gradient defines the gradient to remove
  103603. * @returns the current particle system
  103604. */
  103605. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  103606. // Do nothing as start size is not supported by GPUParticleSystem
  103607. return this;
  103608. };
  103609. /**
  103610. * Not supported by GPUParticleSystem
  103611. * @param gradient defines the gradient to use (between 0 and 1)
  103612. * @param min defines the color remap minimal range
  103613. * @param max defines the color remap maximal range
  103614. * @returns the current particle system
  103615. */
  103616. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  103617. // Do nothing as start size is not supported by GPUParticleSystem
  103618. return this;
  103619. };
  103620. /**
  103621. * Not supported by GPUParticleSystem
  103622. * @param gradient defines the gradient to remove
  103623. * @returns the current particle system
  103624. */
  103625. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  103626. // Do nothing as start size is not supported by GPUParticleSystem
  103627. return this;
  103628. };
  103629. /**
  103630. * Not supported by GPUParticleSystem
  103631. * @param gradient defines the gradient to use (between 0 and 1)
  103632. * @param min defines the alpha remap minimal range
  103633. * @param max defines the alpha remap maximal range
  103634. * @returns the current particle system
  103635. */
  103636. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  103637. // Do nothing as start size is not supported by GPUParticleSystem
  103638. return this;
  103639. };
  103640. /**
  103641. * Not supported by GPUParticleSystem
  103642. * @param gradient defines the gradient to remove
  103643. * @returns the current particle system
  103644. */
  103645. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  103646. // Do nothing as start size is not supported by GPUParticleSystem
  103647. return this;
  103648. };
  103649. /**
  103650. * Not supported by GPUParticleSystem
  103651. * @param gradient defines the gradient to use (between 0 and 1)
  103652. * @param color defines the color to affect to the specified gradient
  103653. * @returns the current particle system
  103654. */
  103655. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  103656. //Not supported by GPUParticleSystem
  103657. return this;
  103658. };
  103659. /**
  103660. * Not supported by GPUParticleSystem
  103661. * @param gradient defines the gradient to remove
  103662. * @returns the current particle system
  103663. */
  103664. GPUParticleSystem.prototype.removeRampGradient = function () {
  103665. //Not supported by GPUParticleSystem
  103666. return this;
  103667. };
  103668. /**
  103669. * Not supported by GPUParticleSystem
  103670. * @returns the list of ramp gradients
  103671. */
  103672. GPUParticleSystem.prototype.getRampGradients = function () {
  103673. return null;
  103674. };
  103675. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  103676. /**
  103677. * Not supported by GPUParticleSystem
  103678. * Gets or sets a boolean indicating that ramp gradients must be used
  103679. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  103680. */
  103681. get: function () {
  103682. //Not supported by GPUParticleSystem
  103683. return false;
  103684. },
  103685. set: function (value) {
  103686. //Not supported by GPUParticleSystem
  103687. },
  103688. enumerable: true,
  103689. configurable: true
  103690. });
  103691. /**
  103692. * Not supported by GPUParticleSystem
  103693. * @param gradient defines the gradient to use (between 0 and 1)
  103694. * @param factor defines the life time factor to affect to the specified gradient
  103695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103696. * @returns the current particle system
  103697. */
  103698. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  103699. //Not supported by GPUParticleSystem
  103700. return this;
  103701. };
  103702. /**
  103703. * Not supported by GPUParticleSystem
  103704. * @param gradient defines the gradient to remove
  103705. * @returns the current particle system
  103706. */
  103707. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  103708. //Not supported by GPUParticleSystem
  103709. return this;
  103710. };
  103711. GPUParticleSystem.prototype._reset = function () {
  103712. this._releaseBuffers();
  103713. };
  103714. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  103715. var updateVertexBuffers = {};
  103716. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  103717. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  103718. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  103719. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  103720. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  103721. var offset = 12;
  103722. if (!this._colorGradientsTexture) {
  103723. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  103724. offset += 4;
  103725. }
  103726. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  103727. offset += 3;
  103728. if (!this._isBillboardBased) {
  103729. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  103730. offset += 3;
  103731. }
  103732. if (this._angularSpeedGradientsTexture) {
  103733. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  103734. offset += 1;
  103735. }
  103736. else {
  103737. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  103738. offset += 2;
  103739. }
  103740. if (this._isAnimationSheetEnabled) {
  103741. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  103742. offset += 1;
  103743. if (this.spriteRandomStartCell) {
  103744. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  103745. offset += 1;
  103746. }
  103747. }
  103748. if (this.noiseTexture) {
  103749. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  103750. offset += 3;
  103751. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  103752. offset += 3;
  103753. }
  103754. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  103755. this._engine.bindArrayBuffer(null);
  103756. return vao;
  103757. };
  103758. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  103759. var renderVertexBuffers = {};
  103760. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  103761. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  103762. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  103763. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  103764. var offset = 12;
  103765. if (!this._colorGradientsTexture) {
  103766. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  103767. offset += 4;
  103768. }
  103769. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  103770. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  103771. }
  103772. offset += 3; // Direction
  103773. if (!this._isBillboardBased) {
  103774. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  103775. offset += 3;
  103776. }
  103777. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  103778. if (this._angularSpeedGradientsTexture) {
  103779. offset++;
  103780. }
  103781. else {
  103782. offset += 2;
  103783. }
  103784. if (this._isAnimationSheetEnabled) {
  103785. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  103786. offset += 1;
  103787. if (this.spriteRandomStartCell) {
  103788. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  103789. offset += 1;
  103790. }
  103791. }
  103792. if (this.noiseTexture) {
  103793. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  103794. offset += 3;
  103795. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  103796. offset += 3;
  103797. }
  103798. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  103799. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  103800. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  103801. this._engine.bindArrayBuffer(null);
  103802. return vao;
  103803. };
  103804. GPUParticleSystem.prototype._initialize = function (force) {
  103805. if (force === void 0) { force = false; }
  103806. if (this._buffer0 && !force) {
  103807. return;
  103808. }
  103809. var engine = this._scene.getEngine();
  103810. var data = new Array();
  103811. this._attributesStrideSize = 21;
  103812. this._targetIndex = 0;
  103813. if (!this.isBillboardBased) {
  103814. this._attributesStrideSize += 3;
  103815. }
  103816. if (this._colorGradientsTexture) {
  103817. this._attributesStrideSize -= 4;
  103818. }
  103819. if (this._angularSpeedGradientsTexture) {
  103820. this._attributesStrideSize -= 1;
  103821. }
  103822. if (this._isAnimationSheetEnabled) {
  103823. this._attributesStrideSize += 1;
  103824. if (this.spriteRandomStartCell) {
  103825. this._attributesStrideSize += 1;
  103826. }
  103827. }
  103828. if (this.noiseTexture) {
  103829. this._attributesStrideSize += 6;
  103830. }
  103831. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  103832. // position
  103833. data.push(0.0);
  103834. data.push(0.0);
  103835. data.push(0.0);
  103836. // Age and life
  103837. data.push(0.0); // create the particle as a dead one to create a new one at start
  103838. data.push(0.0);
  103839. // Seed
  103840. data.push(Math.random());
  103841. data.push(Math.random());
  103842. data.push(Math.random());
  103843. data.push(Math.random());
  103844. // Size
  103845. data.push(0.0);
  103846. data.push(0.0);
  103847. data.push(0.0);
  103848. if (!this._colorGradientsTexture) {
  103849. // color
  103850. data.push(0.0);
  103851. data.push(0.0);
  103852. data.push(0.0);
  103853. data.push(0.0);
  103854. }
  103855. // direction
  103856. data.push(0.0);
  103857. data.push(0.0);
  103858. data.push(0.0);
  103859. if (!this.isBillboardBased) {
  103860. // initialDirection
  103861. data.push(0.0);
  103862. data.push(0.0);
  103863. data.push(0.0);
  103864. }
  103865. // angle
  103866. data.push(0.0);
  103867. if (!this._angularSpeedGradientsTexture) {
  103868. data.push(0.0);
  103869. }
  103870. if (this._isAnimationSheetEnabled) {
  103871. data.push(0.0);
  103872. if (this.spriteRandomStartCell) {
  103873. data.push(0.0);
  103874. }
  103875. }
  103876. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  103877. data.push(Math.random());
  103878. data.push(Math.random());
  103879. data.push(Math.random());
  103880. data.push(Math.random());
  103881. data.push(Math.random());
  103882. data.push(Math.random());
  103883. }
  103884. }
  103885. // Sprite data
  103886. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  103887. -0.5, 0.5, 0, 1,
  103888. -0.5, -0.5, 0, 0,
  103889. 0.5, -0.5, 1, 0]);
  103890. // Buffers
  103891. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  103892. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  103893. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  103894. // Update VAO
  103895. this._updateVAO = [];
  103896. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  103897. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  103898. // Render VAO
  103899. this._renderVAO = [];
  103900. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  103901. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  103902. // Links
  103903. this._sourceBuffer = this._buffer0;
  103904. this._targetBuffer = this._buffer1;
  103905. };
  103906. /** @hidden */
  103907. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  103908. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  103909. if (this._isBillboardBased) {
  103910. defines += "\n#define BILLBOARD";
  103911. }
  103912. if (this._colorGradientsTexture) {
  103913. defines += "\n#define COLORGRADIENTS";
  103914. }
  103915. if (this._sizeGradientsTexture) {
  103916. defines += "\n#define SIZEGRADIENTS";
  103917. }
  103918. if (this._angularSpeedGradientsTexture) {
  103919. defines += "\n#define ANGULARSPEEDGRADIENTS";
  103920. }
  103921. if (this._velocityGradientsTexture) {
  103922. defines += "\n#define VELOCITYGRADIENTS";
  103923. }
  103924. if (this._limitVelocityGradientsTexture) {
  103925. defines += "\n#define LIMITVELOCITYGRADIENTS";
  103926. }
  103927. if (this._dragGradientsTexture) {
  103928. defines += "\n#define DRAGGRADIENTS";
  103929. }
  103930. if (this.isAnimationSheetEnabled) {
  103931. defines += "\n#define ANIMATESHEET";
  103932. if (this.spriteRandomStartCell) {
  103933. defines += "\n#define ANIMATESHEETRANDOMSTART";
  103934. }
  103935. }
  103936. if (this.noiseTexture) {
  103937. defines += "\n#define NOISE";
  103938. }
  103939. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  103940. return;
  103941. }
  103942. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  103943. if (!this._colorGradientsTexture) {
  103944. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  103945. }
  103946. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  103947. if (!this._isBillboardBased) {
  103948. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  103949. }
  103950. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  103951. if (this.isAnimationSheetEnabled) {
  103952. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  103953. if (this.spriteRandomStartCell) {
  103954. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  103955. }
  103956. }
  103957. if (this.noiseTexture) {
  103958. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  103959. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  103960. }
  103961. this._updateEffectOptions.defines = defines;
  103962. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  103963. };
  103964. /** @hidden */
  103965. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  103966. var defines = "";
  103967. if (this._scene.clipPlane) {
  103968. defines = "\n#define CLIPPLANE";
  103969. }
  103970. if (this._scene.clipPlane2) {
  103971. defines = "\n#define CLIPPLANE2";
  103972. }
  103973. if (this._scene.clipPlane3) {
  103974. defines = "\n#define CLIPPLANE3";
  103975. }
  103976. if (this._scene.clipPlane4) {
  103977. defines = "\n#define CLIPPLANE4";
  103978. }
  103979. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  103980. defines = "\n#define BLENDMULTIPLYMODE";
  103981. }
  103982. if (this._isBillboardBased) {
  103983. defines += "\n#define BILLBOARD";
  103984. switch (this.billboardMode) {
  103985. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  103986. defines += "\n#define BILLBOARDY";
  103987. break;
  103988. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  103989. defines += "\n#define BILLBOARDSTRETCHED";
  103990. break;
  103991. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  103992. default:
  103993. break;
  103994. }
  103995. }
  103996. if (this._colorGradientsTexture) {
  103997. defines += "\n#define COLORGRADIENTS";
  103998. }
  103999. if (this.isAnimationSheetEnabled) {
  104000. defines += "\n#define ANIMATESHEET";
  104001. }
  104002. if (this._imageProcessingConfiguration) {
  104003. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  104004. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  104005. }
  104006. if (this._renderEffect && this._renderEffect.defines === defines) {
  104007. return;
  104008. }
  104009. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  104010. var samplers = ["textureSampler", "colorGradientSampler"];
  104011. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  104012. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  104013. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  104014. }
  104015. 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);
  104016. };
  104017. /**
  104018. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104019. * @param preWarm defines if we are in the pre-warmimg phase
  104020. */
  104021. GPUParticleSystem.prototype.animate = function (preWarm) {
  104022. if (preWarm === void 0) { preWarm = false; }
  104023. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  104024. this._actualFrame += this._timeDelta;
  104025. if (!this._stopped) {
  104026. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  104027. this.stop();
  104028. }
  104029. }
  104030. };
  104031. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  104032. var texture = this[textureName];
  104033. if (!factorGradients || !factorGradients.length || texture) {
  104034. return;
  104035. }
  104036. var data = new Float32Array(this._rawTextureWidth);
  104037. for (var x = 0; x < this._rawTextureWidth; x++) {
  104038. var ratio = x / this._rawTextureWidth;
  104039. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  104040. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104041. });
  104042. }
  104043. 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);
  104044. };
  104045. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  104046. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  104047. };
  104048. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  104049. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  104050. };
  104051. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  104052. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  104053. };
  104054. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  104055. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  104056. };
  104057. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  104058. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  104059. };
  104060. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  104061. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  104062. return;
  104063. }
  104064. var data = new Uint8Array(this._rawTextureWidth * 4);
  104065. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  104066. for (var x = 0; x < this._rawTextureWidth; x++) {
  104067. var ratio = x / this._rawTextureWidth;
  104068. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  104069. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  104070. data[x * 4] = tmpColor.r * 255;
  104071. data[x * 4 + 1] = tmpColor.g * 255;
  104072. data[x * 4 + 2] = tmpColor.b * 255;
  104073. data[x * 4 + 3] = tmpColor.a * 255;
  104074. });
  104075. }
  104076. 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);
  104077. };
  104078. /**
  104079. * Renders the particle system in its current state
  104080. * @param preWarm defines if the system should only update the particles but not render them
  104081. * @returns the current number of particles
  104082. */
  104083. GPUParticleSystem.prototype.render = function (preWarm) {
  104084. if (preWarm === void 0) { preWarm = false; }
  104085. if (!this._started) {
  104086. return 0;
  104087. }
  104088. this._createColorGradientTexture();
  104089. this._createSizeGradientTexture();
  104090. this._createAngularSpeedGradientTexture();
  104091. this._createVelocityGradientTexture();
  104092. this._createLimitVelocityGradientTexture();
  104093. this._createDragGradientTexture();
  104094. this._recreateUpdateEffect();
  104095. this._recreateRenderEffect();
  104096. if (!this.isReady()) {
  104097. return 0;
  104098. }
  104099. if (!preWarm) {
  104100. if (!this._preWarmDone && this.preWarmCycles) {
  104101. for (var index = 0; index < this.preWarmCycles; index++) {
  104102. this.animate(true);
  104103. this.render(true);
  104104. }
  104105. this._preWarmDone = true;
  104106. }
  104107. if (this._currentRenderId === this._scene.getFrameId()) {
  104108. return 0;
  104109. }
  104110. this._currentRenderId = this._scene.getFrameId();
  104111. }
  104112. // Get everything ready to render
  104113. this._initialize();
  104114. this._accumulatedCount += this.emitRate * this._timeDelta;
  104115. if (this._accumulatedCount > 1) {
  104116. var intPart = this._accumulatedCount | 0;
  104117. this._accumulatedCount -= intPart;
  104118. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  104119. }
  104120. if (!this._currentActiveCount) {
  104121. return 0;
  104122. }
  104123. // Enable update effect
  104124. this._engine.enableEffect(this._updateEffect);
  104125. this._engine.setState(false);
  104126. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  104127. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  104128. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  104129. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  104130. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  104131. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  104132. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  104133. if (!this._colorGradientsTexture) {
  104134. this._updateEffect.setDirectColor4("color1", this.color1);
  104135. this._updateEffect.setDirectColor4("color2", this.color2);
  104136. }
  104137. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  104138. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  104139. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  104140. this._updateEffect.setVector3("gravity", this.gravity);
  104141. if (this._sizeGradientsTexture) {
  104142. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  104143. }
  104144. if (this._angularSpeedGradientsTexture) {
  104145. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  104146. }
  104147. if (this._velocityGradientsTexture) {
  104148. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  104149. }
  104150. if (this._limitVelocityGradientsTexture) {
  104151. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  104152. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  104153. }
  104154. if (this._dragGradientsTexture) {
  104155. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  104156. }
  104157. if (this.particleEmitterType) {
  104158. this.particleEmitterType.applyToShader(this._updateEffect);
  104159. }
  104160. if (this._isAnimationSheetEnabled) {
  104161. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  104162. }
  104163. if (this.noiseTexture) {
  104164. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  104165. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  104166. }
  104167. var emitterWM;
  104168. if (this.emitter.position) {
  104169. var emitterMesh = this.emitter;
  104170. emitterWM = emitterMesh.getWorldMatrix();
  104171. }
  104172. else {
  104173. var emitterPosition = this.emitter;
  104174. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  104175. }
  104176. this._updateEffect.setMatrix("emitterWM", emitterWM);
  104177. // Bind source VAO
  104178. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  104179. // Update
  104180. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  104181. this._engine.setRasterizerState(false);
  104182. this._engine.beginTransformFeedback(true);
  104183. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  104184. this._engine.endTransformFeedback();
  104185. this._engine.setRasterizerState(true);
  104186. this._engine.bindTransformFeedbackBuffer(null);
  104187. if (!preWarm) {
  104188. // Enable render effect
  104189. this._engine.enableEffect(this._renderEffect);
  104190. var viewMatrix = this._scene.getViewMatrix();
  104191. this._renderEffect.setMatrix("view", viewMatrix);
  104192. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  104193. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  104194. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  104195. if (this._colorGradientsTexture) {
  104196. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  104197. }
  104198. else {
  104199. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  104200. }
  104201. if (this._isAnimationSheetEnabled && this.particleTexture) {
  104202. var baseSize = this.particleTexture.getBaseSize();
  104203. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  104204. }
  104205. if (this._isBillboardBased) {
  104206. var camera = this._scene.activeCamera;
  104207. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  104208. }
  104209. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  104210. var invView = viewMatrix.clone();
  104211. invView.invert();
  104212. this._renderEffect.setMatrix("invView", invView);
  104213. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  104214. }
  104215. // image processing
  104216. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  104217. this._imageProcessingConfiguration.bind(this._renderEffect);
  104218. }
  104219. // Draw order
  104220. switch (this.blendMode) {
  104221. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  104222. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  104223. break;
  104224. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  104225. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  104226. break;
  104227. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  104228. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  104229. break;
  104230. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  104231. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  104232. break;
  104233. }
  104234. if (this.forceDepthWrite) {
  104235. this._engine.setDepthWrite(true);
  104236. }
  104237. // Bind source VAO
  104238. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  104239. // Render
  104240. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  104241. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  104242. }
  104243. // Switch VAOs
  104244. this._targetIndex++;
  104245. if (this._targetIndex === 2) {
  104246. this._targetIndex = 0;
  104247. }
  104248. // Switch buffers
  104249. var tmpBuffer = this._sourceBuffer;
  104250. this._sourceBuffer = this._targetBuffer;
  104251. this._targetBuffer = tmpBuffer;
  104252. return this._currentActiveCount;
  104253. };
  104254. /**
  104255. * Rebuilds the particle system
  104256. */
  104257. GPUParticleSystem.prototype.rebuild = function () {
  104258. this._initialize(true);
  104259. };
  104260. GPUParticleSystem.prototype._releaseBuffers = function () {
  104261. if (this._buffer0) {
  104262. this._buffer0.dispose();
  104263. this._buffer0 = null;
  104264. }
  104265. if (this._buffer1) {
  104266. this._buffer1.dispose();
  104267. this._buffer1 = null;
  104268. }
  104269. if (this._spriteBuffer) {
  104270. this._spriteBuffer.dispose();
  104271. this._spriteBuffer = null;
  104272. }
  104273. };
  104274. GPUParticleSystem.prototype._releaseVAOs = function () {
  104275. if (!this._updateVAO) {
  104276. return;
  104277. }
  104278. for (var index = 0; index < this._updateVAO.length; index++) {
  104279. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  104280. }
  104281. this._updateVAO = [];
  104282. for (var index = 0; index < this._renderVAO.length; index++) {
  104283. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  104284. }
  104285. this._renderVAO = [];
  104286. };
  104287. /**
  104288. * Disposes the particle system and free the associated resources
  104289. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104290. */
  104291. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  104292. if (disposeTexture === void 0) { disposeTexture = true; }
  104293. var index = this._scene.particleSystems.indexOf(this);
  104294. if (index > -1) {
  104295. this._scene.particleSystems.splice(index, 1);
  104296. }
  104297. this._releaseBuffers();
  104298. this._releaseVAOs();
  104299. if (this._colorGradientsTexture) {
  104300. this._colorGradientsTexture.dispose();
  104301. this._colorGradientsTexture = null;
  104302. }
  104303. if (this._sizeGradientsTexture) {
  104304. this._sizeGradientsTexture.dispose();
  104305. this._sizeGradientsTexture = null;
  104306. }
  104307. if (this._angularSpeedGradientsTexture) {
  104308. this._angularSpeedGradientsTexture.dispose();
  104309. this._angularSpeedGradientsTexture = null;
  104310. }
  104311. if (this._velocityGradientsTexture) {
  104312. this._velocityGradientsTexture.dispose();
  104313. this._velocityGradientsTexture = null;
  104314. }
  104315. if (this._limitVelocityGradientsTexture) {
  104316. this._limitVelocityGradientsTexture.dispose();
  104317. this._limitVelocityGradientsTexture = null;
  104318. }
  104319. if (this._dragGradientsTexture) {
  104320. this._dragGradientsTexture.dispose();
  104321. this._dragGradientsTexture = null;
  104322. }
  104323. if (this._randomTexture) {
  104324. this._randomTexture.dispose();
  104325. this._randomTexture = null;
  104326. }
  104327. if (this._randomTexture2) {
  104328. this._randomTexture2.dispose();
  104329. this._randomTexture2 = null;
  104330. }
  104331. if (disposeTexture && this.particleTexture) {
  104332. this.particleTexture.dispose();
  104333. this.particleTexture = null;
  104334. }
  104335. if (disposeTexture && this.noiseTexture) {
  104336. this.noiseTexture.dispose();
  104337. this.noiseTexture = null;
  104338. }
  104339. // Callback
  104340. this.onDisposeObservable.notifyObservers(this);
  104341. this.onDisposeObservable.clear();
  104342. };
  104343. /**
  104344. * Clones the particle system.
  104345. * @param name The name of the cloned object
  104346. * @param newEmitter The new emitter to use
  104347. * @returns the cloned particle system
  104348. */
  104349. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  104350. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  104351. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  104352. if (newEmitter === undefined) {
  104353. newEmitter = this.emitter;
  104354. }
  104355. result.emitter = newEmitter;
  104356. if (this.particleTexture) {
  104357. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  104358. }
  104359. return result;
  104360. };
  104361. /**
  104362. * Serializes the particle system to a JSON object.
  104363. * @returns the JSON object
  104364. */
  104365. GPUParticleSystem.prototype.serialize = function () {
  104366. var serializationObject = {};
  104367. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  104368. serializationObject.activeParticleCount = this.activeParticleCount;
  104369. return serializationObject;
  104370. };
  104371. /**
  104372. * Parses a JSON object to create a GPU particle system.
  104373. * @param parsedParticleSystem The JSON object to parse
  104374. * @param scene The scene to create the particle system in
  104375. * @param rootUrl The root url to use to load external dependencies like texture
  104376. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104377. * @returns the parsed GPU particle system
  104378. */
  104379. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  104380. if (doNotStart === void 0) { doNotStart = false; }
  104381. var name = parsedParticleSystem.name;
  104382. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  104383. if (parsedParticleSystem.activeParticleCount) {
  104384. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  104385. }
  104386. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  104387. // Auto start
  104388. if (parsedParticleSystem.preventAutoStart) {
  104389. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  104390. }
  104391. if (!doNotStart && !particleSystem.preventAutoStart) {
  104392. particleSystem.start();
  104393. }
  104394. return particleSystem;
  104395. };
  104396. return GPUParticleSystem;
  104397. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  104398. /***/ }),
  104399. /***/ "./Particles/index.ts":
  104400. /*!****************************!*\
  104401. !*** ./Particles/index.ts ***!
  104402. \****************************/
  104403. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104404. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104405. "use strict";
  104406. __webpack_require__.r(__webpack_exports__);
  104407. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  104409. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  104411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  104413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  104414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  104415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  104416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  104417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  104418. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  104420. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  104422. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  104423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  104424. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  104426. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  104427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  104428. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  104430. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  104431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  104432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  104433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  104434. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  104435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  104436. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  104438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  104439. /***/ }),
  104440. /***/ "./Particles/particle.ts":
  104441. /*!*******************************!*\
  104442. !*** ./Particles/particle.ts ***!
  104443. \*******************************/
  104444. /*! exports provided: Particle */
  104445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104446. "use strict";
  104447. __webpack_require__.r(__webpack_exports__);
  104448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  104449. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104450. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104451. /**
  104452. * A particle represents one of the element emitted by a particle system.
  104453. * This is mainly define by its coordinates, direction, velocity and age.
  104454. */
  104455. var Particle = /** @class */ (function () {
  104456. /**
  104457. * Creates a new instance Particle
  104458. * @param particleSystem the particle system the particle belongs to
  104459. */
  104460. function Particle(
  104461. /**
  104462. * The particle system the particle belongs to.
  104463. */
  104464. particleSystem) {
  104465. this.particleSystem = particleSystem;
  104466. /**
  104467. * The world position of the particle in the scene.
  104468. */
  104469. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104470. /**
  104471. * The world direction of the particle in the scene.
  104472. */
  104473. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104474. /**
  104475. * The color of the particle.
  104476. */
  104477. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104478. /**
  104479. * The color change of the particle per step.
  104480. */
  104481. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104482. /**
  104483. * Defines how long will the life of the particle be.
  104484. */
  104485. this.lifeTime = 1.0;
  104486. /**
  104487. * The current age of the particle.
  104488. */
  104489. this.age = 0;
  104490. /**
  104491. * The current size of the particle.
  104492. */
  104493. this.size = 0;
  104494. /**
  104495. * The current scale of the particle.
  104496. */
  104497. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  104498. /**
  104499. * The current angle of the particle.
  104500. */
  104501. this.angle = 0;
  104502. /**
  104503. * Defines how fast is the angle changing.
  104504. */
  104505. this.angularSpeed = 0;
  104506. /**
  104507. * Defines the cell index used by the particle to be rendered from a sprite.
  104508. */
  104509. this.cellIndex = 0;
  104510. /** @hidden */
  104511. this._attachedSubEmitters = null;
  104512. /** @hidden */
  104513. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104514. /** @hidden */
  104515. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104516. /** @hidden */
  104517. this._currentSize1 = 0;
  104518. /** @hidden */
  104519. this._currentSize2 = 0;
  104520. /** @hidden */
  104521. this._currentAngularSpeed1 = 0;
  104522. /** @hidden */
  104523. this._currentAngularSpeed2 = 0;
  104524. /** @hidden */
  104525. this._currentVelocity1 = 0;
  104526. /** @hidden */
  104527. this._currentVelocity2 = 0;
  104528. /** @hidden */
  104529. this._currentLimitVelocity1 = 0;
  104530. /** @hidden */
  104531. this._currentLimitVelocity2 = 0;
  104532. /** @hidden */
  104533. this._currentDrag1 = 0;
  104534. /** @hidden */
  104535. this._currentDrag2 = 0;
  104536. this.id = Particle._Count++;
  104537. if (!this.particleSystem.isAnimationSheetEnabled) {
  104538. return;
  104539. }
  104540. this.updateCellInfoFromSystem();
  104541. }
  104542. Particle.prototype.updateCellInfoFromSystem = function () {
  104543. this.cellIndex = this.particleSystem.startSpriteCellID;
  104544. };
  104545. /**
  104546. * Defines how the sprite cell index is updated for the particle
  104547. */
  104548. Particle.prototype.updateCellIndex = function () {
  104549. var offsetAge = this.age;
  104550. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  104551. if (this.particleSystem.spriteRandomStartCell) {
  104552. if (this._randomCellOffset === undefined) {
  104553. this._randomCellOffset = Math.random() * this.lifeTime;
  104554. }
  104555. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  104556. changeSpeed = 1;
  104557. offsetAge = this._randomCellOffset;
  104558. }
  104559. else {
  104560. offsetAge += this._randomCellOffset;
  104561. }
  104562. }
  104563. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  104564. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  104565. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  104566. };
  104567. /** @hidden */
  104568. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  104569. if (subEmitter.particleSystem.emitter.position) {
  104570. var emitterMesh = subEmitter.particleSystem.emitter;
  104571. emitterMesh.position.copyFrom(this.position);
  104572. if (subEmitter.inheritDirection) {
  104573. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104574. // Look at using Y as forward
  104575. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  104576. }
  104577. }
  104578. else {
  104579. var emitterPosition = subEmitter.particleSystem.emitter;
  104580. emitterPosition.copyFrom(this.position);
  104581. }
  104582. // Set inheritedVelocityOffset to be used when new particles are created
  104583. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104584. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104585. };
  104586. /** @hidden */
  104587. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  104588. var _this = this;
  104589. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  104590. this._attachedSubEmitters.forEach(function (subEmitter) {
  104591. _this._inheritParticleInfoToSubEmitter(subEmitter);
  104592. });
  104593. }
  104594. };
  104595. /** @hidden */
  104596. Particle.prototype._reset = function () {
  104597. this.age = 0;
  104598. this._currentColorGradient = null;
  104599. this._currentSizeGradient = null;
  104600. this._currentAngularSpeedGradient = null;
  104601. this._currentVelocityGradient = null;
  104602. this._currentLimitVelocityGradient = null;
  104603. this._currentDragGradient = null;
  104604. this.cellIndex = this.particleSystem.startSpriteCellID;
  104605. this._randomCellOffset = undefined;
  104606. };
  104607. /**
  104608. * Copy the properties of particle to another one.
  104609. * @param other the particle to copy the information to.
  104610. */
  104611. Particle.prototype.copyTo = function (other) {
  104612. other.position.copyFrom(this.position);
  104613. if (this._initialDirection) {
  104614. if (other._initialDirection) {
  104615. other._initialDirection.copyFrom(this._initialDirection);
  104616. }
  104617. else {
  104618. other._initialDirection = this._initialDirection.clone();
  104619. }
  104620. }
  104621. else {
  104622. other._initialDirection = null;
  104623. }
  104624. other.direction.copyFrom(this.direction);
  104625. other.color.copyFrom(this.color);
  104626. other.colorStep.copyFrom(this.colorStep);
  104627. other.lifeTime = this.lifeTime;
  104628. other.age = this.age;
  104629. other._randomCellOffset = this._randomCellOffset;
  104630. other.size = this.size;
  104631. other.scale.copyFrom(this.scale);
  104632. other.angle = this.angle;
  104633. other.angularSpeed = this.angularSpeed;
  104634. other.particleSystem = this.particleSystem;
  104635. other.cellIndex = this.cellIndex;
  104636. other.id = this.id;
  104637. other._attachedSubEmitters = this._attachedSubEmitters;
  104638. if (this._currentColorGradient) {
  104639. other._currentColorGradient = this._currentColorGradient;
  104640. other._currentColor1.copyFrom(this._currentColor1);
  104641. other._currentColor2.copyFrom(this._currentColor2);
  104642. }
  104643. if (this._currentSizeGradient) {
  104644. other._currentSizeGradient = this._currentSizeGradient;
  104645. other._currentSize1 = this._currentSize1;
  104646. other._currentSize2 = this._currentSize2;
  104647. }
  104648. if (this._currentAngularSpeedGradient) {
  104649. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  104650. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  104651. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  104652. }
  104653. if (this._currentVelocityGradient) {
  104654. other._currentVelocityGradient = this._currentVelocityGradient;
  104655. other._currentVelocity1 = this._currentVelocity1;
  104656. other._currentVelocity2 = this._currentVelocity2;
  104657. }
  104658. if (this._currentLimitVelocityGradient) {
  104659. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  104660. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  104661. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  104662. }
  104663. if (this._currentDragGradient) {
  104664. other._currentDragGradient = this._currentDragGradient;
  104665. other._currentDrag1 = this._currentDrag1;
  104666. other._currentDrag2 = this._currentDrag2;
  104667. }
  104668. if (this.particleSystem.isAnimationSheetEnabled) {
  104669. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  104670. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  104671. }
  104672. if (this.particleSystem.useRampGradients) {
  104673. other.remapData.copyFrom(this.remapData);
  104674. }
  104675. if (this._randomNoiseCoordinates1) {
  104676. if (other._randomNoiseCoordinates1) {
  104677. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  104678. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  104679. }
  104680. else {
  104681. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  104682. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  104683. }
  104684. }
  104685. };
  104686. Particle._Count = 0;
  104687. return Particle;
  104688. }());
  104689. /***/ }),
  104690. /***/ "./Particles/particleHelper.ts":
  104691. /*!*************************************!*\
  104692. !*** ./Particles/particleHelper.ts ***!
  104693. \*************************************/
  104694. /*! exports provided: ParticleHelper */
  104695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104696. "use strict";
  104697. __webpack_require__.r(__webpack_exports__);
  104698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  104699. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104700. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104701. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104703. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104704. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104705. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104706. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104707. /**
  104708. * This class is made for on one-liner static method to help creating particle system set.
  104709. */
  104710. var ParticleHelper = /** @class */ (function () {
  104711. function ParticleHelper() {
  104712. }
  104713. /**
  104714. * Create a default particle system that you can tweak
  104715. * @param emitter defines the emitter to use
  104716. * @param capacity defines the system capacity (default is 500 particles)
  104717. * @param scene defines the hosting scene
  104718. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104719. * @returns the new Particle system
  104720. */
  104721. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  104722. if (capacity === void 0) { capacity = 500; }
  104723. if (useGPU === void 0) { useGPU = false; }
  104724. var system;
  104725. if (useGPU) {
  104726. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  104727. }
  104728. else {
  104729. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  104730. }
  104731. system.emitter = emitter;
  104732. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  104733. system.createConeEmitter(0.1, Math.PI / 4);
  104734. // Particle color
  104735. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  104736. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  104737. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  104738. // Particle Size
  104739. system.minSize = 0.1;
  104740. system.maxSize = 0.1;
  104741. // Emission speed
  104742. system.minEmitPower = 2;
  104743. system.maxEmitPower = 2;
  104744. // Update speed
  104745. system.updateSpeed = 1 / 60;
  104746. system.emitRate = 30;
  104747. return system;
  104748. };
  104749. /**
  104750. * This is the main static method (one-liner) of this helper to create different particle systems
  104751. * @param type This string represents the type to the particle system to create
  104752. * @param scene The scene where the particle system should live
  104753. * @param gpu If the system will use gpu
  104754. * @returns the ParticleSystemSet created
  104755. */
  104756. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  104757. if (gpu === void 0) { gpu = false; }
  104758. if (!scene) {
  104759. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  104760. }
  104761. var token = {};
  104762. scene._addPendingData(token);
  104763. return new Promise(function (resolve, reject) {
  104764. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  104765. scene._removePendingData(token);
  104766. return reject("Particle system with GPU is not supported.");
  104767. }
  104768. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  104769. scene._removePendingData(token);
  104770. var newData = JSON.parse(data.toString());
  104771. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  104772. }, undefined, undefined, undefined, function () {
  104773. scene._removePendingData(token);
  104774. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  104775. });
  104776. });
  104777. };
  104778. /**
  104779. * Static function used to export a particle system to a ParticleSystemSet variable.
  104780. * Please note that the emitter shape is not exported
  104781. * @param systems defines the particle systems to export
  104782. * @returns the created particle system set
  104783. */
  104784. ParticleHelper.ExportSet = function (systems) {
  104785. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  104786. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  104787. var system = systems_1[_i];
  104788. set.systems.push(system);
  104789. }
  104790. return set;
  104791. };
  104792. /**
  104793. * Gets or sets base Assets URL
  104794. */
  104795. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  104796. return ParticleHelper;
  104797. }());
  104798. /***/ }),
  104799. /***/ "./Particles/particleSystem.ts":
  104800. /*!*************************************!*\
  104801. !*** ./Particles/particleSystem.ts ***!
  104802. \*************************************/
  104803. /*! exports provided: ParticleSystem */
  104804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104805. "use strict";
  104806. __webpack_require__.r(__webpack_exports__);
  104807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  104808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104809. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104810. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  104811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104812. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104813. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  104814. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  104815. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  104816. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  104817. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  104818. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104819. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  104820. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  104821. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104822. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104823. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104824. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104825. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104826. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104827. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  104828. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104829. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  104830. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  104831. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  104832. /**
  104833. * This represents a particle system in Babylon.
  104834. * 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.
  104835. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  104836. * @example https://doc.babylonjs.com/babylon101/particles
  104837. */
  104838. var ParticleSystem = /** @class */ (function (_super) {
  104839. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  104840. /**
  104841. * Instantiates a particle system.
  104842. * 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.
  104843. * @param name The name of the particle system
  104844. * @param capacity The max number of particles alive at the same time
  104845. * @param scene The scene the particle system belongs to
  104846. * @param customEffect a custom effect used to change the way particles are rendered by default
  104847. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104848. * @param epsilon Offset used to render the particles
  104849. */
  104850. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  104851. if (customEffect === void 0) { customEffect = null; }
  104852. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  104853. if (epsilon === void 0) { epsilon = 0.01; }
  104854. var _this = _super.call(this, name) || this;
  104855. /**
  104856. * @hidden
  104857. */
  104858. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  104859. /**
  104860. * An event triggered when the system is disposed
  104861. */
  104862. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  104863. _this._particles = new Array();
  104864. _this._stockParticles = new Array();
  104865. _this._newPartsExcess = 0;
  104866. _this._vertexBuffers = {};
  104867. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  104868. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  104869. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  104870. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  104871. _this._currentRenderId = -1;
  104872. _this._useInstancing = false;
  104873. _this._started = false;
  104874. _this._stopped = false;
  104875. _this._actualFrame = 0;
  104876. /** @hidden */
  104877. _this._currentEmitRate1 = 0;
  104878. /** @hidden */
  104879. _this._currentEmitRate2 = 0;
  104880. /** @hidden */
  104881. _this._currentStartSize1 = 0;
  104882. /** @hidden */
  104883. _this._currentStartSize2 = 0;
  104884. _this._rawTextureWidth = 256;
  104885. _this._useRampGradients = false;
  104886. /**
  104887. * @hidden
  104888. * If the particle systems emitter should be disposed when the particle system is disposed
  104889. */
  104890. _this._disposeEmitterOnDispose = false;
  104891. // start of sub system methods
  104892. /**
  104893. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  104894. * Its lifetime will start back at 0.
  104895. */
  104896. _this.recycleParticle = function (particle) {
  104897. // move particle from activeParticle list to stock particles
  104898. var lastParticle = _this._particles.pop();
  104899. if (lastParticle !== particle) {
  104900. lastParticle.copyTo(particle);
  104901. }
  104902. _this._stockParticles.push(lastParticle);
  104903. };
  104904. _this._createParticle = function () {
  104905. var particle;
  104906. if (_this._stockParticles.length !== 0) {
  104907. particle = _this._stockParticles.pop();
  104908. particle._reset();
  104909. }
  104910. else {
  104911. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  104912. }
  104913. // Attach emitters
  104914. if (_this._subEmitters && _this._subEmitters.length > 0) {
  104915. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  104916. particle._attachedSubEmitters = [];
  104917. subEmitters.forEach(function (subEmitter) {
  104918. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  104919. var newEmitter = subEmitter.clone();
  104920. particle._attachedSubEmitters.push(newEmitter);
  104921. newEmitter.particleSystem.start();
  104922. }
  104923. });
  104924. }
  104925. return particle;
  104926. };
  104927. _this._emitFromParticle = function (particle) {
  104928. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  104929. return;
  104930. }
  104931. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  104932. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  104933. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  104934. var subSystem = subEmitter.clone();
  104935. particle._inheritParticleInfoToSubEmitter(subSystem);
  104936. subSystem.particleSystem._rootParticleSystem = _this;
  104937. _this.activeSubSystems.push(subSystem.particleSystem);
  104938. subSystem.particleSystem.start();
  104939. }
  104940. });
  104941. };
  104942. _this._capacity = capacity;
  104943. _this._epsilon = epsilon;
  104944. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  104945. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  104946. // Setup the default processing configuration to the scene.
  104947. _this._attachImageProcessingConfiguration(null);
  104948. _this._customEffect = customEffect;
  104949. _this._scene.particleSystems.push(_this);
  104950. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  104951. _this._createIndexBuffer();
  104952. _this._createVertexBuffers();
  104953. // Default emitter type
  104954. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  104955. // Update
  104956. _this.updateFunction = function (particles) {
  104957. var noiseTextureSize = null;
  104958. var noiseTextureData = null;
  104959. if (_this.noiseTexture) { // We need to get texture data back to CPU
  104960. noiseTextureSize = _this.noiseTexture.getSize();
  104961. noiseTextureData = (_this.noiseTexture.getContent());
  104962. }
  104963. var _loop_1 = function () {
  104964. particle = particles[index];
  104965. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  104966. var previousAge = particle.age;
  104967. particle.age += scaledUpdateSpeed;
  104968. // Evaluate step to death
  104969. if (particle.age > particle.lifeTime) {
  104970. var diff = particle.age - previousAge;
  104971. var oldDiff = particle.lifeTime - previousAge;
  104972. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  104973. particle.age = particle.lifeTime;
  104974. }
  104975. var ratio = particle.age / particle.lifeTime;
  104976. // Color
  104977. if (_this._colorGradients && _this._colorGradients.length > 0) {
  104978. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  104979. if (currentGradient !== particle._currentColorGradient) {
  104980. particle._currentColor1.copyFrom(particle._currentColor2);
  104981. nextGradient.getColorToRef(particle._currentColor2);
  104982. particle._currentColorGradient = currentGradient;
  104983. }
  104984. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  104985. });
  104986. }
  104987. else {
  104988. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  104989. particle.color.addInPlace(_this._scaledColorStep);
  104990. if (particle.color.a < 0) {
  104991. particle.color.a = 0;
  104992. }
  104993. }
  104994. // Angular speed
  104995. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  104996. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  104997. if (currentGradient !== particle._currentAngularSpeedGradient) {
  104998. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  104999. particle._currentAngularSpeed2 = nextGradient.getFactor();
  105000. particle._currentAngularSpeedGradient = currentGradient;
  105001. }
  105002. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  105003. });
  105004. }
  105005. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  105006. // Direction
  105007. var directionScale = scaledUpdateSpeed;
  105008. /// Velocity
  105009. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  105010. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  105011. if (currentGradient !== particle._currentVelocityGradient) {
  105012. particle._currentVelocity1 = particle._currentVelocity2;
  105013. particle._currentVelocity2 = nextGradient.getFactor();
  105014. particle._currentVelocityGradient = currentGradient;
  105015. }
  105016. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  105017. });
  105018. }
  105019. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  105020. /// Limit velocity
  105021. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  105022. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  105023. if (currentGradient !== particle._currentLimitVelocityGradient) {
  105024. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  105025. particle._currentLimitVelocity2 = nextGradient.getFactor();
  105026. particle._currentLimitVelocityGradient = currentGradient;
  105027. }
  105028. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  105029. var currentVelocity = particle.direction.length();
  105030. if (currentVelocity > limitVelocity) {
  105031. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  105032. }
  105033. });
  105034. }
  105035. /// Drag
  105036. if (_this._dragGradients && _this._dragGradients.length > 0) {
  105037. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  105038. if (currentGradient !== particle._currentDragGradient) {
  105039. particle._currentDrag1 = particle._currentDrag2;
  105040. particle._currentDrag2 = nextGradient.getFactor();
  105041. particle._currentDragGradient = currentGradient;
  105042. }
  105043. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  105044. _this._scaledDirection.scaleInPlace(1.0 - drag);
  105045. });
  105046. }
  105047. particle.position.addInPlace(_this._scaledDirection);
  105048. // Noise
  105049. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  105050. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105051. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105052. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105053. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  105054. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  105055. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  105056. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  105057. particle.direction.addInPlace(scaledForce);
  105058. }
  105059. // Gravity
  105060. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  105061. particle.direction.addInPlace(_this._scaledGravity);
  105062. // Size
  105063. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  105064. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  105065. if (currentGradient !== particle._currentSizeGradient) {
  105066. particle._currentSize1 = particle._currentSize2;
  105067. particle._currentSize2 = nextGradient.getFactor();
  105068. particle._currentSizeGradient = currentGradient;
  105069. }
  105070. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  105071. });
  105072. }
  105073. // Remap data
  105074. if (_this._useRampGradients) {
  105075. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  105076. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  105077. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105078. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105079. particle.remapData.x = min;
  105080. particle.remapData.y = max - min;
  105081. });
  105082. }
  105083. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  105084. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  105085. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105086. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105087. particle.remapData.z = min;
  105088. particle.remapData.w = max - min;
  105089. });
  105090. }
  105091. }
  105092. if (_this._isAnimationSheetEnabled) {
  105093. particle.updateCellIndex();
  105094. }
  105095. // Update the position of the attached sub-emitters to match their attached particle
  105096. particle._inheritParticleInfoToSubEmitters();
  105097. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  105098. _this._emitFromParticle(particle);
  105099. if (particle._attachedSubEmitters) {
  105100. particle._attachedSubEmitters.forEach(function (subEmitter) {
  105101. subEmitter.particleSystem.disposeOnStop = true;
  105102. subEmitter.particleSystem.stop();
  105103. });
  105104. particle._attachedSubEmitters = null;
  105105. }
  105106. _this.recycleParticle(particle);
  105107. index--;
  105108. return "continue";
  105109. }
  105110. };
  105111. var particle;
  105112. for (var index = 0; index < particles.length; index++) {
  105113. _loop_1();
  105114. }
  105115. };
  105116. return _this;
  105117. }
  105118. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  105119. /**
  105120. * Sets a callback that will be triggered when the system is disposed
  105121. */
  105122. set: function (callback) {
  105123. if (this._onDisposeObserver) {
  105124. this.onDisposeObservable.remove(this._onDisposeObserver);
  105125. }
  105126. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  105127. },
  105128. enumerable: true,
  105129. configurable: true
  105130. });
  105131. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  105132. /** Gets or sets a boolean indicating that ramp gradients must be used
  105133. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105134. */
  105135. get: function () {
  105136. return this._useRampGradients;
  105137. },
  105138. set: function (value) {
  105139. if (this._useRampGradients === value) {
  105140. return;
  105141. }
  105142. this._useRampGradients = value;
  105143. this._resetEffect();
  105144. },
  105145. enumerable: true,
  105146. configurable: true
  105147. });
  105148. Object.defineProperty(ParticleSystem.prototype, "particles", {
  105149. //end of Sub-emitter
  105150. /**
  105151. * Gets the current list of active particles
  105152. */
  105153. get: function () {
  105154. return this._particles;
  105155. },
  105156. enumerable: true,
  105157. configurable: true
  105158. });
  105159. /**
  105160. * Returns the string "ParticleSystem"
  105161. * @returns a string containing the class name
  105162. */
  105163. ParticleSystem.prototype.getClassName = function () {
  105164. return "ParticleSystem";
  105165. };
  105166. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  105167. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105168. newGradient.gradient = gradient;
  105169. newGradient.factor1 = factor;
  105170. newGradient.factor2 = factor2;
  105171. factorGradients.push(newGradient);
  105172. factorGradients.sort(function (a, b) {
  105173. if (a.gradient < b.gradient) {
  105174. return -1;
  105175. }
  105176. else if (a.gradient > b.gradient) {
  105177. return 1;
  105178. }
  105179. return 0;
  105180. });
  105181. };
  105182. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  105183. if (!factorGradients) {
  105184. return;
  105185. }
  105186. var index = 0;
  105187. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  105188. var factorGradient = factorGradients_1[_i];
  105189. if (factorGradient.gradient === gradient) {
  105190. factorGradients.splice(index, 1);
  105191. break;
  105192. }
  105193. index++;
  105194. }
  105195. };
  105196. /**
  105197. * Adds a new life time gradient
  105198. * @param gradient defines the gradient to use (between 0 and 1)
  105199. * @param factor defines the life time factor to affect to the specified gradient
  105200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105201. * @returns the current particle system
  105202. */
  105203. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  105204. if (!this._lifeTimeGradients) {
  105205. this._lifeTimeGradients = [];
  105206. }
  105207. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  105208. return this;
  105209. };
  105210. /**
  105211. * Remove a specific life time gradient
  105212. * @param gradient defines the gradient to remove
  105213. * @returns the current particle system
  105214. */
  105215. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  105216. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  105217. return this;
  105218. };
  105219. /**
  105220. * Adds a new size gradient
  105221. * @param gradient defines the gradient to use (between 0 and 1)
  105222. * @param factor defines the size factor to affect to the specified gradient
  105223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105224. * @returns the current particle system
  105225. */
  105226. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  105227. if (!this._sizeGradients) {
  105228. this._sizeGradients = [];
  105229. }
  105230. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  105231. return this;
  105232. };
  105233. /**
  105234. * Remove a specific size gradient
  105235. * @param gradient defines the gradient to remove
  105236. * @returns the current particle system
  105237. */
  105238. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105239. this._removeFactorGradient(this._sizeGradients, gradient);
  105240. return this;
  105241. };
  105242. /**
  105243. * Adds a new color remap gradient
  105244. * @param gradient defines the gradient to use (between 0 and 1)
  105245. * @param min defines the color remap minimal range
  105246. * @param max defines the color remap maximal range
  105247. * @returns the current particle system
  105248. */
  105249. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  105250. if (!this._colorRemapGradients) {
  105251. this._colorRemapGradients = [];
  105252. }
  105253. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  105254. return this;
  105255. };
  105256. /**
  105257. * Remove a specific color remap gradient
  105258. * @param gradient defines the gradient to remove
  105259. * @returns the current particle system
  105260. */
  105261. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  105262. this._removeFactorGradient(this._colorRemapGradients, gradient);
  105263. return this;
  105264. };
  105265. /**
  105266. * Adds a new alpha remap gradient
  105267. * @param gradient defines the gradient to use (between 0 and 1)
  105268. * @param min defines the alpha remap minimal range
  105269. * @param max defines the alpha remap maximal range
  105270. * @returns the current particle system
  105271. */
  105272. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  105273. if (!this._alphaRemapGradients) {
  105274. this._alphaRemapGradients = [];
  105275. }
  105276. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  105277. return this;
  105278. };
  105279. /**
  105280. * Remove a specific alpha remap gradient
  105281. * @param gradient defines the gradient to remove
  105282. * @returns the current particle system
  105283. */
  105284. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  105285. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  105286. return this;
  105287. };
  105288. /**
  105289. * Adds a new angular speed gradient
  105290. * @param gradient defines the gradient to use (between 0 and 1)
  105291. * @param factor defines the angular speed to affect to the specified gradient
  105292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105293. * @returns the current particle system
  105294. */
  105295. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  105296. if (!this._angularSpeedGradients) {
  105297. this._angularSpeedGradients = [];
  105298. }
  105299. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  105300. return this;
  105301. };
  105302. /**
  105303. * Remove a specific angular speed gradient
  105304. * @param gradient defines the gradient to remove
  105305. * @returns the current particle system
  105306. */
  105307. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105308. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  105309. return this;
  105310. };
  105311. /**
  105312. * Adds a new velocity gradient
  105313. * @param gradient defines the gradient to use (between 0 and 1)
  105314. * @param factor defines the velocity to affect to the specified gradient
  105315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105316. * @returns the current particle system
  105317. */
  105318. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  105319. if (!this._velocityGradients) {
  105320. this._velocityGradients = [];
  105321. }
  105322. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  105323. return this;
  105324. };
  105325. /**
  105326. * Remove a specific velocity gradient
  105327. * @param gradient defines the gradient to remove
  105328. * @returns the current particle system
  105329. */
  105330. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105331. this._removeFactorGradient(this._velocityGradients, gradient);
  105332. return this;
  105333. };
  105334. /**
  105335. * Adds a new limit velocity gradient
  105336. * @param gradient defines the gradient to use (between 0 and 1)
  105337. * @param factor defines the limit velocity value to affect to the specified gradient
  105338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105339. * @returns the current particle system
  105340. */
  105341. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  105342. if (!this._limitVelocityGradients) {
  105343. this._limitVelocityGradients = [];
  105344. }
  105345. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  105346. return this;
  105347. };
  105348. /**
  105349. * Remove a specific limit velocity gradient
  105350. * @param gradient defines the gradient to remove
  105351. * @returns the current particle system
  105352. */
  105353. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105354. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  105355. return this;
  105356. };
  105357. /**
  105358. * Adds a new drag gradient
  105359. * @param gradient defines the gradient to use (between 0 and 1)
  105360. * @param factor defines the drag value to affect to the specified gradient
  105361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105362. * @returns the current particle system
  105363. */
  105364. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  105365. if (!this._dragGradients) {
  105366. this._dragGradients = [];
  105367. }
  105368. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  105369. return this;
  105370. };
  105371. /**
  105372. * Remove a specific drag gradient
  105373. * @param gradient defines the gradient to remove
  105374. * @returns the current particle system
  105375. */
  105376. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  105377. this._removeFactorGradient(this._dragGradients, gradient);
  105378. return this;
  105379. };
  105380. /**
  105381. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  105382. * @param gradient defines the gradient to use (between 0 and 1)
  105383. * @param factor defines the emit rate value to affect to the specified gradient
  105384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105385. * @returns the current particle system
  105386. */
  105387. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105388. if (!this._emitRateGradients) {
  105389. this._emitRateGradients = [];
  105390. }
  105391. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  105392. return this;
  105393. };
  105394. /**
  105395. * Remove a specific emit rate gradient
  105396. * @param gradient defines the gradient to remove
  105397. * @returns the current particle system
  105398. */
  105399. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105400. this._removeFactorGradient(this._emitRateGradients, gradient);
  105401. return this;
  105402. };
  105403. /**
  105404. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  105405. * @param gradient defines the gradient to use (between 0 and 1)
  105406. * @param factor defines the start size value to affect to the specified gradient
  105407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105408. * @returns the current particle system
  105409. */
  105410. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  105411. if (!this._startSizeGradients) {
  105412. this._startSizeGradients = [];
  105413. }
  105414. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  105415. return this;
  105416. };
  105417. /**
  105418. * Remove a specific start size gradient
  105419. * @param gradient defines the gradient to remove
  105420. * @returns the current particle system
  105421. */
  105422. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  105423. this._removeFactorGradient(this._emitRateGradients, gradient);
  105424. return this;
  105425. };
  105426. ParticleSystem.prototype._createRampGradientTexture = function () {
  105427. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  105428. return;
  105429. }
  105430. var data = new Uint8Array(this._rawTextureWidth * 4);
  105431. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  105432. for (var x = 0; x < this._rawTextureWidth; x++) {
  105433. var ratio = x / this._rawTextureWidth;
  105434. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  105435. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  105436. data[x * 4] = tmpColor.r * 255;
  105437. data[x * 4 + 1] = tmpColor.g * 255;
  105438. data[x * 4 + 2] = tmpColor.b * 255;
  105439. data[x * 4 + 3] = 255;
  105440. });
  105441. }
  105442. 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);
  105443. };
  105444. /**
  105445. * Gets the current list of ramp gradients.
  105446. * You must use addRampGradient and removeRampGradient to udpate this list
  105447. * @returns the list of ramp gradients
  105448. */
  105449. ParticleSystem.prototype.getRampGradients = function () {
  105450. return this._rampGradients;
  105451. };
  105452. /**
  105453. * Adds a new ramp gradient used to remap particle colors
  105454. * @param gradient defines the gradient to use (between 0 and 1)
  105455. * @param color defines the color to affect to the specified gradient
  105456. * @returns the current particle system
  105457. */
  105458. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  105459. if (!this._rampGradients) {
  105460. this._rampGradients = [];
  105461. }
  105462. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  105463. rampGradient.gradient = gradient;
  105464. rampGradient.color = color;
  105465. this._rampGradients.push(rampGradient);
  105466. this._rampGradients.sort(function (a, b) {
  105467. if (a.gradient < b.gradient) {
  105468. return -1;
  105469. }
  105470. else if (a.gradient > b.gradient) {
  105471. return 1;
  105472. }
  105473. return 0;
  105474. });
  105475. if (this._rampGradientsTexture) {
  105476. this._rampGradientsTexture.dispose();
  105477. this._rampGradientsTexture = null;
  105478. }
  105479. this._createRampGradientTexture();
  105480. return this;
  105481. };
  105482. /**
  105483. * Remove a specific ramp gradient
  105484. * @param gradient defines the gradient to remove
  105485. * @returns the current particle system
  105486. */
  105487. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  105488. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  105489. this._rampGradientsTexture = null;
  105490. if (this._rampGradients && this._rampGradients.length > 0) {
  105491. this._createRampGradientTexture();
  105492. }
  105493. return this;
  105494. };
  105495. /**
  105496. * Adds a new color gradient
  105497. * @param gradient defines the gradient to use (between 0 and 1)
  105498. * @param color1 defines the color to affect to the specified gradient
  105499. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105500. * @returns this particle system
  105501. */
  105502. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105503. if (!this._colorGradients) {
  105504. this._colorGradients = [];
  105505. }
  105506. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105507. colorGradient.gradient = gradient;
  105508. colorGradient.color1 = color1;
  105509. colorGradient.color2 = color2;
  105510. this._colorGradients.push(colorGradient);
  105511. this._colorGradients.sort(function (a, b) {
  105512. if (a.gradient < b.gradient) {
  105513. return -1;
  105514. }
  105515. else if (a.gradient > b.gradient) {
  105516. return 1;
  105517. }
  105518. return 0;
  105519. });
  105520. return this;
  105521. };
  105522. /**
  105523. * Remove a specific color gradient
  105524. * @param gradient defines the gradient to remove
  105525. * @returns this particle system
  105526. */
  105527. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  105528. if (!this._colorGradients) {
  105529. return this;
  105530. }
  105531. var index = 0;
  105532. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  105533. var colorGradient = _a[_i];
  105534. if (colorGradient.gradient === gradient) {
  105535. this._colorGradients.splice(index, 1);
  105536. break;
  105537. }
  105538. index++;
  105539. }
  105540. return this;
  105541. };
  105542. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  105543. u = Math.abs(u) * 0.5 + 0.5;
  105544. v = Math.abs(v) * 0.5 + 0.5;
  105545. var wrappedU = ((u * width) % width) | 0;
  105546. var wrappedV = ((v * height) % height) | 0;
  105547. var position = (wrappedU + wrappedV * width) * 4;
  105548. return pixels[position] / 255;
  105549. };
  105550. ParticleSystem.prototype._reset = function () {
  105551. this._resetEffect();
  105552. };
  105553. ParticleSystem.prototype._resetEffect = function () {
  105554. if (this._vertexBuffer) {
  105555. this._vertexBuffer.dispose();
  105556. this._vertexBuffer = null;
  105557. }
  105558. if (this._spriteBuffer) {
  105559. this._spriteBuffer.dispose();
  105560. this._spriteBuffer = null;
  105561. }
  105562. this._createVertexBuffers();
  105563. };
  105564. ParticleSystem.prototype._createVertexBuffers = function () {
  105565. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  105566. if (this._isAnimationSheetEnabled) {
  105567. this._vertexBufferSize += 1;
  105568. }
  105569. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105570. this._vertexBufferSize += 3;
  105571. }
  105572. if (this._useRampGradients) {
  105573. this._vertexBufferSize += 4;
  105574. }
  105575. var engine = this._scene.getEngine();
  105576. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  105577. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  105578. var dataOffset = 0;
  105579. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105580. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  105581. dataOffset += 3;
  105582. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105583. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  105584. dataOffset += 4;
  105585. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105586. this._vertexBuffers["angle"] = options;
  105587. dataOffset += 1;
  105588. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105589. this._vertexBuffers["size"] = size;
  105590. dataOffset += 2;
  105591. if (this._isAnimationSheetEnabled) {
  105592. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105593. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  105594. dataOffset += 1;
  105595. }
  105596. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105597. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105598. this._vertexBuffers["direction"] = directionBuffer;
  105599. dataOffset += 3;
  105600. }
  105601. if (this._useRampGradients) {
  105602. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105603. this._vertexBuffers["remapData"] = rampDataBuffer;
  105604. dataOffset += 4;
  105605. }
  105606. var offsets;
  105607. if (this._useInstancing) {
  105608. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  105609. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  105610. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  105611. }
  105612. else {
  105613. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105614. dataOffset += 2;
  105615. }
  105616. this._vertexBuffers["offset"] = offsets;
  105617. };
  105618. ParticleSystem.prototype._createIndexBuffer = function () {
  105619. if (this._useInstancing) {
  105620. return;
  105621. }
  105622. var indices = [];
  105623. var index = 0;
  105624. for (var count = 0; count < this._capacity; count++) {
  105625. indices.push(index);
  105626. indices.push(index + 1);
  105627. indices.push(index + 2);
  105628. indices.push(index);
  105629. indices.push(index + 2);
  105630. indices.push(index + 3);
  105631. index += 4;
  105632. }
  105633. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  105634. };
  105635. /**
  105636. * Gets the maximum number of particles active at the same time.
  105637. * @returns The max number of active particles.
  105638. */
  105639. ParticleSystem.prototype.getCapacity = function () {
  105640. return this._capacity;
  105641. };
  105642. /**
  105643. * Gets whether there are still active particles in the system.
  105644. * @returns True if it is alive, otherwise false.
  105645. */
  105646. ParticleSystem.prototype.isAlive = function () {
  105647. return this._alive;
  105648. };
  105649. /**
  105650. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105651. * @returns True if it has been started, otherwise false.
  105652. */
  105653. ParticleSystem.prototype.isStarted = function () {
  105654. return this._started;
  105655. };
  105656. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  105657. var _this = this;
  105658. this._subEmitters = new Array();
  105659. if (this.subEmitters) {
  105660. this.subEmitters.forEach(function (subEmitter) {
  105661. if (subEmitter instanceof ParticleSystem) {
  105662. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  105663. }
  105664. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  105665. _this._subEmitters.push([subEmitter]);
  105666. }
  105667. else if (subEmitter instanceof Array) {
  105668. _this._subEmitters.push(subEmitter);
  105669. }
  105670. });
  105671. }
  105672. };
  105673. /**
  105674. * Starts the particle system and begins to emit
  105675. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105676. */
  105677. ParticleSystem.prototype.start = function (delay) {
  105678. var _this = this;
  105679. if (delay === void 0) { delay = this.startDelay; }
  105680. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  105681. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  105682. }
  105683. if (delay) {
  105684. setTimeout(function () {
  105685. _this.start(0);
  105686. }, delay);
  105687. return;
  105688. }
  105689. // Convert the subEmitters field to the constant type field _subEmitters
  105690. this._prepareSubEmitterInternalArray();
  105691. this._started = true;
  105692. this._stopped = false;
  105693. this._actualFrame = 0;
  105694. if (this._subEmitters && this._subEmitters.length != 0) {
  105695. this.activeSubSystems = new Array();
  105696. }
  105697. // Reset emit gradient so it acts the same on every start
  105698. if (this._emitRateGradients) {
  105699. if (this._emitRateGradients.length > 0) {
  105700. this._currentEmitRateGradient = this._emitRateGradients[0];
  105701. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  105702. this._currentEmitRate2 = this._currentEmitRate1;
  105703. }
  105704. if (this._emitRateGradients.length > 1) {
  105705. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  105706. }
  105707. }
  105708. // Reset start size gradient so it acts the same on every start
  105709. if (this._startSizeGradients) {
  105710. if (this._startSizeGradients.length > 0) {
  105711. this._currentStartSizeGradient = this._startSizeGradients[0];
  105712. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  105713. this._currentStartSize2 = this._currentStartSize1;
  105714. }
  105715. if (this._startSizeGradients.length > 1) {
  105716. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  105717. }
  105718. }
  105719. if (this.preWarmCycles) {
  105720. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  105721. this.emitter.computeWorldMatrix(true);
  105722. }
  105723. var noiseTextureAsProcedural_1 = this.noiseTexture;
  105724. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  105725. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  105726. setTimeout(function () {
  105727. for (var index = 0; index < _this.preWarmCycles; index++) {
  105728. _this.animate(true);
  105729. noiseTextureAsProcedural_1.render();
  105730. }
  105731. });
  105732. });
  105733. }
  105734. else {
  105735. for (var index = 0; index < this.preWarmCycles; index++) {
  105736. this.animate(true);
  105737. }
  105738. }
  105739. }
  105740. // Animations
  105741. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  105742. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  105743. }
  105744. };
  105745. /**
  105746. * Stops the particle system.
  105747. * @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.
  105748. */
  105749. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  105750. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  105751. this._stopped = true;
  105752. if (stopSubEmitters) {
  105753. this._stopSubEmitters();
  105754. }
  105755. };
  105756. // animation sheet
  105757. /**
  105758. * Remove all active particles
  105759. */
  105760. ParticleSystem.prototype.reset = function () {
  105761. this._stockParticles = [];
  105762. this._particles = [];
  105763. };
  105764. /**
  105765. * @hidden (for internal use only)
  105766. */
  105767. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  105768. var offset = index * this._vertexBufferSize;
  105769. this._vertexData[offset++] = particle.position.x;
  105770. this._vertexData[offset++] = particle.position.y;
  105771. this._vertexData[offset++] = particle.position.z;
  105772. this._vertexData[offset++] = particle.color.r;
  105773. this._vertexData[offset++] = particle.color.g;
  105774. this._vertexData[offset++] = particle.color.b;
  105775. this._vertexData[offset++] = particle.color.a;
  105776. this._vertexData[offset++] = particle.angle;
  105777. this._vertexData[offset++] = particle.scale.x * particle.size;
  105778. this._vertexData[offset++] = particle.scale.y * particle.size;
  105779. if (this._isAnimationSheetEnabled) {
  105780. this._vertexData[offset++] = particle.cellIndex;
  105781. }
  105782. if (!this._isBillboardBased) {
  105783. if (particle._initialDirection) {
  105784. this._vertexData[offset++] = particle._initialDirection.x;
  105785. this._vertexData[offset++] = particle._initialDirection.y;
  105786. this._vertexData[offset++] = particle._initialDirection.z;
  105787. }
  105788. else {
  105789. this._vertexData[offset++] = particle.direction.x;
  105790. this._vertexData[offset++] = particle.direction.y;
  105791. this._vertexData[offset++] = particle.direction.z;
  105792. }
  105793. }
  105794. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105795. this._vertexData[offset++] = particle.direction.x;
  105796. this._vertexData[offset++] = particle.direction.y;
  105797. this._vertexData[offset++] = particle.direction.z;
  105798. }
  105799. if (this._useRampGradients) {
  105800. this._vertexData[offset++] = particle.remapData.x;
  105801. this._vertexData[offset++] = particle.remapData.y;
  105802. this._vertexData[offset++] = particle.remapData.z;
  105803. this._vertexData[offset++] = particle.remapData.w;
  105804. }
  105805. if (!this._useInstancing) {
  105806. if (this._isAnimationSheetEnabled) {
  105807. if (offsetX === 0) {
  105808. offsetX = this._epsilon;
  105809. }
  105810. else if (offsetX === 1) {
  105811. offsetX = 1 - this._epsilon;
  105812. }
  105813. if (offsetY === 0) {
  105814. offsetY = this._epsilon;
  105815. }
  105816. else if (offsetY === 1) {
  105817. offsetY = 1 - this._epsilon;
  105818. }
  105819. }
  105820. this._vertexData[offset++] = offsetX;
  105821. this._vertexData[offset++] = offsetY;
  105822. }
  105823. };
  105824. ParticleSystem.prototype._stopSubEmitters = function () {
  105825. if (!this.activeSubSystems) {
  105826. return;
  105827. }
  105828. this.activeSubSystems.forEach(function (subSystem) {
  105829. subSystem.stop(true);
  105830. });
  105831. this.activeSubSystems = new Array();
  105832. };
  105833. ParticleSystem.prototype._removeFromRoot = function () {
  105834. if (!this._rootParticleSystem) {
  105835. return;
  105836. }
  105837. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  105838. if (index !== -1) {
  105839. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  105840. }
  105841. this._rootParticleSystem = null;
  105842. };
  105843. // End of sub system methods
  105844. ParticleSystem.prototype._update = function (newParticles) {
  105845. var _this = this;
  105846. // Update current
  105847. this._alive = this._particles.length > 0;
  105848. if (this.emitter.position) {
  105849. var emitterMesh = this.emitter;
  105850. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  105851. }
  105852. else {
  105853. var emitterPosition = this.emitter;
  105854. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  105855. }
  105856. this.updateFunction(this._particles);
  105857. // Add new ones
  105858. var particle;
  105859. var _loop_2 = function () {
  105860. if (this_1._particles.length === this_1._capacity) {
  105861. return "break";
  105862. }
  105863. particle = this_1._createParticle();
  105864. this_1._particles.push(particle);
  105865. // Emitter
  105866. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  105867. if (this_1.startPositionFunction) {
  105868. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  105869. }
  105870. else {
  105871. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  105872. }
  105873. if (this_1.startDirectionFunction) {
  105874. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  105875. }
  105876. else {
  105877. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  105878. }
  105879. if (emitPower === 0) {
  105880. if (!particle._initialDirection) {
  105881. particle._initialDirection = particle.direction.clone();
  105882. }
  105883. else {
  105884. particle._initialDirection.copyFrom(particle.direction);
  105885. }
  105886. }
  105887. else {
  105888. particle._initialDirection = null;
  105889. }
  105890. particle.direction.scaleInPlace(emitPower);
  105891. // Life time
  105892. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  105893. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  105894. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  105895. var factorGradient1 = currentGradient;
  105896. var factorGradient2 = nextGradient;
  105897. var lifeTime1 = factorGradient1.getFactor();
  105898. var lifeTime2 = factorGradient2.getFactor();
  105899. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  105900. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  105901. });
  105902. }
  105903. else {
  105904. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  105905. }
  105906. // Size
  105907. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  105908. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  105909. }
  105910. else {
  105911. particle._currentSizeGradient = this_1._sizeGradients[0];
  105912. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  105913. particle.size = particle._currentSize1;
  105914. if (this_1._sizeGradients.length > 1) {
  105915. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  105916. }
  105917. else {
  105918. particle._currentSize2 = particle._currentSize1;
  105919. }
  105920. }
  105921. // Size and scale
  105922. 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));
  105923. // Adjust scale by start size
  105924. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  105925. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  105926. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  105927. if (currentGradient !== _this._currentStartSizeGradient) {
  105928. _this._currentStartSize1 = _this._currentStartSize2;
  105929. _this._currentStartSize2 = nextGradient.getFactor();
  105930. _this._currentStartSizeGradient = currentGradient;
  105931. }
  105932. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  105933. particle.scale.scaleInPlace(value);
  105934. });
  105935. }
  105936. // Angle
  105937. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  105938. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  105939. }
  105940. else {
  105941. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  105942. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  105943. particle._currentAngularSpeed1 = particle.angularSpeed;
  105944. if (this_1._angularSpeedGradients.length > 1) {
  105945. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  105946. }
  105947. else {
  105948. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  105949. }
  105950. }
  105951. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  105952. // Velocity
  105953. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  105954. particle._currentVelocityGradient = this_1._velocityGradients[0];
  105955. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  105956. if (this_1._velocityGradients.length > 1) {
  105957. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  105958. }
  105959. else {
  105960. particle._currentVelocity2 = particle._currentVelocity1;
  105961. }
  105962. }
  105963. // Limit velocity
  105964. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  105965. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  105966. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  105967. if (this_1._limitVelocityGradients.length > 1) {
  105968. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  105969. }
  105970. else {
  105971. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  105972. }
  105973. }
  105974. // Drag
  105975. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  105976. particle._currentDragGradient = this_1._dragGradients[0];
  105977. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  105978. if (this_1._dragGradients.length > 1) {
  105979. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  105980. }
  105981. else {
  105982. particle._currentDrag2 = particle._currentDrag1;
  105983. }
  105984. }
  105985. // Color
  105986. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  105987. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  105988. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  105989. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  105990. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  105991. }
  105992. else {
  105993. particle._currentColorGradient = this_1._colorGradients[0];
  105994. particle._currentColorGradient.getColorToRef(particle.color);
  105995. particle._currentColor1.copyFrom(particle.color);
  105996. if (this_1._colorGradients.length > 1) {
  105997. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  105998. }
  105999. else {
  106000. particle._currentColor2.copyFrom(particle.color);
  106001. }
  106002. }
  106003. // Sheet
  106004. if (this_1._isAnimationSheetEnabled) {
  106005. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  106006. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  106007. }
  106008. // Inherited Velocity
  106009. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  106010. // Ramp
  106011. if (this_1._useRampGradients) {
  106012. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  106013. }
  106014. // Noise texture coordinates
  106015. if (this_1.noiseTexture) {
  106016. if (particle._randomNoiseCoordinates1) {
  106017. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  106018. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  106019. }
  106020. else {
  106021. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106022. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106023. }
  106024. }
  106025. // Update the position of the attached sub-emitters to match their attached particle
  106026. particle._inheritParticleInfoToSubEmitters();
  106027. };
  106028. var this_1 = this, step;
  106029. for (var index = 0; index < newParticles; index++) {
  106030. var state_1 = _loop_2();
  106031. if (state_1 === "break")
  106032. break;
  106033. }
  106034. };
  106035. /** @hidden */
  106036. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  106037. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106038. if (isBillboardBased === void 0) { isBillboardBased = false; }
  106039. if (useRampGradients === void 0) { useRampGradients = false; }
  106040. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  106041. if (isAnimationSheetEnabled) {
  106042. attributeNamesOrOptions.push("cellIndex");
  106043. }
  106044. if (!isBillboardBased) {
  106045. attributeNamesOrOptions.push("direction");
  106046. }
  106047. if (useRampGradients) {
  106048. attributeNamesOrOptions.push("remapData");
  106049. }
  106050. return attributeNamesOrOptions;
  106051. };
  106052. /** @hidden */
  106053. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  106054. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106055. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  106056. if (isAnimationSheetEnabled) {
  106057. effectCreationOption.push("particlesInfos");
  106058. }
  106059. return effectCreationOption;
  106060. };
  106061. /** @hidden */
  106062. ParticleSystem.prototype._getEffect = function (blendMode) {
  106063. if (this._customEffect) {
  106064. return this._customEffect;
  106065. }
  106066. var defines = [];
  106067. if (this._scene.clipPlane) {
  106068. defines.push("#define CLIPPLANE");
  106069. }
  106070. if (this._scene.clipPlane2) {
  106071. defines.push("#define CLIPPLANE2");
  106072. }
  106073. if (this._scene.clipPlane3) {
  106074. defines.push("#define CLIPPLANE3");
  106075. }
  106076. if (this._scene.clipPlane4) {
  106077. defines.push("#define CLIPPLANE4");
  106078. }
  106079. if (this._isAnimationSheetEnabled) {
  106080. defines.push("#define ANIMATESHEET");
  106081. }
  106082. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  106083. defines.push("#define BLENDMULTIPLYMODE");
  106084. }
  106085. if (this._useRampGradients) {
  106086. defines.push("#define RAMPGRADIENT");
  106087. }
  106088. if (this._isBillboardBased) {
  106089. defines.push("#define BILLBOARD");
  106090. switch (this.billboardMode) {
  106091. case ParticleSystem.BILLBOARDMODE_Y:
  106092. defines.push("#define BILLBOARDY");
  106093. break;
  106094. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  106095. defines.push("#define BILLBOARDSTRETCHED");
  106096. break;
  106097. case ParticleSystem.BILLBOARDMODE_ALL:
  106098. default:
  106099. break;
  106100. }
  106101. }
  106102. if (this._imageProcessingConfiguration) {
  106103. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  106104. defines.push(this._imageProcessingConfigurationDefines.toString());
  106105. }
  106106. // Effect
  106107. var join = defines.join("\n");
  106108. if (this._cachedDefines !== join) {
  106109. this._cachedDefines = join;
  106110. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  106111. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  106112. var samplers = ["diffuseSampler", "rampSampler"];
  106113. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  106114. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  106115. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  106116. }
  106117. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  106118. }
  106119. return this._effect;
  106120. };
  106121. /**
  106122. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106123. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  106124. */
  106125. ParticleSystem.prototype.animate = function (preWarmOnly) {
  106126. var _this = this;
  106127. if (preWarmOnly === void 0) { preWarmOnly = false; }
  106128. if (!this._started) {
  106129. return;
  106130. }
  106131. if (!preWarmOnly) {
  106132. // Check
  106133. if (!this.isReady()) {
  106134. return;
  106135. }
  106136. if (this._currentRenderId === this._scene.getFrameId()) {
  106137. return;
  106138. }
  106139. this._currentRenderId = this._scene.getFrameId();
  106140. }
  106141. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  106142. // Determine the number of particles we need to create
  106143. var newParticles;
  106144. if (this.manualEmitCount > -1) {
  106145. newParticles = this.manualEmitCount;
  106146. this._newPartsExcess = 0;
  106147. this.manualEmitCount = 0;
  106148. }
  106149. else {
  106150. var rate_1 = this.emitRate;
  106151. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  106152. var ratio = this._actualFrame / this.targetStopDuration;
  106153. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  106154. if (currentGradient !== _this._currentEmitRateGradient) {
  106155. _this._currentEmitRate1 = _this._currentEmitRate2;
  106156. _this._currentEmitRate2 = nextGradient.getFactor();
  106157. _this._currentEmitRateGradient = currentGradient;
  106158. }
  106159. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  106160. });
  106161. }
  106162. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  106163. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  106164. }
  106165. if (this._newPartsExcess > 1.0) {
  106166. newParticles += this._newPartsExcess >> 0;
  106167. this._newPartsExcess -= this._newPartsExcess >> 0;
  106168. }
  106169. this._alive = false;
  106170. if (!this._stopped) {
  106171. this._actualFrame += this._scaledUpdateSpeed;
  106172. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  106173. this.stop();
  106174. }
  106175. }
  106176. else {
  106177. newParticles = 0;
  106178. }
  106179. this._update(newParticles);
  106180. // Stopped?
  106181. if (this._stopped) {
  106182. if (!this._alive) {
  106183. this._started = false;
  106184. if (this.onAnimationEnd) {
  106185. this.onAnimationEnd();
  106186. }
  106187. if (this.disposeOnStop) {
  106188. this._scene._toBeDisposed.push(this);
  106189. }
  106190. }
  106191. }
  106192. if (!preWarmOnly) {
  106193. // Update VBO
  106194. var offset = 0;
  106195. for (var index = 0; index < this._particles.length; index++) {
  106196. var particle = this._particles[index];
  106197. this._appendParticleVertices(offset, particle);
  106198. offset += this._useInstancing ? 1 : 4;
  106199. }
  106200. if (this._vertexBuffer) {
  106201. this._vertexBuffer.update(this._vertexData);
  106202. }
  106203. }
  106204. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  106205. this.stop();
  106206. }
  106207. };
  106208. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  106209. this._appendParticleVertex(offset++, particle, 0, 0);
  106210. if (!this._useInstancing) {
  106211. this._appendParticleVertex(offset++, particle, 1, 0);
  106212. this._appendParticleVertex(offset++, particle, 1, 1);
  106213. this._appendParticleVertex(offset++, particle, 0, 1);
  106214. }
  106215. };
  106216. /**
  106217. * Rebuilds the particle system.
  106218. */
  106219. ParticleSystem.prototype.rebuild = function () {
  106220. this._createIndexBuffer();
  106221. if (this._vertexBuffer) {
  106222. this._vertexBuffer._rebuild();
  106223. }
  106224. };
  106225. /**
  106226. * Is this system ready to be used/rendered
  106227. * @return true if the system is ready
  106228. */
  106229. ParticleSystem.prototype.isReady = function () {
  106230. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106231. return false;
  106232. }
  106233. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106234. if (!this._getEffect(this.blendMode).isReady()) {
  106235. return false;
  106236. }
  106237. }
  106238. else {
  106239. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  106240. return false;
  106241. }
  106242. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  106243. return false;
  106244. }
  106245. }
  106246. return true;
  106247. };
  106248. ParticleSystem.prototype._render = function (blendMode) {
  106249. var effect = this._getEffect(blendMode);
  106250. var engine = this._scene.getEngine();
  106251. // Render
  106252. engine.enableEffect(effect);
  106253. var viewMatrix = this._scene.getViewMatrix();
  106254. effect.setTexture("diffuseSampler", this.particleTexture);
  106255. effect.setMatrix("view", viewMatrix);
  106256. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  106257. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106258. var baseSize = this.particleTexture.getBaseSize();
  106259. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106260. }
  106261. effect.setVector2("translationPivot", this.translationPivot);
  106262. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  106263. if (this._isBillboardBased) {
  106264. var camera = this._scene.activeCamera;
  106265. effect.setVector3("eyePosition", camera.globalPosition);
  106266. }
  106267. if (this._rampGradientsTexture) {
  106268. effect.setTexture("rampSampler", this._rampGradientsTexture);
  106269. }
  106270. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106271. var invView = viewMatrix.clone();
  106272. invView.invert();
  106273. effect.setMatrix("invView", invView);
  106274. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  106275. }
  106276. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  106277. // image processing
  106278. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106279. this._imageProcessingConfiguration.bind(effect);
  106280. }
  106281. // Draw order
  106282. switch (blendMode) {
  106283. case ParticleSystem.BLENDMODE_ADD:
  106284. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  106285. break;
  106286. case ParticleSystem.BLENDMODE_ONEONE:
  106287. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  106288. break;
  106289. case ParticleSystem.BLENDMODE_STANDARD:
  106290. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  106291. break;
  106292. case ParticleSystem.BLENDMODE_MULTIPLY:
  106293. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  106294. break;
  106295. }
  106296. if (this._useInstancing) {
  106297. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  106298. }
  106299. else {
  106300. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  106301. }
  106302. return this._particles.length;
  106303. };
  106304. /**
  106305. * Renders the particle system in its current state.
  106306. * @returns the current number of particles
  106307. */
  106308. ParticleSystem.prototype.render = function () {
  106309. // Check
  106310. if (!this.isReady() || !this._particles.length) {
  106311. return 0;
  106312. }
  106313. var engine = this._scene.getEngine();
  106314. engine.setState(false);
  106315. if (this.forceDepthWrite) {
  106316. engine.setDepthWrite(true);
  106317. }
  106318. var outparticles = 0;
  106319. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106320. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  106321. }
  106322. outparticles = this._render(this.blendMode);
  106323. engine.unbindInstanceAttributes();
  106324. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  106325. return outparticles;
  106326. };
  106327. /**
  106328. * Disposes the particle system and free the associated resources
  106329. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106330. */
  106331. ParticleSystem.prototype.dispose = function (disposeTexture) {
  106332. if (disposeTexture === void 0) { disposeTexture = true; }
  106333. if (this._vertexBuffer) {
  106334. this._vertexBuffer.dispose();
  106335. this._vertexBuffer = null;
  106336. }
  106337. if (this._spriteBuffer) {
  106338. this._spriteBuffer.dispose();
  106339. this._spriteBuffer = null;
  106340. }
  106341. if (this._indexBuffer) {
  106342. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  106343. this._indexBuffer = null;
  106344. }
  106345. if (disposeTexture && this.particleTexture) {
  106346. this.particleTexture.dispose();
  106347. this.particleTexture = null;
  106348. }
  106349. if (disposeTexture && this.noiseTexture) {
  106350. this.noiseTexture.dispose();
  106351. this.noiseTexture = null;
  106352. }
  106353. if (this._rampGradientsTexture) {
  106354. this._rampGradientsTexture.dispose();
  106355. this._rampGradientsTexture = null;
  106356. }
  106357. this._removeFromRoot();
  106358. if (this._subEmitters && this._subEmitters.length) {
  106359. for (var index = 0; index < this._subEmitters.length; index++) {
  106360. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  106361. var subEmitter = _a[_i];
  106362. subEmitter.dispose();
  106363. }
  106364. }
  106365. this._subEmitters = [];
  106366. this.subEmitters = [];
  106367. }
  106368. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  106369. this.emitter.dispose(true);
  106370. }
  106371. // Remove from scene
  106372. var index = this._scene.particleSystems.indexOf(this);
  106373. if (index > -1) {
  106374. this._scene.particleSystems.splice(index, 1);
  106375. }
  106376. this._scene._activeParticleSystems.dispose();
  106377. // Callback
  106378. this.onDisposeObservable.notifyObservers(this);
  106379. this.onDisposeObservable.clear();
  106380. this.reset();
  106381. };
  106382. // Clone
  106383. /**
  106384. * Clones the particle system.
  106385. * @param name The name of the cloned object
  106386. * @param newEmitter The new emitter to use
  106387. * @returns the cloned particle system
  106388. */
  106389. ParticleSystem.prototype.clone = function (name, newEmitter) {
  106390. var custom = null;
  106391. var program = null;
  106392. if (this.customShader != null) {
  106393. program = this.customShader;
  106394. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106395. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106396. }
  106397. else if (this._customEffect) {
  106398. custom = this._customEffect;
  106399. }
  106400. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  106401. result.customShader = program;
  106402. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  106403. if (newEmitter === undefined) {
  106404. newEmitter = this.emitter;
  106405. }
  106406. result.noiseTexture = this.noiseTexture;
  106407. result.emitter = newEmitter;
  106408. if (this.particleTexture) {
  106409. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  106410. }
  106411. // Clone gradients
  106412. if (this._colorGradients) {
  106413. this._colorGradients.forEach(function (v) {
  106414. result.addColorGradient(v.gradient, v.color1, v.color2);
  106415. });
  106416. }
  106417. if (this._dragGradients) {
  106418. this._dragGradients.forEach(function (v) {
  106419. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  106420. });
  106421. }
  106422. if (this._angularSpeedGradients) {
  106423. this._angularSpeedGradients.forEach(function (v) {
  106424. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  106425. });
  106426. }
  106427. if (this._emitRateGradients) {
  106428. this._emitRateGradients.forEach(function (v) {
  106429. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  106430. });
  106431. }
  106432. if (this._lifeTimeGradients) {
  106433. this._lifeTimeGradients.forEach(function (v) {
  106434. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  106435. });
  106436. }
  106437. if (this._limitVelocityGradients) {
  106438. this._limitVelocityGradients.forEach(function (v) {
  106439. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  106440. });
  106441. }
  106442. if (this._sizeGradients) {
  106443. this._sizeGradients.forEach(function (v) {
  106444. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  106445. });
  106446. }
  106447. if (this._startSizeGradients) {
  106448. this._startSizeGradients.forEach(function (v) {
  106449. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  106450. });
  106451. }
  106452. if (this._velocityGradients) {
  106453. this._velocityGradients.forEach(function (v) {
  106454. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  106455. });
  106456. }
  106457. if (this._rampGradients) {
  106458. this._rampGradients.forEach(function (v) {
  106459. result.addRampGradient(v.gradient, v.color);
  106460. });
  106461. }
  106462. if (this._colorRemapGradients) {
  106463. this._colorRemapGradients.forEach(function (v) {
  106464. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  106465. });
  106466. }
  106467. if (this._alphaRemapGradients) {
  106468. this._alphaRemapGradients.forEach(function (v) {
  106469. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  106470. });
  106471. }
  106472. if (!this.preventAutoStart) {
  106473. result.start();
  106474. }
  106475. return result;
  106476. };
  106477. /**
  106478. * Serializes the particle system to a JSON object.
  106479. * @returns the JSON object
  106480. */
  106481. ParticleSystem.prototype.serialize = function () {
  106482. var serializationObject = {};
  106483. ParticleSystem._Serialize(serializationObject, this);
  106484. serializationObject.textureMask = this.textureMask.asArray();
  106485. serializationObject.customShader = this.customShader;
  106486. serializationObject.preventAutoStart = this.preventAutoStart;
  106487. // SubEmitters
  106488. if (this.subEmitters) {
  106489. serializationObject.subEmitters = [];
  106490. if (!this._subEmitters) {
  106491. this._prepareSubEmitterInternalArray();
  106492. }
  106493. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  106494. var subs = _a[_i];
  106495. var cell = [];
  106496. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  106497. var sub = subs_1[_b];
  106498. cell.push(sub.serialize());
  106499. }
  106500. serializationObject.subEmitters.push(cell);
  106501. }
  106502. }
  106503. return serializationObject;
  106504. };
  106505. /** @hidden */
  106506. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  106507. serializationObject.name = particleSystem.name;
  106508. serializationObject.id = particleSystem.id;
  106509. serializationObject.capacity = particleSystem.getCapacity();
  106510. // Emitter
  106511. if (particleSystem.emitter.position) {
  106512. var emitterMesh = particleSystem.emitter;
  106513. serializationObject.emitterId = emitterMesh.id;
  106514. }
  106515. else {
  106516. var emitterPosition = particleSystem.emitter;
  106517. serializationObject.emitter = emitterPosition.asArray();
  106518. }
  106519. // Emitter
  106520. if (particleSystem.particleEmitterType) {
  106521. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  106522. }
  106523. if (particleSystem.particleTexture) {
  106524. serializationObject.textureName = particleSystem.particleTexture.name;
  106525. serializationObject.invertY = particleSystem.particleTexture._invertY;
  106526. }
  106527. // Animations
  106528. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  106529. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  106530. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  106531. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  106532. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  106533. // Particle system
  106534. serializationObject.startDelay = particleSystem.startDelay;
  106535. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  106536. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  106537. serializationObject.billboardMode = particleSystem.billboardMode;
  106538. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  106539. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  106540. serializationObject.minSize = particleSystem.minSize;
  106541. serializationObject.maxSize = particleSystem.maxSize;
  106542. serializationObject.minScaleX = particleSystem.minScaleX;
  106543. serializationObject.maxScaleX = particleSystem.maxScaleX;
  106544. serializationObject.minScaleY = particleSystem.minScaleY;
  106545. serializationObject.maxScaleY = particleSystem.maxScaleY;
  106546. serializationObject.minEmitPower = particleSystem.minEmitPower;
  106547. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  106548. serializationObject.minLifeTime = particleSystem.minLifeTime;
  106549. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  106550. serializationObject.emitRate = particleSystem.emitRate;
  106551. serializationObject.gravity = particleSystem.gravity.asArray();
  106552. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  106553. serializationObject.color1 = particleSystem.color1.asArray();
  106554. serializationObject.color2 = particleSystem.color2.asArray();
  106555. serializationObject.colorDead = particleSystem.colorDead.asArray();
  106556. serializationObject.updateSpeed = particleSystem.updateSpeed;
  106557. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  106558. serializationObject.blendMode = particleSystem.blendMode;
  106559. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  106560. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  106561. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  106562. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  106563. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  106564. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  106565. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  106566. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  106567. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  106568. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  106569. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  106570. var colorGradients = particleSystem.getColorGradients();
  106571. if (colorGradients) {
  106572. serializationObject.colorGradients = [];
  106573. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  106574. var colorGradient = colorGradients_1[_i];
  106575. var serializedGradient = {
  106576. gradient: colorGradient.gradient,
  106577. color1: colorGradient.color1.asArray()
  106578. };
  106579. if (colorGradient.color2) {
  106580. serializedGradient.color2 = colorGradient.color2.asArray();
  106581. }
  106582. serializationObject.colorGradients.push(serializedGradient);
  106583. }
  106584. }
  106585. var rampGradients = particleSystem.getRampGradients();
  106586. if (rampGradients) {
  106587. serializationObject.rampGradients = [];
  106588. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  106589. var rampGradient = rampGradients_1[_a];
  106590. var serializedGradient = {
  106591. gradient: rampGradient.gradient,
  106592. color: rampGradient.color.asArray()
  106593. };
  106594. serializationObject.rampGradients.push(serializedGradient);
  106595. }
  106596. serializationObject.useRampGradients = particleSystem.useRampGradients;
  106597. }
  106598. var colorRemapGradients = particleSystem.getColorRemapGradients();
  106599. if (colorRemapGradients) {
  106600. serializationObject.colorRemapGradients = [];
  106601. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  106602. var colorRemapGradient = colorRemapGradients_1[_b];
  106603. var serializedGradient = {
  106604. gradient: colorRemapGradient.gradient,
  106605. factor1: colorRemapGradient.factor1
  106606. };
  106607. if (colorRemapGradient.factor2 !== undefined) {
  106608. serializedGradient.factor2 = colorRemapGradient.factor2;
  106609. }
  106610. serializationObject.colorRemapGradients.push(serializedGradient);
  106611. }
  106612. }
  106613. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  106614. if (alphaRemapGradients) {
  106615. serializationObject.alphaRemapGradients = [];
  106616. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  106617. var alphaRemapGradient = alphaRemapGradients_1[_c];
  106618. var serializedGradient = {
  106619. gradient: alphaRemapGradient.gradient,
  106620. factor1: alphaRemapGradient.factor1
  106621. };
  106622. if (alphaRemapGradient.factor2 !== undefined) {
  106623. serializedGradient.factor2 = alphaRemapGradient.factor2;
  106624. }
  106625. serializationObject.alphaRemapGradients.push(serializedGradient);
  106626. }
  106627. }
  106628. var sizeGradients = particleSystem.getSizeGradients();
  106629. if (sizeGradients) {
  106630. serializationObject.sizeGradients = [];
  106631. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  106632. var sizeGradient = sizeGradients_1[_d];
  106633. var serializedGradient = {
  106634. gradient: sizeGradient.gradient,
  106635. factor1: sizeGradient.factor1
  106636. };
  106637. if (sizeGradient.factor2 !== undefined) {
  106638. serializedGradient.factor2 = sizeGradient.factor2;
  106639. }
  106640. serializationObject.sizeGradients.push(serializedGradient);
  106641. }
  106642. }
  106643. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  106644. if (angularSpeedGradients) {
  106645. serializationObject.angularSpeedGradients = [];
  106646. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  106647. var angularSpeedGradient = angularSpeedGradients_1[_e];
  106648. var serializedGradient = {
  106649. gradient: angularSpeedGradient.gradient,
  106650. factor1: angularSpeedGradient.factor1
  106651. };
  106652. if (angularSpeedGradient.factor2 !== undefined) {
  106653. serializedGradient.factor2 = angularSpeedGradient.factor2;
  106654. }
  106655. serializationObject.angularSpeedGradients.push(serializedGradient);
  106656. }
  106657. }
  106658. var velocityGradients = particleSystem.getVelocityGradients();
  106659. if (velocityGradients) {
  106660. serializationObject.velocityGradients = [];
  106661. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  106662. var velocityGradient = velocityGradients_1[_f];
  106663. var serializedGradient = {
  106664. gradient: velocityGradient.gradient,
  106665. factor1: velocityGradient.factor1
  106666. };
  106667. if (velocityGradient.factor2 !== undefined) {
  106668. serializedGradient.factor2 = velocityGradient.factor2;
  106669. }
  106670. serializationObject.velocityGradients.push(serializedGradient);
  106671. }
  106672. }
  106673. var dragGradients = particleSystem.getDragGradients();
  106674. if (dragGradients) {
  106675. serializationObject.dragyGradients = [];
  106676. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  106677. var dragGradient = dragGradients_1[_g];
  106678. var serializedGradient = {
  106679. gradient: dragGradient.gradient,
  106680. factor1: dragGradient.factor1
  106681. };
  106682. if (dragGradient.factor2 !== undefined) {
  106683. serializedGradient.factor2 = dragGradient.factor2;
  106684. }
  106685. serializationObject.dragGradients.push(serializedGradient);
  106686. }
  106687. }
  106688. var emitRateGradients = particleSystem.getEmitRateGradients();
  106689. if (emitRateGradients) {
  106690. serializationObject.emitRateGradients = [];
  106691. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  106692. var emitRateGradient = emitRateGradients_1[_h];
  106693. var serializedGradient = {
  106694. gradient: emitRateGradient.gradient,
  106695. factor1: emitRateGradient.factor1
  106696. };
  106697. if (emitRateGradient.factor2 !== undefined) {
  106698. serializedGradient.factor2 = emitRateGradient.factor2;
  106699. }
  106700. serializationObject.emitRateGradients.push(serializedGradient);
  106701. }
  106702. }
  106703. var startSizeGradients = particleSystem.getStartSizeGradients();
  106704. if (startSizeGradients) {
  106705. serializationObject.startSizeGradients = [];
  106706. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  106707. var startSizeGradient = startSizeGradients_1[_j];
  106708. var serializedGradient = {
  106709. gradient: startSizeGradient.gradient,
  106710. factor1: startSizeGradient.factor1
  106711. };
  106712. if (startSizeGradient.factor2 !== undefined) {
  106713. serializedGradient.factor2 = startSizeGradient.factor2;
  106714. }
  106715. serializationObject.startSizeGradients.push(serializedGradient);
  106716. }
  106717. }
  106718. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  106719. if (lifeTimeGradients) {
  106720. serializationObject.lifeTimeGradients = [];
  106721. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  106722. var lifeTimeGradient = lifeTimeGradients_1[_k];
  106723. var serializedGradient = {
  106724. gradient: lifeTimeGradient.gradient,
  106725. factor1: lifeTimeGradient.factor1
  106726. };
  106727. if (lifeTimeGradient.factor2 !== undefined) {
  106728. serializedGradient.factor2 = lifeTimeGradient.factor2;
  106729. }
  106730. serializationObject.lifeTimeGradients.push(serializedGradient);
  106731. }
  106732. }
  106733. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  106734. if (limitVelocityGradients) {
  106735. serializationObject.limitVelocityGradients = [];
  106736. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  106737. var limitVelocityGradient = limitVelocityGradients_1[_l];
  106738. var serializedGradient = {
  106739. gradient: limitVelocityGradient.gradient,
  106740. factor1: limitVelocityGradient.factor1
  106741. };
  106742. if (limitVelocityGradient.factor2 !== undefined) {
  106743. serializedGradient.factor2 = limitVelocityGradient.factor2;
  106744. }
  106745. serializationObject.limitVelocityGradients.push(serializedGradient);
  106746. }
  106747. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  106748. }
  106749. if (particleSystem.noiseTexture) {
  106750. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  106751. }
  106752. };
  106753. /** @hidden */
  106754. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  106755. // Texture
  106756. if (parsedParticleSystem.textureName) {
  106757. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  106758. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  106759. }
  106760. // Emitter
  106761. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  106762. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  106763. }
  106764. else if (parsedParticleSystem.emitterId) {
  106765. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  106766. }
  106767. else {
  106768. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  106769. }
  106770. // Misc.
  106771. if (parsedParticleSystem.renderingGroupId !== undefined) {
  106772. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  106773. }
  106774. if (parsedParticleSystem.isBillboardBased !== undefined) {
  106775. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  106776. }
  106777. if (parsedParticleSystem.billboardMode !== undefined) {
  106778. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  106779. }
  106780. // Animations
  106781. if (parsedParticleSystem.animations) {
  106782. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  106783. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  106784. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  106785. if (internalClass) {
  106786. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  106787. }
  106788. }
  106789. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  106790. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  106791. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  106792. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  106793. }
  106794. if (parsedParticleSystem.autoAnimate) {
  106795. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  106796. }
  106797. // Particle system
  106798. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  106799. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  106800. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  106801. particleSystem.minSize = parsedParticleSystem.minSize;
  106802. particleSystem.maxSize = parsedParticleSystem.maxSize;
  106803. if (parsedParticleSystem.minScaleX) {
  106804. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  106805. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  106806. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  106807. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  106808. }
  106809. if (parsedParticleSystem.preWarmCycles !== undefined) {
  106810. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  106811. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  106812. }
  106813. if (parsedParticleSystem.minInitialRotation !== undefined) {
  106814. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  106815. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  106816. }
  106817. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  106818. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  106819. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  106820. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  106821. particleSystem.emitRate = parsedParticleSystem.emitRate;
  106822. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  106823. if (parsedParticleSystem.noiseStrength) {
  106824. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  106825. }
  106826. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  106827. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  106828. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  106829. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  106830. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  106831. particleSystem.blendMode = parsedParticleSystem.blendMode;
  106832. if (parsedParticleSystem.colorGradients) {
  106833. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  106834. var colorGradient = _a[_i];
  106835. 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);
  106836. }
  106837. }
  106838. if (parsedParticleSystem.rampGradients) {
  106839. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  106840. var rampGradient = _c[_b];
  106841. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  106842. }
  106843. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  106844. }
  106845. if (parsedParticleSystem.colorRemapGradients) {
  106846. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  106847. var colorRemapGradient = _e[_d];
  106848. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  106849. }
  106850. }
  106851. if (parsedParticleSystem.alphaRemapGradients) {
  106852. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  106853. var alphaRemapGradient = _g[_f];
  106854. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  106855. }
  106856. }
  106857. if (parsedParticleSystem.sizeGradients) {
  106858. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  106859. var sizeGradient = _j[_h];
  106860. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  106861. }
  106862. }
  106863. if (parsedParticleSystem.sizeGradients) {
  106864. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  106865. var sizeGradient = _l[_k];
  106866. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  106867. }
  106868. }
  106869. if (parsedParticleSystem.angularSpeedGradients) {
  106870. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  106871. var angularSpeedGradient = _o[_m];
  106872. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  106873. }
  106874. }
  106875. if (parsedParticleSystem.velocityGradients) {
  106876. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  106877. var velocityGradient = _q[_p];
  106878. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  106879. }
  106880. }
  106881. if (parsedParticleSystem.dragGradients) {
  106882. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  106883. var dragGradient = _s[_r];
  106884. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  106885. }
  106886. }
  106887. if (parsedParticleSystem.emitRateGradients) {
  106888. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  106889. var emitRateGradient = _u[_t];
  106890. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  106891. }
  106892. }
  106893. if (parsedParticleSystem.startSizeGradients) {
  106894. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  106895. var startSizeGradient = _w[_v];
  106896. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  106897. }
  106898. }
  106899. if (parsedParticleSystem.lifeTimeGradients) {
  106900. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  106901. var lifeTimeGradient = _y[_x];
  106902. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  106903. }
  106904. }
  106905. if (parsedParticleSystem.limitVelocityGradients) {
  106906. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  106907. var limitVelocityGradient = _0[_z];
  106908. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  106909. }
  106910. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  106911. }
  106912. if (parsedParticleSystem.noiseTexture) {
  106913. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  106914. }
  106915. // Emitter
  106916. var emitterType;
  106917. if (parsedParticleSystem.particleEmitterType) {
  106918. switch (parsedParticleSystem.particleEmitterType.type) {
  106919. case "SphereParticleEmitter":
  106920. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  106921. break;
  106922. case "SphereDirectedParticleEmitter":
  106923. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  106924. break;
  106925. case "ConeEmitter":
  106926. case "ConeParticleEmitter":
  106927. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  106928. break;
  106929. case "CylinderParticleEmitter":
  106930. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  106931. break;
  106932. case "HemisphericParticleEmitter":
  106933. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  106934. break;
  106935. case "BoxEmitter":
  106936. case "BoxParticleEmitter":
  106937. default:
  106938. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  106939. break;
  106940. }
  106941. emitterType.parse(parsedParticleSystem.particleEmitterType);
  106942. }
  106943. else {
  106944. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  106945. emitterType.parse(parsedParticleSystem);
  106946. }
  106947. particleSystem.particleEmitterType = emitterType;
  106948. // Animation sheet
  106949. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  106950. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  106951. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  106952. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  106953. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  106954. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  106955. };
  106956. /**
  106957. * Parses a JSON object to create a particle system.
  106958. * @param parsedParticleSystem The JSON object to parse
  106959. * @param scene The scene to create the particle system in
  106960. * @param rootUrl The root url to use to load external dependencies like texture
  106961. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106962. * @returns the Parsed particle system
  106963. */
  106964. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  106965. if (doNotStart === void 0) { doNotStart = false; }
  106966. var name = parsedParticleSystem.name;
  106967. var custom = null;
  106968. var program = null;
  106969. if (parsedParticleSystem.customShader) {
  106970. program = parsedParticleSystem.customShader;
  106971. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106972. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106973. }
  106974. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  106975. particleSystem.customShader = program;
  106976. if (parsedParticleSystem.id) {
  106977. particleSystem.id = parsedParticleSystem.id;
  106978. }
  106979. // SubEmitters
  106980. if (parsedParticleSystem.subEmitters) {
  106981. particleSystem.subEmitters = [];
  106982. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  106983. var cell = _a[_i];
  106984. var cellArray = [];
  106985. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  106986. var sub = cell_1[_b];
  106987. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  106988. }
  106989. particleSystem.subEmitters.push(cellArray);
  106990. }
  106991. }
  106992. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  106993. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  106994. // Auto start
  106995. if (parsedParticleSystem.preventAutoStart) {
  106996. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  106997. }
  106998. if (!doNotStart && !particleSystem.preventAutoStart) {
  106999. particleSystem.start();
  107000. }
  107001. return particleSystem;
  107002. };
  107003. /**
  107004. * Billboard mode will only apply to Y axis
  107005. */
  107006. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  107007. /**
  107008. * Billboard mode will apply to all axes
  107009. */
  107010. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107011. /**
  107012. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  107013. */
  107014. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  107015. return ParticleSystem;
  107016. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  107017. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  107018. /***/ }),
  107019. /***/ "./Particles/particleSystemComponent.ts":
  107020. /*!**********************************************!*\
  107021. !*** ./Particles/particleSystemComponent.ts ***!
  107022. \**********************************************/
  107023. /*! exports provided: _IDoNeedToBeInTheBuild */
  107024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107025. "use strict";
  107026. __webpack_require__.r(__webpack_exports__);
  107027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  107028. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107029. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107030. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  107031. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  107032. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107033. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  107034. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  107035. // Adds the parsers to the scene parsers.
  107036. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  107037. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  107038. if (!individualParser) {
  107039. return;
  107040. }
  107041. // Particles Systems
  107042. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  107043. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  107044. var parsedParticleSystem = parsedData.particleSystems[index];
  107045. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  107046. }
  107047. }
  107048. });
  107049. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  107050. if (parsedParticleSystem.activeParticleCount) {
  107051. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107052. return ps;
  107053. }
  107054. else {
  107055. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107056. return ps;
  107057. }
  107058. });
  107059. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  107060. if (uniformsNames === void 0) { uniformsNames = []; }
  107061. if (samplers === void 0) { samplers = []; }
  107062. if (defines === void 0) { defines = ""; }
  107063. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  107064. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  107065. if (defines.indexOf(" BILLBOARD") === -1) {
  107066. defines += "\n#define BILLBOARD\n";
  107067. }
  107068. if (samplers.indexOf("diffuseSampler") === -1) {
  107069. samplers.push("diffuseSampler");
  107070. }
  107071. return this.createEffect({
  107072. vertex: "particles",
  107073. fragmentElement: fragmentName
  107074. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  107075. };
  107076. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  107077. var results = new Array();
  107078. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107079. var particleSystem = this.getScene().particleSystems[index];
  107080. if (particleSystem.emitter === this) {
  107081. results.push(particleSystem);
  107082. }
  107083. }
  107084. return results;
  107085. };
  107086. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  107087. var results = new Array();
  107088. var descendants = this.getDescendants();
  107089. descendants.push(this);
  107090. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107091. var particleSystem = this.getScene().particleSystems[index];
  107092. var emitter = particleSystem.emitter;
  107093. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  107094. results.push(particleSystem);
  107095. }
  107096. }
  107097. return results;
  107098. };
  107099. /**
  107100. * @hidden
  107101. */
  107102. var _IDoNeedToBeInTheBuild = 42;
  107103. /***/ }),
  107104. /***/ "./Particles/particleSystemSet.ts":
  107105. /*!****************************************!*\
  107106. !*** ./Particles/particleSystemSet.ts ***!
  107107. \****************************************/
  107108. /*! exports provided: ParticleSystemSet */
  107109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107110. "use strict";
  107111. __webpack_require__.r(__webpack_exports__);
  107112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  107113. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107114. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  107115. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107116. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107117. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  107118. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  107119. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107120. /** Internal class used to store shapes for emitters */
  107121. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  107122. function ParticleSystemSetEmitterCreationOptions() {
  107123. }
  107124. return ParticleSystemSetEmitterCreationOptions;
  107125. }());
  107126. /**
  107127. * Represents a set of particle systems working together to create a specific effect
  107128. */
  107129. var ParticleSystemSet = /** @class */ (function () {
  107130. function ParticleSystemSet() {
  107131. /**
  107132. * Gets the particle system list
  107133. */
  107134. this.systems = new Array();
  107135. }
  107136. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  107137. /**
  107138. * Gets the emitter node used with this set
  107139. */
  107140. get: function () {
  107141. return this._emitterNode;
  107142. },
  107143. enumerable: true,
  107144. configurable: true
  107145. });
  107146. /**
  107147. * Creates a new emitter mesh as a sphere
  107148. * @param options defines the options used to create the sphere
  107149. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107150. * @param scene defines the hosting scene
  107151. */
  107152. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  107153. if (this._emitterNode) {
  107154. this._emitterNode.dispose();
  107155. }
  107156. this._emitterCreationOptions = {
  107157. kind: "Sphere",
  107158. options: options,
  107159. renderingGroupId: renderingGroupId
  107160. };
  107161. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  107162. emitterMesh.renderingGroupId = renderingGroupId;
  107163. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  107164. material.emissiveColor = options.color;
  107165. emitterMesh.material = material;
  107166. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107167. var system = _a[_i];
  107168. system.emitter = emitterMesh;
  107169. }
  107170. this._emitterNode = emitterMesh;
  107171. };
  107172. /**
  107173. * Starts all particle systems of the set
  107174. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107175. */
  107176. ParticleSystemSet.prototype.start = function (emitter) {
  107177. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107178. var system = _a[_i];
  107179. if (emitter) {
  107180. system.emitter = emitter;
  107181. }
  107182. system.start();
  107183. }
  107184. };
  107185. /**
  107186. * Release all associated resources
  107187. */
  107188. ParticleSystemSet.prototype.dispose = function () {
  107189. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107190. var system = _a[_i];
  107191. system.dispose();
  107192. }
  107193. this.systems = [];
  107194. if (this._emitterNode) {
  107195. this._emitterNode.dispose();
  107196. this._emitterNode = null;
  107197. }
  107198. };
  107199. /**
  107200. * Serialize the set into a JSON compatible object
  107201. * @returns a JSON compatible representation of the set
  107202. */
  107203. ParticleSystemSet.prototype.serialize = function () {
  107204. var result = {};
  107205. result.systems = [];
  107206. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107207. var system = _a[_i];
  107208. result.systems.push(system.serialize());
  107209. }
  107210. if (this._emitterNode) {
  107211. result.emitter = this._emitterCreationOptions;
  107212. }
  107213. return result;
  107214. };
  107215. /**
  107216. * Parse a new ParticleSystemSet from a serialized source
  107217. * @param data defines a JSON compatible representation of the set
  107218. * @param scene defines the hosting scene
  107219. * @param gpu defines if we want GPU particles or CPU particles
  107220. * @returns a new ParticleSystemSet
  107221. */
  107222. ParticleSystemSet.Parse = function (data, scene, gpu) {
  107223. if (gpu === void 0) { gpu = false; }
  107224. var result = new ParticleSystemSet();
  107225. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  107226. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  107227. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  107228. var system = _a[_i];
  107229. 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));
  107230. }
  107231. if (data.emitter) {
  107232. var options = data.emitter.options;
  107233. switch (data.emitter.kind) {
  107234. case "Sphere":
  107235. result.setEmitterAsSphere({
  107236. diameter: options.diameter,
  107237. segments: options.segments,
  107238. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  107239. }, data.emitter.renderingGroupId, scene);
  107240. break;
  107241. }
  107242. }
  107243. return result;
  107244. };
  107245. return ParticleSystemSet;
  107246. }());
  107247. /***/ }),
  107248. /***/ "./Particles/solidParticle.ts":
  107249. /*!************************************!*\
  107250. !*** ./Particles/solidParticle.ts ***!
  107251. \************************************/
  107252. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  107253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107254. "use strict";
  107255. __webpack_require__.r(__webpack_exports__);
  107256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  107257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  107258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  107259. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107260. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107261. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  107262. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107263. /**
  107264. * Represents one particle of a solid particle system.
  107265. */
  107266. var SolidParticle = /** @class */ (function () {
  107267. /**
  107268. * Creates a Solid Particle object.
  107269. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107270. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  107271. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107272. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107273. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107274. * @param shapeId (integer) is the model shape identifier in the SPS.
  107275. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107276. * @param sps defines the sps it is associated to
  107277. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107278. */
  107279. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  107280. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  107281. /**
  107282. * particle global index
  107283. */
  107284. this.idx = 0;
  107285. /**
  107286. * The color of the particle
  107287. */
  107288. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107289. /**
  107290. * The world space position of the particle.
  107291. */
  107292. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107293. /**
  107294. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107295. */
  107296. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107297. /**
  107298. * The scaling of the particle.
  107299. */
  107300. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  107301. /**
  107302. * The uvs of the particle.
  107303. */
  107304. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  107305. /**
  107306. * The current speed of the particle.
  107307. */
  107308. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107309. /**
  107310. * The pivot point in the particle local space.
  107311. */
  107312. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107313. /**
  107314. * Must the particle be translated from its pivot point in its local space ?
  107315. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107316. * Default : false
  107317. */
  107318. this.translateFromPivot = false;
  107319. /**
  107320. * Is the particle active or not ?
  107321. */
  107322. this.alive = true;
  107323. /**
  107324. * Is the particle visible or not ?
  107325. */
  107326. this.isVisible = true;
  107327. /**
  107328. * Index of this particle in the global "positions" array (Internal use)
  107329. * @hidden
  107330. */
  107331. this._pos = 0;
  107332. /**
  107333. * @hidden Index of this particle in the global "indices" array (Internal use)
  107334. */
  107335. this._ind = 0;
  107336. /**
  107337. * ModelShape id of this particle
  107338. */
  107339. this.shapeId = 0;
  107340. /**
  107341. * Index of the particle in its shape id (Internal use)
  107342. */
  107343. this.idxInShape = 0;
  107344. /**
  107345. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107346. */
  107347. this._stillInvisible = false;
  107348. /**
  107349. * @hidden Last computed particle rotation matrix
  107350. */
  107351. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  107352. /**
  107353. * Parent particle Id, if any.
  107354. * Default null.
  107355. */
  107356. this.parentId = null;
  107357. /**
  107358. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107359. * The possible values are :
  107360. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107361. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107362. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107363. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107364. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107365. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107366. * */
  107367. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  107368. /**
  107369. * @hidden Internal global position in the SPS.
  107370. */
  107371. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107372. this.idx = particleIndex;
  107373. this._pos = positionIndex;
  107374. this._ind = indiceIndex;
  107375. this._model = model;
  107376. this.shapeId = shapeId;
  107377. this.idxInShape = idxInShape;
  107378. this._sps = sps;
  107379. if (modelBoundingInfo) {
  107380. this._modelBoundingInfo = modelBoundingInfo;
  107381. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  107382. }
  107383. }
  107384. Object.defineProperty(SolidParticle.prototype, "scale", {
  107385. /**
  107386. * Legacy support, changed scale to scaling
  107387. */
  107388. get: function () {
  107389. return this.scaling;
  107390. },
  107391. /**
  107392. * Legacy support, changed scale to scaling
  107393. */
  107394. set: function (scale) {
  107395. this.scaling = scale;
  107396. },
  107397. enumerable: true,
  107398. configurable: true
  107399. });
  107400. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  107401. /**
  107402. * Legacy support, changed quaternion to rotationQuaternion
  107403. */
  107404. get: function () {
  107405. return this.rotationQuaternion;
  107406. },
  107407. /**
  107408. * Legacy support, changed quaternion to rotationQuaternion
  107409. */
  107410. set: function (q) {
  107411. this.rotationQuaternion = q;
  107412. },
  107413. enumerable: true,
  107414. configurable: true
  107415. });
  107416. /**
  107417. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107418. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107419. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107420. * @returns true if it intersects
  107421. */
  107422. SolidParticle.prototype.intersectsMesh = function (target) {
  107423. if (!this._boundingInfo || !target._boundingInfo) {
  107424. return false;
  107425. }
  107426. if (this._sps._bSphereOnly) {
  107427. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  107428. }
  107429. return this._boundingInfo.intersects(target._boundingInfo, false);
  107430. };
  107431. /**
  107432. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107433. * A particle is in the frustum if its bounding box intersects the frustum
  107434. * @param frustumPlanes defines the frustum to test
  107435. * @returns true if the particle is in the frustum planes
  107436. */
  107437. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  107438. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  107439. };
  107440. /**
  107441. * get the rotation matrix of the particle
  107442. * @hidden
  107443. */
  107444. SolidParticle.prototype.getRotationMatrix = function (m) {
  107445. var quaternion;
  107446. if (this.rotationQuaternion) {
  107447. quaternion = this.rotationQuaternion;
  107448. }
  107449. else {
  107450. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107451. var rotation = this.rotation;
  107452. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107453. }
  107454. quaternion.toRotationMatrix(m);
  107455. };
  107456. return SolidParticle;
  107457. }());
  107458. /**
  107459. * Represents the shape of the model used by one particle of a solid particle system.
  107460. * SPS internal tool, don't use it manually.
  107461. */
  107462. var ModelShape = /** @class */ (function () {
  107463. /**
  107464. * 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.
  107465. * SPS internal tool, don't use it manually.
  107466. * @hidden
  107467. */
  107468. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  107469. /**
  107470. * length of the shape in the model indices array (internal use)
  107471. * @hidden
  107472. */
  107473. this._indicesLength = 0;
  107474. this.shapeID = id;
  107475. this._shape = shape;
  107476. this._indicesLength = indicesLength;
  107477. this._shapeUV = shapeUV;
  107478. this._positionFunction = posFunction;
  107479. this._vertexFunction = vtxFunction;
  107480. }
  107481. return ModelShape;
  107482. }());
  107483. /**
  107484. * Represents a Depth Sorted Particle in the solid particle system.
  107485. */
  107486. var DepthSortedParticle = /** @class */ (function () {
  107487. function DepthSortedParticle() {
  107488. /**
  107489. * Index of the particle in the "indices" array
  107490. */
  107491. this.ind = 0;
  107492. /**
  107493. * Length of the particle shape in the "indices" array
  107494. */
  107495. this.indicesLength = 0;
  107496. /**
  107497. * Squared distance from the particle to the camera
  107498. */
  107499. this.sqDistance = 0.0;
  107500. }
  107501. return DepthSortedParticle;
  107502. }());
  107503. /***/ }),
  107504. /***/ "./Particles/solidParticleSystem.ts":
  107505. /*!******************************************!*\
  107506. !*** ./Particles/solidParticleSystem.ts ***!
  107507. \******************************************/
  107508. /*! exports provided: SolidParticleSystem */
  107509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107510. "use strict";
  107511. __webpack_require__.r(__webpack_exports__);
  107512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  107513. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107514. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107515. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  107516. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107517. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  107518. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107519. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  107520. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107521. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  107522. /**
  107523. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107524. *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.
  107525. * The SPS is also a particle system. It provides some methods to manage the particles.
  107526. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107527. *
  107528. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  107529. */
  107530. var SolidParticleSystem = /** @class */ (function () {
  107531. /**
  107532. * Creates a SPS (Solid Particle System) object.
  107533. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107534. * @param scene (Scene) is the scene in which the SPS is added.
  107535. * @param options defines the options of the sps e.g.
  107536. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107537. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107538. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107539. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107540. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107541. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107542. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107543. */
  107544. function SolidParticleSystem(name, scene, options) {
  107545. /**
  107546. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107547. * Example : var p = SPS.particles[i];
  107548. */
  107549. this.particles = new Array();
  107550. /**
  107551. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107552. */
  107553. this.nbParticles = 0;
  107554. /**
  107555. * If the particles must ever face the camera (default false). Useful for planar particles.
  107556. */
  107557. this.billboard = false;
  107558. /**
  107559. * Recompute normals when adding a shape
  107560. */
  107561. this.recomputeNormals = true;
  107562. /**
  107563. * This a counter ofr your own usage. It's not set by any SPS functions.
  107564. */
  107565. this.counter = 0;
  107566. /**
  107567. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107568. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  107569. */
  107570. this.vars = {};
  107571. /**
  107572. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107573. * @hidden
  107574. */
  107575. this._bSphereOnly = false;
  107576. /**
  107577. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107578. * @hidden
  107579. */
  107580. this._bSphereRadiusFactor = 1.0;
  107581. this._positions = new Array();
  107582. this._indices = new Array();
  107583. this._normals = new Array();
  107584. this._colors = new Array();
  107585. this._uvs = new Array();
  107586. this._index = 0; // indices index
  107587. this._updatable = true;
  107588. this._pickable = false;
  107589. this._isVisibilityBoxLocked = false;
  107590. this._alwaysVisible = false;
  107591. this._depthSort = false;
  107592. this._shapeCounter = 0;
  107593. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  107594. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107595. this._computeParticleColor = true;
  107596. this._computeParticleTexture = true;
  107597. this._computeParticleRotation = true;
  107598. this._computeParticleVertex = false;
  107599. this._computeBoundingBox = false;
  107600. this._depthSortParticles = true;
  107601. this._mustUnrotateFixedNormals = false;
  107602. this._particlesIntersect = false;
  107603. this._needs32Bits = false;
  107604. this.name = name;
  107605. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  107606. this._camera = scene.activeCamera;
  107607. this._pickable = options ? options.isPickable : false;
  107608. this._depthSort = options ? options.enableDepthSort : false;
  107609. this._particlesIntersect = options ? options.particleIntersection : false;
  107610. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  107611. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  107612. if (options && options.updatable !== undefined) {
  107613. this._updatable = options.updatable;
  107614. }
  107615. else {
  107616. this._updatable = true;
  107617. }
  107618. if (this._pickable) {
  107619. this.pickedParticles = [];
  107620. }
  107621. if (this._depthSort) {
  107622. this.depthSortedParticles = [];
  107623. }
  107624. }
  107625. /**
  107626. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107627. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107628. * @returns the created mesh
  107629. */
  107630. SolidParticleSystem.prototype.buildMesh = function () {
  107631. if (this.nbParticles === 0) {
  107632. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  107633. this.addShape(triangle, 1);
  107634. triangle.dispose();
  107635. }
  107636. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  107637. this._positions32 = new Float32Array(this._positions);
  107638. this._uvs32 = new Float32Array(this._uvs);
  107639. this._colors32 = new Float32Array(this._colors);
  107640. if (this.recomputeNormals) {
  107641. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  107642. }
  107643. this._normals32 = new Float32Array(this._normals);
  107644. this._fixedNormal32 = new Float32Array(this._normals);
  107645. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  107646. this._unrotateFixedNormals();
  107647. }
  107648. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  107649. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  107650. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107651. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107652. if (this._uvs32.length > 0) {
  107653. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107654. }
  107655. if (this._colors32.length > 0) {
  107656. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107657. }
  107658. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  107659. vertexData.applyToMesh(mesh, this._updatable);
  107660. this.mesh = mesh;
  107661. this.mesh.isPickable = this._pickable;
  107662. // free memory
  107663. if (!this._depthSort) {
  107664. this._indices = null;
  107665. }
  107666. this._positions = null;
  107667. this._normals = null;
  107668. this._uvs = null;
  107669. this._colors = null;
  107670. if (!this._updatable) {
  107671. this.particles.length = 0;
  107672. }
  107673. return mesh;
  107674. };
  107675. /**
  107676. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107677. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107678. * Thus the particles generated from `digest()` have their property `position` set yet.
  107679. * @param mesh ( Mesh ) is the mesh to be digested
  107680. * @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
  107681. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107682. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107683. * @returns the current SPS
  107684. */
  107685. SolidParticleSystem.prototype.digest = function (mesh, options) {
  107686. var size = (options && options.facetNb) || 1;
  107687. var number = (options && options.number) || 0;
  107688. var delta = (options && options.delta) || 0;
  107689. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107690. var meshInd = mesh.getIndices();
  107691. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107692. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107693. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107694. var f = 0; // facet counter
  107695. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  107696. // compute size from number
  107697. if (number) {
  107698. number = (number > totalFacets) ? totalFacets : number;
  107699. size = Math.round(totalFacets / number);
  107700. delta = 0;
  107701. }
  107702. else {
  107703. size = (size > totalFacets) ? totalFacets : size;
  107704. }
  107705. var facetPos = []; // submesh positions
  107706. var facetInd = []; // submesh indices
  107707. var facetUV = []; // submesh UV
  107708. var facetCol = []; // submesh colors
  107709. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107710. var sizeO = size;
  107711. while (f < totalFacets) {
  107712. size = sizeO + Math.floor((1 + delta) * Math.random());
  107713. if (f > totalFacets - size) {
  107714. size = totalFacets - f;
  107715. }
  107716. // reset temp arrays
  107717. facetPos.length = 0;
  107718. facetInd.length = 0;
  107719. facetUV.length = 0;
  107720. facetCol.length = 0;
  107721. // iterate over "size" facets
  107722. var fi = 0;
  107723. for (var j = f * 3; j < (f + size) * 3; j++) {
  107724. facetInd.push(fi);
  107725. var i = meshInd[j];
  107726. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  107727. if (meshUV) {
  107728. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  107729. }
  107730. if (meshCol) {
  107731. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  107732. }
  107733. fi++;
  107734. }
  107735. // create a model shape for each single particle
  107736. var idx = this.nbParticles;
  107737. var shape = this._posToShape(facetPos);
  107738. var shapeUV = this._uvsToShapeUV(facetUV);
  107739. // compute the barycenter of the shape
  107740. var v;
  107741. for (v = 0; v < shape.length; v++) {
  107742. barycenter.addInPlace(shape[v]);
  107743. }
  107744. barycenter.scaleInPlace(1 / shape.length);
  107745. // shift the shape from its barycenter to the origin
  107746. for (v = 0; v < shape.length; v++) {
  107747. shape[v].subtractInPlace(barycenter);
  107748. }
  107749. var bInfo;
  107750. if (this._particlesIntersect) {
  107751. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  107752. }
  107753. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  107754. // add the particle in the SPS
  107755. var currentPos = this._positions.length;
  107756. var currentInd = this._indices.length;
  107757. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  107758. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  107759. // initialize the particle position
  107760. this.particles[this.nbParticles].position.addInPlace(barycenter);
  107761. this._index += shape.length;
  107762. idx++;
  107763. this.nbParticles++;
  107764. this._shapeCounter++;
  107765. f += size;
  107766. }
  107767. return this;
  107768. };
  107769. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107770. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  107771. var index = 0;
  107772. var idx = 0;
  107773. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107774. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107775. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107776. for (var p = 0; p < this.particles.length; p++) {
  107777. var particle = this.particles[p];
  107778. var shape = particle._model._shape;
  107779. // computing the inverse of the rotation matrix from the quaternion
  107780. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  107781. if (particle.rotationQuaternion) {
  107782. particle.rotationQuaternion.conjugateToRef(quaternion);
  107783. }
  107784. else {
  107785. var rotation = particle.rotation;
  107786. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107787. quaternion.conjugateInPlace();
  107788. }
  107789. quaternion.toRotationMatrix(invertedRotMatrix);
  107790. for (var pt = 0; pt < shape.length; pt++) {
  107791. idx = index + pt * 3;
  107792. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  107793. tmpNormal.toArray(this._fixedNormal32, idx);
  107794. }
  107795. index = idx + 3;
  107796. }
  107797. };
  107798. //reset copy
  107799. SolidParticleSystem.prototype._resetCopy = function () {
  107800. var copy = this._copy;
  107801. copy.position.setAll(0);
  107802. copy.rotation.setAll(0);
  107803. copy.rotationQuaternion = null;
  107804. copy.scaling.setAll(1);
  107805. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  107806. copy.color = null;
  107807. copy.translateFromPivot = false;
  107808. };
  107809. // _meshBuilder : inserts the shape model in the global SPS mesh
  107810. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  107811. var i;
  107812. var u = 0;
  107813. var c = 0;
  107814. var n = 0;
  107815. this._resetCopy();
  107816. var copy = this._copy;
  107817. if (options && options.positionFunction) { // call to custom positionFunction
  107818. options.positionFunction(copy, idx, idxInShape);
  107819. this._mustUnrotateFixedNormals = true;
  107820. }
  107821. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107822. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107823. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107824. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107825. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107826. copy.getRotationMatrix(rotMatrix);
  107827. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  107828. if (copy.translateFromPivot) {
  107829. pivotBackTranslation.setAll(0.0);
  107830. }
  107831. else {
  107832. pivotBackTranslation.copyFrom(scaledPivot);
  107833. }
  107834. for (i = 0; i < shape.length; i++) {
  107835. tmpVertex.copyFrom(shape[i]);
  107836. if (options && options.vertexFunction) {
  107837. options.vertexFunction(copy, tmpVertex, i);
  107838. }
  107839. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107840. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  107841. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  107842. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  107843. if (meshUV) {
  107844. var copyUvs = copy.uvs;
  107845. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  107846. u += 2;
  107847. }
  107848. if (copy.color) {
  107849. this._color = copy.color;
  107850. }
  107851. else {
  107852. var color = this._color;
  107853. if (meshCol && meshCol[c] !== undefined) {
  107854. color.r = meshCol[c];
  107855. color.g = meshCol[c + 1];
  107856. color.b = meshCol[c + 2];
  107857. color.a = meshCol[c + 3];
  107858. }
  107859. else {
  107860. color.r = 1.0;
  107861. color.g = 1.0;
  107862. color.b = 1.0;
  107863. color.a = 1.0;
  107864. }
  107865. }
  107866. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  107867. c += 4;
  107868. if (!this.recomputeNormals && meshNor) {
  107869. tmpVertex.x = meshNor[n];
  107870. tmpVertex.y = meshNor[n + 1];
  107871. tmpVertex.z = meshNor[n + 2];
  107872. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  107873. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  107874. n += 3;
  107875. }
  107876. }
  107877. for (i = 0; i < meshInd.length; i++) {
  107878. var current_ind = p + meshInd[i];
  107879. indices.push(current_ind);
  107880. if (current_ind > 65535) {
  107881. this._needs32Bits = true;
  107882. }
  107883. }
  107884. if (this._pickable) {
  107885. var nbfaces = meshInd.length / 3;
  107886. for (i = 0; i < nbfaces; i++) {
  107887. this.pickedParticles.push({ idx: idx, faceId: i });
  107888. }
  107889. }
  107890. if (this._depthSort) {
  107891. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  107892. }
  107893. return copy;
  107894. };
  107895. // returns a shape array from positions array
  107896. SolidParticleSystem.prototype._posToShape = function (positions) {
  107897. var shape = [];
  107898. for (var i = 0; i < positions.length; i += 3) {
  107899. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  107900. }
  107901. return shape;
  107902. };
  107903. // returns a shapeUV array from a Vector4 uvs
  107904. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  107905. var shapeUV = [];
  107906. if (uvs) {
  107907. for (var i = 0; i < uvs.length; i++) {
  107908. shapeUV.push(uvs[i]);
  107909. }
  107910. }
  107911. return shapeUV;
  107912. };
  107913. // adds a new particle object in the particles array
  107914. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  107915. if (bInfo === void 0) { bInfo = null; }
  107916. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  107917. this.particles.push(sp);
  107918. return sp;
  107919. };
  107920. /**
  107921. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107922. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  107923. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107924. * @param nb (positive integer) the number of particles to be created from this model
  107925. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107926. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107927. * @returns the number of shapes in the system
  107928. */
  107929. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  107930. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107931. var meshInd = mesh.getIndices();
  107932. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107933. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107934. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107935. var bbInfo;
  107936. if (this._particlesIntersect) {
  107937. bbInfo = mesh.getBoundingInfo();
  107938. }
  107939. var shape = this._posToShape(meshPos);
  107940. var shapeUV = this._uvsToShapeUV(meshUV);
  107941. var posfunc = options ? options.positionFunction : null;
  107942. var vtxfunc = options ? options.vertexFunction : null;
  107943. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  107944. // particles
  107945. var sp;
  107946. var currentCopy;
  107947. var idx = this.nbParticles;
  107948. for (var i = 0; i < nb; i++) {
  107949. var currentPos = this._positions.length;
  107950. var currentInd = this._indices.length;
  107951. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  107952. if (this._updatable) {
  107953. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  107954. sp.position.copyFrom(currentCopy.position);
  107955. sp.rotation.copyFrom(currentCopy.rotation);
  107956. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  107957. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  107958. }
  107959. if (currentCopy.color && sp.color) {
  107960. sp.color.copyFrom(currentCopy.color);
  107961. }
  107962. sp.scaling.copyFrom(currentCopy.scaling);
  107963. sp.uvs.copyFrom(currentCopy.uvs);
  107964. }
  107965. this._index += shape.length;
  107966. idx++;
  107967. }
  107968. this.nbParticles += nb;
  107969. this._shapeCounter++;
  107970. return this._shapeCounter - 1;
  107971. };
  107972. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107973. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  107974. this._resetCopy();
  107975. var copy = this._copy;
  107976. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  107977. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  107978. }
  107979. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107980. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107981. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107982. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107983. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107984. copy.getRotationMatrix(rotMatrix);
  107985. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  107986. if (copy.translateFromPivot) {
  107987. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  107988. }
  107989. else {
  107990. pivotBackTranslation.copyFrom(scaledPivot);
  107991. }
  107992. var shape = particle._model._shape;
  107993. for (var pt = 0; pt < shape.length; pt++) {
  107994. tmpVertex.copyFrom(shape[pt]);
  107995. if (particle._model._vertexFunction) {
  107996. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  107997. }
  107998. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107999. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108000. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  108001. }
  108002. particle.position.setAll(0.0);
  108003. particle.rotation.setAll(0.0);
  108004. particle.rotationQuaternion = null;
  108005. particle.scaling.setAll(1.0);
  108006. particle.uvs.setAll(0.0);
  108007. particle.pivot.setAll(0.0);
  108008. particle.translateFromPivot = false;
  108009. particle.parentId = null;
  108010. };
  108011. /**
  108012. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108013. * @returns the SPS.
  108014. */
  108015. SolidParticleSystem.prototype.rebuildMesh = function () {
  108016. for (var p = 0; p < this.particles.length; p++) {
  108017. this._rebuildParticle(this.particles[p]);
  108018. }
  108019. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  108020. return this;
  108021. };
  108022. /**
  108023. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108024. * This method calls `updateParticle()` for each particle of the SPS.
  108025. * For an animated SPS, it is usually called within the render loop.
  108026. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108027. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108028. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108029. * @returns the SPS.
  108030. */
  108031. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  108032. if (start === void 0) { start = 0; }
  108033. if (end === void 0) { end = this.nbParticles - 1; }
  108034. if (update === void 0) { update = true; }
  108035. if (!this._updatable) {
  108036. return this;
  108037. }
  108038. // custom beforeUpdate
  108039. this.beforeUpdateParticles(start, end, update);
  108040. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108041. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  108042. var mesh = this.mesh;
  108043. var colors32 = this._colors32;
  108044. var positions32 = this._positions32;
  108045. var normals32 = this._normals32;
  108046. var uvs32 = this._uvs32;
  108047. var indices32 = this._indices32;
  108048. var indices = this._indices;
  108049. var fixedNormal32 = this._fixedNormal32;
  108050. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  108051. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  108052. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  108053. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  108054. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  108055. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  108056. var camInvertedPosition = tempVectors[10].setAll(0);
  108057. // cases when the World Matrix is to be computed first
  108058. if (this.billboard || this._depthSort) {
  108059. this.mesh.computeWorldMatrix(true);
  108060. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  108061. }
  108062. // if the particles will always face the camera
  108063. if (this.billboard) {
  108064. // compute the camera position and un-rotate it by the current mesh rotation
  108065. var tmpVertex = tempVectors[0];
  108066. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  108067. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  108068. camAxisZ.normalize();
  108069. // same for camera up vector extracted from the cam view matrix
  108070. var view = this._camera.getViewMatrix(true);
  108071. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  108072. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  108073. camAxisY.normalize();
  108074. camAxisX.normalize();
  108075. }
  108076. // if depthSort, compute the camera global position in the mesh local system
  108077. if (this._depthSort) {
  108078. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  108079. }
  108080. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  108081. var idx = 0; // current position index in the global array positions32
  108082. var index = 0; // position start index in the global array positions32 of the current particle
  108083. var colidx = 0; // current color index in the global array colors32
  108084. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  108085. var uvidx = 0; // current uv index in the global array uvs32
  108086. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  108087. var pt = 0; // current index in the particle model shape
  108088. if (this.mesh.isFacetDataEnabled) {
  108089. this._computeBoundingBox = true;
  108090. }
  108091. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  108092. if (this._computeBoundingBox) {
  108093. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  108094. var boundingInfo = this.mesh._boundingInfo;
  108095. if (boundingInfo) {
  108096. minimum.copyFrom(boundingInfo.minimum);
  108097. maximum.copyFrom(boundingInfo.maximum);
  108098. }
  108099. }
  108100. }
  108101. // particle loop
  108102. index = this.particles[start]._pos;
  108103. var vpos = (index / 3) | 0;
  108104. colorIndex = vpos * 4;
  108105. uvIndex = vpos * 2;
  108106. for (var p = start; p <= end; p++) {
  108107. var particle = this.particles[p];
  108108. // call to custom user function to update the particle properties
  108109. this.updateParticle(particle);
  108110. var shape = particle._model._shape;
  108111. var shapeUV = particle._model._shapeUV;
  108112. var particleRotationMatrix = particle._rotationMatrix;
  108113. var particlePosition = particle.position;
  108114. var particleRotation = particle.rotation;
  108115. var particleScaling = particle.scaling;
  108116. var particleGlobalPosition = particle._globalPosition;
  108117. // camera-particle distance for depth sorting
  108118. if (this._depthSort && this._depthSortParticles) {
  108119. var dsp = this.depthSortedParticles[p];
  108120. dsp.ind = particle._ind;
  108121. dsp.indicesLength = particle._model._indicesLength;
  108122. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  108123. }
  108124. // skip the computations for inactive or already invisible particles
  108125. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  108126. // increment indexes for the next particle
  108127. pt = shape.length;
  108128. index += pt * 3;
  108129. colorIndex += pt * 4;
  108130. uvIndex += pt * 2;
  108131. continue;
  108132. }
  108133. if (particle.isVisible) {
  108134. particle._stillInvisible = false; // un-mark permanent invisibility
  108135. var scaledPivot = tempVectors[12];
  108136. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  108137. // particle rotation matrix
  108138. if (this.billboard) {
  108139. particleRotation.x = 0.0;
  108140. particleRotation.y = 0.0;
  108141. }
  108142. if (this._computeParticleRotation || this.billboard) {
  108143. particle.getRotationMatrix(rotMatrix);
  108144. }
  108145. var particleHasParent = (particle.parentId !== null);
  108146. if (particleHasParent) {
  108147. var parent_1 = this.particles[particle.parentId];
  108148. var parentRotationMatrix = parent_1._rotationMatrix;
  108149. var parentGlobalPosition = parent_1._globalPosition;
  108150. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  108151. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  108152. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  108153. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  108154. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  108155. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  108156. if (this._computeParticleRotation || this.billboard) {
  108157. var rotMatrixValues = rotMatrix.m;
  108158. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  108159. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  108160. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  108161. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  108162. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  108163. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  108164. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  108165. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  108166. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  108167. }
  108168. }
  108169. else {
  108170. particleGlobalPosition.x = particlePosition.x;
  108171. particleGlobalPosition.y = particlePosition.y;
  108172. particleGlobalPosition.z = particlePosition.z;
  108173. if (this._computeParticleRotation || this.billboard) {
  108174. var rotMatrixValues = rotMatrix.m;
  108175. particleRotationMatrix[0] = rotMatrixValues[0];
  108176. particleRotationMatrix[1] = rotMatrixValues[1];
  108177. particleRotationMatrix[2] = rotMatrixValues[2];
  108178. particleRotationMatrix[3] = rotMatrixValues[4];
  108179. particleRotationMatrix[4] = rotMatrixValues[5];
  108180. particleRotationMatrix[5] = rotMatrixValues[6];
  108181. particleRotationMatrix[6] = rotMatrixValues[8];
  108182. particleRotationMatrix[7] = rotMatrixValues[9];
  108183. particleRotationMatrix[8] = rotMatrixValues[10];
  108184. }
  108185. }
  108186. var pivotBackTranslation = tempVectors[11];
  108187. if (particle.translateFromPivot) {
  108188. pivotBackTranslation.setAll(0.0);
  108189. }
  108190. else {
  108191. pivotBackTranslation.copyFrom(scaledPivot);
  108192. }
  108193. // particle vertex loop
  108194. for (pt = 0; pt < shape.length; pt++) {
  108195. idx = index + pt * 3;
  108196. colidx = colorIndex + pt * 4;
  108197. uvidx = uvIndex + pt * 2;
  108198. var tmpVertex = tempVectors[0];
  108199. tmpVertex.copyFrom(shape[pt]);
  108200. if (this._computeParticleVertex) {
  108201. this.updateParticleVertex(particle, tmpVertex, pt);
  108202. }
  108203. // positions
  108204. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  108205. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  108206. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  108207. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  108208. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  108209. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  108210. rotatedX += pivotBackTranslation.x;
  108211. rotatedY += pivotBackTranslation.y;
  108212. rotatedZ += pivotBackTranslation.z;
  108213. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108214. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108215. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108216. if (this._computeBoundingBox) {
  108217. minimum.minimizeInPlaceFromFloats(px, py, pz);
  108218. maximum.maximizeInPlaceFromFloats(px, py, pz);
  108219. }
  108220. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  108221. if (!this._computeParticleVertex) {
  108222. var normalx = fixedNormal32[idx];
  108223. var normaly = fixedNormal32[idx + 1];
  108224. var normalz = fixedNormal32[idx + 2];
  108225. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  108226. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  108227. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  108228. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  108229. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  108230. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  108231. }
  108232. if (this._computeParticleColor && particle.color) {
  108233. var color = particle.color;
  108234. var colors32_1 = this._colors32;
  108235. colors32_1[colidx] = color.r;
  108236. colors32_1[colidx + 1] = color.g;
  108237. colors32_1[colidx + 2] = color.b;
  108238. colors32_1[colidx + 3] = color.a;
  108239. }
  108240. if (this._computeParticleTexture) {
  108241. var uvs = particle.uvs;
  108242. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108243. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108244. }
  108245. }
  108246. }
  108247. // particle just set invisible : scaled to zero and positioned at the origin
  108248. else {
  108249. particle._stillInvisible = true; // mark the particle as invisible
  108250. for (pt = 0; pt < shape.length; pt++) {
  108251. idx = index + pt * 3;
  108252. colidx = colorIndex + pt * 4;
  108253. uvidx = uvIndex + pt * 2;
  108254. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  108255. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  108256. if (this._computeParticleColor && particle.color) {
  108257. var color = particle.color;
  108258. colors32[colidx] = color.r;
  108259. colors32[colidx + 1] = color.g;
  108260. colors32[colidx + 2] = color.b;
  108261. colors32[colidx + 3] = color.a;
  108262. }
  108263. if (this._computeParticleTexture) {
  108264. var uvs = particle.uvs;
  108265. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108266. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108267. }
  108268. }
  108269. }
  108270. // if the particle intersections must be computed : update the bbInfo
  108271. if (this._particlesIntersect) {
  108272. var bInfo = particle._boundingInfo;
  108273. var bBox = bInfo.boundingBox;
  108274. var bSphere = bInfo.boundingSphere;
  108275. var modelBoundingInfo = particle._modelBoundingInfo;
  108276. if (!this._bSphereOnly) {
  108277. // place, scale and rotate the particle bbox within the SPS local system, then update it
  108278. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  108279. var tempMin = tempVectors[1];
  108280. var tempMax = tempVectors[2];
  108281. tempMin.setAll(Number.MAX_VALUE);
  108282. tempMax.setAll(-Number.MAX_VALUE);
  108283. for (var b = 0; b < 8; b++) {
  108284. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  108285. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  108286. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  108287. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  108288. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  108289. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  108290. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108291. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108292. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108293. tempMin.minimizeInPlaceFromFloats(x, y, z);
  108294. tempMax.maximizeInPlaceFromFloats(x, y, z);
  108295. }
  108296. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  108297. }
  108298. // place and scale the particle bouding sphere in the SPS local system, then update it
  108299. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  108300. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  108301. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  108302. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  108303. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  108304. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  108305. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  108306. }
  108307. // increment indexes for the next particle
  108308. index = idx + 3;
  108309. colorIndex = colidx + 4;
  108310. uvIndex = uvidx + 2;
  108311. }
  108312. // if the VBO must be updated
  108313. if (update) {
  108314. if (this._computeParticleColor) {
  108315. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  108316. }
  108317. if (this._computeParticleTexture) {
  108318. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  108319. }
  108320. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  108321. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  108322. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  108323. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  108324. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  108325. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  108326. for (var i = 0; i < normals32.length; i++) {
  108327. fixedNormal32[i] = normals32[i];
  108328. }
  108329. }
  108330. if (!mesh.areNormalsFrozen) {
  108331. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  108332. }
  108333. }
  108334. if (this._depthSort && this._depthSortParticles) {
  108335. var depthSortedParticles = this.depthSortedParticles;
  108336. depthSortedParticles.sort(depthSortFunction);
  108337. var dspl = depthSortedParticles.length;
  108338. var sid = 0;
  108339. for (var sorted = 0; sorted < dspl; sorted++) {
  108340. var lind = depthSortedParticles[sorted].indicesLength;
  108341. var sind = depthSortedParticles[sorted].ind;
  108342. for (var i = 0; i < lind; i++) {
  108343. indices32[sid] = indices[sind + i];
  108344. sid++;
  108345. }
  108346. }
  108347. mesh.updateIndices(indices32);
  108348. }
  108349. }
  108350. if (this._computeBoundingBox) {
  108351. if (mesh._boundingInfo) {
  108352. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  108353. }
  108354. else {
  108355. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  108356. }
  108357. }
  108358. this.afterUpdateParticles(start, end, update);
  108359. return this;
  108360. };
  108361. /**
  108362. * Disposes the SPS.
  108363. */
  108364. SolidParticleSystem.prototype.dispose = function () {
  108365. this.mesh.dispose();
  108366. this.vars = null;
  108367. // drop references to internal big arrays for the GC
  108368. this._positions = null;
  108369. this._indices = null;
  108370. this._normals = null;
  108371. this._uvs = null;
  108372. this._colors = null;
  108373. this._indices32 = null;
  108374. this._positions32 = null;
  108375. this._normals32 = null;
  108376. this._fixedNormal32 = null;
  108377. this._uvs32 = null;
  108378. this._colors32 = null;
  108379. this.pickedParticles = null;
  108380. };
  108381. /**
  108382. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108383. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108384. * @returns the SPS.
  108385. */
  108386. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  108387. if (!this._isVisibilityBoxLocked) {
  108388. this.mesh.refreshBoundingInfo();
  108389. }
  108390. return this;
  108391. };
  108392. /**
  108393. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108394. * @param size the size (float) of the visibility box
  108395. * note : this doesn't lock the SPS mesh bounding box.
  108396. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108397. */
  108398. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  108399. var vis = size / 2;
  108400. 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));
  108401. };
  108402. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  108403. /**
  108404. * Gets whether the SPS as always visible or not
  108405. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108406. */
  108407. get: function () {
  108408. return this._alwaysVisible;
  108409. },
  108410. /**
  108411. * Sets the SPS as always visible or not
  108412. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108413. */
  108414. set: function (val) {
  108415. this._alwaysVisible = val;
  108416. this.mesh.alwaysSelectAsActiveMesh = val;
  108417. },
  108418. enumerable: true,
  108419. configurable: true
  108420. });
  108421. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  108422. /**
  108423. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108424. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108425. */
  108426. get: function () {
  108427. return this._isVisibilityBoxLocked;
  108428. },
  108429. /**
  108430. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108431. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108432. */
  108433. set: function (val) {
  108434. this._isVisibilityBoxLocked = val;
  108435. var boundingInfo = this.mesh.getBoundingInfo();
  108436. boundingInfo.isLocked = val;
  108437. },
  108438. enumerable: true,
  108439. configurable: true
  108440. });
  108441. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  108442. /**
  108443. * Gets if `setParticles()` computes the particle rotations or not.
  108444. * Default value : true. The SPS is faster when it's set to false.
  108445. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108446. */
  108447. get: function () {
  108448. return this._computeParticleRotation;
  108449. },
  108450. /**
  108451. * Tells to `setParticles()` to compute the particle rotations or not.
  108452. * Default value : true. The SPS is faster when it's set to false.
  108453. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108454. */
  108455. set: function (val) {
  108456. this._computeParticleRotation = val;
  108457. },
  108458. enumerable: true,
  108459. configurable: true
  108460. });
  108461. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  108462. /**
  108463. * Gets if `setParticles()` computes the particle colors or not.
  108464. * Default value : true. The SPS is faster when it's set to false.
  108465. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108466. */
  108467. get: function () {
  108468. return this._computeParticleColor;
  108469. },
  108470. /**
  108471. * Tells to `setParticles()` to compute the particle colors or not.
  108472. * Default value : true. The SPS is faster when it's set to false.
  108473. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108474. */
  108475. set: function (val) {
  108476. this._computeParticleColor = val;
  108477. },
  108478. enumerable: true,
  108479. configurable: true
  108480. });
  108481. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  108482. /**
  108483. * Gets if `setParticles()` computes the particle textures or not.
  108484. * Default value : true. The SPS is faster when it's set to false.
  108485. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108486. */
  108487. get: function () {
  108488. return this._computeParticleTexture;
  108489. },
  108490. set: function (val) {
  108491. this._computeParticleTexture = val;
  108492. },
  108493. enumerable: true,
  108494. configurable: true
  108495. });
  108496. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  108497. /**
  108498. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108499. * Default value : false. The SPS is faster when it's set to false.
  108500. * Note : the particle custom vertex positions aren't stored values.
  108501. */
  108502. get: function () {
  108503. return this._computeParticleVertex;
  108504. },
  108505. /**
  108506. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108507. * Default value : false. The SPS is faster when it's set to false.
  108508. * Note : the particle custom vertex positions aren't stored values.
  108509. */
  108510. set: function (val) {
  108511. this._computeParticleVertex = val;
  108512. },
  108513. enumerable: true,
  108514. configurable: true
  108515. });
  108516. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  108517. /**
  108518. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108519. */
  108520. get: function () {
  108521. return this._computeBoundingBox;
  108522. },
  108523. /**
  108524. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108525. */
  108526. set: function (val) {
  108527. this._computeBoundingBox = val;
  108528. },
  108529. enumerable: true,
  108530. configurable: true
  108531. });
  108532. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  108533. /**
  108534. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108535. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108536. * Default : `true`
  108537. */
  108538. get: function () {
  108539. return this._depthSortParticles;
  108540. },
  108541. /**
  108542. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108543. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108544. * Default : `true`
  108545. */
  108546. set: function (val) {
  108547. this._depthSortParticles = val;
  108548. },
  108549. enumerable: true,
  108550. configurable: true
  108551. });
  108552. // =======================================================================
  108553. // Particle behavior logic
  108554. // these following methods may be overwritten by the user to fit his needs
  108555. /**
  108556. * This function does nothing. It may be overwritten to set all the particle first values.
  108557. * The SPS doesn't call this function, you may have to call it by your own.
  108558. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108559. */
  108560. SolidParticleSystem.prototype.initParticles = function () {
  108561. };
  108562. /**
  108563. * This function does nothing. It may be overwritten to recycle a particle.
  108564. * The SPS doesn't call this function, you may have to call it by your own.
  108565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108566. * @param particle The particle to recycle
  108567. * @returns the recycled particle
  108568. */
  108569. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  108570. return particle;
  108571. };
  108572. /**
  108573. * Updates a particle : this function should be overwritten by the user.
  108574. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108575. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108576. * @example : just set a particle position or velocity and recycle conditions
  108577. * @param particle The particle to update
  108578. * @returns the updated particle
  108579. */
  108580. SolidParticleSystem.prototype.updateParticle = function (particle) {
  108581. return particle;
  108582. };
  108583. /**
  108584. * Updates a vertex of a particle : it can be overwritten by the user.
  108585. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108586. * @param particle the current particle
  108587. * @param vertex the current index of the current particle
  108588. * @param pt the index of the current vertex in the particle shape
  108589. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  108590. * @example : just set a vertex particle position
  108591. * @returns the updated vertex
  108592. */
  108593. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  108594. return vertex;
  108595. };
  108596. /**
  108597. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108598. * This does nothing and may be overwritten by the user.
  108599. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108600. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108601. * @param update the boolean update value actually passed to setParticles()
  108602. */
  108603. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  108604. };
  108605. /**
  108606. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108607. * This will be passed three parameters.
  108608. * This does nothing and may be overwritten by the user.
  108609. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108610. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108611. * @param update the boolean update value actually passed to setParticles()
  108612. */
  108613. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  108614. };
  108615. return SolidParticleSystem;
  108616. }());
  108617. /***/ }),
  108618. /***/ "./Particles/subEmitter.ts":
  108619. /*!*********************************!*\
  108620. !*** ./Particles/subEmitter.ts ***!
  108621. \*********************************/
  108622. /*! exports provided: SubEmitterType, SubEmitter */
  108623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108624. "use strict";
  108625. __webpack_require__.r(__webpack_exports__);
  108626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  108627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  108628. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108629. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108630. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108631. /**
  108632. * Type of sub emitter
  108633. */
  108634. var SubEmitterType;
  108635. (function (SubEmitterType) {
  108636. /**
  108637. * Attached to the particle over it's lifetime
  108638. */
  108639. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  108640. /**
  108641. * Created when the particle dies
  108642. */
  108643. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  108644. })(SubEmitterType || (SubEmitterType = {}));
  108645. /**
  108646. * Sub emitter class used to emit particles from an existing particle
  108647. */
  108648. var SubEmitter = /** @class */ (function () {
  108649. /**
  108650. * Creates a sub emitter
  108651. * @param particleSystem the particle system to be used by the sub emitter
  108652. */
  108653. function SubEmitter(
  108654. /**
  108655. * the particle system to be used by the sub emitter
  108656. */
  108657. particleSystem) {
  108658. this.particleSystem = particleSystem;
  108659. /**
  108660. * Type of the submitter (Default: END)
  108661. */
  108662. this.type = SubEmitterType.END;
  108663. /**
  108664. * 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)
  108665. * Note: This only is supported when using an emitter of type Mesh
  108666. */
  108667. this.inheritDirection = false;
  108668. /**
  108669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  108670. */
  108671. this.inheritedVelocityAmount = 0;
  108672. // Create mesh as emitter to support rotation
  108673. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  108674. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  108675. }
  108676. // Automatically dispose of subemitter when system is disposed
  108677. particleSystem.onDisposeObservable.add(function () {
  108678. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  108679. particleSystem.emitter.dispose();
  108680. }
  108681. });
  108682. }
  108683. /**
  108684. * Clones the sub emitter
  108685. * @returns the cloned sub emitter
  108686. */
  108687. SubEmitter.prototype.clone = function () {
  108688. // Clone particle system
  108689. var emitter = this.particleSystem.emitter;
  108690. if (!emitter) {
  108691. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108692. }
  108693. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  108694. emitter = emitter.clone();
  108695. }
  108696. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  108697. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  108698. emitter.isVisible = false;
  108699. }
  108700. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  108701. // Clone properties
  108702. clone.type = this.type;
  108703. clone.inheritDirection = this.inheritDirection;
  108704. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  108705. clone.particleSystem._disposeEmitterOnDispose = true;
  108706. clone.particleSystem.disposeOnStop = true;
  108707. return clone;
  108708. };
  108709. /**
  108710. * Serialize current object to a JSON object
  108711. * @returns the serialized object
  108712. */
  108713. SubEmitter.prototype.serialize = function () {
  108714. var serializationObject = {};
  108715. serializationObject.type = this.type;
  108716. serializationObject.inheritDirection = this.inheritDirection;
  108717. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  108718. serializationObject.particleSystem = this.particleSystem.serialize();
  108719. return serializationObject;
  108720. };
  108721. /** @hidden */
  108722. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  108723. throw "Import ParseParticle before parsing SubEmitter.";
  108724. };
  108725. /**
  108726. * Creates a new SubEmitter from a serialized JSON version
  108727. * @param serializationObject defines the JSON object to read from
  108728. * @param scene defines the hosting scene
  108729. * @param rootUrl defines the rootUrl for data loading
  108730. * @returns a new SubEmitter
  108731. */
  108732. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  108733. var system = serializationObject.particleSystem;
  108734. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  108735. subEmitter.type = serializationObject.type;
  108736. subEmitter.inheritDirection = serializationObject.inheritDirection;
  108737. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  108738. subEmitter.particleSystem._isSubEmitter = true;
  108739. return subEmitter;
  108740. };
  108741. /** Release associated resources */
  108742. SubEmitter.prototype.dispose = function () {
  108743. this.particleSystem.dispose();
  108744. };
  108745. return SubEmitter;
  108746. }());
  108747. /***/ }),
  108748. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  108749. /*!*****************************************!*\
  108750. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  108751. \*****************************************/
  108752. /*! exports provided: AmmoJSPlugin */
  108753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108754. "use strict";
  108755. __webpack_require__.r(__webpack_exports__);
  108756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  108757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108758. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  108759. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  108760. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  108761. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  108762. /**
  108763. * AmmoJS Physics plugin
  108764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108765. * @see https://github.com/kripken/ammo.js/
  108766. */
  108767. var AmmoJSPlugin = /** @class */ (function () {
  108768. /**
  108769. * Initializes the ammoJS plugin
  108770. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108771. * @param ammoInjection can be used to inject your own ammo reference
  108772. */
  108773. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  108774. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108775. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  108776. var _this = this;
  108777. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108778. /**
  108779. * Reference to the Ammo library
  108780. */
  108781. this.bjsAMMO = {};
  108782. /**
  108783. * Name of the plugin
  108784. */
  108785. this.name = "AmmoJSPlugin";
  108786. this._timeStep = 1 / 60;
  108787. this._fixedTimeStep = 1 / 60;
  108788. this._maxSteps = 5;
  108789. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  108790. this._tmpContactCallbackResult = false;
  108791. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108792. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  108793. if (typeof ammoInjection === "function") {
  108794. ammoInjection(this.bjsAMMO);
  108795. }
  108796. else {
  108797. this.bjsAMMO = ammoInjection;
  108798. }
  108799. if (!this.isSupported()) {
  108800. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  108801. return;
  108802. }
  108803. // Initialize the physics world
  108804. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  108805. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  108806. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  108807. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  108808. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  108809. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  108810. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  108811. // Create temp ammo variables
  108812. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  108813. this._tmpAmmoTransform.setIdentity();
  108814. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  108815. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  108816. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  108817. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  108818. }
  108819. /**
  108820. * Sets the gravity of the physics world (m/(s^2))
  108821. * @param gravity Gravity to set
  108822. */
  108823. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  108824. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  108825. this.world.setGravity(this._tmpAmmoVectorA);
  108826. };
  108827. /**
  108828. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108829. * @param timeStep timestep to use in seconds
  108830. */
  108831. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  108832. this._timeStep = timeStep;
  108833. };
  108834. /**
  108835. * 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)
  108836. * @param fixedTimeStep fixedTimeStep to use in seconds
  108837. */
  108838. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  108839. this._fixedTimeStep = fixedTimeStep;
  108840. };
  108841. /**
  108842. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108843. * @param maxSteps the maximum number of steps by the physics engine per frame
  108844. */
  108845. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  108846. this._maxSteps = maxSteps;
  108847. };
  108848. /**
  108849. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108850. * @returns the current timestep in seconds
  108851. */
  108852. AmmoJSPlugin.prototype.getTimeStep = function () {
  108853. return this._timeStep;
  108854. };
  108855. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  108856. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  108857. this._tmpContactCallbackResult = false;
  108858. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  108859. return this._tmpContactCallbackResult;
  108860. };
  108861. // Ammo's collision events have some weird quirks
  108862. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  108863. // so only fire event if both contactTest and contactPairTest have a hit
  108864. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  108865. this._tmpContactCallbackResult = false;
  108866. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  108867. return this._tmpContactCallbackResult;
  108868. };
  108869. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  108870. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  108871. //
  108872. // When maxSteps is 0 do the entire simulation in one step
  108873. // 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)
  108874. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  108875. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  108876. if (timeStep === void 0) { timeStep = 1 / 60; }
  108877. if (maxSteps === void 0) { maxSteps = 10; }
  108878. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  108879. if (maxSteps == 0) {
  108880. this.world.stepSimulation(timeStep, 0);
  108881. }
  108882. else {
  108883. while (maxSteps > 0 && timeStep > 0) {
  108884. if (timeStep - fixedTimeStep < fixedTimeStep) {
  108885. this.world.stepSimulation(timeStep, 0);
  108886. timeStep = 0;
  108887. }
  108888. else {
  108889. timeStep -= fixedTimeStep;
  108890. this.world.stepSimulation(fixedTimeStep, 0);
  108891. }
  108892. maxSteps--;
  108893. }
  108894. }
  108895. };
  108896. /**
  108897. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108898. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108899. * After the step the babylon meshes are set to the position of the physics imposters
  108900. * @param delta amount of time to step forward
  108901. * @param impostors array of imposters to update before/after the step
  108902. */
  108903. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  108904. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  108905. var impostor = impostors_1[_i];
  108906. // Update physics world objects to match babylon world
  108907. impostor.beforeStep();
  108908. }
  108909. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  108910. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  108911. var mainImpostor = impostors_2[_a];
  108912. // After physics update make babylon world objects match physics world objects
  108913. mainImpostor.afterStep();
  108914. // Handle collision event
  108915. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  108916. if (this._isImpostorInContact(mainImpostor)) {
  108917. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  108918. var collideCallback = _c[_b];
  108919. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  108920. var otherImpostor = _e[_d];
  108921. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  108922. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  108923. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  108924. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  108925. }
  108926. }
  108927. }
  108928. }
  108929. }
  108930. }
  108931. }
  108932. };
  108933. /**
  108934. * Applies an implulse on the imposter
  108935. * @param impostor imposter to apply impulse
  108936. * @param force amount of force to be applied to the imposter
  108937. * @param contactPoint the location to apply the impulse on the imposter
  108938. */
  108939. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108940. impostor.physicsBody.activate();
  108941. var worldPoint = this._tmpAmmoVectorA;
  108942. var impulse = this._tmpAmmoVectorB;
  108943. // Convert contactPoint into world space
  108944. if (impostor.object && impostor.object.getWorldMatrix) {
  108945. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  108946. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  108947. contactPoint = this._tmpVector;
  108948. }
  108949. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108950. impulse.setValue(force.x, force.y, force.z);
  108951. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108952. };
  108953. /**
  108954. * Applies a force on the imposter
  108955. * @param impostor imposter to apply force
  108956. * @param force amount of force to be applied to the imposter
  108957. * @param contactPoint the location to apply the force on the imposter
  108958. */
  108959. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108960. impostor.physicsBody.activate();
  108961. var worldPoint = this._tmpAmmoVectorA;
  108962. var impulse = this._tmpAmmoVectorB;
  108963. // Convert contactPoint into world space
  108964. if (impostor.object && impostor.object.getWorldMatrix) {
  108965. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  108966. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  108967. contactPoint = this._tmpVector;
  108968. }
  108969. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108970. impulse.setValue(force.x, force.y, force.z);
  108971. impostor.physicsBody.applyForce(impulse, worldPoint);
  108972. };
  108973. /**
  108974. * Creates a physics body using the plugin
  108975. * @param impostor the imposter to create the physics body on
  108976. */
  108977. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108978. impostor._pluginData = { toDispose: [] };
  108979. //parent-child relationship
  108980. if (impostor.parent) {
  108981. if (impostor.physicsBody) {
  108982. this.removePhysicsBody(impostor);
  108983. impostor.forceUpdate();
  108984. }
  108985. return;
  108986. }
  108987. if (impostor.isBodyInitRequired()) {
  108988. var colShape = this._createShape(impostor);
  108989. var mass = impostor.getParam("mass");
  108990. impostor._pluginData.mass = mass;
  108991. var localInertia = new Ammo.btVector3(0, 0, 0);
  108992. var startTransform = new Ammo.btTransform();
  108993. startTransform.setIdentity();
  108994. if (mass !== 0) {
  108995. colShape.calculateLocalInertia(mass, localInertia);
  108996. }
  108997. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  108998. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  108999. startTransform.setOrigin(this._tmpAmmoVectorA);
  109000. startTransform.setRotation(this._tmpAmmoQuaternion);
  109001. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  109002. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  109003. var body = new Ammo.btRigidBody(rbInfo);
  109004. // Make objects kinematic if it's mass is 0
  109005. if (mass === 0) {
  109006. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  109007. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  109008. }
  109009. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  109010. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  109011. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  109012. }
  109013. this.world.addRigidBody(body);
  109014. impostor.physicsBody = body;
  109015. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  109016. this.setBodyFriction(impostor, impostor.getParam("friction"));
  109017. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  109018. }
  109019. };
  109020. /**
  109021. * Removes the physics body from the imposter and disposes of the body's memory
  109022. * @param impostor imposter to remove the physics body from
  109023. */
  109024. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109025. var _this = this;
  109026. if (this.world) {
  109027. this.world.removeRigidBody(impostor.physicsBody);
  109028. impostor._pluginData.toDispose.forEach(function (d) {
  109029. _this.bjsAMMO.destroy(d);
  109030. });
  109031. }
  109032. };
  109033. /**
  109034. * Generates a joint
  109035. * @param impostorJoint the imposter joint to create the joint with
  109036. */
  109037. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109038. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109039. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109040. if (!mainBody || !connectedBody) {
  109041. return;
  109042. }
  109043. var jointData = impostorJoint.joint.jointData;
  109044. if (!jointData.mainPivot) {
  109045. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109046. }
  109047. if (!jointData.connectedPivot) {
  109048. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109049. }
  109050. var joint;
  109051. switch (impostorJoint.joint.type) {
  109052. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  109053. var distance = jointData.maxDistance;
  109054. if (distance) {
  109055. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  109056. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  109057. }
  109058. 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));
  109059. break;
  109060. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  109061. if (!jointData.mainAxis) {
  109062. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109063. }
  109064. if (!jointData.connectedAxis) {
  109065. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109066. }
  109067. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  109068. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  109069. 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);
  109070. break;
  109071. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  109072. 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));
  109073. break;
  109074. default:
  109075. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  109076. 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));
  109077. break;
  109078. }
  109079. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  109080. impostorJoint.joint.physicsJoint = joint;
  109081. };
  109082. /**
  109083. * Removes a joint
  109084. * @param impostorJoint the imposter joint to remove the joint from
  109085. */
  109086. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109087. if (this.world) {
  109088. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109089. }
  109090. };
  109091. // adds all verticies (including child verticies) to the triangle mesh
  109092. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  109093. var _this = this;
  109094. var triangleCount = 0;
  109095. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  109096. var indices = object.getIndices();
  109097. if (!indices) {
  109098. indices = [];
  109099. }
  109100. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  109101. if (!vertexPositions) {
  109102. vertexPositions = [];
  109103. }
  109104. object.computeWorldMatrix(false);
  109105. var faceCount = indices.length / 3;
  109106. for (var i = 0; i < faceCount; i++) {
  109107. var triPoints = [];
  109108. for (var point = 0; point < 3; point++) {
  109109. 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]);
  109110. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  109111. v.subtractInPlace(topLevelObject.position);
  109112. var vec;
  109113. if (point == 0) {
  109114. vec = this._tmpAmmoVectorA;
  109115. }
  109116. else if (point == 1) {
  109117. vec = this._tmpAmmoVectorB;
  109118. }
  109119. else {
  109120. vec = this._tmpAmmoVectorC;
  109121. }
  109122. vec.setValue(v.x, v.y, v.z);
  109123. triPoints.push(vec);
  109124. }
  109125. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  109126. triangleCount++;
  109127. }
  109128. object.getChildMeshes().forEach(function (m) {
  109129. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  109130. });
  109131. }
  109132. return triangleCount;
  109133. };
  109134. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  109135. var _this = this;
  109136. if (ignoreChildren === void 0) { ignoreChildren = false; }
  109137. var object = impostor.object;
  109138. var returnValue;
  109139. var extendSize = impostor.getObjectExtendSize();
  109140. if (!ignoreChildren) {
  109141. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  109142. returnValue = new Ammo.btCompoundShape();
  109143. // Add shape of all children to the compound shape
  109144. var childrenAdded = 0;
  109145. meshChildren.forEach(function (childMesh) {
  109146. var childImpostor = childMesh.getPhysicsImpostor();
  109147. if (childImpostor) {
  109148. var shape = _this._createShape(childImpostor);
  109149. // Position needs to be scaled based on parent's scaling
  109150. var parentMat = childMesh.parent.getWorldMatrix().clone();
  109151. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109152. parentMat.decompose(s);
  109153. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  109154. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  109155. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  109156. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  109157. childImpostor.dispose();
  109158. childrenAdded++;
  109159. }
  109160. });
  109161. if (childrenAdded > 0) {
  109162. // Add parents shape as a child if present
  109163. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  109164. var shape = this._createShape(impostor, true);
  109165. if (shape) {
  109166. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  109167. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  109168. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  109169. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  109170. }
  109171. }
  109172. return returnValue;
  109173. }
  109174. else {
  109175. // If no children with impostors create the actual shape below instead
  109176. Ammo.destroy(returnValue);
  109177. returnValue = null;
  109178. }
  109179. }
  109180. switch (impostor.type) {
  109181. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  109182. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109183. break;
  109184. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  109185. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109186. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  109187. break;
  109188. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  109189. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  109190. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109191. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  109192. break;
  109193. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  109194. var tetraMesh = new Ammo.btTriangleMesh();
  109195. impostor._pluginData.toDispose.concat([tetraMesh]);
  109196. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  109197. if (triangeCount == 0) {
  109198. returnValue = new Ammo.btCompoundShape();
  109199. }
  109200. else {
  109201. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  109202. }
  109203. break;
  109204. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  109205. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  109206. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109207. break;
  109208. default:
  109209. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  109210. break;
  109211. }
  109212. return returnValue;
  109213. };
  109214. /**
  109215. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109216. * @param impostor imposter containing the physics body and babylon object
  109217. */
  109218. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109219. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109220. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  109221. if (!impostor.object.rotationQuaternion) {
  109222. if (impostor.object.rotation) {
  109223. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109224. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  109225. }
  109226. }
  109227. else {
  109228. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109229. }
  109230. };
  109231. /**
  109232. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109233. * @param impostor imposter containing the physics body and babylon object
  109234. * @param newPosition new position
  109235. * @param newRotation new rotation
  109236. */
  109237. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109238. var trans = impostor.physicsBody.getWorldTransform();
  109239. // If rotation/position has changed update and activate riged body
  109240. if (trans.getOrigin().x() != newPosition.x ||
  109241. trans.getOrigin().y() != newPosition.y ||
  109242. trans.getOrigin().z() != newPosition.z ||
  109243. trans.getRotation().x() != newRotation.x ||
  109244. trans.getRotation().y() != newRotation.y ||
  109245. trans.getRotation().z() != newRotation.z ||
  109246. trans.getRotation().w() != newRotation.w) {
  109247. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  109248. trans.setOrigin(this._tmpAmmoVectorA);
  109249. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  109250. trans.setRotation(this._tmpAmmoQuaternion);
  109251. impostor.physicsBody.setWorldTransform(trans);
  109252. if (impostor.mass == 0) {
  109253. // Kinematic objects must be updated using motion state
  109254. var motionState = impostor.physicsBody.getMotionState();
  109255. if (motionState) {
  109256. motionState.setWorldTransform(trans);
  109257. }
  109258. }
  109259. else {
  109260. impostor.physicsBody.activate();
  109261. }
  109262. }
  109263. };
  109264. /**
  109265. * If this plugin is supported
  109266. * @returns true if its supported
  109267. */
  109268. AmmoJSPlugin.prototype.isSupported = function () {
  109269. return this.bjsAMMO !== undefined;
  109270. };
  109271. /**
  109272. * Sets the linear velocity of the physics body
  109273. * @param impostor imposter to set the velocity on
  109274. * @param velocity velocity to set
  109275. */
  109276. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109277. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109278. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  109279. };
  109280. /**
  109281. * Sets the angular velocity of the physics body
  109282. * @param impostor imposter to set the velocity on
  109283. * @param velocity velocity to set
  109284. */
  109285. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109286. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109287. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  109288. };
  109289. /**
  109290. * gets the linear velocity
  109291. * @param impostor imposter to get linear velocity from
  109292. * @returns linear velocity
  109293. */
  109294. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109295. var v = impostor.physicsBody.getLinearVelocity();
  109296. if (!v) {
  109297. return null;
  109298. }
  109299. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109300. };
  109301. /**
  109302. * gets the angular velocity
  109303. * @param impostor imposter to get angular velocity from
  109304. * @returns angular velocity
  109305. */
  109306. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109307. var v = impostor.physicsBody.getAngularVelocity();
  109308. if (!v) {
  109309. return null;
  109310. }
  109311. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109312. };
  109313. /**
  109314. * Sets the mass of physics body
  109315. * @param impostor imposter to set the mass on
  109316. * @param mass mass to set
  109317. */
  109318. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109319. impostor.physicsBody.setMassProps(mass);
  109320. impostor._pluginData.mass = mass;
  109321. };
  109322. /**
  109323. * Gets the mass of the physics body
  109324. * @param impostor imposter to get the mass from
  109325. * @returns mass
  109326. */
  109327. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  109328. return impostor._pluginData.mass;
  109329. };
  109330. /**
  109331. * Gets friction of the impostor
  109332. * @param impostor impostor to get friction from
  109333. * @returns friction value
  109334. */
  109335. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109336. return impostor._pluginData.friction;
  109337. };
  109338. /**
  109339. * Sets friction of the impostor
  109340. * @param impostor impostor to set friction on
  109341. * @param friction friction value
  109342. */
  109343. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109344. impostor.physicsBody.setFriction(friction);
  109345. impostor._pluginData.friction = friction;
  109346. };
  109347. /**
  109348. * Gets restitution of the impostor
  109349. * @param impostor impostor to get restitution from
  109350. * @returns restitution value
  109351. */
  109352. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109353. return impostor._pluginData.restitution;
  109354. };
  109355. /**
  109356. * Sets resitution of the impostor
  109357. * @param impostor impostor to set resitution on
  109358. * @param restitution resitution value
  109359. */
  109360. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109361. impostor.physicsBody.setRestitution(restitution);
  109362. impostor._pluginData.restitution = restitution;
  109363. };
  109364. /**
  109365. * Sleeps the physics body and stops it from being active
  109366. * @param impostor impostor to sleep
  109367. */
  109368. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  109369. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  109370. };
  109371. /**
  109372. * Activates the physics body
  109373. * @param impostor impostor to activate
  109374. */
  109375. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109376. impostor.physicsBody.activate();
  109377. };
  109378. /**
  109379. * Updates the distance parameters of the joint
  109380. * @param joint joint to update
  109381. * @param maxDistance maximum distance of the joint
  109382. * @param minDistance minimum distance of the joint
  109383. */
  109384. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109385. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  109386. };
  109387. /**
  109388. * Sets a motor on the joint
  109389. * @param joint joint to set motor on
  109390. * @param speed speed of the motor
  109391. * @param maxForce maximum force of the motor
  109392. * @param motorIndex index of the motor
  109393. */
  109394. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109395. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  109396. };
  109397. /**
  109398. * Sets the motors limit
  109399. * @param joint joint to set limit on
  109400. * @param upperLimit upper limit
  109401. * @param lowerLimit lower limit
  109402. */
  109403. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109404. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  109405. };
  109406. /**
  109407. * Syncs the position and rotation of a mesh with the impostor
  109408. * @param mesh mesh to sync
  109409. * @param impostor impostor to update the mesh with
  109410. */
  109411. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109412. var body = impostor.physicsBody;
  109413. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109414. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  109415. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  109416. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  109417. if (mesh.rotationQuaternion) {
  109418. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  109419. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  109420. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  109421. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  109422. }
  109423. };
  109424. /**
  109425. * Gets the radius of the impostor
  109426. * @param impostor impostor to get radius from
  109427. * @returns the radius
  109428. */
  109429. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  109430. var exntend = impostor.getObjectExtendSize();
  109431. return exntend.x / 2;
  109432. };
  109433. /**
  109434. * Gets the box size of the impostor
  109435. * @param impostor impostor to get box size from
  109436. * @param result the resulting box size
  109437. */
  109438. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109439. var exntend = impostor.getObjectExtendSize();
  109440. result.x = exntend.x;
  109441. result.y = exntend.y;
  109442. result.z = exntend.z;
  109443. };
  109444. /**
  109445. * Disposes of the impostor
  109446. */
  109447. AmmoJSPlugin.prototype.dispose = function () {
  109448. // Dispose of world
  109449. Ammo.destroy(this.world);
  109450. Ammo.destroy(this._solver);
  109451. Ammo.destroy(this._overlappingPairCache);
  109452. Ammo.destroy(this._dispatcher);
  109453. Ammo.destroy(this._collisionConfiguration);
  109454. // Dispose of tmp variables
  109455. Ammo.destroy(this._tmpAmmoVectorA);
  109456. Ammo.destroy(this._tmpAmmoVectorB);
  109457. Ammo.destroy(this._tmpAmmoVectorC);
  109458. Ammo.destroy(this._tmpAmmoTransform);
  109459. Ammo.destroy(this._tmpAmmoQuaternion);
  109460. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  109461. this.world = null;
  109462. };
  109463. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  109464. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  109465. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  109466. return AmmoJSPlugin;
  109467. }());
  109468. /***/ }),
  109469. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  109470. /*!*******************************************!*\
  109471. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  109472. \*******************************************/
  109473. /*! exports provided: CannonJSPlugin */
  109474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109475. "use strict";
  109476. __webpack_require__.r(__webpack_exports__);
  109477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  109478. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109480. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109481. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109482. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109483. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109484. /** @hidden */
  109485. var CannonJSPlugin = /** @class */ (function () {
  109486. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  109487. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109488. if (iterations === void 0) { iterations = 10; }
  109489. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  109490. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109491. this.name = "CannonJSPlugin";
  109492. this._physicsMaterials = new Array();
  109493. this._fixedTimeStep = 1 / 60;
  109494. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  109495. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  109496. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109497. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109498. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  109499. this.BJSCANNON = cannonInjection;
  109500. if (!this.isSupported()) {
  109501. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  109502. return;
  109503. }
  109504. this._extendNamespace();
  109505. this.world = new this.BJSCANNON.World();
  109506. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  109507. this.world.solver.iterations = iterations;
  109508. }
  109509. CannonJSPlugin.prototype.setGravity = function (gravity) {
  109510. this.world.gravity.copy(gravity);
  109511. };
  109512. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  109513. this._fixedTimeStep = timeStep;
  109514. };
  109515. CannonJSPlugin.prototype.getTimeStep = function () {
  109516. return this._fixedTimeStep;
  109517. };
  109518. CannonJSPlugin.prototype.executeStep = function (delta) {
  109519. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  109520. };
  109521. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109522. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109523. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109524. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109525. };
  109526. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109527. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109528. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109529. impostor.physicsBody.applyForce(impulse, worldPoint);
  109530. };
  109531. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109532. //parent-child relationship. Does this impostor has a parent impostor?
  109533. if (impostor.parent) {
  109534. if (impostor.physicsBody) {
  109535. this.removePhysicsBody(impostor);
  109536. //TODO is that needed?
  109537. impostor.forceUpdate();
  109538. }
  109539. return;
  109540. }
  109541. //should a new body be created for this impostor?
  109542. if (impostor.isBodyInitRequired()) {
  109543. var shape = this._createShape(impostor);
  109544. //unregister events, if body is being changed
  109545. var oldBody = impostor.physicsBody;
  109546. if (oldBody) {
  109547. this.removePhysicsBody(impostor);
  109548. }
  109549. //create the body and material
  109550. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  109551. var bodyCreationObject = {
  109552. mass: impostor.getParam("mass"),
  109553. material: material
  109554. };
  109555. // A simple extend, in case native options were used.
  109556. var nativeOptions = impostor.getParam("nativeOptions");
  109557. for (var key in nativeOptions) {
  109558. if (nativeOptions.hasOwnProperty(key)) {
  109559. bodyCreationObject[key] = nativeOptions[key];
  109560. }
  109561. }
  109562. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  109563. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  109564. this.world.addEventListener("preStep", impostor.beforeStep);
  109565. this.world.addEventListener("postStep", impostor.afterStep);
  109566. impostor.physicsBody.addShape(shape);
  109567. this.world.add(impostor.physicsBody);
  109568. //try to keep the body moving in the right direction by taking old properties.
  109569. //Should be tested!
  109570. if (oldBody) {
  109571. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  109572. impostor.physicsBody[param].copy(oldBody[param]);
  109573. });
  109574. }
  109575. this._processChildMeshes(impostor);
  109576. }
  109577. //now update the body's transformation
  109578. this._updatePhysicsBodyTransformation(impostor);
  109579. };
  109580. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  109581. var _this = this;
  109582. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  109583. var currentRotation = mainImpostor.object.rotationQuaternion;
  109584. if (meshChildren.length) {
  109585. var processMesh = function (localPosition, mesh) {
  109586. if (!currentRotation || !mesh.rotationQuaternion) {
  109587. return;
  109588. }
  109589. var childImpostor = mesh.getPhysicsImpostor();
  109590. if (childImpostor) {
  109591. var parent = childImpostor.parent;
  109592. if (parent !== mainImpostor) {
  109593. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  109594. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  109595. if (childImpostor.physicsBody) {
  109596. _this.removePhysicsBody(childImpostor);
  109597. childImpostor.physicsBody = null;
  109598. }
  109599. childImpostor.parent = mainImpostor;
  109600. childImpostor.resetUpdateFlags();
  109601. 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));
  109602. //Add the mass of the children.
  109603. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  109604. }
  109605. }
  109606. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  109607. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  109608. };
  109609. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  109610. }
  109611. };
  109612. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109613. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  109614. this.world.removeEventListener("preStep", impostor.beforeStep);
  109615. this.world.removeEventListener("postStep", impostor.afterStep);
  109616. this.world.remove(impostor.physicsBody);
  109617. };
  109618. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109619. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109620. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109621. if (!mainBody || !connectedBody) {
  109622. return;
  109623. }
  109624. var constraint;
  109625. var jointData = impostorJoint.joint.jointData;
  109626. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  109627. var constraintData = {
  109628. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  109629. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  109630. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  109631. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  109632. maxForce: jointData.nativeParams.maxForce,
  109633. collideConnected: !!jointData.collision
  109634. };
  109635. switch (impostorJoint.joint.type) {
  109636. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  109637. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  109638. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  109639. break;
  109640. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  109641. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  109642. break;
  109643. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  109644. var springData = jointData;
  109645. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  109646. restLength: springData.length,
  109647. stiffness: springData.stiffness,
  109648. damping: springData.damping,
  109649. localAnchorA: constraintData.pivotA,
  109650. localAnchorB: constraintData.pivotB
  109651. });
  109652. break;
  109653. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  109654. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  109655. break;
  109656. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  109657. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  109658. default:
  109659. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  109660. break;
  109661. }
  109662. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  109663. constraint.collideConnected = !!jointData.collision;
  109664. impostorJoint.joint.physicsJoint = constraint;
  109665. //don't add spring as constraint, as it is not one.
  109666. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  109667. this.world.addConstraint(constraint);
  109668. }
  109669. else {
  109670. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  109671. constraint.applyForce();
  109672. };
  109673. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  109674. }
  109675. };
  109676. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109677. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  109678. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109679. }
  109680. else {
  109681. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  109682. }
  109683. };
  109684. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  109685. var index;
  109686. var mat;
  109687. for (index = 0; index < this._physicsMaterials.length; index++) {
  109688. mat = this._physicsMaterials[index];
  109689. if (mat.friction === friction && mat.restitution === restitution) {
  109690. return mat;
  109691. }
  109692. }
  109693. var currentMat = new this.BJSCANNON.Material(name);
  109694. currentMat.friction = friction;
  109695. currentMat.restitution = restitution;
  109696. this._physicsMaterials.push(currentMat);
  109697. return currentMat;
  109698. };
  109699. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  109700. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  109701. };
  109702. CannonJSPlugin.prototype._createShape = function (impostor) {
  109703. var object = impostor.object;
  109704. var returnValue;
  109705. var extendSize = impostor.getObjectExtendSize();
  109706. switch (impostor.type) {
  109707. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  109708. var radiusX = extendSize.x;
  109709. var radiusY = extendSize.y;
  109710. var radiusZ = extendSize.z;
  109711. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  109712. break;
  109713. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  109714. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  109715. var nativeParams = impostor.getParam("nativeOptions");
  109716. if (!nativeParams) {
  109717. nativeParams = {};
  109718. }
  109719. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  109720. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  109721. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  109722. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  109723. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  109724. // Rotate 90 degrees as this shape is horizontal in cannon
  109725. var quat = new this.BJSCANNON.Quaternion();
  109726. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  109727. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  109728. returnValue.transformAllPoints(translation, quat);
  109729. break;
  109730. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  109731. var box = extendSize.scale(0.5);
  109732. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  109733. break;
  109734. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  109735. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  109736. returnValue = new this.BJSCANNON.Plane();
  109737. break;
  109738. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  109739. // should transform the vertex data to world coordinates!!
  109740. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  109741. var rawFaces = object.getIndices ? object.getIndices() : [];
  109742. if (!rawVerts) {
  109743. return;
  109744. }
  109745. // get only scale! so the object could transform correctly.
  109746. var oldPosition = object.position.clone();
  109747. var oldRotation = object.rotation && object.rotation.clone();
  109748. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  109749. object.position.copyFromFloats(0, 0, 0);
  109750. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  109751. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  109752. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  109753. var transform = object.computeWorldMatrix(true);
  109754. // convert rawVerts to object space
  109755. var temp = new Array();
  109756. var index;
  109757. for (index = 0; index < rawVerts.length; index += 3) {
  109758. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  109759. }
  109760. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  109761. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  109762. //now set back the transformation!
  109763. object.position.copyFrom(oldPosition);
  109764. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  109765. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  109766. break;
  109767. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  109768. var oldPosition2 = object.position.clone();
  109769. var oldRotation2 = object.rotation && object.rotation.clone();
  109770. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  109771. object.position.copyFromFloats(0, 0, 0);
  109772. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  109773. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  109774. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  109775. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  109776. returnValue = this._createHeightmap(object);
  109777. object.position.copyFrom(oldPosition2);
  109778. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  109779. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  109780. object.computeWorldMatrix(true);
  109781. break;
  109782. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  109783. returnValue = new this.BJSCANNON.Particle();
  109784. break;
  109785. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  109786. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  109787. break;
  109788. }
  109789. return returnValue;
  109790. };
  109791. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  109792. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  109793. var transform = object.computeWorldMatrix(true);
  109794. // convert rawVerts to object space
  109795. var temp = new Array();
  109796. var index;
  109797. for (index = 0; index < pos.length; index += 3) {
  109798. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  109799. }
  109800. pos = temp;
  109801. var matrix = new Array();
  109802. //For now pointDepth will not be used and will be automatically calculated.
  109803. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  109804. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  109805. var boundingInfo = object.getBoundingInfo();
  109806. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  109807. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  109808. var elementSize = dim * 2 / arraySize;
  109809. for (var i = 0; i < pos.length; i = i + 3) {
  109810. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  109811. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  109812. var y = -pos[i + 2] + minY;
  109813. if (!matrix[x]) {
  109814. matrix[x] = [];
  109815. }
  109816. if (!matrix[x][z]) {
  109817. matrix[x][z] = y;
  109818. }
  109819. matrix[x][z] = Math.max(y, matrix[x][z]);
  109820. }
  109821. for (var x = 0; x <= arraySize; ++x) {
  109822. if (!matrix[x]) {
  109823. var loc = 1;
  109824. while (!matrix[(x + loc) % arraySize]) {
  109825. loc++;
  109826. }
  109827. matrix[x] = matrix[(x + loc) % arraySize].slice();
  109828. //console.log("missing x", x);
  109829. }
  109830. for (var z = 0; z <= arraySize; ++z) {
  109831. if (!matrix[x][z]) {
  109832. var loc = 1;
  109833. var newValue;
  109834. while (newValue === undefined) {
  109835. newValue = matrix[x][(z + loc++) % arraySize];
  109836. }
  109837. matrix[x][z] = newValue;
  109838. }
  109839. }
  109840. }
  109841. var shape = new this.BJSCANNON.Heightfield(matrix, {
  109842. elementSize: elementSize
  109843. });
  109844. //For future reference, needed for body transformation
  109845. shape.minY = minY;
  109846. return shape;
  109847. };
  109848. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  109849. var object = impostor.object;
  109850. //make sure it is updated...
  109851. object.computeWorldMatrix && object.computeWorldMatrix(true);
  109852. // The delta between the mesh position and the mesh bounding box center
  109853. var bInfo = object.getBoundingInfo();
  109854. if (!bInfo) {
  109855. return;
  109856. }
  109857. var center = impostor.getObjectCenter();
  109858. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  109859. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  109860. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  109861. this._tmpPosition.copyFrom(center);
  109862. var quaternion = object.rotationQuaternion;
  109863. if (!quaternion) {
  109864. return;
  109865. }
  109866. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  109867. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  109868. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  109869. //-90 DEG in X, precalculated
  109870. quaternion = quaternion.multiply(this._minus90X);
  109871. //Invert! (Precalculated, 90 deg in X)
  109872. //No need to clone. this will never change.
  109873. impostor.setDeltaRotation(this._plus90X);
  109874. }
  109875. //If it is a heightfield, if should be centered.
  109876. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  109877. var mesh = object;
  109878. var boundingInfo = mesh.getBoundingInfo();
  109879. //calculate the correct body position:
  109880. var rotationQuaternion = mesh.rotationQuaternion;
  109881. mesh.rotationQuaternion = this._tmpUnityRotation;
  109882. mesh.computeWorldMatrix(true);
  109883. //get original center with no rotation
  109884. var c = center.clone();
  109885. var oldPivot = mesh.getPivotMatrix();
  109886. if (oldPivot) {
  109887. // create a copy the pivot Matrix as it is modified in place
  109888. oldPivot = oldPivot.clone();
  109889. }
  109890. else {
  109891. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  109892. }
  109893. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  109894. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  109895. mesh.setPreTransformMatrix(p);
  109896. mesh.computeWorldMatrix(true);
  109897. //calculate the translation
  109898. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  109899. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  109900. //add it inverted to the delta
  109901. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  109902. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  109903. //rotation is back
  109904. mesh.rotationQuaternion = rotationQuaternion;
  109905. mesh.setPreTransformMatrix(oldPivot);
  109906. mesh.computeWorldMatrix(true);
  109907. }
  109908. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  109909. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  109910. //this._tmpPosition.copyFrom(object.position);
  109911. }
  109912. impostor.setDeltaPosition(this._tmpDeltaPosition);
  109913. //Now update the impostor object
  109914. impostor.physicsBody.position.copy(this._tmpPosition);
  109915. impostor.physicsBody.quaternion.copy(quaternion);
  109916. };
  109917. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109918. impostor.object.position.copyFrom(impostor.physicsBody.position);
  109919. if (impostor.object.rotationQuaternion) {
  109920. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  109921. }
  109922. };
  109923. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109924. impostor.physicsBody.position.copy(newPosition);
  109925. impostor.physicsBody.quaternion.copy(newRotation);
  109926. };
  109927. CannonJSPlugin.prototype.isSupported = function () {
  109928. return this.BJSCANNON !== undefined;
  109929. };
  109930. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109931. impostor.physicsBody.velocity.copy(velocity);
  109932. };
  109933. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109934. impostor.physicsBody.angularVelocity.copy(velocity);
  109935. };
  109936. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109937. var v = impostor.physicsBody.velocity;
  109938. if (!v) {
  109939. return null;
  109940. }
  109941. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  109942. };
  109943. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109944. var v = impostor.physicsBody.angularVelocity;
  109945. if (!v) {
  109946. return null;
  109947. }
  109948. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  109949. };
  109950. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109951. impostor.physicsBody.mass = mass;
  109952. impostor.physicsBody.updateMassProperties();
  109953. };
  109954. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  109955. return impostor.physicsBody.mass;
  109956. };
  109957. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  109958. return impostor.physicsBody.material.friction;
  109959. };
  109960. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109961. impostor.physicsBody.material.friction = friction;
  109962. };
  109963. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109964. return impostor.physicsBody.material.restitution;
  109965. };
  109966. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109967. impostor.physicsBody.material.restitution = restitution;
  109968. };
  109969. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  109970. impostor.physicsBody.sleep();
  109971. };
  109972. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  109973. impostor.physicsBody.wakeUp();
  109974. };
  109975. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  109976. joint.physicsJoint.distance = maxDistance;
  109977. };
  109978. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109979. // if (!motorIndex) {
  109980. // joint.physicsJoint.enableMotor();
  109981. // }
  109982. // }
  109983. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109984. // if (!motorIndex) {
  109985. // joint.physicsJoint.disableMotor();
  109986. // }
  109987. // }
  109988. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109989. if (!motorIndex) {
  109990. joint.physicsJoint.enableMotor();
  109991. joint.physicsJoint.setMotorSpeed(speed);
  109992. if (maxForce) {
  109993. this.setLimit(joint, maxForce);
  109994. }
  109995. }
  109996. };
  109997. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109998. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  109999. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  110000. };
  110001. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110002. var body = impostor.physicsBody;
  110003. mesh.position.x = body.position.x;
  110004. mesh.position.y = body.position.y;
  110005. mesh.position.z = body.position.z;
  110006. if (mesh.rotationQuaternion) {
  110007. mesh.rotationQuaternion.x = body.quaternion.x;
  110008. mesh.rotationQuaternion.y = body.quaternion.y;
  110009. mesh.rotationQuaternion.z = body.quaternion.z;
  110010. mesh.rotationQuaternion.w = body.quaternion.w;
  110011. }
  110012. };
  110013. CannonJSPlugin.prototype.getRadius = function (impostor) {
  110014. var shape = impostor.physicsBody.shapes[0];
  110015. return shape.boundingSphereRadius;
  110016. };
  110017. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110018. var shape = impostor.physicsBody.shapes[0];
  110019. result.x = shape.halfExtents.x * 2;
  110020. result.y = shape.halfExtents.y * 2;
  110021. result.z = shape.halfExtents.z * 2;
  110022. };
  110023. CannonJSPlugin.prototype.dispose = function () {
  110024. };
  110025. CannonJSPlugin.prototype._extendNamespace = function () {
  110026. //this will force cannon to execute at least one step when using interpolation
  110027. var step_tmp1 = new this.BJSCANNON.Vec3();
  110028. var Engine = this.BJSCANNON;
  110029. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  110030. maxSubSteps = maxSubSteps || 10;
  110031. timeSinceLastCalled = timeSinceLastCalled || 0;
  110032. if (timeSinceLastCalled === 0) {
  110033. this.internalStep(dt);
  110034. this.time += dt;
  110035. }
  110036. else {
  110037. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  110038. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  110039. var t0 = performance.now();
  110040. for (var i = 0; i !== internalSteps; i++) {
  110041. this.internalStep(dt);
  110042. if (performance.now() - t0 > dt * 1000) {
  110043. break;
  110044. }
  110045. }
  110046. this.time += timeSinceLastCalled;
  110047. var h = this.time % dt;
  110048. var h_div_dt = h / dt;
  110049. var interpvelo = step_tmp1;
  110050. var bodies = this.bodies;
  110051. for (var j = 0; j !== bodies.length; j++) {
  110052. var b = bodies[j];
  110053. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  110054. b.position.vsub(b.previousPosition, interpvelo);
  110055. interpvelo.scale(h_div_dt, interpvelo);
  110056. b.position.vadd(interpvelo, b.interpolatedPosition);
  110057. }
  110058. else {
  110059. b.interpolatedPosition.copy(b.position);
  110060. b.interpolatedQuaternion.copy(b.quaternion);
  110061. }
  110062. }
  110063. }
  110064. };
  110065. };
  110066. return CannonJSPlugin;
  110067. }());
  110068. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  110069. /***/ }),
  110070. /***/ "./Physics/Plugins/index.ts":
  110071. /*!**********************************!*\
  110072. !*** ./Physics/Plugins/index.ts ***!
  110073. \**********************************/
  110074. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110076. "use strict";
  110077. __webpack_require__.r(__webpack_exports__);
  110078. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  110079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  110080. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  110081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  110082. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  110083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  110084. /***/ }),
  110085. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  110086. /*!*****************************************!*\
  110087. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  110088. \*****************************************/
  110089. /*! exports provided: OimoJSPlugin */
  110090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110091. "use strict";
  110092. __webpack_require__.r(__webpack_exports__);
  110093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  110094. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110095. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110096. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  110097. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110098. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110099. /** @hidden */
  110100. var OimoJSPlugin = /** @class */ (function () {
  110101. function OimoJSPlugin(iterations, oimoInjection) {
  110102. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  110103. this.name = "OimoJSPlugin";
  110104. this._tmpImpostorsArray = [];
  110105. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110106. this.BJSOIMO = oimoInjection;
  110107. this.world = new this.BJSOIMO.World({
  110108. iterations: iterations
  110109. });
  110110. this.world.clear();
  110111. }
  110112. OimoJSPlugin.prototype.setGravity = function (gravity) {
  110113. this.world.gravity.copy(gravity);
  110114. };
  110115. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  110116. this.world.timeStep = timeStep;
  110117. };
  110118. OimoJSPlugin.prototype.getTimeStep = function () {
  110119. return this.world.timeStep;
  110120. };
  110121. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  110122. var _this = this;
  110123. impostors.forEach(function (impostor) {
  110124. impostor.beforeStep();
  110125. });
  110126. this.world.step();
  110127. impostors.forEach(function (impostor) {
  110128. impostor.afterStep();
  110129. //update the ordered impostors array
  110130. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  110131. });
  110132. //check for collisions
  110133. var contact = this.world.contacts;
  110134. while (contact !== null) {
  110135. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  110136. contact = contact.next;
  110137. continue;
  110138. }
  110139. //is this body colliding with any other? get the impostor
  110140. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  110141. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  110142. if (!mainImpostor || !collidingImpostor) {
  110143. contact = contact.next;
  110144. continue;
  110145. }
  110146. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  110147. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  110148. contact = contact.next;
  110149. }
  110150. };
  110151. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110152. var mass = impostor.physicsBody.mass;
  110153. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  110154. };
  110155. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110156. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  110157. this.applyImpulse(impostor, force, contactPoint);
  110158. };
  110159. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110160. var _this = this;
  110161. //parent-child relationship. Does this impostor has a parent impostor?
  110162. if (impostor.parent) {
  110163. if (impostor.physicsBody) {
  110164. this.removePhysicsBody(impostor);
  110165. //TODO is that needed?
  110166. impostor.forceUpdate();
  110167. }
  110168. return;
  110169. }
  110170. if (impostor.isBodyInitRequired()) {
  110171. var bodyConfig = {
  110172. name: impostor.uniqueId,
  110173. //Oimo must have mass, also for static objects.
  110174. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  110175. size: [],
  110176. type: [],
  110177. pos: [],
  110178. posShape: [],
  110179. rot: [],
  110180. rotShape: [],
  110181. move: impostor.getParam("mass") !== 0,
  110182. density: impostor.getParam("mass"),
  110183. friction: impostor.getParam("friction"),
  110184. restitution: impostor.getParam("restitution"),
  110185. //Supporting older versions of Oimo
  110186. world: this.world
  110187. };
  110188. var impostors = [impostor];
  110189. var addToArray = function (parent) {
  110190. if (!parent.getChildMeshes) {
  110191. return;
  110192. }
  110193. parent.getChildMeshes().forEach(function (m) {
  110194. if (m.physicsImpostor) {
  110195. impostors.push(m.physicsImpostor);
  110196. //m.physicsImpostor._init();
  110197. }
  110198. });
  110199. };
  110200. addToArray(impostor.object);
  110201. var checkWithEpsilon_1 = function (value) {
  110202. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  110203. };
  110204. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  110205. impostors.forEach(function (i) {
  110206. if (!i.object.rotationQuaternion) {
  110207. return;
  110208. }
  110209. //get the correct bounding box
  110210. var oldQuaternion = i.object.rotationQuaternion;
  110211. globalQuaternion_1 = oldQuaternion.clone();
  110212. var rot = oldQuaternion.toEulerAngles();
  110213. var extendSize = i.getObjectExtendSize();
  110214. var radToDeg = 57.295779513082320876;
  110215. if (i === impostor) {
  110216. var center = impostor.getObjectCenter();
  110217. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  110218. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  110219. //Can also use Array.prototype.push.apply
  110220. bodyConfig.pos.push(center.x);
  110221. bodyConfig.pos.push(center.y);
  110222. bodyConfig.pos.push(center.z);
  110223. bodyConfig.posShape.push(0, 0, 0);
  110224. bodyConfig.rotShape.push(0, 0, 0);
  110225. }
  110226. else {
  110227. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  110228. bodyConfig.posShape.push(localPosition.x);
  110229. bodyConfig.posShape.push(localPosition.y);
  110230. bodyConfig.posShape.push(localPosition.z);
  110231. bodyConfig.pos.push(0, 0, 0);
  110232. bodyConfig.rotShape.push(rot.x * radToDeg);
  110233. bodyConfig.rotShape.push(rot.y * radToDeg);
  110234. bodyConfig.rotShape.push(rot.z * radToDeg);
  110235. }
  110236. // register mesh
  110237. switch (i.type) {
  110238. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  110239. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  110240. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  110241. var radiusX = extendSize.x;
  110242. var radiusY = extendSize.y;
  110243. var radiusZ = extendSize.z;
  110244. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  110245. bodyConfig.type.push('sphere');
  110246. //due to the way oimo works with compounds, add 3 times
  110247. bodyConfig.size.push(size);
  110248. bodyConfig.size.push(size);
  110249. bodyConfig.size.push(size);
  110250. break;
  110251. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  110252. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  110253. var sizeY = checkWithEpsilon_1(extendSize.y);
  110254. bodyConfig.type.push('cylinder');
  110255. bodyConfig.size.push(sizeX);
  110256. bodyConfig.size.push(sizeY);
  110257. //due to the way oimo works with compounds, add one more value.
  110258. bodyConfig.size.push(sizeY);
  110259. break;
  110260. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  110261. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  110262. default:
  110263. var sizeX = checkWithEpsilon_1(extendSize.x);
  110264. var sizeY = checkWithEpsilon_1(extendSize.y);
  110265. var sizeZ = checkWithEpsilon_1(extendSize.z);
  110266. bodyConfig.type.push('box');
  110267. //if (i === impostor) {
  110268. bodyConfig.size.push(sizeX);
  110269. bodyConfig.size.push(sizeY);
  110270. bodyConfig.size.push(sizeZ);
  110271. //} else {
  110272. // bodyConfig.size.push(0,0,0);
  110273. //}
  110274. break;
  110275. }
  110276. //actually not needed, but hey...
  110277. i.object.rotationQuaternion = oldQuaternion;
  110278. });
  110279. impostor.physicsBody = this.world.add(bodyConfig);
  110280. // set the quaternion, ignoring the previously defined (euler) rotation
  110281. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  110282. // update with delta 0, so the body will reveive the new rotation.
  110283. impostor.physicsBody.updatePosition(0);
  110284. }
  110285. else {
  110286. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  110287. }
  110288. impostor.setDeltaPosition(this._tmpPositionVector);
  110289. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  110290. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  110291. };
  110292. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110293. //impostor.physicsBody.dispose();
  110294. //Same as : (older oimo versions)
  110295. this.world.removeRigidBody(impostor.physicsBody);
  110296. };
  110297. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110298. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110299. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110300. if (!mainBody || !connectedBody) {
  110301. return;
  110302. }
  110303. var jointData = impostorJoint.joint.jointData;
  110304. var options = jointData.nativeParams || {};
  110305. var type;
  110306. var nativeJointData = {
  110307. body1: mainBody,
  110308. body2: connectedBody,
  110309. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  110310. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  110311. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  110312. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  110313. min: options.min,
  110314. max: options.max,
  110315. collision: options.collision || jointData.collision,
  110316. spring: options.spring,
  110317. //supporting older version of Oimo
  110318. world: this.world
  110319. };
  110320. switch (impostorJoint.joint.type) {
  110321. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  110322. type = "jointBall";
  110323. break;
  110324. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  110325. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  110326. var springData = jointData;
  110327. nativeJointData.min = springData.length || nativeJointData.min;
  110328. //Max should also be set, just make sure it is at least min
  110329. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  110330. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  110331. type = "jointDistance";
  110332. nativeJointData.max = jointData.maxDistance;
  110333. break;
  110334. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  110335. type = "jointPrisme";
  110336. break;
  110337. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  110338. type = "jointSlide";
  110339. break;
  110340. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  110341. type = "jointWheel";
  110342. break;
  110343. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  110344. default:
  110345. type = "jointHinge";
  110346. break;
  110347. }
  110348. nativeJointData.type = type;
  110349. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  110350. };
  110351. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110352. //Bug in Oimo prevents us from disposing a joint in the playground
  110353. //joint.joint.physicsJoint.dispose();
  110354. //So we will bruteforce it!
  110355. try {
  110356. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  110357. }
  110358. catch (e) {
  110359. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  110360. }
  110361. };
  110362. OimoJSPlugin.prototype.isSupported = function () {
  110363. return this.BJSOIMO !== undefined;
  110364. };
  110365. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110366. if (!impostor.physicsBody.sleeping) {
  110367. //TODO check that
  110368. /*if (impostor.physicsBody.shapes.next) {
  110369. var parentShape = this._getLastShape(impostor.physicsBody);
  110370. impostor.object.position.copyFrom(parentShape.position);
  110371. console.log(parentShape.position);
  110372. } else {*/
  110373. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  110374. //}
  110375. if (impostor.object.rotationQuaternion) {
  110376. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  110377. }
  110378. }
  110379. };
  110380. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110381. var body = impostor.physicsBody;
  110382. body.position.copy(newPosition);
  110383. body.orientation.copy(newRotation);
  110384. body.syncShapes();
  110385. body.awake();
  110386. };
  110387. /*private _getLastShape(body: any): any {
  110388. var lastShape = body.shapes;
  110389. while (lastShape.next) {
  110390. lastShape = lastShape.next;
  110391. }
  110392. return lastShape;
  110393. }*/
  110394. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110395. impostor.physicsBody.linearVelocity.copy(velocity);
  110396. };
  110397. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110398. impostor.physicsBody.angularVelocity.copy(velocity);
  110399. };
  110400. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110401. var v = impostor.physicsBody.linearVelocity;
  110402. if (!v) {
  110403. return null;
  110404. }
  110405. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110406. };
  110407. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110408. var v = impostor.physicsBody.angularVelocity;
  110409. if (!v) {
  110410. return null;
  110411. }
  110412. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110413. };
  110414. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110415. var staticBody = mass === 0;
  110416. //this will actually set the body's density and not its mass.
  110417. //But this is how oimo treats the mass variable.
  110418. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  110419. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  110420. };
  110421. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  110422. return impostor.physicsBody.shapes.density;
  110423. };
  110424. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  110425. return impostor.physicsBody.shapes.friction;
  110426. };
  110427. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110428. impostor.physicsBody.shapes.friction = friction;
  110429. };
  110430. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110431. return impostor.physicsBody.shapes.restitution;
  110432. };
  110433. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110434. impostor.physicsBody.shapes.restitution = restitution;
  110435. };
  110436. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  110437. impostor.physicsBody.sleep();
  110438. };
  110439. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  110440. impostor.physicsBody.awake();
  110441. };
  110442. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  110443. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  110444. if (minDistance !== void 0) {
  110445. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  110446. }
  110447. };
  110448. OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110449. // Keep defaults consistant with other physics plugins
  110450. if (maxForce !== undefined) {
  110451. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin does not support setMotor with maxForce");
  110452. }
  110453. maxForce = 1e6;
  110454. speed *= -1;
  110455. //TODO separate rotational and transational motors.
  110456. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110457. if (motor) {
  110458. motor.setMotor(speed, maxForce);
  110459. }
  110460. };
  110461. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  110462. //TODO separate rotational and transational motors.
  110463. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110464. if (motor) {
  110465. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  110466. }
  110467. };
  110468. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110469. var body = impostor.physicsBody;
  110470. mesh.position.x = body.position.x;
  110471. mesh.position.y = body.position.y;
  110472. mesh.position.z = body.position.z;
  110473. if (mesh.rotationQuaternion) {
  110474. mesh.rotationQuaternion.x = body.orientation.x;
  110475. mesh.rotationQuaternion.y = body.orientation.y;
  110476. mesh.rotationQuaternion.z = body.orientation.z;
  110477. mesh.rotationQuaternion.w = body.orientation.s;
  110478. }
  110479. };
  110480. OimoJSPlugin.prototype.getRadius = function (impostor) {
  110481. return impostor.physicsBody.shapes.radius;
  110482. };
  110483. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110484. var shape = impostor.physicsBody.shapes;
  110485. result.x = shape.halfWidth * 2;
  110486. result.y = shape.halfHeight * 2;
  110487. result.z = shape.halfDepth * 2;
  110488. };
  110489. OimoJSPlugin.prototype.dispose = function () {
  110490. this.world.clear();
  110491. };
  110492. return OimoJSPlugin;
  110493. }());
  110494. /***/ }),
  110495. /***/ "./Physics/index.ts":
  110496. /*!**************************!*\
  110497. !*** ./Physics/index.ts ***!
  110498. \**************************/
  110499. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110501. "use strict";
  110502. __webpack_require__.r(__webpack_exports__);
  110503. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  110505. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  110506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  110507. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  110508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  110509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  110510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  110511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  110512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  110513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  110514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  110515. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  110516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  110517. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  110519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  110520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  110521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  110522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  110523. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  110524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  110525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  110526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  110527. /***/ }),
  110528. /***/ "./Physics/physicsEngine.ts":
  110529. /*!**********************************!*\
  110530. !*** ./Physics/physicsEngine.ts ***!
  110531. \**********************************/
  110532. /*! exports provided: PhysicsEngine */
  110533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110534. "use strict";
  110535. __webpack_require__.r(__webpack_exports__);
  110536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  110537. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110538. /**
  110539. * Class used to control physics engine
  110540. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110541. */
  110542. var PhysicsEngine = /** @class */ (function () {
  110543. /**
  110544. * Creates a new Physics Engine
  110545. * @param gravity defines the gravity vector used by the simulation
  110546. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110547. */
  110548. function PhysicsEngine(gravity, _physicsPlugin) {
  110549. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  110550. this._physicsPlugin = _physicsPlugin;
  110551. this._impostors = [];
  110552. this._joints = [];
  110553. if (!this._physicsPlugin.isSupported()) {
  110554. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  110555. + "Please make sure it is included.");
  110556. }
  110557. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  110558. this.setGravity(gravity);
  110559. this.setTimeStep();
  110560. }
  110561. /**
  110562. * Factory used to create the default physics plugin.
  110563. * @returns The default physics plugin
  110564. */
  110565. PhysicsEngine.DefaultPluginFactory = function () {
  110566. throw "Import CannonJSPlugin or Fill DefaultPluginFactory static property on PhysicsEngine before relying on default physics plugin.";
  110567. };
  110568. /**
  110569. * Sets the gravity vector used by the simulation
  110570. * @param gravity defines the gravity vector to use
  110571. */
  110572. PhysicsEngine.prototype.setGravity = function (gravity) {
  110573. this.gravity = gravity;
  110574. this._physicsPlugin.setGravity(this.gravity);
  110575. };
  110576. /**
  110577. * Set the time step of the physics engine.
  110578. * Default is 1/60.
  110579. * To slow it down, enter 1/600 for example.
  110580. * To speed it up, 1/30
  110581. * @param newTimeStep defines the new timestep to apply to this world.
  110582. */
  110583. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  110584. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  110585. this._physicsPlugin.setTimeStep(newTimeStep);
  110586. };
  110587. /**
  110588. * Get the time step of the physics engine.
  110589. * @returns the current time step
  110590. */
  110591. PhysicsEngine.prototype.getTimeStep = function () {
  110592. return this._physicsPlugin.getTimeStep();
  110593. };
  110594. /**
  110595. * Release all resources
  110596. */
  110597. PhysicsEngine.prototype.dispose = function () {
  110598. this._impostors.forEach(function (impostor) {
  110599. impostor.dispose();
  110600. });
  110601. this._physicsPlugin.dispose();
  110602. };
  110603. /**
  110604. * Gets the name of the current physics plugin
  110605. * @returns the name of the plugin
  110606. */
  110607. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  110608. return this._physicsPlugin.name;
  110609. };
  110610. /**
  110611. * Adding a new impostor for the impostor tracking.
  110612. * This will be done by the impostor itself.
  110613. * @param impostor the impostor to add
  110614. */
  110615. PhysicsEngine.prototype.addImpostor = function (impostor) {
  110616. impostor.uniqueId = this._impostors.push(impostor);
  110617. //if no parent, generate the body
  110618. if (!impostor.parent) {
  110619. this._physicsPlugin.generatePhysicsBody(impostor);
  110620. }
  110621. };
  110622. /**
  110623. * Remove an impostor from the engine.
  110624. * This impostor and its mesh will not longer be updated by the physics engine.
  110625. * @param impostor the impostor to remove
  110626. */
  110627. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  110628. var index = this._impostors.indexOf(impostor);
  110629. if (index > -1) {
  110630. var removed = this._impostors.splice(index, 1);
  110631. //Is it needed?
  110632. if (removed.length) {
  110633. //this will also remove it from the world.
  110634. removed[0].physicsBody = null;
  110635. }
  110636. }
  110637. };
  110638. /**
  110639. * Add a joint to the physics engine
  110640. * @param mainImpostor defines the main impostor to which the joint is added.
  110641. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  110642. * @param joint defines the joint that will connect both impostors.
  110643. */
  110644. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  110645. var impostorJoint = {
  110646. mainImpostor: mainImpostor,
  110647. connectedImpostor: connectedImpostor,
  110648. joint: joint
  110649. };
  110650. joint.physicsPlugin = this._physicsPlugin;
  110651. this._joints.push(impostorJoint);
  110652. this._physicsPlugin.generateJoint(impostorJoint);
  110653. };
  110654. /**
  110655. * Removes a joint from the simulation
  110656. * @param mainImpostor defines the impostor used with the joint
  110657. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  110658. * @param joint defines the joint to remove
  110659. */
  110660. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  110661. var matchingJoints = this._joints.filter(function (impostorJoint) {
  110662. return (impostorJoint.connectedImpostor === connectedImpostor
  110663. && impostorJoint.joint === joint
  110664. && impostorJoint.mainImpostor === mainImpostor);
  110665. });
  110666. if (matchingJoints.length) {
  110667. this._physicsPlugin.removeJoint(matchingJoints[0]);
  110668. //TODO remove it from the list as well
  110669. }
  110670. };
  110671. /**
  110672. * Called by the scene. No need to call it.
  110673. * @param delta defines the timespam between frames
  110674. */
  110675. PhysicsEngine.prototype._step = function (delta) {
  110676. var _this = this;
  110677. //check if any mesh has no body / requires an update
  110678. this._impostors.forEach(function (impostor) {
  110679. if (impostor.isBodyInitRequired()) {
  110680. _this._physicsPlugin.generatePhysicsBody(impostor);
  110681. }
  110682. });
  110683. if (delta > 0.1) {
  110684. delta = 0.1;
  110685. }
  110686. else if (delta <= 0) {
  110687. delta = 1.0 / 60.0;
  110688. }
  110689. this._physicsPlugin.executeStep(delta, this._impostors);
  110690. };
  110691. /**
  110692. * Gets the current plugin used to run the simulation
  110693. * @returns current plugin
  110694. */
  110695. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  110696. return this._physicsPlugin;
  110697. };
  110698. /**
  110699. * Gets the list of physic impostors
  110700. * @returns an array of PhysicsImpostor
  110701. */
  110702. PhysicsEngine.prototype.getImpostors = function () {
  110703. return this._impostors;
  110704. };
  110705. /**
  110706. * Gets the impostor for a physics enabled object
  110707. * @param object defines the object impersonated by the impostor
  110708. * @returns the PhysicsImpostor or null if not found
  110709. */
  110710. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  110711. for (var i = 0; i < this._impostors.length; ++i) {
  110712. if (this._impostors[i].object === object) {
  110713. return this._impostors[i];
  110714. }
  110715. }
  110716. return null;
  110717. };
  110718. /**
  110719. * Gets the impostor for a physics body object
  110720. * @param body defines physics body used by the impostor
  110721. * @returns the PhysicsImpostor or null if not found
  110722. */
  110723. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  110724. for (var i = 0; i < this._impostors.length; ++i) {
  110725. if (this._impostors[i].physicsBody === body) {
  110726. return this._impostors[i];
  110727. }
  110728. }
  110729. return null;
  110730. };
  110731. /**
  110732. * Global value used to control the smallest number supported by the simulation
  110733. */
  110734. PhysicsEngine.Epsilon = 0.001;
  110735. return PhysicsEngine;
  110736. }());
  110737. /***/ }),
  110738. /***/ "./Physics/physicsEngineComponent.ts":
  110739. /*!*******************************************!*\
  110740. !*** ./Physics/physicsEngineComponent.ts ***!
  110741. \*******************************************/
  110742. /*! exports provided: PhysicsEngineSceneComponent */
  110743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110744. "use strict";
  110745. __webpack_require__.r(__webpack_exports__);
  110746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  110747. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110748. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  110749. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110750. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  110751. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  110752. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110753. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110754. /**
  110755. * Gets the current physics engine
  110756. * @returns a IPhysicsEngine or null if none attached
  110757. */
  110758. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  110759. return this._physicsEngine;
  110760. };
  110761. /**
  110762. * Enables physics to the current scene
  110763. * @param gravity defines the scene's gravity for the physics engine
  110764. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110765. * @return a boolean indicating if the physics engine was initialized
  110766. */
  110767. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  110768. if (gravity === void 0) { gravity = null; }
  110769. if (this._physicsEngine) {
  110770. return true;
  110771. }
  110772. // Register the component to the scene
  110773. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  110774. if (!component) {
  110775. component = new PhysicsEngineSceneComponent(this);
  110776. this._addComponent(component);
  110777. }
  110778. try {
  110779. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  110780. return true;
  110781. }
  110782. catch (e) {
  110783. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  110784. return false;
  110785. }
  110786. };
  110787. /**
  110788. * Disables and disposes the physics engine associated with the scene
  110789. */
  110790. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  110791. if (!this._physicsEngine) {
  110792. return;
  110793. }
  110794. this._physicsEngine.dispose();
  110795. this._physicsEngine = null;
  110796. };
  110797. /**
  110798. * Gets a boolean indicating if there is an active physics engine
  110799. * @returns a boolean indicating if there is an active physics engine
  110800. */
  110801. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  110802. return this._physicsEngine !== undefined;
  110803. };
  110804. /**
  110805. * Deletes a physics compound impostor
  110806. * @param compound defines the compound to delete
  110807. */
  110808. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  110809. var mesh = compound.parts[0].mesh;
  110810. if (mesh.physicsImpostor) {
  110811. mesh.physicsImpostor.dispose( /*true*/);
  110812. mesh.physicsImpostor = null;
  110813. }
  110814. };
  110815. /** @hidden */
  110816. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  110817. if (this._physicsEngine) {
  110818. this.onBeforePhysicsObservable.notifyObservers(this);
  110819. this._physicsEngine._step(step / 1000);
  110820. this.onAfterPhysicsObservable.notifyObservers(this);
  110821. }
  110822. };
  110823. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  110824. get: function () {
  110825. return this._physicsImpostor;
  110826. },
  110827. set: function (value) {
  110828. var _this = this;
  110829. if (this._physicsImpostor === value) {
  110830. return;
  110831. }
  110832. if (this._disposePhysicsObserver) {
  110833. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  110834. }
  110835. this._physicsImpostor = value;
  110836. if (value) {
  110837. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  110838. // Physics
  110839. if (_this.physicsImpostor) {
  110840. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  110841. _this.physicsImpostor = null;
  110842. }
  110843. });
  110844. }
  110845. },
  110846. enumerable: true,
  110847. configurable: true
  110848. });
  110849. /**
  110850. * Gets the current physics impostor
  110851. * @see http://doc.babylonjs.com/features/physics_engine
  110852. * @returns a physics impostor or null
  110853. */
  110854. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  110855. return this.physicsImpostor;
  110856. };
  110857. /**
  110858. * Apply a physic impulse to the mesh
  110859. * @param force defines the force to apply
  110860. * @param contactPoint defines where to apply the force
  110861. * @returns the current mesh
  110862. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110863. */
  110864. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  110865. if (!this.physicsImpostor) {
  110866. return this;
  110867. }
  110868. this.physicsImpostor.applyImpulse(force, contactPoint);
  110869. return this;
  110870. };
  110871. /**
  110872. * Creates a physic joint between two meshes
  110873. * @param otherMesh defines the other mesh to use
  110874. * @param pivot1 defines the pivot to use on this mesh
  110875. * @param pivot2 defines the pivot to use on the other mesh
  110876. * @param options defines additional options (can be plugin dependent)
  110877. * @returns the current mesh
  110878. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110879. */
  110880. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  110881. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  110882. return this;
  110883. }
  110884. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  110885. mainPivot: pivot1,
  110886. connectedPivot: pivot2,
  110887. nativeParams: options
  110888. });
  110889. return this;
  110890. };
  110891. /**
  110892. * Defines the physics engine scene component responsible to manage a physics engine
  110893. */
  110894. var PhysicsEngineSceneComponent = /** @class */ (function () {
  110895. /**
  110896. * Creates a new instance of the component for the given scene
  110897. * @param scene Defines the scene to register the component in
  110898. */
  110899. function PhysicsEngineSceneComponent(scene) {
  110900. var _this = this;
  110901. /**
  110902. * The component name helpful to identify the component in the list of scene components.
  110903. */
  110904. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  110905. this.scene = scene;
  110906. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  110907. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  110908. // Replace the function used to get the deterministic frame time
  110909. this.scene.getDeterministicFrameTime = function () {
  110910. if (_this.scene._physicsEngine) {
  110911. return _this.scene._physicsEngine.getTimeStep() * 1000;
  110912. }
  110913. return 1000.0 / 60.0;
  110914. };
  110915. }
  110916. /**
  110917. * Registers the component in a given scene
  110918. */
  110919. PhysicsEngineSceneComponent.prototype.register = function () {
  110920. };
  110921. /**
  110922. * Rebuilds the elements related to this component in case of
  110923. * context lost for instance.
  110924. */
  110925. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  110926. // Nothing to do for this component
  110927. };
  110928. /**
  110929. * Disposes the component and the associated ressources
  110930. */
  110931. PhysicsEngineSceneComponent.prototype.dispose = function () {
  110932. this.scene.onBeforePhysicsObservable.clear();
  110933. this.scene.onAfterPhysicsObservable.clear();
  110934. if (this.scene._physicsEngine) {
  110935. this.scene.disablePhysicsEngine();
  110936. }
  110937. };
  110938. return PhysicsEngineSceneComponent;
  110939. }());
  110940. /***/ }),
  110941. /***/ "./Physics/physicsHelper.ts":
  110942. /*!**********************************!*\
  110943. !*** ./Physics/physicsHelper.ts ***!
  110944. \**********************************/
  110945. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  110946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110947. "use strict";
  110948. __webpack_require__.r(__webpack_exports__);
  110949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  110950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  110951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  110952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  110953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  110954. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  110955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  110956. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110957. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110958. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  110959. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  110960. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  110961. /**
  110962. * A helper for physics simulations
  110963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110964. */
  110965. var PhysicsHelper = /** @class */ (function () {
  110966. /**
  110967. * Initializes the Physics helper
  110968. * @param scene Babylon.js scene
  110969. */
  110970. function PhysicsHelper(scene) {
  110971. this._scene = scene;
  110972. this._physicsEngine = this._scene.getPhysicsEngine();
  110973. if (!this._physicsEngine) {
  110974. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  110975. }
  110976. }
  110977. /**
  110978. * Applies a radial explosion impulse
  110979. * @param origin the origin of the explosion
  110980. * @param radius the explosion radius
  110981. * @param strength the explosion strength
  110982. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110983. * @returns A physics radial explosion event, or null
  110984. */
  110985. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  110986. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110987. if (!this._physicsEngine) {
  110988. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  110989. return null;
  110990. }
  110991. var impostors = this._physicsEngine.getImpostors();
  110992. if (impostors.length === 0) {
  110993. return null;
  110994. }
  110995. var event = new PhysicsRadialExplosionEvent(this._scene);
  110996. impostors.forEach(function (impostor) {
  110997. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110998. if (!impostorForceAndContactPoint) {
  110999. return;
  111000. }
  111001. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111002. });
  111003. event.dispose(false);
  111004. return event;
  111005. };
  111006. /**
  111007. * Applies a radial explosion force
  111008. * @param origin the origin of the explosion
  111009. * @param radius the explosion radius
  111010. * @param strength the explosion strength
  111011. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111012. * @returns A physics radial explosion event, or null
  111013. */
  111014. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  111015. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111016. if (!this._physicsEngine) {
  111017. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111018. return null;
  111019. }
  111020. var impostors = this._physicsEngine.getImpostors();
  111021. if (impostors.length === 0) {
  111022. return null;
  111023. }
  111024. var event = new PhysicsRadialExplosionEvent(this._scene);
  111025. impostors.forEach(function (impostor) {
  111026. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111027. if (!impostorForceAndContactPoint) {
  111028. return;
  111029. }
  111030. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111031. });
  111032. event.dispose(false);
  111033. return event;
  111034. };
  111035. /**
  111036. * Creates a gravitational field
  111037. * @param origin the origin of the explosion
  111038. * @param radius the explosion radius
  111039. * @param strength the explosion strength
  111040. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111041. * @returns A physics gravitational field event, or null
  111042. */
  111043. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  111044. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111045. if (!this._physicsEngine) {
  111046. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111047. return null;
  111048. }
  111049. var impostors = this._physicsEngine.getImpostors();
  111050. if (impostors.length === 0) {
  111051. return null;
  111052. }
  111053. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  111054. event.dispose(false);
  111055. return event;
  111056. };
  111057. /**
  111058. * Creates a physics updraft event
  111059. * @param origin the origin of the updraft
  111060. * @param radius the radius of the updraft
  111061. * @param strength the strength of the updraft
  111062. * @param height the height of the updraft
  111063. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111064. * @returns A physics updraft event, or null
  111065. */
  111066. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  111067. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  111068. if (!this._physicsEngine) {
  111069. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111070. return null;
  111071. }
  111072. if (this._physicsEngine.getImpostors().length === 0) {
  111073. return null;
  111074. }
  111075. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  111076. event.dispose(false);
  111077. return event;
  111078. };
  111079. /**
  111080. * Creates a physics vortex event
  111081. * @param origin the of the vortex
  111082. * @param radius the radius of the vortex
  111083. * @param strength the strength of the vortex
  111084. * @param height the height of the vortex
  111085. * @returns a Physics vortex event, or null
  111086. * A physics vortex event or null
  111087. */
  111088. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  111089. if (!this._physicsEngine) {
  111090. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111091. return null;
  111092. }
  111093. if (this._physicsEngine.getImpostors().length === 0) {
  111094. return null;
  111095. }
  111096. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  111097. event.dispose(false);
  111098. return event;
  111099. };
  111100. return PhysicsHelper;
  111101. }());
  111102. /**
  111103. * Represents a physics radial explosion event
  111104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111105. */
  111106. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  111107. /**
  111108. * Initializes a radial explosioin event
  111109. * @param scene BabylonJS scene
  111110. */
  111111. function PhysicsRadialExplosionEvent(scene) {
  111112. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  111113. this._rays = [];
  111114. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  111115. this._scene = scene;
  111116. }
  111117. /**
  111118. * Returns the data related to the radial explosion event (sphere & rays).
  111119. * @returns The radial explosion event data
  111120. */
  111121. PhysicsRadialExplosionEvent.prototype.getData = function () {
  111122. this._dataFetched = true;
  111123. return {
  111124. sphere: this._sphere,
  111125. rays: this._rays,
  111126. };
  111127. };
  111128. /**
  111129. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111130. * @param impostor A physics imposter
  111131. * @param origin the origin of the explosion
  111132. * @param radius the explosion radius
  111133. * @param strength the explosion strength
  111134. * @param falloff possible options: Constant & Linear
  111135. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  111136. */
  111137. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  111138. if (impostor.mass === 0) {
  111139. return null;
  111140. }
  111141. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  111142. return null;
  111143. }
  111144. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111145. return null;
  111146. }
  111147. var impostorObjectCenter = impostor.getObjectCenter();
  111148. var direction = impostorObjectCenter.subtract(origin);
  111149. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  111150. this._rays.push(ray);
  111151. var hit = ray.intersectsMesh(impostor.object);
  111152. var contactPoint = hit.pickedPoint;
  111153. if (!contactPoint) {
  111154. return null;
  111155. }
  111156. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  111157. if (distanceFromOrigin > radius) {
  111158. return null;
  111159. }
  111160. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  111161. ? strength
  111162. : strength * (1 - (distanceFromOrigin / radius));
  111163. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111164. return { force: force, contactPoint: contactPoint };
  111165. };
  111166. /**
  111167. * Disposes the sphere.
  111168. * @param force Specifies if the sphere should be disposed by force
  111169. */
  111170. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  111171. var _this = this;
  111172. if (force === void 0) { force = true; }
  111173. if (force) {
  111174. this._sphere.dispose();
  111175. }
  111176. else {
  111177. setTimeout(function () {
  111178. if (!_this._dataFetched) {
  111179. _this._sphere.dispose();
  111180. }
  111181. }, 0);
  111182. }
  111183. };
  111184. /*** Helpers ***/
  111185. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  111186. if (!this._sphere) {
  111187. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  111188. this._sphere.isVisible = false;
  111189. }
  111190. };
  111191. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  111192. var impostorObject = impostor.object;
  111193. this._prepareSphere();
  111194. this._sphere.position = origin;
  111195. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  111196. this._sphere._updateBoundingInfo();
  111197. this._sphere.computeWorldMatrix(true);
  111198. return this._sphere.intersectsMesh(impostorObject, true);
  111199. };
  111200. return PhysicsRadialExplosionEvent;
  111201. }());
  111202. /**
  111203. * Represents a gravitational field event
  111204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111205. */
  111206. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  111207. /**
  111208. * Initializes the physics gravitational field event
  111209. * @param physicsHelper A physics helper
  111210. * @param scene BabylonJS scene
  111211. * @param origin The origin position of the gravitational field event
  111212. * @param radius The radius of the gravitational field event
  111213. * @param strength The strength of the gravitational field event
  111214. * @param falloff The falloff for the gravitational field event
  111215. */
  111216. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  111217. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111218. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111219. this._physicsHelper = physicsHelper;
  111220. this._scene = scene;
  111221. this._origin = origin;
  111222. this._radius = radius;
  111223. this._strength = strength;
  111224. this._falloff = falloff;
  111225. this._tickCallback = this._tick.bind(this);
  111226. }
  111227. /**
  111228. * Returns the data related to the gravitational field event (sphere).
  111229. * @returns A gravitational field event
  111230. */
  111231. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  111232. this._dataFetched = true;
  111233. return {
  111234. sphere: this._sphere,
  111235. };
  111236. };
  111237. /**
  111238. * Enables the gravitational field.
  111239. */
  111240. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  111241. this._tickCallback.call(this);
  111242. this._scene.registerBeforeRender(this._tickCallback);
  111243. };
  111244. /**
  111245. * Disables the gravitational field.
  111246. */
  111247. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  111248. this._scene.unregisterBeforeRender(this._tickCallback);
  111249. };
  111250. /**
  111251. * Disposes the sphere.
  111252. * @param force The force to dispose from the gravitational field event
  111253. */
  111254. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  111255. var _this = this;
  111256. if (force === void 0) { force = true; }
  111257. if (force) {
  111258. this._sphere.dispose();
  111259. }
  111260. else {
  111261. setTimeout(function () {
  111262. if (!_this._dataFetched) {
  111263. _this._sphere.dispose();
  111264. }
  111265. }, 0);
  111266. }
  111267. };
  111268. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  111269. // Since the params won't change, we fetch the event only once
  111270. if (this._sphere) {
  111271. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111272. }
  111273. else {
  111274. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111275. if (radialExplosionEvent) {
  111276. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  111277. }
  111278. }
  111279. };
  111280. return PhysicsGravitationalFieldEvent;
  111281. }());
  111282. /**
  111283. * Represents a physics updraft event
  111284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111285. */
  111286. var PhysicsUpdraftEvent = /** @class */ (function () {
  111287. /**
  111288. * Initializes the physics updraft event
  111289. * @param _scene BabylonJS scene
  111290. * @param _origin The origin position of the updraft
  111291. * @param _radius The radius of the updraft
  111292. * @param _strength The strength of the updraft
  111293. * @param _height The height of the updraft
  111294. * @param _updraftMode The mode of the updraft
  111295. */
  111296. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  111297. this._scene = _scene;
  111298. this._origin = _origin;
  111299. this._radius = _radius;
  111300. this._strength = _strength;
  111301. this._height = _height;
  111302. this._updraftMode = _updraftMode;
  111303. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111304. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  111305. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  111306. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111307. this._physicsEngine = this._scene.getPhysicsEngine();
  111308. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111309. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111310. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111311. this._originDirection = this._origin.subtract(this._originTop).normalize();
  111312. }
  111313. this._tickCallback = this._tick.bind(this);
  111314. this._prepareCylinder();
  111315. }
  111316. /**
  111317. * Returns the data related to the updraft event (cylinder).
  111318. * @returns A physics updraft event
  111319. */
  111320. PhysicsUpdraftEvent.prototype.getData = function () {
  111321. this._dataFetched = true;
  111322. return {
  111323. cylinder: this._cylinder,
  111324. };
  111325. };
  111326. /**
  111327. * Enables the updraft.
  111328. */
  111329. PhysicsUpdraftEvent.prototype.enable = function () {
  111330. this._tickCallback.call(this);
  111331. this._scene.registerBeforeRender(this._tickCallback);
  111332. };
  111333. /**
  111334. * Disables the cortex.
  111335. */
  111336. PhysicsUpdraftEvent.prototype.disable = function () {
  111337. this._scene.unregisterBeforeRender(this._tickCallback);
  111338. };
  111339. /**
  111340. * Disposes the sphere.
  111341. * @param force Specifies if the updraft should be disposed by force
  111342. */
  111343. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  111344. var _this = this;
  111345. if (force === void 0) { force = true; }
  111346. if (!this._cylinder) {
  111347. return;
  111348. }
  111349. if (force) {
  111350. this._cylinder.dispose();
  111351. }
  111352. else {
  111353. setTimeout(function () {
  111354. if (!_this._dataFetched) {
  111355. _this._cylinder.dispose();
  111356. }
  111357. }, 0);
  111358. }
  111359. };
  111360. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111361. if (impostor.mass === 0) {
  111362. return null;
  111363. }
  111364. if (!this._intersectsWithCylinder(impostor)) {
  111365. return null;
  111366. }
  111367. var impostorObjectCenter = impostor.getObjectCenter();
  111368. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111369. var direction = this._originDirection;
  111370. }
  111371. else {
  111372. var direction = impostorObjectCenter.subtract(this._originTop);
  111373. }
  111374. var multiplier = this._strength * -1;
  111375. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111376. return { force: force, contactPoint: impostorObjectCenter };
  111377. };
  111378. PhysicsUpdraftEvent.prototype._tick = function () {
  111379. var _this = this;
  111380. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111381. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111382. if (!impostorForceAndContactPoint) {
  111383. return;
  111384. }
  111385. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111386. });
  111387. };
  111388. /*** Helpers ***/
  111389. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  111390. if (!this._cylinder) {
  111391. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  111392. height: this._height,
  111393. diameter: this._radius * 2,
  111394. }, this._scene);
  111395. this._cylinder.isVisible = false;
  111396. }
  111397. };
  111398. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  111399. var impostorObject = impostor.object;
  111400. this._cylinder.position = this._cylinderPosition;
  111401. return this._cylinder.intersectsMesh(impostorObject, true);
  111402. };
  111403. return PhysicsUpdraftEvent;
  111404. }());
  111405. /**
  111406. * Represents a physics vortex event
  111407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111408. */
  111409. var PhysicsVortexEvent = /** @class */ (function () {
  111410. /**
  111411. * Initializes the physics vortex event
  111412. * @param _scene The BabylonJS scene
  111413. * @param _origin The origin position of the vortex
  111414. * @param _radius The radius of the vortex
  111415. * @param _strength The strength of the vortex
  111416. * @param _height The height of the vortex
  111417. */
  111418. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  111419. this._scene = _scene;
  111420. this._origin = _origin;
  111421. this._radius = _radius;
  111422. this._strength = _strength;
  111423. this._height = _height;
  111424. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111425. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  111426. this._updraftMultiplier = 0.02;
  111427. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  111428. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111429. this._physicsEngine = this._scene.getPhysicsEngine();
  111430. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111431. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111432. this._tickCallback = this._tick.bind(this);
  111433. this._prepareCylinder();
  111434. }
  111435. /**
  111436. * Returns the data related to the vortex event (cylinder).
  111437. * @returns The physics vortex event data
  111438. */
  111439. PhysicsVortexEvent.prototype.getData = function () {
  111440. this._dataFetched = true;
  111441. return {
  111442. cylinder: this._cylinder,
  111443. };
  111444. };
  111445. /**
  111446. * Enables the vortex.
  111447. */
  111448. PhysicsVortexEvent.prototype.enable = function () {
  111449. this._tickCallback.call(this);
  111450. this._scene.registerBeforeRender(this._tickCallback);
  111451. };
  111452. /**
  111453. * Disables the cortex.
  111454. */
  111455. PhysicsVortexEvent.prototype.disable = function () {
  111456. this._scene.unregisterBeforeRender(this._tickCallback);
  111457. };
  111458. /**
  111459. * Disposes the sphere.
  111460. * @param force
  111461. */
  111462. PhysicsVortexEvent.prototype.dispose = function (force) {
  111463. var _this = this;
  111464. if (force === void 0) { force = true; }
  111465. if (force) {
  111466. this._cylinder.dispose();
  111467. }
  111468. else {
  111469. setTimeout(function () {
  111470. if (!_this._dataFetched) {
  111471. _this._cylinder.dispose();
  111472. }
  111473. }, 0);
  111474. }
  111475. };
  111476. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111477. if (impostor.mass === 0) {
  111478. return null;
  111479. }
  111480. if (!this._intersectsWithCylinder(impostor)) {
  111481. return null;
  111482. }
  111483. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111484. return null;
  111485. }
  111486. var impostorObjectCenter = impostor.getObjectCenter();
  111487. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  111488. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  111489. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  111490. var hit = ray.intersectsMesh(impostor.object);
  111491. var contactPoint = hit.pickedPoint;
  111492. if (!contactPoint) {
  111493. return null;
  111494. }
  111495. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  111496. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  111497. var directionToOrigin = contactPoint.normalize();
  111498. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111499. directionToOrigin = directionToOrigin.negate();
  111500. }
  111501. // TODO: find a more physically based solution
  111502. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111503. var forceX = directionToOrigin.x * this._strength / 8;
  111504. var forceY = directionToOrigin.y * this._updraftMultiplier;
  111505. var forceZ = directionToOrigin.z * this._strength / 8;
  111506. }
  111507. else {
  111508. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  111509. var forceY = this._originTop.y * this._updraftMultiplier;
  111510. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  111511. }
  111512. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  111513. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  111514. return { force: force, contactPoint: impostorObjectCenter };
  111515. };
  111516. PhysicsVortexEvent.prototype._tick = function () {
  111517. var _this = this;
  111518. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111519. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111520. if (!impostorForceAndContactPoint) {
  111521. return;
  111522. }
  111523. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111524. });
  111525. };
  111526. /*** Helpers ***/
  111527. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  111528. if (!this._cylinder) {
  111529. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  111530. height: this._height,
  111531. diameter: this._radius * 2,
  111532. }, this._scene);
  111533. this._cylinder.isVisible = false;
  111534. }
  111535. };
  111536. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  111537. var impostorObject = impostor.object;
  111538. this._cylinder.position = this._cylinderPosition;
  111539. return this._cylinder.intersectsMesh(impostorObject, true);
  111540. };
  111541. return PhysicsVortexEvent;
  111542. }());
  111543. /**
  111544. * The strenght of the force in correspondence to the distance of the affected object
  111545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111546. */
  111547. var PhysicsRadialImpulseFalloff;
  111548. (function (PhysicsRadialImpulseFalloff) {
  111549. /** Defines that impulse is constant in strength across it's whole radius */
  111550. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  111551. /** DEfines that impulse gets weaker if it's further from the origin */
  111552. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  111553. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  111554. /**
  111555. * The strength of the force in correspondence to the distance of the affected object
  111556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111557. */
  111558. var PhysicsUpdraftMode;
  111559. (function (PhysicsUpdraftMode) {
  111560. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111561. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  111562. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111563. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  111564. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  111565. /***/ }),
  111566. /***/ "./Physics/physicsImpostor.ts":
  111567. /*!************************************!*\
  111568. !*** ./Physics/physicsImpostor.ts ***!
  111569. \************************************/
  111570. /*! exports provided: PhysicsImpostor */
  111571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111572. "use strict";
  111573. __webpack_require__.r(__webpack_exports__);
  111574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  111575. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111576. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  111577. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111578. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111579. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111580. /**
  111581. * Represents a physics imposter
  111582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111583. */
  111584. var PhysicsImpostor = /** @class */ (function () {
  111585. /**
  111586. * Initializes the physics imposter
  111587. * @param object The physics-enabled object used as the physics imposter
  111588. * @param type The type of the physics imposter
  111589. * @param _options The options for the physics imposter
  111590. * @param _scene The Babylon scene
  111591. */
  111592. function PhysicsImpostor(
  111593. /**
  111594. * The physics-enabled object used as the physics imposter
  111595. */
  111596. object,
  111597. /**
  111598. * The type of the physics imposter
  111599. */
  111600. type, _options, _scene) {
  111601. if (_options === void 0) { _options = { mass: 0 }; }
  111602. var _this = this;
  111603. this.object = object;
  111604. this.type = type;
  111605. this._options = _options;
  111606. this._scene = _scene;
  111607. this._bodyUpdateRequired = false;
  111608. this._onBeforePhysicsStepCallbacks = new Array();
  111609. this._onAfterPhysicsStepCallbacks = new Array();
  111610. /** @hidden */
  111611. this._onPhysicsCollideCallbacks = [];
  111612. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111613. this._isDisposed = false;
  111614. //temp variables for parent rotation calculations
  111615. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  111616. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111617. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111618. /**
  111619. * this function is executed by the physics engine.
  111620. */
  111621. this.beforeStep = function () {
  111622. if (!_this._physicsEngine) {
  111623. return;
  111624. }
  111625. _this.object.translate(_this._deltaPosition, -1);
  111626. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  111627. _this.object.computeWorldMatrix(false);
  111628. if (_this.object.parent && _this.object.rotationQuaternion) {
  111629. _this.getParentsRotation();
  111630. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  111631. }
  111632. else {
  111633. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  111634. }
  111635. if (!_this._options.disableBidirectionalTransformation) {
  111636. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  111637. }
  111638. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  111639. func(_this);
  111640. });
  111641. };
  111642. /**
  111643. * this function is executed by the physics engine
  111644. */
  111645. this.afterStep = function () {
  111646. if (!_this._physicsEngine) {
  111647. return;
  111648. }
  111649. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  111650. func(_this);
  111651. });
  111652. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  111653. // object has now its world rotation. needs to be converted to local.
  111654. if (_this.object.parent && _this.object.rotationQuaternion) {
  111655. _this.getParentsRotation();
  111656. _this._tmpQuat.conjugateInPlace();
  111657. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  111658. }
  111659. // take the position set and make it the absolute position of this object.
  111660. _this.object.setAbsolutePosition(_this.object.position);
  111661. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  111662. _this.object.translate(_this._deltaPosition, 1);
  111663. };
  111664. /**
  111665. * Legacy collision detection event support
  111666. */
  111667. this.onCollideEvent = null;
  111668. /**
  111669. * event and body object due to cannon's event-based architecture.
  111670. */
  111671. this.onCollide = function (e) {
  111672. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  111673. return;
  111674. }
  111675. if (!_this._physicsEngine) {
  111676. return;
  111677. }
  111678. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  111679. if (otherImpostor) {
  111680. // Legacy collision detection event support
  111681. if (_this.onCollideEvent) {
  111682. _this.onCollideEvent(_this, otherImpostor);
  111683. }
  111684. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  111685. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  111686. }).forEach(function (obj) {
  111687. obj.callback(_this, otherImpostor);
  111688. });
  111689. }
  111690. };
  111691. //sanity check!
  111692. if (!this.object) {
  111693. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  111694. return;
  111695. }
  111696. // Legacy support for old syntax.
  111697. if (!this._scene && object.getScene) {
  111698. this._scene = object.getScene();
  111699. }
  111700. if (!this._scene) {
  111701. return;
  111702. }
  111703. this._physicsEngine = this._scene.getPhysicsEngine();
  111704. if (!this._physicsEngine) {
  111705. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  111706. }
  111707. else {
  111708. //set the object's quaternion, if not set
  111709. if (!this.object.rotationQuaternion) {
  111710. if (this.object.rotation) {
  111711. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  111712. }
  111713. else {
  111714. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111715. }
  111716. }
  111717. //default options params
  111718. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  111719. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  111720. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  111721. this._joints = [];
  111722. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  111723. if (!this.object.parent || this._options.ignoreParent) {
  111724. this._init();
  111725. }
  111726. else if (this.object.parent.physicsImpostor) {
  111727. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  111728. }
  111729. }
  111730. }
  111731. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  111732. /**
  111733. * Specifies if the physics imposter is disposed
  111734. */
  111735. get: function () {
  111736. return this._isDisposed;
  111737. },
  111738. enumerable: true,
  111739. configurable: true
  111740. });
  111741. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  111742. /**
  111743. * Gets the mass of the physics imposter
  111744. */
  111745. get: function () {
  111746. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  111747. },
  111748. set: function (value) {
  111749. this.setMass(value);
  111750. },
  111751. enumerable: true,
  111752. configurable: true
  111753. });
  111754. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  111755. /**
  111756. * Gets the coefficient of friction
  111757. */
  111758. get: function () {
  111759. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  111760. },
  111761. /**
  111762. * Sets the coefficient of friction
  111763. */
  111764. set: function (value) {
  111765. if (!this._physicsEngine) {
  111766. return;
  111767. }
  111768. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  111769. },
  111770. enumerable: true,
  111771. configurable: true
  111772. });
  111773. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  111774. /**
  111775. * Gets the coefficient of restitution
  111776. */
  111777. get: function () {
  111778. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  111779. },
  111780. /**
  111781. * Sets the coefficient of restitution
  111782. */
  111783. set: function (value) {
  111784. if (!this._physicsEngine) {
  111785. return;
  111786. }
  111787. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  111788. },
  111789. enumerable: true,
  111790. configurable: true
  111791. });
  111792. /**
  111793. * This function will completly initialize this impostor.
  111794. * It will create a new body - but only if this mesh has no parent.
  111795. * If it has, this impostor will not be used other than to define the impostor
  111796. * of the child mesh.
  111797. * @hidden
  111798. */
  111799. PhysicsImpostor.prototype._init = function () {
  111800. if (!this._physicsEngine) {
  111801. return;
  111802. }
  111803. this._physicsEngine.removeImpostor(this);
  111804. this.physicsBody = null;
  111805. this._parent = this._parent || this._getPhysicsParent();
  111806. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  111807. this._physicsEngine.addImpostor(this);
  111808. }
  111809. };
  111810. PhysicsImpostor.prototype._getPhysicsParent = function () {
  111811. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  111812. var parentMesh = this.object.parent;
  111813. return parentMesh.physicsImpostor;
  111814. }
  111815. return null;
  111816. };
  111817. /**
  111818. * Should a new body be generated.
  111819. * @returns boolean specifying if body initialization is required
  111820. */
  111821. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  111822. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  111823. };
  111824. /**
  111825. * Sets the updated scaling
  111826. * @param updated Specifies if the scaling is updated
  111827. */
  111828. PhysicsImpostor.prototype.setScalingUpdated = function () {
  111829. this.forceUpdate();
  111830. };
  111831. /**
  111832. * Force a regeneration of this or the parent's impostor's body.
  111833. * Use under cautious - This will remove all joints already implemented.
  111834. */
  111835. PhysicsImpostor.prototype.forceUpdate = function () {
  111836. this._init();
  111837. if (this.parent && !this._options.ignoreParent) {
  111838. this.parent.forceUpdate();
  111839. }
  111840. };
  111841. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  111842. /*public get mesh(): AbstractMesh {
  111843. return this._mesh;
  111844. }*/
  111845. /**
  111846. * Gets the body that holds this impostor. Either its own, or its parent.
  111847. */
  111848. get: function () {
  111849. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  111850. },
  111851. /**
  111852. * Set the physics body. Used mainly by the physics engine/plugin
  111853. */
  111854. set: function (physicsBody) {
  111855. if (this._physicsBody && this._physicsEngine) {
  111856. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  111857. }
  111858. this._physicsBody = physicsBody;
  111859. this.resetUpdateFlags();
  111860. },
  111861. enumerable: true,
  111862. configurable: true
  111863. });
  111864. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  111865. /**
  111866. * Get the parent of the physics imposter
  111867. * @returns Physics imposter or null
  111868. */
  111869. get: function () {
  111870. return !this._options.ignoreParent && this._parent ? this._parent : null;
  111871. },
  111872. /**
  111873. * Sets the parent of the physics imposter
  111874. */
  111875. set: function (value) {
  111876. this._parent = value;
  111877. },
  111878. enumerable: true,
  111879. configurable: true
  111880. });
  111881. /**
  111882. * Resets the update flags
  111883. */
  111884. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  111885. this._bodyUpdateRequired = false;
  111886. };
  111887. /**
  111888. * Gets the object extend size
  111889. * @returns the object extend size
  111890. */
  111891. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  111892. if (this.object.getBoundingInfo) {
  111893. var q = this.object.rotationQuaternion;
  111894. //reset rotation
  111895. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  111896. //calculate the world matrix with no rotation
  111897. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  111898. var boundingInfo = this.object.getBoundingInfo();
  111899. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  111900. //bring back the rotation
  111901. this.object.rotationQuaternion = q;
  111902. //calculate the world matrix with the new rotation
  111903. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  111904. return size;
  111905. }
  111906. else {
  111907. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  111908. }
  111909. };
  111910. /**
  111911. * Gets the object center
  111912. * @returns The object center
  111913. */
  111914. PhysicsImpostor.prototype.getObjectCenter = function () {
  111915. if (this.object.getBoundingInfo) {
  111916. var boundingInfo = this.object.getBoundingInfo();
  111917. return boundingInfo.boundingBox.centerWorld;
  111918. }
  111919. else {
  111920. return this.object.position;
  111921. }
  111922. };
  111923. /**
  111924. * Get a specific parametes from the options parameter
  111925. * @param paramName The object parameter name
  111926. * @returns The object parameter
  111927. */
  111928. PhysicsImpostor.prototype.getParam = function (paramName) {
  111929. return this._options[paramName];
  111930. };
  111931. /**
  111932. * Sets a specific parameter in the options given to the physics plugin
  111933. * @param paramName The parameter name
  111934. * @param value The value of the parameter
  111935. */
  111936. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  111937. this._options[paramName] = value;
  111938. this._bodyUpdateRequired = true;
  111939. };
  111940. /**
  111941. * Specifically change the body's mass option. Won't recreate the physics body object
  111942. * @param mass The mass of the physics imposter
  111943. */
  111944. PhysicsImpostor.prototype.setMass = function (mass) {
  111945. if (this.getParam("mass") !== mass) {
  111946. this.setParam("mass", mass);
  111947. }
  111948. if (this._physicsEngine) {
  111949. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  111950. }
  111951. };
  111952. /**
  111953. * Gets the linear velocity
  111954. * @returns linear velocity or null
  111955. */
  111956. PhysicsImpostor.prototype.getLinearVelocity = function () {
  111957. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111958. };
  111959. /**
  111960. * Sets the linear velocity
  111961. * @param velocity linear velocity or null
  111962. */
  111963. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  111964. if (this._physicsEngine) {
  111965. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  111966. }
  111967. };
  111968. /**
  111969. * Gets the angular velocity
  111970. * @returns angular velocity or null
  111971. */
  111972. PhysicsImpostor.prototype.getAngularVelocity = function () {
  111973. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111974. };
  111975. /**
  111976. * Sets the angular velocity
  111977. * @param velocity The velocity or null
  111978. */
  111979. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  111980. if (this._physicsEngine) {
  111981. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  111982. }
  111983. };
  111984. /**
  111985. * Execute a function with the physics plugin native code
  111986. * Provide a function the will have two variables - the world object and the physics body object
  111987. * @param func The function to execute with the physics plugin native code
  111988. */
  111989. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  111990. if (this._physicsEngine) {
  111991. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  111992. }
  111993. };
  111994. /**
  111995. * Register a function that will be executed before the physics world is stepping forward
  111996. * @param func The function to execute before the physics world is stepped forward
  111997. */
  111998. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  111999. this._onBeforePhysicsStepCallbacks.push(func);
  112000. };
  112001. /**
  112002. * Unregister a function that will be executed before the physics world is stepping forward
  112003. * @param func The function to execute before the physics world is stepped forward
  112004. */
  112005. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  112006. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  112007. if (index > -1) {
  112008. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  112009. }
  112010. else {
  112011. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112012. }
  112013. };
  112014. /**
  112015. * Register a function that will be executed after the physics step
  112016. * @param func The function to execute after physics step
  112017. */
  112018. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  112019. this._onAfterPhysicsStepCallbacks.push(func);
  112020. };
  112021. /**
  112022. * Unregisters a function that will be executed after the physics step
  112023. * @param func The function to execute after physics step
  112024. */
  112025. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  112026. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  112027. if (index > -1) {
  112028. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  112029. }
  112030. else {
  112031. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112032. }
  112033. };
  112034. /**
  112035. * register a function that will be executed when this impostor collides against a different body
  112036. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112037. * @param func Callback that is executed on collision
  112038. */
  112039. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  112040. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112041. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  112042. };
  112043. /**
  112044. * Unregisters the physics imposter on contact
  112045. * @param collideAgainst The physics object to collide against
  112046. * @param func Callback to execute on collision
  112047. */
  112048. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  112049. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112050. var index = -1;
  112051. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  112052. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  112053. // chcek the arrays match
  112054. var sameList = cbDef.otherImpostors.every(function (impostor) {
  112055. return collidedAgainstList.indexOf(impostor) > -1;
  112056. });
  112057. if (sameList) {
  112058. index = idx;
  112059. }
  112060. return sameList;
  112061. }
  112062. return false;
  112063. });
  112064. if (found) {
  112065. this._onPhysicsCollideCallbacks.splice(index, 1);
  112066. }
  112067. else {
  112068. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112069. }
  112070. };
  112071. /**
  112072. * Get the parent rotation
  112073. * @returns The parent rotation
  112074. */
  112075. PhysicsImpostor.prototype.getParentsRotation = function () {
  112076. var parent = this.object.parent;
  112077. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  112078. while (parent) {
  112079. if (parent.rotationQuaternion) {
  112080. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  112081. }
  112082. else {
  112083. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  112084. }
  112085. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  112086. parent = parent.parent;
  112087. }
  112088. return this._tmpQuat;
  112089. };
  112090. /**
  112091. * Apply a force
  112092. * @param force The force to apply
  112093. * @param contactPoint The contact point for the force
  112094. * @returns The physics imposter
  112095. */
  112096. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  112097. if (this._physicsEngine) {
  112098. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  112099. }
  112100. return this;
  112101. };
  112102. /**
  112103. * Apply an impulse
  112104. * @param force The impulse force
  112105. * @param contactPoint The contact point for the impulse force
  112106. * @returns The physics imposter
  112107. */
  112108. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  112109. if (this._physicsEngine) {
  112110. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  112111. }
  112112. return this;
  112113. };
  112114. /**
  112115. * A help function to create a joint
  112116. * @param otherImpostor A physics imposter used to create a joint
  112117. * @param jointType The type of joint
  112118. * @param jointData The data for the joint
  112119. * @returns The physics imposter
  112120. */
  112121. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  112122. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"](jointType, jointData);
  112123. this.addJoint(otherImpostor, joint);
  112124. return this;
  112125. };
  112126. /**
  112127. * Add a joint to this impostor with a different impostor
  112128. * @param otherImpostor A physics imposter used to add a joint
  112129. * @param joint The joint to add
  112130. * @returns The physics imposter
  112131. */
  112132. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  112133. this._joints.push({
  112134. otherImpostor: otherImpostor,
  112135. joint: joint
  112136. });
  112137. if (this._physicsEngine) {
  112138. this._physicsEngine.addJoint(this, otherImpostor, joint);
  112139. }
  112140. return this;
  112141. };
  112142. /**
  112143. * Will keep this body still, in a sleep mode.
  112144. * @returns the physics imposter
  112145. */
  112146. PhysicsImpostor.prototype.sleep = function () {
  112147. if (this._physicsEngine) {
  112148. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  112149. }
  112150. return this;
  112151. };
  112152. /**
  112153. * Wake the body up.
  112154. * @returns The physics imposter
  112155. */
  112156. PhysicsImpostor.prototype.wakeUp = function () {
  112157. if (this._physicsEngine) {
  112158. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  112159. }
  112160. return this;
  112161. };
  112162. /**
  112163. * Clones the physics imposter
  112164. * @param newObject The physics imposter clones to this physics-enabled object
  112165. * @returns A nullable physics imposter
  112166. */
  112167. PhysicsImpostor.prototype.clone = function (newObject) {
  112168. if (!newObject) {
  112169. return null;
  112170. }
  112171. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  112172. };
  112173. /**
  112174. * Disposes the physics imposter
  112175. */
  112176. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  112177. var _this = this;
  112178. //no dispose if no physics engine is available.
  112179. if (!this._physicsEngine) {
  112180. return;
  112181. }
  112182. this._joints.forEach(function (j) {
  112183. if (_this._physicsEngine) {
  112184. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  112185. }
  112186. });
  112187. //dispose the physics body
  112188. this._physicsEngine.removeImpostor(this);
  112189. if (this.parent) {
  112190. this.parent.forceUpdate();
  112191. }
  112192. else {
  112193. /*this._object.getChildMeshes().forEach(function(mesh) {
  112194. if (mesh.physicsImpostor) {
  112195. if (disposeChildren) {
  112196. mesh.physicsImpostor.dispose();
  112197. mesh.physicsImpostor = null;
  112198. }
  112199. }
  112200. })*/
  112201. }
  112202. this._isDisposed = true;
  112203. };
  112204. /**
  112205. * Sets the delta position
  112206. * @param position The delta position amount
  112207. */
  112208. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  112209. this._deltaPosition.copyFrom(position);
  112210. };
  112211. /**
  112212. * Sets the delta rotation
  112213. * @param rotation The delta rotation amount
  112214. */
  112215. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  112216. if (!this._deltaRotation) {
  112217. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112218. }
  112219. this._deltaRotation.copyFrom(rotation);
  112220. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  112221. };
  112222. /**
  112223. * Gets the box size of the physics imposter and stores the result in the input parameter
  112224. * @param result Stores the box size
  112225. * @returns The physics imposter
  112226. */
  112227. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  112228. if (this._physicsEngine) {
  112229. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  112230. }
  112231. return this;
  112232. };
  112233. /**
  112234. * Gets the radius of the physics imposter
  112235. * @returns Radius of the physics imposter
  112236. */
  112237. PhysicsImpostor.prototype.getRadius = function () {
  112238. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  112239. };
  112240. /**
  112241. * Sync a bone with this impostor
  112242. * @param bone The bone to sync to the impostor.
  112243. * @param boneMesh The mesh that the bone is influencing.
  112244. * @param jointPivot The pivot of the joint / bone in local space.
  112245. * @param distToJoint Optional distance from the impostor to the joint.
  112246. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112247. */
  112248. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  112249. var tempVec = PhysicsImpostor._tmpVecs[0];
  112250. var mesh = this.object;
  112251. if (mesh.rotationQuaternion) {
  112252. if (adjustRotation) {
  112253. var tempQuat = PhysicsImpostor._tmpQuat;
  112254. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  112255. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112256. }
  112257. else {
  112258. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112259. }
  112260. }
  112261. tempVec.x = 0;
  112262. tempVec.y = 0;
  112263. tempVec.z = 0;
  112264. if (jointPivot) {
  112265. tempVec.x = jointPivot.x;
  112266. tempVec.y = jointPivot.y;
  112267. tempVec.z = jointPivot.z;
  112268. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  112269. if (distToJoint === undefined || distToJoint === null) {
  112270. distToJoint = jointPivot.length();
  112271. }
  112272. tempVec.x *= distToJoint;
  112273. tempVec.y *= distToJoint;
  112274. tempVec.z *= distToJoint;
  112275. }
  112276. if (bone.getParent()) {
  112277. tempVec.addInPlace(mesh.getAbsolutePosition());
  112278. bone.setAbsolutePosition(tempVec, boneMesh);
  112279. }
  112280. else {
  112281. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  112282. boneMesh.position.x -= tempVec.x;
  112283. boneMesh.position.y -= tempVec.y;
  112284. boneMesh.position.z -= tempVec.z;
  112285. }
  112286. };
  112287. /**
  112288. * Sync impostor to a bone
  112289. * @param bone The bone that the impostor will be synced to.
  112290. * @param boneMesh The mesh that the bone is influencing.
  112291. * @param jointPivot The pivot of the joint / bone in local space.
  112292. * @param distToJoint Optional distance from the impostor to the joint.
  112293. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112294. * @param boneAxis Optional vector3 axis the bone is aligned with
  112295. */
  112296. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  112297. var mesh = this.object;
  112298. if (mesh.rotationQuaternion) {
  112299. if (adjustRotation) {
  112300. var tempQuat = PhysicsImpostor._tmpQuat;
  112301. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  112302. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  112303. }
  112304. else {
  112305. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  112306. }
  112307. }
  112308. var pos = PhysicsImpostor._tmpVecs[0];
  112309. var boneDir = PhysicsImpostor._tmpVecs[1];
  112310. if (!boneAxis) {
  112311. boneAxis = PhysicsImpostor._tmpVecs[2];
  112312. boneAxis.x = 0;
  112313. boneAxis.y = 1;
  112314. boneAxis.z = 0;
  112315. }
  112316. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  112317. bone.getAbsolutePositionToRef(boneMesh, pos);
  112318. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  112319. distToJoint = jointPivot.length();
  112320. }
  112321. if (distToJoint !== undefined && distToJoint !== null) {
  112322. pos.x += boneDir.x * distToJoint;
  112323. pos.y += boneDir.y * distToJoint;
  112324. pos.z += boneDir.z * distToJoint;
  112325. }
  112326. mesh.setAbsolutePosition(pos);
  112327. };
  112328. /**
  112329. * The default object size of the imposter
  112330. */
  112331. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  112332. /**
  112333. * The identity quaternion of the imposter
  112334. */
  112335. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112336. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  112337. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112338. //Impostor types
  112339. /**
  112340. * No-Imposter type
  112341. */
  112342. PhysicsImpostor.NoImpostor = 0;
  112343. /**
  112344. * Sphere-Imposter type
  112345. */
  112346. PhysicsImpostor.SphereImpostor = 1;
  112347. /**
  112348. * Box-Imposter type
  112349. */
  112350. PhysicsImpostor.BoxImpostor = 2;
  112351. /**
  112352. * Plane-Imposter type
  112353. */
  112354. PhysicsImpostor.PlaneImpostor = 3;
  112355. /**
  112356. * Mesh-imposter type
  112357. */
  112358. PhysicsImpostor.MeshImpostor = 4;
  112359. /**
  112360. * Cylinder-Imposter type
  112361. */
  112362. PhysicsImpostor.CylinderImpostor = 7;
  112363. /**
  112364. * Particle-Imposter type
  112365. */
  112366. PhysicsImpostor.ParticleImpostor = 8;
  112367. /**
  112368. * Heightmap-Imposter type
  112369. */
  112370. PhysicsImpostor.HeightmapImpostor = 9;
  112371. return PhysicsImpostor;
  112372. }());
  112373. /***/ }),
  112374. /***/ "./Physics/physicsJoint.ts":
  112375. /*!*********************************!*\
  112376. !*** ./Physics/physicsJoint.ts ***!
  112377. \*********************************/
  112378. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  112379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112380. "use strict";
  112381. __webpack_require__.r(__webpack_exports__);
  112382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  112383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  112384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  112385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  112386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  112387. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112388. /**
  112389. * This is a holder class for the physics joint created by the physics plugin
  112390. * It holds a set of functions to control the underlying joint
  112391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112392. */
  112393. var PhysicsJoint = /** @class */ (function () {
  112394. /**
  112395. * Initializes the physics joint
  112396. * @param type The type of the physics joint
  112397. * @param jointData The data for the physics joint
  112398. */
  112399. function PhysicsJoint(
  112400. /**
  112401. * The type of the physics joint
  112402. */
  112403. type,
  112404. /**
  112405. * The data for the physics joint
  112406. */
  112407. jointData) {
  112408. this.type = type;
  112409. this.jointData = jointData;
  112410. jointData.nativeParams = jointData.nativeParams || {};
  112411. }
  112412. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  112413. /**
  112414. * Gets the physics joint
  112415. */
  112416. get: function () {
  112417. return this._physicsJoint;
  112418. },
  112419. /**
  112420. * Sets the physics joint
  112421. */
  112422. set: function (newJoint) {
  112423. if (this._physicsJoint) {
  112424. //remove from the wolrd
  112425. }
  112426. this._physicsJoint = newJoint;
  112427. },
  112428. enumerable: true,
  112429. configurable: true
  112430. });
  112431. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  112432. /**
  112433. * Sets the physics plugin
  112434. */
  112435. set: function (physicsPlugin) {
  112436. this._physicsPlugin = physicsPlugin;
  112437. },
  112438. enumerable: true,
  112439. configurable: true
  112440. });
  112441. /**
  112442. * Execute a function that is physics-plugin specific.
  112443. * @param {Function} func the function that will be executed.
  112444. * It accepts two parameters: the physics world and the physics joint
  112445. */
  112446. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  112447. func(this._physicsPlugin.world, this._physicsJoint);
  112448. };
  112449. //TODO check if the native joints are the same
  112450. //Joint Types
  112451. /**
  112452. * Distance-Joint type
  112453. */
  112454. PhysicsJoint.DistanceJoint = 0;
  112455. /**
  112456. * Hinge-Joint type
  112457. */
  112458. PhysicsJoint.HingeJoint = 1;
  112459. /**
  112460. * Ball-and-Socket joint type
  112461. */
  112462. PhysicsJoint.BallAndSocketJoint = 2;
  112463. /**
  112464. * Wheel-Joint type
  112465. */
  112466. PhysicsJoint.WheelJoint = 3;
  112467. /**
  112468. * Slider-Joint type
  112469. */
  112470. PhysicsJoint.SliderJoint = 4;
  112471. //OIMO
  112472. /**
  112473. * Prismatic-Joint type
  112474. */
  112475. PhysicsJoint.PrismaticJoint = 5;
  112476. //
  112477. /**
  112478. * Universal-Joint type
  112479. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112480. */
  112481. PhysicsJoint.UniversalJoint = 6;
  112482. /**
  112483. * Hinge-Joint 2 type
  112484. */
  112485. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  112486. //Cannon
  112487. /**
  112488. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112489. */
  112490. PhysicsJoint.PointToPointJoint = 8;
  112491. //Cannon only at the moment
  112492. /**
  112493. * Spring-Joint type
  112494. */
  112495. PhysicsJoint.SpringJoint = 9;
  112496. /**
  112497. * Lock-Joint type
  112498. */
  112499. PhysicsJoint.LockJoint = 10;
  112500. return PhysicsJoint;
  112501. }());
  112502. /**
  112503. * A class representing a physics distance joint
  112504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112505. */
  112506. var DistanceJoint = /** @class */ (function (_super) {
  112507. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  112508. /**
  112509. *
  112510. * @param jointData The data for the Distance-Joint
  112511. */
  112512. function DistanceJoint(jointData) {
  112513. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  112514. }
  112515. /**
  112516. * Update the predefined distance.
  112517. * @param maxDistance The maximum preferred distance
  112518. * @param minDistance The minimum preferred distance
  112519. */
  112520. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  112521. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  112522. };
  112523. return DistanceJoint;
  112524. }(PhysicsJoint));
  112525. /**
  112526. * Represents a Motor-Enabled Joint
  112527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112528. */
  112529. var MotorEnabledJoint = /** @class */ (function (_super) {
  112530. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  112531. /**
  112532. * Initializes the Motor-Enabled Joint
  112533. * @param type The type of the joint
  112534. * @param jointData The physica joint data for the joint
  112535. */
  112536. function MotorEnabledJoint(type, jointData) {
  112537. return _super.call(this, type, jointData) || this;
  112538. }
  112539. /**
  112540. * Set the motor values.
  112541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112542. * @param force the force to apply
  112543. * @param maxForce max force for this motor.
  112544. */
  112545. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  112546. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112547. };
  112548. /**
  112549. * Set the motor's limits.
  112550. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112551. * @param upperLimit The upper limit of the motor
  112552. * @param lowerLimit The lower limit of the motor
  112553. */
  112554. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112555. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112556. };
  112557. return MotorEnabledJoint;
  112558. }(PhysicsJoint));
  112559. /**
  112560. * This class represents a single physics Hinge-Joint
  112561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112562. */
  112563. var HingeJoint = /** @class */ (function (_super) {
  112564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  112565. /**
  112566. * Initializes the Hinge-Joint
  112567. * @param jointData The joint data for the Hinge-Joint
  112568. */
  112569. function HingeJoint(jointData) {
  112570. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  112571. }
  112572. /**
  112573. * Set the motor values.
  112574. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112575. * @param {number} force the force to apply
  112576. * @param {number} maxForce max force for this motor.
  112577. */
  112578. HingeJoint.prototype.setMotor = function (force, maxForce) {
  112579. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112580. };
  112581. /**
  112582. * Set the motor's limits.
  112583. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112584. * @param upperLimit The upper limit of the motor
  112585. * @param lowerLimit The lower limit of the motor
  112586. */
  112587. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112588. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112589. };
  112590. return HingeJoint;
  112591. }(MotorEnabledJoint));
  112592. /**
  112593. * This class represents a dual hinge physics joint (same as wheel joint)
  112594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112595. */
  112596. var Hinge2Joint = /** @class */ (function (_super) {
  112597. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  112598. /**
  112599. * Initializes the Hinge2-Joint
  112600. * @param jointData The joint data for the Hinge2-Joint
  112601. */
  112602. function Hinge2Joint(jointData) {
  112603. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  112604. }
  112605. /**
  112606. * Set the motor values.
  112607. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112608. * @param {number} force the force to apply
  112609. * @param {number} maxForce max force for this motor.
  112610. * @param {motorIndex} the motor's index, 0 or 1.
  112611. */
  112612. Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
  112613. if (motorIndex === void 0) { motorIndex = 0; }
  112614. this._physicsPlugin.setMotor(this, force || 0, maxForce, motorIndex);
  112615. };
  112616. /**
  112617. * Set the motor limits.
  112618. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112619. * @param {number} upperLimit the upper limit
  112620. * @param {number} lowerLimit lower limit
  112621. * @param {motorIndex} the motor's index, 0 or 1.
  112622. */
  112623. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  112624. if (motorIndex === void 0) { motorIndex = 0; }
  112625. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  112626. };
  112627. return Hinge2Joint;
  112628. }(MotorEnabledJoint));
  112629. /***/ }),
  112630. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  112631. /*!****************************************************************************!*\
  112632. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  112633. \****************************************************************************/
  112634. /*! exports provided: DefaultRenderingPipeline */
  112635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112636. "use strict";
  112637. __webpack_require__.r(__webpack_exports__);
  112638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  112639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112640. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  112641. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  112642. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112643. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  112644. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  112645. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  112646. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  112647. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  112648. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  112649. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  112650. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112651. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112652. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  112653. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  112654. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  112655. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  112656. /**
  112657. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112658. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112659. */
  112660. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  112661. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  112662. /**
  112663. * @constructor
  112664. * @param name - The rendering pipeline name (default: "")
  112665. * @param hdr - If high dynamic range textures should be used (default: true)
  112666. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112667. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112668. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112669. */
  112670. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  112671. if (name === void 0) { name = ""; }
  112672. if (hdr === void 0) { hdr = true; }
  112673. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  112674. if (automaticBuild === void 0) { automaticBuild = true; }
  112675. var _this = _super.call(this, scene.getEngine(), name) || this;
  112676. _this._camerasToBeAttached = [];
  112677. /**
  112678. * ID of the sharpen post process,
  112679. */
  112680. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  112681. /**
  112682. * @ignore
  112683. * ID of the image processing post process;
  112684. */
  112685. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  112686. /**
  112687. * @ignore
  112688. * ID of the Fast Approximate Anti-Aliasing post process;
  112689. */
  112690. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  112691. /**
  112692. * ID of the chromatic aberration post process,
  112693. */
  112694. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  112695. /**
  112696. * ID of the grain post process
  112697. */
  112698. _this.GrainPostProcessId = "GrainPostProcessEffect";
  112699. /**
  112700. * Glow post process which adds a glow to emmisive areas of the image
  112701. */
  112702. _this._glowLayer = null;
  112703. /**
  112704. * Animations which can be used to tweak settings over a period of time
  112705. */
  112706. _this.animations = [];
  112707. _this._imageProcessingConfigurationObserver = null;
  112708. // Values
  112709. _this._sharpenEnabled = false;
  112710. _this._bloomEnabled = false;
  112711. _this._depthOfFieldEnabled = false;
  112712. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  112713. _this._fxaaEnabled = false;
  112714. _this._imageProcessingEnabled = true;
  112715. _this._bloomScale = 0.5;
  112716. _this._chromaticAberrationEnabled = false;
  112717. _this._grainEnabled = false;
  112718. _this._buildAllowed = true;
  112719. _this._resizeObserver = null;
  112720. _this._hardwareScaleLevel = 1.0;
  112721. _this._bloomKernel = 64;
  112722. /**
  112723. * Specifies the weight of the bloom in the final rendering
  112724. */
  112725. _this._bloomWeight = 0.15;
  112726. /**
  112727. * Specifies the luma threshold for the area that will be blurred by the bloom
  112728. */
  112729. _this._bloomThreshold = 0.9;
  112730. _this._samples = 1;
  112731. _this._hasCleared = false;
  112732. _this._prevPostProcess = null;
  112733. _this._prevPrevPostProcess = null;
  112734. _this._depthOfFieldSceneObserver = null;
  112735. _this._cameras = cameras || scene.cameras;
  112736. _this._cameras = _this._cameras.slice();
  112737. _this._camerasToBeAttached = _this._cameras.slice();
  112738. _this._buildAllowed = automaticBuild;
  112739. // Initialize
  112740. _this._scene = scene;
  112741. var caps = _this._scene.getEngine().getCaps();
  112742. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  112743. // Misc
  112744. if (_this._hdr) {
  112745. if (caps.textureHalfFloatRender) {
  112746. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  112747. }
  112748. else if (caps.textureFloatRender) {
  112749. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  112750. }
  112751. }
  112752. else {
  112753. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  112754. }
  112755. // Attach
  112756. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112757. var engine = _this._scene.getEngine();
  112758. // Create post processes before hand so they can be modified before enabled.
  112759. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  112760. _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);
  112761. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  112762. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  112763. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  112764. _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);
  112765. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  112766. _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);
  112767. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  112768. _this._resizeObserver = engine.onResizeObservable.add(function () {
  112769. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  112770. _this.bloomKernel = _this.bloomKernel;
  112771. });
  112772. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  112773. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  112774. });
  112775. _this._buildPipeline();
  112776. return _this;
  112777. }
  112778. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  112779. get: function () {
  112780. return this._sharpenEnabled;
  112781. },
  112782. /**
  112783. * Enable or disable the sharpen process from the pipeline
  112784. */
  112785. set: function (enabled) {
  112786. if (this._sharpenEnabled === enabled) {
  112787. return;
  112788. }
  112789. this._sharpenEnabled = enabled;
  112790. this._buildPipeline();
  112791. },
  112792. enumerable: true,
  112793. configurable: true
  112794. });
  112795. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  112796. /**
  112797. * Specifies the size of the bloom blur kernel, relative to the final output size
  112798. */
  112799. get: function () {
  112800. return this._bloomKernel;
  112801. },
  112802. set: function (value) {
  112803. this._bloomKernel = value;
  112804. this.bloom.kernel = value / this._hardwareScaleLevel;
  112805. },
  112806. enumerable: true,
  112807. configurable: true
  112808. });
  112809. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  112810. get: function () {
  112811. return this._bloomWeight;
  112812. },
  112813. /**
  112814. * The strength of the bloom.
  112815. */
  112816. set: function (value) {
  112817. if (this._bloomWeight === value) {
  112818. return;
  112819. }
  112820. this.bloom.weight = value;
  112821. this._bloomWeight = value;
  112822. },
  112823. enumerable: true,
  112824. configurable: true
  112825. });
  112826. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  112827. get: function () {
  112828. return this._bloomThreshold;
  112829. },
  112830. /**
  112831. * The strength of the bloom.
  112832. */
  112833. set: function (value) {
  112834. if (this._bloomThreshold === value) {
  112835. return;
  112836. }
  112837. this.bloom.threshold = value;
  112838. this._bloomThreshold = value;
  112839. },
  112840. enumerable: true,
  112841. configurable: true
  112842. });
  112843. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  112844. get: function () {
  112845. return this._bloomScale;
  112846. },
  112847. /**
  112848. * The scale of the bloom, lower value will provide better performance.
  112849. */
  112850. set: function (value) {
  112851. if (this._bloomScale === value) {
  112852. return;
  112853. }
  112854. this._bloomScale = value;
  112855. // recreate bloom and dispose old as this setting is not dynamic
  112856. this._rebuildBloom();
  112857. this._buildPipeline();
  112858. },
  112859. enumerable: true,
  112860. configurable: true
  112861. });
  112862. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  112863. get: function () {
  112864. return this._bloomEnabled;
  112865. },
  112866. /**
  112867. * Enable or disable the bloom from the pipeline
  112868. */
  112869. set: function (enabled) {
  112870. if (this._bloomEnabled === enabled) {
  112871. return;
  112872. }
  112873. this._bloomEnabled = enabled;
  112874. this._buildPipeline();
  112875. },
  112876. enumerable: true,
  112877. configurable: true
  112878. });
  112879. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  112880. // recreate bloom and dispose old as this setting is not dynamic
  112881. var oldBloom = this.bloom;
  112882. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  112883. this.bloom.threshold = oldBloom.threshold;
  112884. for (var i = 0; i < this._cameras.length; i++) {
  112885. oldBloom.disposeEffects(this._cameras[i]);
  112886. }
  112887. };
  112888. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  112889. /**
  112890. * If the depth of field is enabled.
  112891. */
  112892. get: function () {
  112893. return this._depthOfFieldEnabled;
  112894. },
  112895. set: function (enabled) {
  112896. if (this._depthOfFieldEnabled === enabled) {
  112897. return;
  112898. }
  112899. this._depthOfFieldEnabled = enabled;
  112900. this._buildPipeline();
  112901. },
  112902. enumerable: true,
  112903. configurable: true
  112904. });
  112905. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  112906. /**
  112907. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112908. */
  112909. get: function () {
  112910. return this._depthOfFieldBlurLevel;
  112911. },
  112912. set: function (value) {
  112913. if (this._depthOfFieldBlurLevel === value) {
  112914. return;
  112915. }
  112916. this._depthOfFieldBlurLevel = value;
  112917. // recreate dof and dispose old as this setting is not dynamic
  112918. var oldDof = this.depthOfField;
  112919. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  112920. this.depthOfField.focalLength = oldDof.focalLength;
  112921. this.depthOfField.focusDistance = oldDof.focusDistance;
  112922. this.depthOfField.fStop = oldDof.fStop;
  112923. this.depthOfField.lensSize = oldDof.lensSize;
  112924. for (var i = 0; i < this._cameras.length; i++) {
  112925. oldDof.disposeEffects(this._cameras[i]);
  112926. }
  112927. this._buildPipeline();
  112928. },
  112929. enumerable: true,
  112930. configurable: true
  112931. });
  112932. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  112933. get: function () {
  112934. return this._fxaaEnabled;
  112935. },
  112936. /**
  112937. * If the anti aliasing is enabled.
  112938. */
  112939. set: function (enabled) {
  112940. if (this._fxaaEnabled === enabled) {
  112941. return;
  112942. }
  112943. this._fxaaEnabled = enabled;
  112944. this._buildPipeline();
  112945. },
  112946. enumerable: true,
  112947. configurable: true
  112948. });
  112949. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  112950. get: function () {
  112951. return this._samples;
  112952. },
  112953. /**
  112954. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112955. */
  112956. set: function (sampleCount) {
  112957. if (this._samples === sampleCount) {
  112958. return;
  112959. }
  112960. this._samples = sampleCount;
  112961. this._buildPipeline();
  112962. },
  112963. enumerable: true,
  112964. configurable: true
  112965. });
  112966. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  112967. get: function () {
  112968. return this._imageProcessingEnabled;
  112969. },
  112970. /**
  112971. * If image processing is enabled.
  112972. */
  112973. set: function (enabled) {
  112974. if (this._imageProcessingEnabled === enabled) {
  112975. return;
  112976. }
  112977. this._imageProcessingEnabled = enabled;
  112978. this._buildPipeline();
  112979. },
  112980. enumerable: true,
  112981. configurable: true
  112982. });
  112983. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  112984. get: function () {
  112985. return this._glowLayer == null;
  112986. },
  112987. /**
  112988. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112989. */
  112990. set: function (enabled) {
  112991. if (enabled && !this._glowLayer) {
  112992. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  112993. }
  112994. else if (!enabled && this._glowLayer) {
  112995. this._glowLayer.dispose();
  112996. this._glowLayer = null;
  112997. }
  112998. },
  112999. enumerable: true,
  113000. configurable: true
  113001. });
  113002. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  113003. get: function () {
  113004. return this._chromaticAberrationEnabled;
  113005. },
  113006. /**
  113007. * Enable or disable the chromaticAberration process from the pipeline
  113008. */
  113009. set: function (enabled) {
  113010. if (this._chromaticAberrationEnabled === enabled) {
  113011. return;
  113012. }
  113013. this._chromaticAberrationEnabled = enabled;
  113014. this._buildPipeline();
  113015. },
  113016. enumerable: true,
  113017. configurable: true
  113018. });
  113019. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  113020. get: function () {
  113021. return this._grainEnabled;
  113022. },
  113023. /**
  113024. * Enable or disable the grain process from the pipeline
  113025. */
  113026. set: function (enabled) {
  113027. if (this._grainEnabled === enabled) {
  113028. return;
  113029. }
  113030. this._grainEnabled = enabled;
  113031. this._buildPipeline();
  113032. },
  113033. enumerable: true,
  113034. configurable: true
  113035. });
  113036. /**
  113037. * Force the compilation of the entire pipeline.
  113038. */
  113039. DefaultRenderingPipeline.prototype.prepare = function () {
  113040. var previousState = this._buildAllowed;
  113041. this._buildAllowed = true;
  113042. this._buildPipeline();
  113043. this._buildAllowed = previousState;
  113044. };
  113045. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  113046. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  113047. if (this._hasCleared) {
  113048. postProcess.autoClear = false;
  113049. }
  113050. else {
  113051. postProcess.autoClear = true;
  113052. this._scene.autoClear = false;
  113053. this._hasCleared = true;
  113054. }
  113055. if (!skipTextureSharing) {
  113056. if (this._prevPrevPostProcess) {
  113057. postProcess.shareOutputWith(this._prevPrevPostProcess);
  113058. }
  113059. else {
  113060. postProcess.useOwnOutput();
  113061. }
  113062. if (this._prevPostProcess) {
  113063. this._prevPrevPostProcess = this._prevPostProcess;
  113064. }
  113065. this._prevPostProcess = postProcess;
  113066. }
  113067. };
  113068. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  113069. var _this = this;
  113070. if (!this._buildAllowed) {
  113071. return;
  113072. }
  113073. this._scene.autoClear = true;
  113074. var engine = this._scene.getEngine();
  113075. this._disposePostProcesses();
  113076. if (this._cameras !== null) {
  113077. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113078. // get back cameras to be used to reattach pipeline
  113079. this._cameras = this._camerasToBeAttached.slice();
  113080. }
  113081. this._reset();
  113082. this._prevPostProcess = null;
  113083. this._prevPrevPostProcess = null;
  113084. this._hasCleared = false;
  113085. if (this.depthOfFieldEnabled) {
  113086. // Multi camera suport
  113087. if (this._cameras.length > 1) {
  113088. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  113089. var camera = _a[_i];
  113090. var depthRenderer = this._scene.enableDepthRenderer(camera);
  113091. depthRenderer.useOnlyInActiveCamera = true;
  113092. }
  113093. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  113094. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  113095. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  113096. }
  113097. });
  113098. }
  113099. else {
  113100. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113101. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  113102. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  113103. }
  113104. if (!this.depthOfField._isReady()) {
  113105. this.depthOfField._updateEffects();
  113106. }
  113107. this.addEffect(this.depthOfField);
  113108. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  113109. }
  113110. else {
  113111. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113112. }
  113113. if (this.bloomEnabled) {
  113114. if (!this.bloom._isReady()) {
  113115. this.bloom._updateEffects();
  113116. }
  113117. this.addEffect(this.bloom);
  113118. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  113119. }
  113120. if (this._imageProcessingEnabled) {
  113121. 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);
  113122. if (this._hdr) {
  113123. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  113124. this._setAutoClearAndTextureSharing(this.imageProcessing);
  113125. }
  113126. else {
  113127. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  113128. }
  113129. }
  113130. if (this.sharpenEnabled) {
  113131. if (!this.sharpen.isReady()) {
  113132. this.sharpen.updateEffect();
  113133. }
  113134. this.addEffect(this._sharpenEffect);
  113135. this._setAutoClearAndTextureSharing(this.sharpen);
  113136. }
  113137. if (this.grainEnabled) {
  113138. if (!this.grain.isReady()) {
  113139. this.grain.updateEffect();
  113140. }
  113141. this.addEffect(this._grainEffect);
  113142. this._setAutoClearAndTextureSharing(this.grain);
  113143. }
  113144. if (this.chromaticAberrationEnabled) {
  113145. if (!this.chromaticAberration.isReady()) {
  113146. this.chromaticAberration.updateEffect();
  113147. }
  113148. this.addEffect(this._chromaticAberrationEffect);
  113149. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  113150. }
  113151. if (this.fxaaEnabled) {
  113152. 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);
  113153. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  113154. this._setAutoClearAndTextureSharing(this.fxaa, true);
  113155. }
  113156. if (this._cameras !== null) {
  113157. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  113158. }
  113159. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  113160. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  113161. }
  113162. };
  113163. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  113164. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  113165. for (var i = 0; i < this._cameras.length; i++) {
  113166. var camera = this._cameras[i];
  113167. if (this.imageProcessing) {
  113168. this.imageProcessing.dispose(camera);
  113169. }
  113170. if (this.fxaa) {
  113171. this.fxaa.dispose(camera);
  113172. }
  113173. // These are created in the constructor and should not be disposed on every pipeline change
  113174. if (disposeNonRecreated) {
  113175. if (this.sharpen) {
  113176. this.sharpen.dispose(camera);
  113177. }
  113178. if (this.depthOfField) {
  113179. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113180. this.depthOfField.disposeEffects(camera);
  113181. }
  113182. if (this.bloom) {
  113183. this.bloom.disposeEffects(camera);
  113184. }
  113185. if (this.chromaticAberration) {
  113186. this.chromaticAberration.dispose(camera);
  113187. }
  113188. if (this.grain) {
  113189. this.grain.dispose(camera);
  113190. }
  113191. if (this._glowLayer) {
  113192. this._glowLayer.dispose();
  113193. }
  113194. }
  113195. }
  113196. this.imageProcessing = null;
  113197. this.fxaa = null;
  113198. if (disposeNonRecreated) {
  113199. this.sharpen = null;
  113200. this._sharpenEffect = null;
  113201. this.depthOfField = null;
  113202. this.bloom = null;
  113203. this.chromaticAberration = null;
  113204. this._chromaticAberrationEffect = null;
  113205. this.grain = null;
  113206. this._grainEffect = null;
  113207. this._glowLayer = null;
  113208. }
  113209. };
  113210. /**
  113211. * Adds a camera to the pipeline
  113212. * @param camera the camera to be added
  113213. */
  113214. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  113215. this._camerasToBeAttached.push(camera);
  113216. this._buildPipeline();
  113217. };
  113218. /**
  113219. * Removes a camera from the pipeline
  113220. * @param camera the camera to remove
  113221. */
  113222. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  113223. var index = this._camerasToBeAttached.indexOf(camera);
  113224. this._camerasToBeAttached.splice(index, 1);
  113225. this._buildPipeline();
  113226. };
  113227. /**
  113228. * Dispose of the pipeline and stop all post processes
  113229. */
  113230. DefaultRenderingPipeline.prototype.dispose = function () {
  113231. this._disposePostProcesses(true);
  113232. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113233. this._scene.autoClear = true;
  113234. if (this._resizeObserver) {
  113235. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  113236. this._resizeObserver = null;
  113237. }
  113238. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  113239. _super.prototype.dispose.call(this);
  113240. };
  113241. /**
  113242. * Serialize the rendering pipeline (Used when exporting)
  113243. * @returns the serialized object
  113244. */
  113245. DefaultRenderingPipeline.prototype.serialize = function () {
  113246. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  113247. serializationObject.customType = "DefaultRenderingPipeline";
  113248. return serializationObject;
  113249. };
  113250. /**
  113251. * Parse the serialized pipeline
  113252. * @param source Source pipeline.
  113253. * @param scene The scene to load the pipeline to.
  113254. * @param rootUrl The URL of the serialized pipeline.
  113255. * @returns An instantiated pipeline from the serialized object.
  113256. */
  113257. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  113258. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  113259. };
  113260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113262. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  113263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113265. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  113266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113268. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  113269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113271. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  113272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113274. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  113275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113277. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  113278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113280. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  113281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113283. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  113284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113286. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  113287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113289. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  113290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113292. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  113293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113295. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  113296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113298. ], DefaultRenderingPipeline.prototype, "samples", null);
  113299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113301. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  113302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113304. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  113305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113307. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  113308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113310. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  113311. return DefaultRenderingPipeline;
  113312. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  113313. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  113314. /***/ }),
  113315. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  113316. /*!*********************************************************!*\
  113317. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  113318. \*********************************************************/
  113319. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  113320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113321. "use strict";
  113322. __webpack_require__.r(__webpack_exports__);
  113323. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  113324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  113325. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  113326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  113327. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  113328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  113329. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  113330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  113331. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  113332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  113333. /***/ }),
  113334. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  113335. /*!*************************************************************************!*\
  113336. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  113337. \*************************************************************************/
  113338. /*! exports provided: LensRenderingPipeline */
  113339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113340. "use strict";
  113341. __webpack_require__.r(__webpack_exports__);
  113342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  113343. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113344. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113345. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113346. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113347. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113348. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113349. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  113350. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  113351. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  113352. /**
  113353. * BABYLON.JS Chromatic Aberration GLSL Shader
  113354. * Author: Olivier Guyot
  113355. * Separates very slightly R, G and B colors on the edges of the screen
  113356. * Inspired by Francois Tarlier & Martins Upitis
  113357. */
  113358. var LensRenderingPipeline = /** @class */ (function (_super) {
  113359. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  113360. /**
  113361. * @constructor
  113362. *
  113363. * Effect parameters are as follow:
  113364. * {
  113365. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113366. * edge_blur: number; // from 0 to x (1 for realism)
  113367. * distortion: number; // from 0 to x (1 for realism)
  113368. * grain_amount: number; // from 0 to 1
  113369. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113370. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113371. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113372. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113373. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113374. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113375. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113376. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113377. * }
  113378. * Note: if an effect parameter is unset, effect is disabled
  113379. *
  113380. * @param name The rendering pipeline name
  113381. * @param parameters - An object containing all parameters (see above)
  113382. * @param scene The scene linked to this pipeline
  113383. * @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)
  113384. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113385. */
  113386. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  113387. if (ratio === void 0) { ratio = 1.0; }
  113388. var _this = _super.call(this, scene.getEngine(), name) || this;
  113389. // Lens effects can be of the following:
  113390. // - chromatic aberration (slight shift of RGB colors)
  113391. // - blur on the edge of the lens
  113392. // - lens distortion
  113393. // - depth-of-field blur & highlights enhancing
  113394. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  113395. // - grain effect (noise or custom texture)
  113396. // Two additional texture samplers are needed:
  113397. // - depth map (for depth-of-field)
  113398. // - grain texture
  113399. /**
  113400. * @ignore
  113401. * The chromatic aberration PostProcess id in the pipeline
  113402. */
  113403. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  113404. /**
  113405. * @ignore
  113406. * The highlights enhancing PostProcess id in the pipeline
  113407. */
  113408. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  113409. /**
  113410. * @ignore
  113411. * The depth-of-field PostProcess id in the pipeline
  113412. */
  113413. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  113414. _this._scene = scene;
  113415. // Fetch texture samplers
  113416. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113417. if (parameters.grain_texture) {
  113418. _this._grainTexture = parameters.grain_texture;
  113419. }
  113420. else {
  113421. _this._createGrainTexture();
  113422. }
  113423. // save parameters
  113424. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  113425. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  113426. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  113427. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  113428. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  113429. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  113430. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  113431. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  113432. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  113433. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  113434. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  113435. // Create effects
  113436. _this._createChromaticAberrationPostProcess(ratio);
  113437. _this._createHighlightsPostProcess(ratio);
  113438. _this._createDepthOfFieldPostProcess(ratio / 4);
  113439. // Set up pipeline
  113440. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  113441. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  113442. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  113443. if (_this._highlightsGain === -1) {
  113444. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  113445. }
  113446. // Finish
  113447. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113448. if (cameras) {
  113449. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113450. }
  113451. return _this;
  113452. }
  113453. // public methods (self explanatory)
  113454. /**
  113455. * Sets the amount of blur at the edges
  113456. * @param amount blur amount
  113457. */
  113458. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  113459. /**
  113460. * Sets edge blur to 0
  113461. */
  113462. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  113463. /**
  113464. * Sets the amout of grain
  113465. * @param amount Amount of grain
  113466. */
  113467. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  113468. /**
  113469. * Set grain amount to 0
  113470. */
  113471. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  113472. /**
  113473. * Sets the chromatic aberration amount
  113474. * @param amount amount of chromatic aberration
  113475. */
  113476. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  113477. /**
  113478. * Sets chromatic aberration amount to 0
  113479. */
  113480. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  113481. /**
  113482. * Sets the EdgeDistortion amount
  113483. * @param amount amount of EdgeDistortion
  113484. */
  113485. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  113486. /**
  113487. * Sets edge distortion to 0
  113488. */
  113489. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  113490. /**
  113491. * Sets the FocusDistance amount
  113492. * @param amount amount of FocusDistance
  113493. */
  113494. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  113495. /**
  113496. * Disables depth of field
  113497. */
  113498. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  113499. /**
  113500. * Sets the Aperture amount
  113501. * @param amount amount of Aperture
  113502. */
  113503. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  113504. /**
  113505. * Sets the DarkenOutOfFocus amount
  113506. * @param amount amount of DarkenOutOfFocus
  113507. */
  113508. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  113509. /**
  113510. * Creates a pentagon bokeh effect
  113511. */
  113512. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  113513. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  113514. };
  113515. /**
  113516. * Disables the pentagon bokeh effect
  113517. */
  113518. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  113519. this._highlightsPostProcess.updateEffect();
  113520. };
  113521. /**
  113522. * Enables noise blur
  113523. */
  113524. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  113525. /**
  113526. * Disables noise blur
  113527. */
  113528. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  113529. /**
  113530. * Sets the HighlightsGain amount
  113531. * @param amount amount of HighlightsGain
  113532. */
  113533. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  113534. this._highlightsGain = amount;
  113535. };
  113536. /**
  113537. * Sets the HighlightsThreshold amount
  113538. * @param amount amount of HighlightsThreshold
  113539. */
  113540. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  113541. if (this._highlightsGain === -1) {
  113542. this._highlightsGain = 1.0;
  113543. }
  113544. this._highlightsThreshold = amount;
  113545. };
  113546. /**
  113547. * Disables highlights
  113548. */
  113549. LensRenderingPipeline.prototype.disableHighlights = function () {
  113550. this._highlightsGain = -1;
  113551. };
  113552. /**
  113553. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113554. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113555. */
  113556. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113557. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113558. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113559. this._chromaticAberrationPostProcess = null;
  113560. this._highlightsPostProcess = null;
  113561. this._depthOfFieldPostProcess = null;
  113562. this._grainTexture.dispose();
  113563. if (disableDepthRender) {
  113564. this._scene.disableDepthRenderer();
  113565. }
  113566. };
  113567. // colors shifting and distortion
  113568. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  113569. var _this = this;
  113570. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  113571. [], // samplers
  113572. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113573. this._chromaticAberrationPostProcess.onApply = function (effect) {
  113574. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  113575. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113576. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113577. effect.setFloat('radialIntensity', 1);
  113578. effect.setFloat2('direction', 17, 17);
  113579. effect.setFloat2('centerPosition', 0.5, 0.5);
  113580. };
  113581. };
  113582. // highlights enhancing
  113583. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  113584. var _this = this;
  113585. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  113586. [], // samplers
  113587. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  113588. this._highlightsPostProcess.onApply = function (effect) {
  113589. effect.setFloat('gain', _this._highlightsGain);
  113590. effect.setFloat('threshold', _this._highlightsThreshold);
  113591. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  113592. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113593. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113594. };
  113595. };
  113596. // colors shifting and distortion
  113597. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  113598. var _this = this;
  113599. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  113600. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  113601. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  113602. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113603. this._depthOfFieldPostProcess.onApply = function (effect) {
  113604. effect.setTexture("depthSampler", _this._depthTexture);
  113605. effect.setTexture("grainSampler", _this._grainTexture);
  113606. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  113607. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  113608. effect.setFloat('grain_amount', _this._grainAmount);
  113609. effect.setBool('blur_noise', _this._blurNoise);
  113610. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113611. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113612. effect.setFloat('distortion', _this._distortion);
  113613. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  113614. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  113615. effect.setFloat('aperture', _this._dofAperture);
  113616. effect.setFloat('darken', _this._dofDarken);
  113617. effect.setFloat('edge_blur', _this._edgeBlur);
  113618. effect.setBool('highlights', (_this._highlightsGain !== -1));
  113619. if (_this._scene.activeCamera) {
  113620. effect.setFloat('near', _this._scene.activeCamera.minZ);
  113621. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  113622. }
  113623. };
  113624. };
  113625. // creates a black and white random noise texture, 512x512
  113626. LensRenderingPipeline.prototype._createGrainTexture = function () {
  113627. var size = 512;
  113628. 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);
  113629. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  113630. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  113631. var context = this._grainTexture.getContext();
  113632. var rand = function (min, max) {
  113633. return Math.random() * (max - min) + min;
  113634. };
  113635. var value;
  113636. for (var x = 0; x < size; x++) {
  113637. for (var y = 0; y < size; y++) {
  113638. value = Math.floor(rand(0.42, 0.58) * 255);
  113639. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  113640. context.fillRect(x, y, 1, 1);
  113641. }
  113642. }
  113643. this._grainTexture.update(false);
  113644. };
  113645. return LensRenderingPipeline;
  113646. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  113647. /***/ }),
  113648. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  113649. /*!**************************************************************************!*\
  113650. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  113651. \**************************************************************************/
  113652. /*! exports provided: SSAO2RenderingPipeline */
  113653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113654. "use strict";
  113655. __webpack_require__.r(__webpack_exports__);
  113656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  113657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113658. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113659. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113660. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113661. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113662. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113663. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113664. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113665. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113666. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  113667. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113668. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113669. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  113670. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  113671. /**
  113672. * Render pipeline to produce ssao effect
  113673. */
  113674. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  113675. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  113676. /**
  113677. * @constructor
  113678. * @param name The rendering pipeline name
  113679. * @param scene The scene linked to this pipeline
  113680. * @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 }
  113681. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113682. */
  113683. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  113684. var _this = _super.call(this, scene.getEngine(), name) || this;
  113685. // Members
  113686. /**
  113687. * @ignore
  113688. * The PassPostProcess id in the pipeline that contains the original scene color
  113689. */
  113690. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  113691. /**
  113692. * @ignore
  113693. * The SSAO PostProcess id in the pipeline
  113694. */
  113695. _this.SSAORenderEffect = "SSAORenderEffect";
  113696. /**
  113697. * @ignore
  113698. * The horizontal blur PostProcess id in the pipeline
  113699. */
  113700. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  113701. /**
  113702. * @ignore
  113703. * The vertical blur PostProcess id in the pipeline
  113704. */
  113705. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  113706. /**
  113707. * @ignore
  113708. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113709. */
  113710. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  113711. /**
  113712. * The output strength of the SSAO post-process. Default value is 1.0.
  113713. */
  113714. _this.totalStrength = 1.0;
  113715. /**
  113716. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113717. */
  113718. _this.maxZ = 100.0;
  113719. /**
  113720. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113721. */
  113722. _this.minZAspect = 0.2;
  113723. _this._samples = 8;
  113724. _this._textureSamples = 1;
  113725. _this._expensiveBlur = true;
  113726. /**
  113727. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113728. */
  113729. _this.radius = 2.0;
  113730. /**
  113731. * The base color of the SSAO post-process
  113732. * The final result is "base + ssao" between [0, 1]
  113733. */
  113734. _this.base = 0;
  113735. _this._firstUpdate = true;
  113736. _this._bits = new Uint32Array(1);
  113737. _this._scene = scene;
  113738. _this._ratio = ratio;
  113739. if (!_this.isSupported) {
  113740. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  113741. return _this;
  113742. }
  113743. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  113744. var blurRatio = _this._ratio.blurRatio || ratio;
  113745. // Set up assets
  113746. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  113747. _this._createRandomTexture();
  113748. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  113749. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  113750. _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);
  113751. _this._originalColorPostProcess.samples = _this.textureSamples;
  113752. _this._createSSAOPostProcess(1.0);
  113753. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  113754. _this._createSSAOCombinePostProcess(blurRatio);
  113755. // Set up pipeline
  113756. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  113757. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  113758. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  113759. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  113760. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  113761. // Finish
  113762. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113763. if (cameras) {
  113764. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113765. }
  113766. return _this;
  113767. }
  113768. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  113769. get: function () {
  113770. return this._samples;
  113771. },
  113772. /**
  113773. * Number of samples used for the SSAO calculations. Default value is 8
  113774. */
  113775. set: function (n) {
  113776. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  113777. this._samples = n;
  113778. this._sampleSphere = this._generateHemisphere();
  113779. this._firstUpdate = true;
  113780. },
  113781. enumerable: true,
  113782. configurable: true
  113783. });
  113784. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  113785. get: function () {
  113786. return this._textureSamples;
  113787. },
  113788. /**
  113789. * Number of samples to use for antialiasing
  113790. */
  113791. set: function (n) {
  113792. this._textureSamples = n;
  113793. this._originalColorPostProcess.samples = n;
  113794. this._blurHPostProcess.samples = n;
  113795. this._blurVPostProcess.samples = n;
  113796. this._ssaoPostProcess.samples = n;
  113797. this._ssaoCombinePostProcess.samples = n;
  113798. },
  113799. enumerable: true,
  113800. configurable: true
  113801. });
  113802. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  113803. get: function () {
  113804. return this._expensiveBlur;
  113805. },
  113806. /**
  113807. * If bilateral blur should be used
  113808. */
  113809. set: function (b) {
  113810. 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"]);
  113811. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  113812. this._expensiveBlur = b;
  113813. this._firstUpdate = true;
  113814. },
  113815. enumerable: true,
  113816. configurable: true
  113817. });
  113818. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  113819. /**
  113820. * Support test.
  113821. */
  113822. get: function () {
  113823. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  113824. if (!engine) {
  113825. return false;
  113826. }
  113827. return engine.getCaps().drawBuffersExtension;
  113828. },
  113829. enumerable: true,
  113830. configurable: true
  113831. });
  113832. // Public Methods
  113833. /**
  113834. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113835. */
  113836. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  113837. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  113838. for (var i = 0; i < this._scene.cameras.length; i++) {
  113839. var camera = this._scene.cameras[i];
  113840. this._originalColorPostProcess.dispose(camera);
  113841. this._ssaoPostProcess.dispose(camera);
  113842. this._blurHPostProcess.dispose(camera);
  113843. this._blurVPostProcess.dispose(camera);
  113844. this._ssaoCombinePostProcess.dispose(camera);
  113845. }
  113846. this._randomTexture.dispose();
  113847. if (disableGeometryBufferRenderer) {
  113848. this._scene.disableGeometryBufferRenderer();
  113849. }
  113850. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113851. _super.prototype.dispose.call(this);
  113852. };
  113853. // Private Methods
  113854. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  113855. var _this = this;
  113856. this._samplerOffsets = [];
  113857. var expensive = this.expensiveBlur;
  113858. for (var i = -8; i < 8; i++) {
  113859. this._samplerOffsets.push(i * 2 + 0.5);
  113860. }
  113861. 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");
  113862. this._blurHPostProcess.onApply = function (effect) {
  113863. if (!_this._scene.activeCamera) {
  113864. return;
  113865. }
  113866. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  113867. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113868. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113869. effect.setFloat("radius", _this.radius);
  113870. effect.setTexture("depthSampler", _this._depthTexture);
  113871. if (_this._firstUpdate) {
  113872. effect.setArray("samplerOffsets", _this._samplerOffsets);
  113873. }
  113874. };
  113875. 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");
  113876. this._blurVPostProcess.onApply = function (effect) {
  113877. if (!_this._scene.activeCamera) {
  113878. return;
  113879. }
  113880. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  113881. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113882. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113883. effect.setFloat("radius", _this.radius);
  113884. effect.setTexture("depthSampler", _this._depthTexture);
  113885. if (_this._firstUpdate) {
  113886. effect.setArray("samplerOffsets", _this._samplerOffsets);
  113887. _this._firstUpdate = false;
  113888. }
  113889. };
  113890. this._blurHPostProcess.samples = this.textureSamples;
  113891. this._blurVPostProcess.samples = this.textureSamples;
  113892. };
  113893. /** @hidden */
  113894. SSAO2RenderingPipeline.prototype._rebuild = function () {
  113895. this._firstUpdate = true;
  113896. _super.prototype._rebuild.call(this);
  113897. };
  113898. //Van der Corput radical inverse
  113899. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  113900. this._bits[0] = i;
  113901. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  113902. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  113903. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  113904. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  113905. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  113906. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  113907. };
  113908. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  113909. return [i / n, this._radicalInverse_VdC(i)];
  113910. };
  113911. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  113912. var phi = v * 2.0 * Math.PI;
  113913. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  113914. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  113915. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  113916. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  113917. };
  113918. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  113919. var numSamples = this.samples;
  113920. var result = [];
  113921. var vector;
  113922. var i = 0;
  113923. while (i < numSamples) {
  113924. if (numSamples < 16) {
  113925. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  113926. }
  113927. else {
  113928. var rand = this._hammersley(i, numSamples);
  113929. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  113930. }
  113931. result.push(vector.x, vector.y, vector.z);
  113932. i++;
  113933. }
  113934. return result;
  113935. };
  113936. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  113937. var _this = this;
  113938. var numSamples = this.samples;
  113939. this._sampleSphere = this._generateHemisphere();
  113940. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  113941. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  113942. "base", "range", "projection", "near", "far", "texelSize",
  113943. "xViewport", "yViewport", "maxZ", "minZAspect"
  113944. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  113945. this._ssaoPostProcess.onApply = function (effect) {
  113946. if (_this._firstUpdate) {
  113947. effect.setArray3("sampleSphere", _this._sampleSphere);
  113948. effect.setFloat("randTextureTiles", 32.0);
  113949. }
  113950. if (!_this._scene.activeCamera) {
  113951. return;
  113952. }
  113953. effect.setFloat("samplesFactor", 1 / _this.samples);
  113954. effect.setFloat("totalStrength", _this.totalStrength);
  113955. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  113956. effect.setFloat("radius", _this.radius);
  113957. effect.setFloat("maxZ", _this.maxZ);
  113958. effect.setFloat("minZAspect", _this.minZAspect);
  113959. effect.setFloat("base", _this.base);
  113960. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113961. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113962. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  113963. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  113964. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  113965. effect.setTexture("textureSampler", _this._depthTexture);
  113966. effect.setTexture("normalSampler", _this._normalTexture);
  113967. effect.setTexture("randomSampler", _this._randomTexture);
  113968. };
  113969. this._ssaoPostProcess.samples = this.textureSamples;
  113970. };
  113971. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113972. var _this = this;
  113973. 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);
  113974. this._ssaoCombinePostProcess.onApply = function (effect) {
  113975. var viewport = _this._scene.activeCamera.viewport;
  113976. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  113977. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113978. };
  113979. this._ssaoCombinePostProcess.samples = this.textureSamples;
  113980. };
  113981. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  113982. var size = 128;
  113983. 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);
  113984. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113985. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113986. var context = this._randomTexture.getContext();
  113987. var rand = function (min, max) {
  113988. return Math.random() * (max - min) + min;
  113989. };
  113990. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  113991. for (var x = 0; x < size; x++) {
  113992. for (var y = 0; y < size; y++) {
  113993. randVector.x = rand(0.0, 1.0);
  113994. randVector.y = rand(0.0, 1.0);
  113995. randVector.z = 0.0;
  113996. randVector.normalize();
  113997. randVector.scaleInPlace(255);
  113998. randVector.x = Math.floor(randVector.x);
  113999. randVector.y = Math.floor(randVector.y);
  114000. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114001. context.fillRect(x, y, 1, 1);
  114002. }
  114003. }
  114004. this._randomTexture.update(false);
  114005. };
  114006. /**
  114007. * Serialize the rendering pipeline (Used when exporting)
  114008. * @returns the serialized object
  114009. */
  114010. SSAO2RenderingPipeline.prototype.serialize = function () {
  114011. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  114012. serializationObject.customType = "SSAO2RenderingPipeline";
  114013. return serializationObject;
  114014. };
  114015. /**
  114016. * Parse the serialized pipeline
  114017. * @param source Source pipeline.
  114018. * @param scene The scene to load the pipeline to.
  114019. * @param rootUrl The URL of the serialized pipeline.
  114020. * @returns An instantiated pipeline from the serialized object.
  114021. */
  114022. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  114023. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114024. };
  114025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114027. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  114028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114030. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  114031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114033. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  114034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  114036. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  114037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  114039. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  114040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114042. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  114043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  114045. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  114046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114048. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  114049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114051. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  114052. return SSAO2RenderingPipeline;
  114053. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114054. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  114055. /***/ }),
  114056. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  114057. /*!*************************************************************************!*\
  114058. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  114059. \*************************************************************************/
  114060. /*! exports provided: SSAORenderingPipeline */
  114061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114062. "use strict";
  114063. __webpack_require__.r(__webpack_exports__);
  114064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  114065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114066. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114067. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114068. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114069. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114070. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114071. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114072. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114073. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114074. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114075. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114076. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  114077. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114078. /**
  114079. * Render pipeline to produce ssao effect
  114080. */
  114081. var SSAORenderingPipeline = /** @class */ (function (_super) {
  114082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  114083. /**
  114084. * @constructor
  114085. * @param name - The rendering pipeline name
  114086. * @param scene - The scene linked to this pipeline
  114087. * @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 }
  114088. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114089. */
  114090. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  114091. var _this = _super.call(this, scene.getEngine(), name) || this;
  114092. // Members
  114093. /**
  114094. * @ignore
  114095. * The PassPostProcess id in the pipeline that contains the original scene color
  114096. */
  114097. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114098. /**
  114099. * @ignore
  114100. * The SSAO PostProcess id in the pipeline
  114101. */
  114102. _this.SSAORenderEffect = "SSAORenderEffect";
  114103. /**
  114104. * @ignore
  114105. * The horizontal blur PostProcess id in the pipeline
  114106. */
  114107. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114108. /**
  114109. * @ignore
  114110. * The vertical blur PostProcess id in the pipeline
  114111. */
  114112. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114113. /**
  114114. * @ignore
  114115. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114116. */
  114117. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114118. /**
  114119. * The output strength of the SSAO post-process. Default value is 1.0.
  114120. */
  114121. _this.totalStrength = 1.0;
  114122. /**
  114123. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114124. */
  114125. _this.radius = 0.0001;
  114126. /**
  114127. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114128. * Must not be equal to fallOff and superior to fallOff.
  114129. * Default value is 0.975
  114130. */
  114131. _this.area = 0.0075;
  114132. /**
  114133. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114134. * Must not be equal to area and inferior to area.
  114135. * Default value is 0.0
  114136. */
  114137. _this.fallOff = 0.000001;
  114138. /**
  114139. * The base color of the SSAO post-process
  114140. * The final result is "base + ssao" between [0, 1]
  114141. */
  114142. _this.base = 0.5;
  114143. _this._firstUpdate = true;
  114144. _this._scene = scene;
  114145. // Set up assets
  114146. _this._createRandomTexture();
  114147. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  114148. var ssaoRatio = ratio.ssaoRatio || ratio;
  114149. var combineRatio = ratio.combineRatio || ratio;
  114150. _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);
  114151. _this._createSSAOPostProcess(ssaoRatio);
  114152. _this._createBlurPostProcess(ssaoRatio);
  114153. _this._createSSAOCombinePostProcess(combineRatio);
  114154. // Set up pipeline
  114155. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114156. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114157. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114158. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114159. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114160. // Finish
  114161. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114162. if (cameras) {
  114163. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114164. }
  114165. return _this;
  114166. }
  114167. // Public Methods
  114168. /**
  114169. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114170. */
  114171. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  114172. if (disableDepthRender === void 0) { disableDepthRender = false; }
  114173. for (var i = 0; i < this._scene.cameras.length; i++) {
  114174. var camera = this._scene.cameras[i];
  114175. this._originalColorPostProcess.dispose(camera);
  114176. this._ssaoPostProcess.dispose(camera);
  114177. this._blurHPostProcess.dispose(camera);
  114178. this._blurVPostProcess.dispose(camera);
  114179. this._ssaoCombinePostProcess.dispose(camera);
  114180. }
  114181. this._randomTexture.dispose();
  114182. if (disableDepthRender) {
  114183. this._scene.disableDepthRenderer();
  114184. }
  114185. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114186. _super.prototype.dispose.call(this);
  114187. };
  114188. // Private Methods
  114189. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  114190. var _this = this;
  114191. var size = 16;
  114192. 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);
  114193. 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);
  114194. this._blurHPostProcess.onActivateObservable.add(function () {
  114195. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  114196. _this._blurHPostProcess.kernel = size * dw;
  114197. });
  114198. this._blurVPostProcess.onActivateObservable.add(function () {
  114199. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  114200. _this._blurVPostProcess.kernel = size * dw;
  114201. });
  114202. };
  114203. /** @hidden */
  114204. SSAORenderingPipeline.prototype._rebuild = function () {
  114205. this._firstUpdate = true;
  114206. _super.prototype._rebuild.call(this);
  114207. };
  114208. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114209. var _this = this;
  114210. var numSamples = 16;
  114211. var sampleSphere = [
  114212. 0.5381, 0.1856, -0.4319,
  114213. 0.1379, 0.2486, 0.4430,
  114214. 0.3371, 0.5679, -0.0057,
  114215. -0.6999, -0.0451, -0.0019,
  114216. 0.0689, -0.1598, -0.8547,
  114217. 0.0560, 0.0069, -0.1843,
  114218. -0.0146, 0.1402, 0.0762,
  114219. 0.0100, -0.1924, -0.0344,
  114220. -0.3577, -0.5301, -0.4358,
  114221. -0.3169, 0.1063, 0.0158,
  114222. 0.0103, -0.5869, 0.0046,
  114223. -0.0897, -0.4940, 0.3287,
  114224. 0.7119, -0.0154, -0.0918,
  114225. -0.0533, 0.0596, -0.5411,
  114226. 0.0352, -0.0631, 0.5460,
  114227. -0.4776, 0.2847, -0.0271
  114228. ];
  114229. var samplesFactor = 1.0 / numSamples;
  114230. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  114231. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114232. "area", "fallOff", "base", "range", "viewport"
  114233. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114234. this._ssaoPostProcess.onApply = function (effect) {
  114235. if (_this._firstUpdate) {
  114236. effect.setArray3("sampleSphere", sampleSphere);
  114237. effect.setFloat("samplesFactor", samplesFactor);
  114238. effect.setFloat("randTextureTiles", 4.0);
  114239. }
  114240. effect.setFloat("totalStrength", _this.totalStrength);
  114241. effect.setFloat("radius", _this.radius);
  114242. effect.setFloat("area", _this.area);
  114243. effect.setFloat("fallOff", _this.fallOff);
  114244. effect.setFloat("base", _this.base);
  114245. effect.setTexture("textureSampler", _this._depthTexture);
  114246. effect.setTexture("randomSampler", _this._randomTexture);
  114247. };
  114248. };
  114249. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114250. var _this = this;
  114251. 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);
  114252. this._ssaoCombinePostProcess.onApply = function (effect) {
  114253. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  114254. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114255. };
  114256. };
  114257. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  114258. var size = 512;
  114259. 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);
  114260. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114261. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114262. var context = this._randomTexture.getContext();
  114263. var rand = function (min, max) {
  114264. return Math.random() * (max - min) + min;
  114265. };
  114266. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114267. for (var x = 0; x < size; x++) {
  114268. for (var y = 0; y < size; y++) {
  114269. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  114270. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  114271. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  114272. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114273. context.fillRect(x, y, 1, 1);
  114274. }
  114275. }
  114276. this._randomTexture.update(false);
  114277. };
  114278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114280. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  114281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114283. ], SSAORenderingPipeline.prototype, "radius", void 0);
  114284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114286. ], SSAORenderingPipeline.prototype, "area", void 0);
  114287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114289. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  114290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114292. ], SSAORenderingPipeline.prototype, "base", void 0);
  114293. return SSAORenderingPipeline;
  114294. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  114295. /***/ }),
  114296. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  114297. /*!*****************************************************************************!*\
  114298. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  114299. \*****************************************************************************/
  114300. /*! exports provided: StandardRenderingPipeline */
  114301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114302. "use strict";
  114303. __webpack_require__.r(__webpack_exports__);
  114304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  114305. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114306. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114307. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114308. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114309. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  114310. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114311. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114312. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114313. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114314. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114315. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114316. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114317. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114318. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  114319. /**
  114320. * Standard rendering pipeline
  114321. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114322. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114323. */
  114324. var StandardRenderingPipeline = /** @class */ (function (_super) {
  114325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  114326. /**
  114327. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114328. * @constructor
  114329. * @param name The rendering pipeline name
  114330. * @param scene The scene linked to this pipeline
  114331. * @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)
  114332. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114333. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114334. */
  114335. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  114336. if (originalPostProcess === void 0) { originalPostProcess = null; }
  114337. var _this = _super.call(this, scene.getEngine(), name) || this;
  114338. /**
  114339. * Post-process used to down scale an image x4
  114340. */
  114341. _this.downSampleX4PostProcess = null;
  114342. /**
  114343. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114344. */
  114345. _this.brightPassPostProcess = null;
  114346. /**
  114347. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114348. */
  114349. _this.blurHPostProcesses = [];
  114350. /**
  114351. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114352. */
  114353. _this.blurVPostProcesses = [];
  114354. /**
  114355. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114356. */
  114357. _this.textureAdderPostProcess = null;
  114358. /**
  114359. * Post-process used to create volumetric lighting effect
  114360. */
  114361. _this.volumetricLightPostProcess = null;
  114362. /**
  114363. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114364. */
  114365. _this.volumetricLightSmoothXPostProcess = null;
  114366. /**
  114367. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114368. */
  114369. _this.volumetricLightSmoothYPostProcess = null;
  114370. /**
  114371. * Post-process used to merge the volumetric light effect and the real scene color
  114372. */
  114373. _this.volumetricLightMergePostProces = null;
  114374. /**
  114375. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114376. */
  114377. _this.volumetricLightFinalPostProcess = null;
  114378. /**
  114379. * Base post-process used to calculate the average luminance of the final image for HDR
  114380. */
  114381. _this.luminancePostProcess = null;
  114382. /**
  114383. * Post-processes used to create down sample post-processes in order to get
  114384. * the average luminance of the final image for HDR
  114385. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114386. */
  114387. _this.luminanceDownSamplePostProcesses = [];
  114388. /**
  114389. * Post-process used to create a HDR effect (light adaptation)
  114390. */
  114391. _this.hdrPostProcess = null;
  114392. /**
  114393. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114394. */
  114395. _this.textureAdderFinalPostProcess = null;
  114396. /**
  114397. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114398. */
  114399. _this.lensFlareFinalPostProcess = null;
  114400. /**
  114401. * Post-process used to merge the final HDR post-process and the real scene color
  114402. */
  114403. _this.hdrFinalPostProcess = null;
  114404. /**
  114405. * Post-process used to create a lens flare effect
  114406. */
  114407. _this.lensFlarePostProcess = null;
  114408. /**
  114409. * Post-process that merges the result of the lens flare post-process and the real scene color
  114410. */
  114411. _this.lensFlareComposePostProcess = null;
  114412. /**
  114413. * Post-process used to create a motion blur effect
  114414. */
  114415. _this.motionBlurPostProcess = null;
  114416. /**
  114417. * Post-process used to create a depth of field effect
  114418. */
  114419. _this.depthOfFieldPostProcess = null;
  114420. /**
  114421. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114422. */
  114423. _this.fxaaPostProcess = null;
  114424. // Values
  114425. /**
  114426. * Represents the brightness threshold in order to configure the illuminated surfaces
  114427. */
  114428. _this.brightThreshold = 1.0;
  114429. /**
  114430. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114431. */
  114432. _this.blurWidth = 512.0;
  114433. /**
  114434. * Sets if the blur for highlighted surfaces must be only horizontal
  114435. */
  114436. _this.horizontalBlur = false;
  114437. /**
  114438. * Sets the overall exposure used by the pipeline
  114439. */
  114440. _this.exposure = 1.0;
  114441. /**
  114442. * Texture used typically to simulate "dirty" on camera lens
  114443. */
  114444. _this.lensTexture = null;
  114445. /**
  114446. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114447. */
  114448. _this.volumetricLightCoefficient = 0.2;
  114449. /**
  114450. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114451. */
  114452. _this.volumetricLightPower = 4.0;
  114453. /**
  114454. * Used the set the blur intensity to smooth the volumetric lights
  114455. */
  114456. _this.volumetricLightBlurScale = 64.0;
  114457. /**
  114458. * Light (spot or directional) used to generate the volumetric lights rays
  114459. * The source light must have a shadow generate so the pipeline can get its
  114460. * depth map
  114461. */
  114462. _this.sourceLight = null;
  114463. /**
  114464. * For eye adaptation, represents the minimum luminance the eye can see
  114465. */
  114466. _this.hdrMinimumLuminance = 1.0;
  114467. /**
  114468. * For eye adaptation, represents the decrease luminance speed
  114469. */
  114470. _this.hdrDecreaseRate = 0.5;
  114471. /**
  114472. * For eye adaptation, represents the increase luminance speed
  114473. */
  114474. _this.hdrIncreaseRate = 0.5;
  114475. /**
  114476. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114477. */
  114478. _this.lensColorTexture = null;
  114479. /**
  114480. * The overall strengh for the lens flare effect
  114481. */
  114482. _this.lensFlareStrength = 20.0;
  114483. /**
  114484. * Dispersion coefficient for lens flare ghosts
  114485. */
  114486. _this.lensFlareGhostDispersal = 1.4;
  114487. /**
  114488. * Main lens flare halo width
  114489. */
  114490. _this.lensFlareHaloWidth = 0.7;
  114491. /**
  114492. * Based on the lens distortion effect, defines how much the lens flare result
  114493. * is distorted
  114494. */
  114495. _this.lensFlareDistortionStrength = 16.0;
  114496. /**
  114497. * Lens star texture must be used to simulate rays on the flares and is available
  114498. * in the documentation
  114499. */
  114500. _this.lensStarTexture = null;
  114501. /**
  114502. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114503. * flare effect by taking account of the dirt texture
  114504. */
  114505. _this.lensFlareDirtTexture = null;
  114506. /**
  114507. * Represents the focal length for the depth of field effect
  114508. */
  114509. _this.depthOfFieldDistance = 10.0;
  114510. /**
  114511. * Represents the blur intensity for the blurred part of the depth of field effect
  114512. */
  114513. _this.depthOfFieldBlurWidth = 64.0;
  114514. /**
  114515. * For motion blur, defines how much the image is blurred by the movement
  114516. */
  114517. _this.motionStrength = 1.0;
  114518. /**
  114519. * List of animations for the pipeline (IAnimatable implementation)
  114520. */
  114521. _this.animations = [];
  114522. _this._currentDepthOfFieldSource = null;
  114523. _this._hdrCurrentLuminance = 1.0;
  114524. // Getters and setters
  114525. _this._bloomEnabled = false;
  114526. _this._depthOfFieldEnabled = false;
  114527. _this._vlsEnabled = false;
  114528. _this._lensFlareEnabled = false;
  114529. _this._hdrEnabled = false;
  114530. _this._motionBlurEnabled = false;
  114531. _this._fxaaEnabled = false;
  114532. _this._motionBlurSamples = 64.0;
  114533. _this._volumetricLightStepsCount = 50.0;
  114534. _this._samples = 1;
  114535. _this._cameras = cameras || [];
  114536. // Initialize
  114537. _this._scene = scene;
  114538. _this._basePostProcess = originalPostProcess;
  114539. _this._ratio = ratio;
  114540. // Misc
  114541. _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;
  114542. // Finish
  114543. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114544. _this._buildPipeline();
  114545. return _this;
  114546. }
  114547. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  114548. /**
  114549. * @ignore
  114550. * Specifies if the bloom pipeline is enabled
  114551. */
  114552. get: function () {
  114553. return this._bloomEnabled;
  114554. },
  114555. set: function (enabled) {
  114556. if (this._bloomEnabled === enabled) {
  114557. return;
  114558. }
  114559. this._bloomEnabled = enabled;
  114560. this._buildPipeline();
  114561. },
  114562. enumerable: true,
  114563. configurable: true
  114564. });
  114565. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  114566. /**
  114567. * @ignore
  114568. * Specifies if the depth of field pipeline is enabed
  114569. */
  114570. get: function () {
  114571. return this._depthOfFieldEnabled;
  114572. },
  114573. set: function (enabled) {
  114574. if (this._depthOfFieldEnabled === enabled) {
  114575. return;
  114576. }
  114577. this._depthOfFieldEnabled = enabled;
  114578. this._buildPipeline();
  114579. },
  114580. enumerable: true,
  114581. configurable: true
  114582. });
  114583. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  114584. /**
  114585. * @ignore
  114586. * Specifies if the lens flare pipeline is enabed
  114587. */
  114588. get: function () {
  114589. return this._lensFlareEnabled;
  114590. },
  114591. set: function (enabled) {
  114592. if (this._lensFlareEnabled === enabled) {
  114593. return;
  114594. }
  114595. this._lensFlareEnabled = enabled;
  114596. this._buildPipeline();
  114597. },
  114598. enumerable: true,
  114599. configurable: true
  114600. });
  114601. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  114602. /**
  114603. * @ignore
  114604. * Specifies if the HDR pipeline is enabled
  114605. */
  114606. get: function () {
  114607. return this._hdrEnabled;
  114608. },
  114609. set: function (enabled) {
  114610. if (this._hdrEnabled === enabled) {
  114611. return;
  114612. }
  114613. this._hdrEnabled = enabled;
  114614. this._buildPipeline();
  114615. },
  114616. enumerable: true,
  114617. configurable: true
  114618. });
  114619. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  114620. /**
  114621. * @ignore
  114622. * Specifies if the volumetric lights scattering effect is enabled
  114623. */
  114624. get: function () {
  114625. return this._vlsEnabled;
  114626. },
  114627. set: function (enabled) {
  114628. if (this._vlsEnabled === enabled) {
  114629. return;
  114630. }
  114631. if (enabled) {
  114632. var geometry = this._scene.enableGeometryBufferRenderer();
  114633. if (!geometry) {
  114634. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  114635. return;
  114636. }
  114637. }
  114638. this._vlsEnabled = enabled;
  114639. this._buildPipeline();
  114640. },
  114641. enumerable: true,
  114642. configurable: true
  114643. });
  114644. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  114645. /**
  114646. * @ignore
  114647. * Specifies if the motion blur effect is enabled
  114648. */
  114649. get: function () {
  114650. return this._motionBlurEnabled;
  114651. },
  114652. set: function (enabled) {
  114653. if (this._motionBlurEnabled === enabled) {
  114654. return;
  114655. }
  114656. this._motionBlurEnabled = enabled;
  114657. this._buildPipeline();
  114658. },
  114659. enumerable: true,
  114660. configurable: true
  114661. });
  114662. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  114663. /**
  114664. * Specifies if anti-aliasing is enabled
  114665. */
  114666. get: function () {
  114667. return this._fxaaEnabled;
  114668. },
  114669. set: function (enabled) {
  114670. if (this._fxaaEnabled === enabled) {
  114671. return;
  114672. }
  114673. this._fxaaEnabled = enabled;
  114674. this._buildPipeline();
  114675. },
  114676. enumerable: true,
  114677. configurable: true
  114678. });
  114679. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  114680. /**
  114681. * Specifies the number of steps used to calculate the volumetric lights
  114682. * Typically in interval [50, 200]
  114683. */
  114684. get: function () {
  114685. return this._volumetricLightStepsCount;
  114686. },
  114687. set: function (count) {
  114688. if (this.volumetricLightPostProcess) {
  114689. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  114690. }
  114691. this._volumetricLightStepsCount = count;
  114692. },
  114693. enumerable: true,
  114694. configurable: true
  114695. });
  114696. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  114697. /**
  114698. * Specifies the number of samples used for the motion blur effect
  114699. * Typically in interval [16, 64]
  114700. */
  114701. get: function () {
  114702. return this._motionBlurSamples;
  114703. },
  114704. set: function (samples) {
  114705. if (this.motionBlurPostProcess) {
  114706. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  114707. }
  114708. this._motionBlurSamples = samples;
  114709. },
  114710. enumerable: true,
  114711. configurable: true
  114712. });
  114713. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  114714. /**
  114715. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114716. */
  114717. get: function () {
  114718. return this._samples;
  114719. },
  114720. set: function (sampleCount) {
  114721. if (this._samples === sampleCount) {
  114722. return;
  114723. }
  114724. this._samples = sampleCount;
  114725. this._buildPipeline();
  114726. },
  114727. enumerable: true,
  114728. configurable: true
  114729. });
  114730. StandardRenderingPipeline.prototype._buildPipeline = function () {
  114731. var _this = this;
  114732. var ratio = this._ratio;
  114733. var scene = this._scene;
  114734. this._disposePostProcesses();
  114735. this._reset();
  114736. // Create pass post-process
  114737. if (!this._basePostProcess) {
  114738. 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);
  114739. this.originalPostProcess.onApply = function () {
  114740. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  114741. };
  114742. }
  114743. else {
  114744. this.originalPostProcess = this._basePostProcess;
  114745. }
  114746. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  114747. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  114748. }
  114749. this._currentDepthOfFieldSource = this.originalPostProcess;
  114750. if (this._bloomEnabled) {
  114751. // Create down sample X4 post-process
  114752. this._createDownSampleX4PostProcess(scene, ratio / 2);
  114753. // Create bright pass post-process
  114754. this._createBrightPassPostProcess(scene, ratio / 2);
  114755. // Create gaussian blur post-processes (down sampling blurs)
  114756. this._createBlurPostProcesses(scene, ratio / 4, 1);
  114757. // Create texture adder post-process
  114758. this._createTextureAdderPostProcess(scene, ratio);
  114759. // Create depth-of-field source post-process
  114760. 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);
  114761. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  114762. }
  114763. if (this._vlsEnabled) {
  114764. // Create volumetric light
  114765. this._createVolumetricLightPostProcess(scene, ratio);
  114766. // Create volumetric light final post-process
  114767. 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);
  114768. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  114769. }
  114770. if (this._lensFlareEnabled) {
  114771. // Create lens flare post-process
  114772. this._createLensFlarePostProcess(scene, ratio);
  114773. // Create depth-of-field source post-process post lens-flare and disable it now
  114774. 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);
  114775. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  114776. }
  114777. if (this._hdrEnabled) {
  114778. // Create luminance
  114779. this._createLuminancePostProcesses(scene, this._floatTextureType);
  114780. // Create HDR
  114781. this._createHdrPostProcess(scene, ratio);
  114782. // Create depth-of-field source post-process post hdr and disable it now
  114783. 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);
  114784. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  114785. }
  114786. if (this._depthOfFieldEnabled) {
  114787. // Create gaussian blur used by depth-of-field
  114788. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  114789. // Create depth-of-field post-process
  114790. this._createDepthOfFieldPostProcess(scene, ratio);
  114791. }
  114792. if (this._motionBlurEnabled) {
  114793. // Create motion blur post-process
  114794. this._createMotionBlurPostProcess(scene, ratio);
  114795. }
  114796. if (this._fxaaEnabled) {
  114797. // Create fxaa post-process
  114798. 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);
  114799. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  114800. }
  114801. if (this._cameras !== null) {
  114802. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  114803. }
  114804. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  114805. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  114806. }
  114807. };
  114808. // Down Sample X4 Post-Processs
  114809. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  114810. var _this = this;
  114811. var downSampleX4Offsets = new Array(32);
  114812. 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);
  114813. this.downSampleX4PostProcess.onApply = function (effect) {
  114814. var id = 0;
  114815. var width = _this.downSampleX4PostProcess.width;
  114816. var height = _this.downSampleX4PostProcess.height;
  114817. for (var i = -2; i < 2; i++) {
  114818. for (var j = -2; j < 2; j++) {
  114819. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  114820. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  114821. id += 2;
  114822. }
  114823. }
  114824. effect.setArray2("dsOffsets", downSampleX4Offsets);
  114825. };
  114826. // Add to pipeline
  114827. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  114828. };
  114829. // Brightpass Post-Process
  114830. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  114831. var _this = this;
  114832. var brightOffsets = new Array(8);
  114833. 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);
  114834. this.brightPassPostProcess.onApply = function (effect) {
  114835. var sU = (1.0 / _this.brightPassPostProcess.width);
  114836. var sV = (1.0 / _this.brightPassPostProcess.height);
  114837. brightOffsets[0] = -0.5 * sU;
  114838. brightOffsets[1] = 0.5 * sV;
  114839. brightOffsets[2] = 0.5 * sU;
  114840. brightOffsets[3] = 0.5 * sV;
  114841. brightOffsets[4] = -0.5 * sU;
  114842. brightOffsets[5] = -0.5 * sV;
  114843. brightOffsets[6] = 0.5 * sU;
  114844. brightOffsets[7] = -0.5 * sV;
  114845. effect.setArray2("dsOffsets", brightOffsets);
  114846. effect.setFloat("brightThreshold", _this.brightThreshold);
  114847. };
  114848. // Add to pipeline
  114849. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  114850. };
  114851. // Create blur H&V post-processes
  114852. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  114853. var _this = this;
  114854. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  114855. var engine = scene.getEngine();
  114856. 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);
  114857. 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);
  114858. blurX.onActivateObservable.add(function () {
  114859. var dw = blurX.width / engine.getRenderWidth();
  114860. blurX.kernel = _this[blurWidthKey] * dw;
  114861. });
  114862. blurY.onActivateObservable.add(function () {
  114863. var dw = blurY.height / engine.getRenderHeight();
  114864. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  114865. });
  114866. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  114867. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  114868. this.blurHPostProcesses.push(blurX);
  114869. this.blurVPostProcesses.push(blurY);
  114870. };
  114871. // Create texture adder post-process
  114872. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  114873. var _this = this;
  114874. 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);
  114875. this.textureAdderPostProcess.onApply = function (effect) {
  114876. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  114877. effect.setTexture("lensSampler", _this.lensTexture);
  114878. effect.setFloat("exposure", _this.exposure);
  114879. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  114880. };
  114881. // Add to pipeline
  114882. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  114883. };
  114884. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  114885. var _this = this;
  114886. var geometryRenderer = scene.enableGeometryBufferRenderer();
  114887. geometryRenderer.enablePosition = true;
  114888. var geometry = geometryRenderer.getGBuffer();
  114889. // Base post-process
  114890. 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));
  114891. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  114892. this.volumetricLightPostProcess.onApply = function (effect) {
  114893. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  114894. var generator = _this.sourceLight.getShadowGenerator();
  114895. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  114896. effect.setTexture("positionSampler", geometry.textures[2]);
  114897. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  114898. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  114899. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  114900. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  114901. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  114902. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  114903. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  114904. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  114905. effect.setVector2("depthValues", depthValues);
  114906. }
  114907. };
  114908. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  114909. // Smooth
  114910. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  114911. // Merge
  114912. 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");
  114913. this.volumetricLightMergePostProces.onApply = function (effect) {
  114914. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  114915. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  114916. };
  114917. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  114918. };
  114919. // Create luminance
  114920. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  114921. var _this = this;
  114922. // Create luminance
  114923. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  114924. 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);
  114925. var offsets = [];
  114926. this.luminancePostProcess.onApply = function (effect) {
  114927. var sU = (1.0 / _this.luminancePostProcess.width);
  114928. var sV = (1.0 / _this.luminancePostProcess.height);
  114929. offsets[0] = -0.5 * sU;
  114930. offsets[1] = 0.5 * sV;
  114931. offsets[2] = 0.5 * sU;
  114932. offsets[3] = 0.5 * sV;
  114933. offsets[4] = -0.5 * sU;
  114934. offsets[5] = -0.5 * sV;
  114935. offsets[6] = 0.5 * sU;
  114936. offsets[7] = -0.5 * sV;
  114937. effect.setArray2("lumOffsets", offsets);
  114938. };
  114939. // Add to pipeline
  114940. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  114941. // Create down sample luminance
  114942. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  114943. var size = Math.pow(3, i);
  114944. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  114945. if (i === 0) {
  114946. defines += "#define FINAL_DOWN_SAMPLER";
  114947. }
  114948. 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);
  114949. this.luminanceDownSamplePostProcesses.push(postProcess);
  114950. }
  114951. // Create callbacks and add effects
  114952. var lastLuminance = this.luminancePostProcess;
  114953. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  114954. var downSampleOffsets = new Array(18);
  114955. pp.onApply = function (effect) {
  114956. if (!lastLuminance) {
  114957. return;
  114958. }
  114959. var id = 0;
  114960. for (var x = -1; x < 2; x++) {
  114961. for (var y = -1; y < 2; y++) {
  114962. downSampleOffsets[id] = x / lastLuminance.width;
  114963. downSampleOffsets[id + 1] = y / lastLuminance.height;
  114964. id += 2;
  114965. }
  114966. }
  114967. effect.setArray2("dsOffsets", downSampleOffsets);
  114968. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  114969. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114970. lastLuminance = _this.luminancePostProcess;
  114971. }
  114972. else {
  114973. lastLuminance = pp;
  114974. }
  114975. };
  114976. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114977. pp.onAfterRender = function () {
  114978. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  114979. 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);
  114980. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  114981. };
  114982. }
  114983. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  114984. });
  114985. };
  114986. // Create HDR post-process
  114987. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  114988. var _this = this;
  114989. 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, "#define HDR", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  114990. var outputLiminance = 1;
  114991. var time = 0;
  114992. var lastTime = 0;
  114993. this.hdrPostProcess.onApply = function (effect) {
  114994. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  114995. time += scene.getEngine().getDeltaTime();
  114996. if (outputLiminance < 0) {
  114997. outputLiminance = _this._hdrCurrentLuminance;
  114998. }
  114999. else {
  115000. var dt = (lastTime - time) / 1000.0;
  115001. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  115002. outputLiminance += _this.hdrDecreaseRate * dt;
  115003. }
  115004. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  115005. outputLiminance -= _this.hdrIncreaseRate * dt;
  115006. }
  115007. else {
  115008. outputLiminance = _this._hdrCurrentLuminance;
  115009. }
  115010. }
  115011. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  115012. effect.setFloat("averageLuminance", outputLiminance);
  115013. lastTime = time;
  115014. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  115015. };
  115016. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  115017. };
  115018. // Create lens flare post-process
  115019. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  115020. var _this = this;
  115021. 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);
  115022. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  115023. this._createBlurPostProcesses(scene, ratio / 4, 2);
  115024. 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);
  115025. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  115026. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  115027. // Lens flare
  115028. this.lensFlarePostProcess.onApply = function (effect) {
  115029. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  115030. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  115031. effect.setFloat("strength", _this.lensFlareStrength);
  115032. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  115033. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  115034. // Shift
  115035. resolution.x = _this.lensFlarePostProcess.width;
  115036. resolution.y = _this.lensFlarePostProcess.height;
  115037. effect.setVector2("resolution", resolution);
  115038. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  115039. };
  115040. // Compose
  115041. 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);
  115042. 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);
  115043. this.lensFlareComposePostProcess.onApply = function (effect) {
  115044. if (!_this._scene.activeCamera) {
  115045. return;
  115046. }
  115047. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115048. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  115049. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  115050. // Lens start rotation matrix
  115051. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  115052. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  115053. 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));
  115054. camRot *= 4.0;
  115055. 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);
  115056. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  115057. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  115058. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  115059. };
  115060. };
  115061. // Create depth-of-field post-process
  115062. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  115063. var _this = this;
  115064. 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);
  115065. this.depthOfFieldPostProcess.onApply = function (effect) {
  115066. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115067. effect.setTexture("depthSampler", _this._getDepthTexture());
  115068. effect.setFloat("distance", _this.depthOfFieldDistance);
  115069. };
  115070. // Add to pipeline
  115071. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  115072. };
  115073. // Create motion blur post-process
  115074. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  115075. var _this = this;
  115076. 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);
  115077. var motionScale = 0;
  115078. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115079. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115080. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115081. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115082. this.motionBlurPostProcess.onApply = function (effect) {
  115083. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  115084. viewProjection.invertToRef(invViewProjection);
  115085. effect.setMatrix("inverseViewProjection", invViewProjection);
  115086. effect.setMatrix("prevViewProjection", prevViewProjection);
  115087. prevViewProjection = viewProjection;
  115088. screenSize.x = _this.motionBlurPostProcess.width;
  115089. screenSize.y = _this.motionBlurPostProcess.height;
  115090. effect.setVector2("screenSize", screenSize);
  115091. motionScale = scene.getEngine().getFps() / 60.0;
  115092. effect.setFloat("motionScale", motionScale);
  115093. effect.setFloat("motionStrength", _this.motionStrength);
  115094. effect.setTexture("depthSampler", _this._getDepthTexture());
  115095. };
  115096. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  115097. };
  115098. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  115099. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  115100. var renderer = this._scene.enableGeometryBufferRenderer();
  115101. return renderer.getGBuffer().textures[0];
  115102. }
  115103. return this._scene.enableDepthRenderer().getDepthMap();
  115104. };
  115105. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  115106. for (var i = 0; i < this._cameras.length; i++) {
  115107. var camera = this._cameras[i];
  115108. if (this.originalPostProcess) {
  115109. this.originalPostProcess.dispose(camera);
  115110. }
  115111. if (this.downSampleX4PostProcess) {
  115112. this.downSampleX4PostProcess.dispose(camera);
  115113. }
  115114. if (this.brightPassPostProcess) {
  115115. this.brightPassPostProcess.dispose(camera);
  115116. }
  115117. if (this.textureAdderPostProcess) {
  115118. this.textureAdderPostProcess.dispose(camera);
  115119. }
  115120. if (this.textureAdderFinalPostProcess) {
  115121. this.textureAdderFinalPostProcess.dispose(camera);
  115122. }
  115123. if (this.volumetricLightPostProcess) {
  115124. this.volumetricLightPostProcess.dispose(camera);
  115125. }
  115126. if (this.volumetricLightSmoothXPostProcess) {
  115127. this.volumetricLightSmoothXPostProcess.dispose(camera);
  115128. }
  115129. if (this.volumetricLightSmoothYPostProcess) {
  115130. this.volumetricLightSmoothYPostProcess.dispose(camera);
  115131. }
  115132. if (this.volumetricLightMergePostProces) {
  115133. this.volumetricLightMergePostProces.dispose(camera);
  115134. }
  115135. if (this.volumetricLightFinalPostProcess) {
  115136. this.volumetricLightFinalPostProcess.dispose(camera);
  115137. }
  115138. if (this.lensFlarePostProcess) {
  115139. this.lensFlarePostProcess.dispose(camera);
  115140. }
  115141. if (this.lensFlareComposePostProcess) {
  115142. this.lensFlareComposePostProcess.dispose(camera);
  115143. }
  115144. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  115145. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  115146. }
  115147. if (this.luminancePostProcess) {
  115148. this.luminancePostProcess.dispose(camera);
  115149. }
  115150. if (this.hdrPostProcess) {
  115151. this.hdrPostProcess.dispose(camera);
  115152. }
  115153. if (this.hdrFinalPostProcess) {
  115154. this.hdrFinalPostProcess.dispose(camera);
  115155. }
  115156. if (this.depthOfFieldPostProcess) {
  115157. this.depthOfFieldPostProcess.dispose(camera);
  115158. }
  115159. if (this.motionBlurPostProcess) {
  115160. this.motionBlurPostProcess.dispose(camera);
  115161. }
  115162. if (this.fxaaPostProcess) {
  115163. this.fxaaPostProcess.dispose(camera);
  115164. }
  115165. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  115166. this.blurHPostProcesses[j].dispose(camera);
  115167. }
  115168. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  115169. this.blurVPostProcesses[j].dispose(camera);
  115170. }
  115171. }
  115172. this.originalPostProcess = null;
  115173. this.downSampleX4PostProcess = null;
  115174. this.brightPassPostProcess = null;
  115175. this.textureAdderPostProcess = null;
  115176. this.textureAdderFinalPostProcess = null;
  115177. this.volumetricLightPostProcess = null;
  115178. this.volumetricLightSmoothXPostProcess = null;
  115179. this.volumetricLightSmoothYPostProcess = null;
  115180. this.volumetricLightMergePostProces = null;
  115181. this.volumetricLightFinalPostProcess = null;
  115182. this.lensFlarePostProcess = null;
  115183. this.lensFlareComposePostProcess = null;
  115184. this.luminancePostProcess = null;
  115185. this.hdrPostProcess = null;
  115186. this.hdrFinalPostProcess = null;
  115187. this.depthOfFieldPostProcess = null;
  115188. this.motionBlurPostProcess = null;
  115189. this.fxaaPostProcess = null;
  115190. this.luminanceDownSamplePostProcesses = [];
  115191. this.blurHPostProcesses = [];
  115192. this.blurVPostProcesses = [];
  115193. };
  115194. /**
  115195. * Dispose of the pipeline and stop all post processes
  115196. */
  115197. StandardRenderingPipeline.prototype.dispose = function () {
  115198. this._disposePostProcesses();
  115199. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115200. _super.prototype.dispose.call(this);
  115201. };
  115202. /**
  115203. * Serialize the rendering pipeline (Used when exporting)
  115204. * @returns the serialized object
  115205. */
  115206. StandardRenderingPipeline.prototype.serialize = function () {
  115207. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115208. if (this.sourceLight) {
  115209. serializationObject.sourceLightId = this.sourceLight.id;
  115210. }
  115211. serializationObject.customType = "StandardRenderingPipeline";
  115212. return serializationObject;
  115213. };
  115214. /**
  115215. * Parse the serialized pipeline
  115216. * @param source Source pipeline.
  115217. * @param scene The scene to load the pipeline to.
  115218. * @param rootUrl The URL of the serialized pipeline.
  115219. * @returns An instantiated pipeline from the serialized object.
  115220. */
  115221. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115222. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115223. if (source.sourceLightId) {
  115224. p.sourceLight = scene.getLightByID(source.sourceLightId);
  115225. }
  115226. return p;
  115227. };
  115228. /**
  115229. * Luminance steps
  115230. */
  115231. StandardRenderingPipeline.LuminanceSteps = 6;
  115232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115234. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  115235. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115236. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115237. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  115238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115240. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  115241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115243. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  115244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  115246. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  115247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115249. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  115250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115252. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  115253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115255. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  115256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115258. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  115259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115261. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  115262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115264. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  115265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  115267. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  115268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115270. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  115271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115273. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  115274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115276. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  115277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115279. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  115280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  115282. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  115283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  115285. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  115286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115288. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  115289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115291. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  115292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115294. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  115295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115297. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  115298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115300. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  115301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115303. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  115304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115306. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  115307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115309. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  115310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115312. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  115313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115315. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  115316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115318. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  115319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115321. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  115322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115324. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  115325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115327. ], StandardRenderingPipeline.prototype, "samples", null);
  115328. return StandardRenderingPipeline;
  115329. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  115330. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  115331. /***/ }),
  115332. /***/ "./PostProcesses/RenderPipeline/index.ts":
  115333. /*!***********************************************!*\
  115334. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  115335. \***********************************************/
  115336. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115338. "use strict";
  115339. __webpack_require__.r(__webpack_exports__);
  115340. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  115341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  115343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  115344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  115345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  115346. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  115348. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  115350. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  115352. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  115353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  115354. /***/ }),
  115355. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  115356. /*!*****************************************************************!*\
  115357. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  115358. \*****************************************************************/
  115359. /*! exports provided: PostProcessRenderEffect */
  115360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115361. "use strict";
  115362. __webpack_require__.r(__webpack_exports__);
  115363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  115364. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115365. /**
  115366. * This represents a set of one or more post processes in Babylon.
  115367. * A post process can be used to apply a shader to a texture after it is rendered.
  115368. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115369. */
  115370. var PostProcessRenderEffect = /** @class */ (function () {
  115371. /**
  115372. * Instantiates a post process render effect.
  115373. * A post process can be used to apply a shader to a texture after it is rendered.
  115374. * @param engine The engine the effect is tied to
  115375. * @param name The name of the effect
  115376. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  115377. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  115378. */
  115379. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  115380. this._name = name;
  115381. this._singleInstance = singleInstance || true;
  115382. this._getPostProcesses = getPostProcesses;
  115383. this._cameras = {};
  115384. this._indicesForCamera = {};
  115385. this._postProcesses = {};
  115386. }
  115387. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  115388. /**
  115389. * Checks if all the post processes in the effect are supported.
  115390. */
  115391. get: function () {
  115392. for (var index in this._postProcesses) {
  115393. if (this._postProcesses.hasOwnProperty(index)) {
  115394. var pps = this._postProcesses[index];
  115395. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  115396. if (!pps[ppIndex].isSupported) {
  115397. return false;
  115398. }
  115399. }
  115400. }
  115401. }
  115402. return true;
  115403. },
  115404. enumerable: true,
  115405. configurable: true
  115406. });
  115407. /**
  115408. * Updates the current state of the effect
  115409. * @hidden
  115410. */
  115411. PostProcessRenderEffect.prototype._update = function () {
  115412. };
  115413. /**
  115414. * Attaches the effect on cameras
  115415. * @param cameras The camera to attach to.
  115416. * @hidden
  115417. */
  115418. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  115419. var _this = this;
  115420. var cameraKey;
  115421. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115422. if (!cams) {
  115423. return;
  115424. }
  115425. for (var i = 0; i < cams.length; i++) {
  115426. var camera = cams[i];
  115427. var cameraName = camera.name;
  115428. if (this._singleInstance) {
  115429. cameraKey = 0;
  115430. }
  115431. else {
  115432. cameraKey = cameraName;
  115433. }
  115434. if (!this._postProcesses[cameraKey]) {
  115435. var postProcess = this._getPostProcesses();
  115436. if (postProcess) {
  115437. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  115438. }
  115439. }
  115440. if (!this._indicesForCamera[cameraName]) {
  115441. this._indicesForCamera[cameraName] = [];
  115442. }
  115443. this._postProcesses[cameraKey].forEach(function (postProcess) {
  115444. var index = camera.attachPostProcess(postProcess);
  115445. _this._indicesForCamera[cameraName].push(index);
  115446. });
  115447. if (!this._cameras[cameraName]) {
  115448. this._cameras[cameraName] = camera;
  115449. }
  115450. }
  115451. };
  115452. /**
  115453. * Detatches the effect on cameras
  115454. * @param cameras The camera to detatch from.
  115455. * @hidden
  115456. */
  115457. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  115458. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115459. if (!cams) {
  115460. return;
  115461. }
  115462. for (var i = 0; i < cams.length; i++) {
  115463. var camera = cams[i];
  115464. var cameraName = camera.name;
  115465. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  115466. if (postProcesses) {
  115467. postProcesses.forEach(function (postProcess) {
  115468. camera.detachPostProcess(postProcess);
  115469. });
  115470. }
  115471. if (this._cameras[cameraName]) {
  115472. this._cameras[cameraName] = null;
  115473. }
  115474. }
  115475. };
  115476. /**
  115477. * Enables the effect on given cameras
  115478. * @param cameras The camera to enable.
  115479. * @hidden
  115480. */
  115481. PostProcessRenderEffect.prototype._enable = function (cameras) {
  115482. var _this = this;
  115483. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115484. if (!cams) {
  115485. return;
  115486. }
  115487. for (var i = 0; i < cams.length; i++) {
  115488. var camera = cams[i];
  115489. var cameraName = camera.name;
  115490. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  115491. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  115492. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115493. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  115494. });
  115495. }
  115496. }
  115497. }
  115498. };
  115499. /**
  115500. * Disables the effect on the given cameras
  115501. * @param cameras The camera to disable.
  115502. * @hidden
  115503. */
  115504. PostProcessRenderEffect.prototype._disable = function (cameras) {
  115505. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115506. if (!cams) {
  115507. return;
  115508. }
  115509. for (var i = 0; i < cams.length; i++) {
  115510. var camera = cams[i];
  115511. var cameraName = camera.name;
  115512. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115513. camera.detachPostProcess(postProcess);
  115514. });
  115515. }
  115516. };
  115517. /**
  115518. * Gets a list of the post processes contained in the effect.
  115519. * @param camera The camera to get the post processes on.
  115520. * @returns The list of the post processes in the effect.
  115521. */
  115522. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  115523. if (this._singleInstance) {
  115524. return this._postProcesses[0];
  115525. }
  115526. else {
  115527. if (!camera) {
  115528. return null;
  115529. }
  115530. return this._postProcesses[camera.name];
  115531. }
  115532. };
  115533. return PostProcessRenderEffect;
  115534. }());
  115535. /***/ }),
  115536. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  115537. /*!*******************************************************************!*\
  115538. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  115539. \*******************************************************************/
  115540. /*! exports provided: PostProcessRenderPipeline */
  115541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115542. "use strict";
  115543. __webpack_require__.r(__webpack_exports__);
  115544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  115545. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115546. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115547. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  115548. /**
  115549. * PostProcessRenderPipeline
  115550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115551. */
  115552. var PostProcessRenderPipeline = /** @class */ (function () {
  115553. /**
  115554. * Initializes a PostProcessRenderPipeline
  115555. * @param engine engine to add the pipeline to
  115556. * @param name name of the pipeline
  115557. */
  115558. function PostProcessRenderPipeline(engine, name) {
  115559. this.engine = engine;
  115560. this._name = name;
  115561. this._renderEffects = {};
  115562. this._renderEffectsForIsolatedPass = new Array();
  115563. this._cameras = [];
  115564. }
  115565. /**
  115566. * "PostProcessRenderPipeline"
  115567. * @returns "PostProcessRenderPipeline"
  115568. */
  115569. PostProcessRenderPipeline.prototype.getClassName = function () {
  115570. return "PostProcessRenderPipeline";
  115571. };
  115572. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  115573. /**
  115574. * If all the render effects in the pipeline are support
  115575. */
  115576. get: function () {
  115577. for (var renderEffectName in this._renderEffects) {
  115578. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115579. if (!this._renderEffects[renderEffectName].isSupported) {
  115580. return false;
  115581. }
  115582. }
  115583. }
  115584. return true;
  115585. },
  115586. enumerable: true,
  115587. configurable: true
  115588. });
  115589. /**
  115590. * Adds an effect to the pipeline
  115591. * @param renderEffect the effect to add
  115592. */
  115593. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  115594. this._renderEffects[renderEffect._name] = renderEffect;
  115595. };
  115596. // private
  115597. /** @hidden */
  115598. PostProcessRenderPipeline.prototype._rebuild = function () {
  115599. };
  115600. /** @hidden */
  115601. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  115602. var renderEffects = this._renderEffects[renderEffectName];
  115603. if (!renderEffects) {
  115604. return;
  115605. }
  115606. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115607. };
  115608. /** @hidden */
  115609. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  115610. var renderEffects = this._renderEffects[renderEffectName];
  115611. if (!renderEffects) {
  115612. return;
  115613. }
  115614. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  115615. };
  115616. /** @hidden */
  115617. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  115618. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115619. if (!cams) {
  115620. return;
  115621. }
  115622. var indicesToDelete = [];
  115623. var i;
  115624. for (i = 0; i < cams.length; i++) {
  115625. var camera = cams[i];
  115626. var cameraName = camera.name;
  115627. if (this._cameras.indexOf(camera) === -1) {
  115628. this._cameras[cameraName] = camera;
  115629. }
  115630. else if (unique) {
  115631. indicesToDelete.push(i);
  115632. }
  115633. }
  115634. for (i = 0; i < indicesToDelete.length; i++) {
  115635. cameras.splice(indicesToDelete[i], 1);
  115636. }
  115637. for (var renderEffectName in this._renderEffects) {
  115638. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115639. this._renderEffects[renderEffectName]._attachCameras(cams);
  115640. }
  115641. }
  115642. };
  115643. /** @hidden */
  115644. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  115645. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  115646. if (!cams) {
  115647. return;
  115648. }
  115649. for (var renderEffectName in this._renderEffects) {
  115650. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115651. this._renderEffects[renderEffectName]._detachCameras(cams);
  115652. }
  115653. }
  115654. for (var i = 0; i < cams.length; i++) {
  115655. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  115656. }
  115657. };
  115658. /** @hidden */
  115659. PostProcessRenderPipeline.prototype._update = function () {
  115660. for (var renderEffectName in this._renderEffects) {
  115661. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  115662. this._renderEffects[renderEffectName]._update();
  115663. }
  115664. }
  115665. for (var i = 0; i < this._cameras.length; i++) {
  115666. var cameraName = this._cameras[i].name;
  115667. if (this._renderEffectsForIsolatedPass[cameraName]) {
  115668. this._renderEffectsForIsolatedPass[cameraName]._update();
  115669. }
  115670. }
  115671. };
  115672. /** @hidden */
  115673. PostProcessRenderPipeline.prototype._reset = function () {
  115674. this._renderEffects = {};
  115675. this._renderEffectsForIsolatedPass = new Array();
  115676. };
  115677. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  115678. // 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)
  115679. var effectKeys = Object.keys(this._renderEffects);
  115680. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  115681. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  115682. if (postProcesses) {
  115683. postProcesses[0].samples = sampleCount;
  115684. return true;
  115685. }
  115686. }
  115687. return false;
  115688. };
  115689. /**
  115690. * Disposes of the pipeline
  115691. */
  115692. PostProcessRenderPipeline.prototype.dispose = function () {
  115693. // Must be implemented by children
  115694. };
  115695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115697. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  115698. return PostProcessRenderPipeline;
  115699. }());
  115700. /***/ }),
  115701. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  115702. /*!**************************************************************************!*\
  115703. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  115704. \**************************************************************************/
  115705. /*! exports provided: PostProcessRenderPipelineManager */
  115706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115707. "use strict";
  115708. __webpack_require__.r(__webpack_exports__);
  115709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  115710. /**
  115711. * PostProcessRenderPipelineManager class
  115712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115713. */
  115714. var PostProcessRenderPipelineManager = /** @class */ (function () {
  115715. /**
  115716. * Initializes a PostProcessRenderPipelineManager
  115717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115718. */
  115719. function PostProcessRenderPipelineManager() {
  115720. this._renderPipelines = {};
  115721. }
  115722. /**
  115723. * Adds a pipeline to the manager
  115724. * @param renderPipeline The pipeline to add
  115725. */
  115726. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  115727. this._renderPipelines[renderPipeline._name] = renderPipeline;
  115728. };
  115729. /**
  115730. * Attaches a camera to the pipeline
  115731. * @param renderPipelineName The name of the pipeline to attach to
  115732. * @param cameras the camera to attach
  115733. * @param unique if the camera can be attached multiple times to the pipeline
  115734. */
  115735. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  115736. if (unique === void 0) { unique = false; }
  115737. var renderPipeline = this._renderPipelines[renderPipelineName];
  115738. if (!renderPipeline) {
  115739. return;
  115740. }
  115741. renderPipeline._attachCameras(cameras, unique);
  115742. };
  115743. /**
  115744. * Detaches a camera from the pipeline
  115745. * @param renderPipelineName The name of the pipeline to detach from
  115746. * @param cameras the camera to detach
  115747. */
  115748. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  115749. var renderPipeline = this._renderPipelines[renderPipelineName];
  115750. if (!renderPipeline) {
  115751. return;
  115752. }
  115753. renderPipeline._detachCameras(cameras);
  115754. };
  115755. /**
  115756. * Enables an effect by name on a pipeline
  115757. * @param renderPipelineName the name of the pipeline to enable the effect in
  115758. * @param renderEffectName the name of the effect to enable
  115759. * @param cameras the cameras that the effect should be enabled on
  115760. */
  115761. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  115762. var renderPipeline = this._renderPipelines[renderPipelineName];
  115763. if (!renderPipeline) {
  115764. return;
  115765. }
  115766. renderPipeline._enableEffect(renderEffectName, cameras);
  115767. };
  115768. /**
  115769. * Disables an effect by name on a pipeline
  115770. * @param renderPipelineName the name of the pipeline to disable the effect in
  115771. * @param renderEffectName the name of the effect to disable
  115772. * @param cameras the cameras that the effect should be disabled on
  115773. */
  115774. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  115775. var renderPipeline = this._renderPipelines[renderPipelineName];
  115776. if (!renderPipeline) {
  115777. return;
  115778. }
  115779. renderPipeline._disableEffect(renderEffectName, cameras);
  115780. };
  115781. /**
  115782. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  115783. */
  115784. PostProcessRenderPipelineManager.prototype.update = function () {
  115785. for (var renderPipelineName in this._renderPipelines) {
  115786. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115787. var pipeline = this._renderPipelines[renderPipelineName];
  115788. if (!pipeline.isSupported) {
  115789. pipeline.dispose();
  115790. delete this._renderPipelines[renderPipelineName];
  115791. }
  115792. else {
  115793. pipeline._update();
  115794. }
  115795. }
  115796. }
  115797. };
  115798. /** @hidden */
  115799. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  115800. for (var renderPipelineName in this._renderPipelines) {
  115801. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115802. var pipeline = this._renderPipelines[renderPipelineName];
  115803. pipeline._rebuild();
  115804. }
  115805. }
  115806. };
  115807. /**
  115808. * Disposes of the manager and pipelines
  115809. */
  115810. PostProcessRenderPipelineManager.prototype.dispose = function () {
  115811. for (var renderPipelineName in this._renderPipelines) {
  115812. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115813. var pipeline = this._renderPipelines[renderPipelineName];
  115814. pipeline.dispose();
  115815. }
  115816. }
  115817. };
  115818. return PostProcessRenderPipelineManager;
  115819. }());
  115820. /***/ }),
  115821. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  115822. /*!****************************************************************************************!*\
  115823. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  115824. \****************************************************************************************/
  115825. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  115826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115827. "use strict";
  115828. __webpack_require__.r(__webpack_exports__);
  115829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  115830. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  115831. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115832. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  115833. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  115834. get: function () {
  115835. if (!this._postProcessRenderPipelineManager) {
  115836. // Register the G Buffer component to the scene.
  115837. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  115838. if (!component) {
  115839. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  115840. this._addComponent(component);
  115841. }
  115842. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  115843. }
  115844. return this._postProcessRenderPipelineManager;
  115845. },
  115846. enumerable: true,
  115847. configurable: true
  115848. });
  115849. /**
  115850. * Defines the Render Pipeline scene component responsible to rendering pipelines
  115851. */
  115852. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  115853. /**
  115854. * Creates a new instance of the component for the given scene
  115855. * @param scene Defines the scene to register the component in
  115856. */
  115857. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  115858. /**
  115859. * The component name helpfull to identify the component in the list of scene components.
  115860. */
  115861. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  115862. this.scene = scene;
  115863. }
  115864. /**
  115865. * Registers the component in a given scene
  115866. */
  115867. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  115868. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  115869. };
  115870. /**
  115871. * Rebuilds the elements related to this component in case of
  115872. * context lost for instance.
  115873. */
  115874. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  115875. if (this.scene._postProcessRenderPipelineManager) {
  115876. this.scene._postProcessRenderPipelineManager._rebuild();
  115877. }
  115878. };
  115879. /**
  115880. * Disposes the component and the associated ressources
  115881. */
  115882. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  115883. if (this.scene._postProcessRenderPipelineManager) {
  115884. this.scene._postProcessRenderPipelineManager.dispose();
  115885. }
  115886. };
  115887. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  115888. if (this.scene._postProcessRenderPipelineManager) {
  115889. this.scene._postProcessRenderPipelineManager.update();
  115890. }
  115891. };
  115892. return PostProcessRenderPipelineManagerSceneComponent;
  115893. }());
  115894. /***/ }),
  115895. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  115896. /*!**********************************************!*\
  115897. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  115898. \**********************************************/
  115899. /*! exports provided: AnaglyphPostProcess */
  115900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115901. "use strict";
  115902. __webpack_require__.r(__webpack_exports__);
  115903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  115904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115905. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115906. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  115907. /**
  115908. * Postprocess used to generate anaglyphic rendering
  115909. */
  115910. var AnaglyphPostProcess = /** @class */ (function (_super) {
  115911. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  115912. /**
  115913. * Creates a new AnaglyphPostProcess
  115914. * @param name defines postprocess name
  115915. * @param options defines creation options or target ratio scale
  115916. * @param rigCameras defines cameras using this postprocess
  115917. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115918. * @param engine defines hosting engine
  115919. * @param reusable defines if the postprocess will be reused multiple times per frame
  115920. */
  115921. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  115922. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  115923. _this._passedProcess = rigCameras[0]._rigPostProcess;
  115924. _this.onApplyObservable.add(function (effect) {
  115925. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  115926. });
  115927. return _this;
  115928. }
  115929. return AnaglyphPostProcess;
  115930. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115931. /***/ }),
  115932. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  115933. /*!***************************************************!*\
  115934. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  115935. \***************************************************/
  115936. /*! exports provided: BlackAndWhitePostProcess */
  115937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115938. "use strict";
  115939. __webpack_require__.r(__webpack_exports__);
  115940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  115941. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115942. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115943. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  115944. /**
  115945. * Post process used to render in black and white
  115946. */
  115947. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  115948. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  115949. /**
  115950. * Creates a black and white post process
  115951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  115952. * @param name The name of the effect.
  115953. * @param options The required width/height ratio to downsize to before computing the render pass.
  115954. * @param camera The camera to apply the render pass to.
  115955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115956. * @param engine The engine which the post process will be applied. (default: current engine)
  115957. * @param reusable If the post process can be reused on the same frame. (default: false)
  115958. */
  115959. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  115960. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  115961. /**
  115962. * Linear about to convert he result to black and white (default: 1)
  115963. */
  115964. _this.degree = 1;
  115965. _this.onApplyObservable.add(function (effect) {
  115966. effect.setFloat("degree", _this.degree);
  115967. });
  115968. return _this;
  115969. }
  115970. return BlackAndWhitePostProcess;
  115971. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115972. /***/ }),
  115973. /***/ "./PostProcesses/bloomEffect.ts":
  115974. /*!**************************************!*\
  115975. !*** ./PostProcesses/bloomEffect.ts ***!
  115976. \**************************************/
  115977. /*! exports provided: BloomEffect */
  115978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115979. "use strict";
  115980. __webpack_require__.r(__webpack_exports__);
  115981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  115982. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115983. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115984. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  115985. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115986. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  115987. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115988. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115989. /**
  115990. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  115991. */
  115992. var BloomEffect = /** @class */ (function (_super) {
  115993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  115994. /**
  115995. * Creates a new instance of @see BloomEffect
  115996. * @param scene The scene the effect belongs to.
  115997. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  115998. * @param bloomKernel The size of the kernel to be used when applying the blur.
  115999. * @param bloomWeight The the strength of bloom.
  116000. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116001. * @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)
  116002. */
  116003. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  116004. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116005. if (blockCompilation === void 0) { blockCompilation = false; }
  116006. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  116007. return _this._effects;
  116008. }, true) || this;
  116009. _this.bloomScale = bloomScale;
  116010. /**
  116011. * @hidden Internal
  116012. */
  116013. _this._effects = [];
  116014. _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);
  116015. _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);
  116016. _this._blurX.alwaysForcePOT = true;
  116017. _this._blurX.autoClear = false;
  116018. _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);
  116019. _this._blurY.alwaysForcePOT = true;
  116020. _this._blurY.autoClear = false;
  116021. _this.kernel = bloomKernel;
  116022. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  116023. _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);
  116024. _this._merge.autoClear = false;
  116025. _this._effects.push(_this._merge);
  116026. return _this;
  116027. }
  116028. Object.defineProperty(BloomEffect.prototype, "threshold", {
  116029. /**
  116030. * The luminance threshold to find bright areas of the image to bloom.
  116031. */
  116032. get: function () {
  116033. return this._downscale.threshold;
  116034. },
  116035. set: function (value) {
  116036. this._downscale.threshold = value;
  116037. },
  116038. enumerable: true,
  116039. configurable: true
  116040. });
  116041. Object.defineProperty(BloomEffect.prototype, "weight", {
  116042. /**
  116043. * The strength of the bloom.
  116044. */
  116045. get: function () {
  116046. return this._merge.weight;
  116047. },
  116048. set: function (value) {
  116049. this._merge.weight = value;
  116050. },
  116051. enumerable: true,
  116052. configurable: true
  116053. });
  116054. Object.defineProperty(BloomEffect.prototype, "kernel", {
  116055. /**
  116056. * Specifies the size of the bloom blur kernel, relative to the final output size
  116057. */
  116058. get: function () {
  116059. return this._blurX.kernel / this.bloomScale;
  116060. },
  116061. set: function (value) {
  116062. this._blurX.kernel = value * this.bloomScale;
  116063. this._blurY.kernel = value * this.bloomScale;
  116064. },
  116065. enumerable: true,
  116066. configurable: true
  116067. });
  116068. /**
  116069. * Disposes each of the internal effects for a given camera.
  116070. * @param camera The camera to dispose the effect on.
  116071. */
  116072. BloomEffect.prototype.disposeEffects = function (camera) {
  116073. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116074. this._effects[effectIndex].dispose(camera);
  116075. }
  116076. };
  116077. /**
  116078. * @hidden Internal
  116079. */
  116080. BloomEffect.prototype._updateEffects = function () {
  116081. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116082. this._effects[effectIndex].updateEffect();
  116083. }
  116084. };
  116085. /**
  116086. * Internal
  116087. * @returns if all the contained post processes are ready.
  116088. * @hidden
  116089. */
  116090. BloomEffect.prototype._isReady = function () {
  116091. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116092. if (!this._effects[effectIndex].isReady()) {
  116093. return false;
  116094. }
  116095. }
  116096. return true;
  116097. };
  116098. return BloomEffect;
  116099. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  116100. /***/ }),
  116101. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  116102. /*!************************************************!*\
  116103. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  116104. \************************************************/
  116105. /*! exports provided: BloomMergePostProcess */
  116106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116107. "use strict";
  116108. __webpack_require__.r(__webpack_exports__);
  116109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  116110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116111. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116112. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116113. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  116114. /**
  116115. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116116. */
  116117. var BloomMergePostProcess = /** @class */ (function (_super) {
  116118. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  116119. /**
  116120. * Creates a new instance of @see BloomMergePostProcess
  116121. * @param name The name of the effect.
  116122. * @param originalFromInput Post process which's input will be used for the merge.
  116123. * @param blurred Blurred highlights post process which's output will be used.
  116124. * @param weight Weight of the bloom to be added to the original input.
  116125. * @param options The required width/height ratio to downsize to before computing the render pass.
  116126. * @param camera The camera to apply the render pass to.
  116127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116128. * @param engine The engine which the post process will be applied. (default: current engine)
  116129. * @param reusable If the post process can be reused on the same frame. (default: false)
  116130. * @param textureType Type of textures used when performing the post process. (default: 0)
  116131. * @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)
  116132. */
  116133. function BloomMergePostProcess(name, originalFromInput, blurred,
  116134. /** Weight of the bloom to be added to the original input. */
  116135. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116136. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116137. if (blockCompilation === void 0) { blockCompilation = false; }
  116138. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116139. _this.weight = weight;
  116140. _this.onApplyObservable.add(function (effect) {
  116141. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116142. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  116143. effect.setFloat("bloomWeight", _this.weight);
  116144. });
  116145. if (!blockCompilation) {
  116146. _this.updateEffect();
  116147. }
  116148. return _this;
  116149. }
  116150. return BloomMergePostProcess;
  116151. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116152. /***/ }),
  116153. /***/ "./PostProcesses/blurPostProcess.ts":
  116154. /*!******************************************!*\
  116155. !*** ./PostProcesses/blurPostProcess.ts ***!
  116156. \******************************************/
  116157. /*! exports provided: BlurPostProcess */
  116158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116159. "use strict";
  116160. __webpack_require__.r(__webpack_exports__);
  116161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  116162. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116163. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116164. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116165. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116166. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  116167. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  116168. /**
  116169. * The Blur Post Process which blurs an image based on a kernel and direction.
  116170. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  116171. */
  116172. var BlurPostProcess = /** @class */ (function (_super) {
  116173. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  116174. /**
  116175. * Creates a new instance BlurPostProcess
  116176. * @param name The name of the effect.
  116177. * @param direction The direction in which to blur the image.
  116178. * @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.
  116179. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  116180. * @param camera The camera to apply the render pass to.
  116181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116182. * @param engine The engine which the post process will be applied. (default: current engine)
  116183. * @param reusable If the post process can be reused on the same frame. (default: false)
  116184. * @param textureType Type of textures used when performing the post process. (default: 0)
  116185. * @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)
  116186. */
  116187. function BlurPostProcess(name,
  116188. /** The direction in which to blur the image. */
  116189. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  116190. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  116191. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116192. if (defines === void 0) { defines = ""; }
  116193. if (blockCompilation === void 0) { blockCompilation = false; }
  116194. 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;
  116195. _this.direction = direction;
  116196. _this.blockCompilation = blockCompilation;
  116197. _this._packedFloat = false;
  116198. _this._staticDefines = "";
  116199. _this._staticDefines = defines;
  116200. _this.onApplyObservable.add(function (effect) {
  116201. if (_this._outputTexture) {
  116202. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  116203. }
  116204. else {
  116205. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  116206. }
  116207. });
  116208. _this.kernel = kernel;
  116209. return _this;
  116210. }
  116211. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  116212. /**
  116213. * Gets the length in pixels of the blur sample region
  116214. */
  116215. get: function () {
  116216. return this._idealKernel;
  116217. },
  116218. /**
  116219. * Sets the length in pixels of the blur sample region
  116220. */
  116221. set: function (v) {
  116222. if (this._idealKernel === v) {
  116223. return;
  116224. }
  116225. v = Math.max(v, 1);
  116226. this._idealKernel = v;
  116227. this._kernel = this._nearestBestKernel(v);
  116228. if (!this.blockCompilation) {
  116229. this._updateParameters();
  116230. }
  116231. },
  116232. enumerable: true,
  116233. configurable: true
  116234. });
  116235. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  116236. /**
  116237. * Gets wether or not the blur is unpacking/repacking floats
  116238. */
  116239. get: function () {
  116240. return this._packedFloat;
  116241. },
  116242. /**
  116243. * Sets wether or not the blur needs to unpack/repack floats
  116244. */
  116245. set: function (v) {
  116246. if (this._packedFloat === v) {
  116247. return;
  116248. }
  116249. this._packedFloat = v;
  116250. if (!this.blockCompilation) {
  116251. this._updateParameters();
  116252. }
  116253. },
  116254. enumerable: true,
  116255. configurable: true
  116256. });
  116257. /**
  116258. * Updates the effect with the current post process compile time values and recompiles the shader.
  116259. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116260. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116261. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116262. * @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
  116263. * @param onCompiled Called when the shader has been compiled.
  116264. * @param onError Called if there is an error when compiling a shader.
  116265. */
  116266. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116267. if (defines === void 0) { defines = null; }
  116268. if (uniforms === void 0) { uniforms = null; }
  116269. if (samplers === void 0) { samplers = null; }
  116270. this._updateParameters(onCompiled, onError);
  116271. };
  116272. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  116273. // Generate sampling offsets and weights
  116274. var N = this._kernel;
  116275. var centerIndex = (N - 1) / 2;
  116276. // Generate Gaussian sampling weights over kernel
  116277. var offsets = [];
  116278. var weights = [];
  116279. var totalWeight = 0;
  116280. for (var i = 0; i < N; i++) {
  116281. var u = i / (N - 1);
  116282. var w = this._gaussianWeight(u * 2.0 - 1);
  116283. offsets[i] = (i - centerIndex);
  116284. weights[i] = w;
  116285. totalWeight += w;
  116286. }
  116287. // Normalize weights
  116288. for (var i = 0; i < weights.length; i++) {
  116289. weights[i] /= totalWeight;
  116290. }
  116291. // Optimize: combine samples to take advantage of hardware linear sampling
  116292. // Walk from left to center, combining pairs (symmetrically)
  116293. var linearSamplingWeights = [];
  116294. var linearSamplingOffsets = [];
  116295. var linearSamplingMap = [];
  116296. for (var i = 0; i <= centerIndex; i += 2) {
  116297. var j = Math.min(i + 1, Math.floor(centerIndex));
  116298. var singleCenterSample = i === j;
  116299. if (singleCenterSample) {
  116300. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116301. }
  116302. else {
  116303. var sharedCell = j === centerIndex;
  116304. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  116305. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  116306. if (offsetLinear === 0) {
  116307. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116308. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  116309. }
  116310. else {
  116311. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  116312. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  116313. }
  116314. }
  116315. }
  116316. for (var i = 0; i < linearSamplingMap.length; i++) {
  116317. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  116318. linearSamplingWeights[i] = linearSamplingMap[i].w;
  116319. }
  116320. // Replace with optimized
  116321. offsets = linearSamplingOffsets;
  116322. weights = linearSamplingWeights;
  116323. // Generate shaders
  116324. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  116325. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  116326. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  116327. var defines = "";
  116328. defines += this._staticDefines;
  116329. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  116330. if (this._staticDefines.indexOf("DOF") != -1) {
  116331. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  116332. varyingCount--;
  116333. }
  116334. for (var i = 0; i < varyingCount; i++) {
  116335. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  116336. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  116337. }
  116338. var depCount = 0;
  116339. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  116340. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  116341. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  116342. depCount++;
  116343. }
  116344. if (this.packedFloat) {
  116345. defines += "#define PACKEDFLOAT 1";
  116346. }
  116347. this.blockCompilation = false;
  116348. _super.prototype.updateEffect.call(this, defines, null, null, {
  116349. varyingCount: varyingCount,
  116350. depCount: depCount
  116351. }, onCompiled, onError);
  116352. };
  116353. /**
  116354. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  116355. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  116356. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  116357. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  116358. * The gaps between physical kernels are compensated for in the weighting of the samples
  116359. * @param idealKernel Ideal blur kernel.
  116360. * @return Nearest best kernel.
  116361. */
  116362. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  116363. var v = Math.round(idealKernel);
  116364. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  116365. var k = _a[_i];
  116366. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  116367. return Math.max(k, 3);
  116368. }
  116369. }
  116370. return Math.max(v, 3);
  116371. };
  116372. /**
  116373. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  116374. * @param x The point on the Gaussian distribution to sample.
  116375. * @return the value of the Gaussian function at x.
  116376. */
  116377. BlurPostProcess.prototype._gaussianWeight = function (x) {
  116378. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  116379. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  116380. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  116381. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  116382. // truncated at around 1.3% of peak strength.
  116383. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  116384. var sigma = (1 / 3);
  116385. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  116386. var exponent = -((x * x) / (2.0 * sigma * sigma));
  116387. var weight = (1.0 / denominator) * Math.exp(exponent);
  116388. return weight;
  116389. };
  116390. /**
  116391. * Generates a string that can be used as a floating point number in GLSL.
  116392. * @param x Value to print.
  116393. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  116394. * @return GLSL float string.
  116395. */
  116396. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  116397. if (decimalFigures === void 0) { decimalFigures = 8; }
  116398. return x.toFixed(decimalFigures).replace(/0+$/, '');
  116399. };
  116400. return BlurPostProcess;
  116401. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116402. /***/ }),
  116403. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  116404. /*!*********************************************************!*\
  116405. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  116406. \*********************************************************/
  116407. /*! exports provided: ChromaticAberrationPostProcess */
  116408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116409. "use strict";
  116410. __webpack_require__.r(__webpack_exports__);
  116411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  116412. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116413. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116414. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116415. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116416. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  116417. /**
  116418. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116419. */
  116420. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  116421. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  116422. /**
  116423. * Creates a new instance ChromaticAberrationPostProcess
  116424. * @param name The name of the effect.
  116425. * @param screenWidth The width of the screen to apply the effect on.
  116426. * @param screenHeight The height of the screen to apply the effect on.
  116427. * @param options The required width/height ratio to downsize to before computing the render pass.
  116428. * @param camera The camera to apply the render pass to.
  116429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116430. * @param engine The engine which the post process will be applied. (default: current engine)
  116431. * @param reusable If the post process can be reused on the same frame. (default: false)
  116432. * @param textureType Type of textures used when performing the post process. (default: 0)
  116433. * @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)
  116434. */
  116435. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116436. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116437. if (blockCompilation === void 0) { blockCompilation = false; }
  116438. 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;
  116439. /**
  116440. * The amount of seperation of rgb channels (default: 30)
  116441. */
  116442. _this.aberrationAmount = 30;
  116443. /**
  116444. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116445. */
  116446. _this.radialIntensity = 0;
  116447. /**
  116448. * 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))
  116449. */
  116450. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  116451. /**
  116452. * 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))
  116453. */
  116454. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  116455. _this.onApplyObservable.add(function (effect) {
  116456. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  116457. effect.setFloat('screen_width', screenWidth);
  116458. effect.setFloat('screen_height', screenHeight);
  116459. effect.setFloat('radialIntensity', _this.radialIntensity);
  116460. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  116461. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  116462. });
  116463. return _this;
  116464. }
  116465. return ChromaticAberrationPostProcess;
  116466. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116467. /***/ }),
  116468. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  116469. /*!*******************************************************!*\
  116470. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  116471. \*******************************************************/
  116472. /*! exports provided: CircleOfConfusionPostProcess */
  116473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116474. "use strict";
  116475. __webpack_require__.r(__webpack_exports__);
  116476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  116477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116478. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116479. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116480. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116481. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  116482. /**
  116483. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116484. */
  116485. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  116486. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  116487. /**
  116488. * Creates a new instance CircleOfConfusionPostProcess
  116489. * @param name The name of the effect.
  116490. * @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.
  116491. * @param options The required width/height ratio to downsize to before computing the render pass.
  116492. * @param camera The camera to apply the render pass to.
  116493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116494. * @param engine The engine which the post process will be applied. (default: current engine)
  116495. * @param reusable If the post process can be reused on the same frame. (default: false)
  116496. * @param textureType Type of textures used when performing the post process. (default: 0)
  116497. * @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)
  116498. */
  116499. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116500. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116501. if (blockCompilation === void 0) { blockCompilation = false; }
  116502. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116503. /**
  116504. * 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.
  116505. */
  116506. _this.lensSize = 50;
  116507. /**
  116508. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116509. */
  116510. _this.fStop = 1.4;
  116511. /**
  116512. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116513. */
  116514. _this.focusDistance = 2000;
  116515. /**
  116516. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116517. */
  116518. _this.focalLength = 50;
  116519. _this._depthTexture = null;
  116520. _this._depthTexture = depthTexture;
  116521. _this.onApplyObservable.add(function (effect) {
  116522. if (!_this._depthTexture) {
  116523. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  116524. return;
  116525. }
  116526. effect.setTexture("depthSampler", _this._depthTexture);
  116527. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  116528. var aperture = _this.lensSize / _this.fStop;
  116529. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  116530. effect.setFloat('focusDistance', _this.focusDistance);
  116531. effect.setFloat('cocPrecalculation', cocPrecalculation);
  116532. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  116533. });
  116534. return _this;
  116535. }
  116536. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  116537. /**
  116538. * 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.
  116539. */
  116540. set: function (value) {
  116541. this._depthTexture = value;
  116542. },
  116543. enumerable: true,
  116544. configurable: true
  116545. });
  116546. return CircleOfConfusionPostProcess;
  116547. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116548. /***/ }),
  116549. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  116550. /*!*****************************************************!*\
  116551. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  116552. \*****************************************************/
  116553. /*! exports provided: ColorCorrectionPostProcess */
  116554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116555. "use strict";
  116556. __webpack_require__.r(__webpack_exports__);
  116557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  116558. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116559. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116560. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116561. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  116562. /**
  116563. *
  116564. * This post-process allows the modification of rendered colors by using
  116565. * a 'look-up table' (LUT). This effect is also called Color Grading.
  116566. *
  116567. * The object needs to be provided an url to a texture containing the color
  116568. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  116569. * Use an image editing software to tweak the LUT to match your needs.
  116570. *
  116571. * For an example of a color LUT, see here:
  116572. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  116573. * For explanations on color grading, see here:
  116574. * @see http://udn.epicgames.com/Three/ColorGrading.html
  116575. *
  116576. */
  116577. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  116578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  116579. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  116580. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  116581. _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);
  116582. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  116583. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116584. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  116585. _this.onApply = function (effect) {
  116586. effect.setTexture("colorTable", _this._colorTableTexture);
  116587. };
  116588. return _this;
  116589. }
  116590. return ColorCorrectionPostProcess;
  116591. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116592. /***/ }),
  116593. /***/ "./PostProcesses/convolutionPostProcess.ts":
  116594. /*!*************************************************!*\
  116595. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  116596. \*************************************************/
  116597. /*! exports provided: ConvolutionPostProcess */
  116598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116599. "use strict";
  116600. __webpack_require__.r(__webpack_exports__);
  116601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  116602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116603. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116604. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116605. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  116606. /**
  116607. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  116608. * input texture to perform effects such as edge detection or sharpening
  116609. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  116610. */
  116611. var ConvolutionPostProcess = /** @class */ (function (_super) {
  116612. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  116613. /**
  116614. * Creates a new instance ConvolutionPostProcess
  116615. * @param name The name of the effect.
  116616. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  116617. * @param options The required width/height ratio to downsize to before computing the render pass.
  116618. * @param camera The camera to apply the render pass to.
  116619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116620. * @param engine The engine which the post process will be applied. (default: current engine)
  116621. * @param reusable If the post process can be reused on the same frame. (default: false)
  116622. * @param textureType Type of textures used when performing the post process. (default: 0)
  116623. */
  116624. function ConvolutionPostProcess(name,
  116625. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116626. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  116627. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116628. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  116629. _this.kernel = kernel;
  116630. _this.onApply = function (effect) {
  116631. effect.setFloat2("screenSize", _this.width, _this.height);
  116632. effect.setArray("kernel", _this.kernel);
  116633. };
  116634. return _this;
  116635. }
  116636. // Statics
  116637. /**
  116638. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116639. */
  116640. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  116641. /**
  116642. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116643. */
  116644. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  116645. /**
  116646. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116647. */
  116648. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  116649. /**
  116650. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116651. */
  116652. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  116653. /**
  116654. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116655. */
  116656. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  116657. /**
  116658. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116659. */
  116660. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  116661. return ConvolutionPostProcess;
  116662. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116663. /***/ }),
  116664. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  116665. /*!******************************************************!*\
  116666. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  116667. \******************************************************/
  116668. /*! exports provided: DepthOfFieldBlurPostProcess */
  116669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116670. "use strict";
  116671. __webpack_require__.r(__webpack_exports__);
  116672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  116673. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116674. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116675. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116676. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116677. /**
  116678. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  116679. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  116680. * based on samples that have a large difference in distance than the center pixel.
  116681. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116682. */
  116683. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  116684. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  116685. /**
  116686. * Creates a new instance CircleOfConfusionPostProcess
  116687. * @param name The name of the effect.
  116688. * @param scene The scene the effect belongs to.
  116689. * @param direction The direction the blur should be applied.
  116690. * @param kernel The size of the kernel used to blur.
  116691. * @param options The required width/height ratio to downsize to before computing the render pass.
  116692. * @param camera The camera to apply the render pass to.
  116693. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  116694. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  116695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116696. * @param engine The engine which the post process will be applied. (default: current engine)
  116697. * @param reusable If the post process can be reused on the same frame. (default: false)
  116698. * @param textureType Type of textures used when performing the post process. (default: 0)
  116699. * @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)
  116700. */
  116701. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  116702. if (imageToBlur === void 0) { imageToBlur = null; }
  116703. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  116704. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116705. if (blockCompilation === void 0) { blockCompilation = false; }
  116706. 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;
  116707. _this.direction = direction;
  116708. _this.onApplyObservable.add(function (effect) {
  116709. if (imageToBlur != null) {
  116710. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  116711. }
  116712. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116713. if (scene.activeCamera) {
  116714. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  116715. }
  116716. });
  116717. return _this;
  116718. }
  116719. return DepthOfFieldBlurPostProcess;
  116720. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  116721. /***/ }),
  116722. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  116723. /*!*********************************************!*\
  116724. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  116725. \*********************************************/
  116726. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  116727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116728. "use strict";
  116729. __webpack_require__.r(__webpack_exports__);
  116730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  116731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  116732. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116733. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116734. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116735. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116736. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  116737. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  116738. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  116739. /**
  116740. * Specifies the level of max blur that should be applied when using the depth of field effect
  116741. */
  116742. var DepthOfFieldEffectBlurLevel;
  116743. (function (DepthOfFieldEffectBlurLevel) {
  116744. /**
  116745. * Subtle blur
  116746. */
  116747. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  116748. /**
  116749. * Medium blur
  116750. */
  116751. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  116752. /**
  116753. * Large blur
  116754. */
  116755. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  116756. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  116757. /**
  116758. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  116759. */
  116760. var DepthOfFieldEffect = /** @class */ (function (_super) {
  116761. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  116762. /**
  116763. * Creates a new instance DepthOfFieldEffect
  116764. * @param scene The scene the effect belongs to.
  116765. * @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.
  116766. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116767. * @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)
  116768. */
  116769. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  116770. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  116771. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116772. if (blockCompilation === void 0) { blockCompilation = false; }
  116773. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  116774. return _this._effects;
  116775. }, true) || this;
  116776. /**
  116777. * @hidden Internal post processes in depth of field effect
  116778. */
  116779. _this._effects = [];
  116780. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  116781. _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);
  116782. // 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)
  116783. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  116784. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116785. _this._depthOfFieldBlurY = [];
  116786. _this._depthOfFieldBlurX = [];
  116787. var blurCount = 1;
  116788. var kernelSize = 15;
  116789. switch (blurLevel) {
  116790. case DepthOfFieldEffectBlurLevel.High: {
  116791. blurCount = 3;
  116792. kernelSize = 51;
  116793. break;
  116794. }
  116795. case DepthOfFieldEffectBlurLevel.Medium: {
  116796. blurCount = 2;
  116797. kernelSize = 31;
  116798. break;
  116799. }
  116800. default: {
  116801. kernelSize = 15;
  116802. blurCount = 1;
  116803. break;
  116804. }
  116805. }
  116806. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  116807. var ratio = 1.0;
  116808. for (var i = 0; i < blurCount; i++) {
  116809. 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);
  116810. blurY.autoClear = false;
  116811. ratio = 0.75 / Math.pow(2, i);
  116812. 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);
  116813. blurX.autoClear = false;
  116814. _this._depthOfFieldBlurY.push(blurY);
  116815. _this._depthOfFieldBlurX.push(blurX);
  116816. }
  116817. // Set all post processes on the effect.
  116818. _this._effects = [_this._circleOfConfusion];
  116819. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  116820. _this._effects.push(_this._depthOfFieldBlurY[i]);
  116821. _this._effects.push(_this._depthOfFieldBlurX[i]);
  116822. }
  116823. // Merge blurred images with original image based on circleOfConfusion
  116824. _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);
  116825. _this._dofMerge.autoClear = false;
  116826. _this._effects.push(_this._dofMerge);
  116827. return _this;
  116828. }
  116829. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  116830. get: function () {
  116831. return this._circleOfConfusion.focalLength;
  116832. },
  116833. /**
  116834. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  116835. */
  116836. set: function (value) {
  116837. this._circleOfConfusion.focalLength = value;
  116838. },
  116839. enumerable: true,
  116840. configurable: true
  116841. });
  116842. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  116843. get: function () {
  116844. return this._circleOfConfusion.fStop;
  116845. },
  116846. /**
  116847. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116848. */
  116849. set: function (value) {
  116850. this._circleOfConfusion.fStop = value;
  116851. },
  116852. enumerable: true,
  116853. configurable: true
  116854. });
  116855. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  116856. get: function () {
  116857. return this._circleOfConfusion.focusDistance;
  116858. },
  116859. /**
  116860. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116861. */
  116862. set: function (value) {
  116863. this._circleOfConfusion.focusDistance = value;
  116864. },
  116865. enumerable: true,
  116866. configurable: true
  116867. });
  116868. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  116869. get: function () {
  116870. return this._circleOfConfusion.lensSize;
  116871. },
  116872. /**
  116873. * 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.
  116874. */
  116875. set: function (value) {
  116876. this._circleOfConfusion.lensSize = value;
  116877. },
  116878. enumerable: true,
  116879. configurable: true
  116880. });
  116881. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  116882. /**
  116883. * 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.
  116884. */
  116885. set: function (value) {
  116886. this._circleOfConfusion.depthTexture = value;
  116887. },
  116888. enumerable: true,
  116889. configurable: true
  116890. });
  116891. /**
  116892. * Disposes each of the internal effects for a given camera.
  116893. * @param camera The camera to dispose the effect on.
  116894. */
  116895. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  116896. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116897. this._effects[effectIndex].dispose(camera);
  116898. }
  116899. };
  116900. /**
  116901. * @hidden Internal
  116902. */
  116903. DepthOfFieldEffect.prototype._updateEffects = function () {
  116904. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116905. this._effects[effectIndex].updateEffect();
  116906. }
  116907. };
  116908. /**
  116909. * Internal
  116910. * @returns if all the contained post processes are ready.
  116911. * @hidden
  116912. */
  116913. DepthOfFieldEffect.prototype._isReady = function () {
  116914. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116915. if (!this._effects[effectIndex].isReady()) {
  116916. return false;
  116917. }
  116918. }
  116919. return true;
  116920. };
  116921. return DepthOfFieldEffect;
  116922. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  116923. /***/ }),
  116924. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  116925. /*!*******************************************************!*\
  116926. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  116927. \*******************************************************/
  116928. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  116929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116930. "use strict";
  116931. __webpack_require__.r(__webpack_exports__);
  116932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  116933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  116934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116935. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116936. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116937. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  116938. /**
  116939. * Options to be set when merging outputs from the default pipeline.
  116940. */
  116941. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  116942. function DepthOfFieldMergePostProcessOptions() {
  116943. }
  116944. return DepthOfFieldMergePostProcessOptions;
  116945. }());
  116946. /**
  116947. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116948. */
  116949. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  116950. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  116951. /**
  116952. * Creates a new instance of DepthOfFieldMergePostProcess
  116953. * @param name The name of the effect.
  116954. * @param originalFromInput Post process which's input will be used for the merge.
  116955. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  116956. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  116957. * @param options The required width/height ratio to downsize to before computing the render pass.
  116958. * @param camera The camera to apply the render pass to.
  116959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116960. * @param engine The engine which the post process will be applied. (default: current engine)
  116961. * @param reusable If the post process can be reused on the same frame. (default: false)
  116962. * @param textureType Type of textures used when performing the post process. (default: 0)
  116963. * @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)
  116964. */
  116965. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116966. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116967. if (blockCompilation === void 0) { blockCompilation = false; }
  116968. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116969. _this.blurSteps = blurSteps;
  116970. _this.onApplyObservable.add(function (effect) {
  116971. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116972. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116973. blurSteps.forEach(function (step, index) {
  116974. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  116975. });
  116976. });
  116977. if (!blockCompilation) {
  116978. _this.updateEffect();
  116979. }
  116980. return _this;
  116981. }
  116982. /**
  116983. * Updates the effect with the current post process compile time values and recompiles the shader.
  116984. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116985. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116986. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116987. * @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
  116988. * @param onCompiled Called when the shader has been compiled.
  116989. * @param onError Called if there is an error when compiling a shader.
  116990. */
  116991. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116992. if (defines === void 0) { defines = null; }
  116993. if (uniforms === void 0) { uniforms = null; }
  116994. if (samplers === void 0) { samplers = null; }
  116995. if (!defines) {
  116996. defines = "";
  116997. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  116998. }
  116999. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  117000. };
  117001. return DepthOfFieldMergePostProcess;
  117002. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117003. /***/ }),
  117004. /***/ "./PostProcesses/displayPassPostProcess.ts":
  117005. /*!*************************************************!*\
  117006. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  117007. \*************************************************/
  117008. /*! exports provided: DisplayPassPostProcess */
  117009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117010. "use strict";
  117011. __webpack_require__.r(__webpack_exports__);
  117012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  117013. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117014. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117015. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  117016. /**
  117017. * DisplayPassPostProcess which produces an output the same as it's input
  117018. */
  117019. var DisplayPassPostProcess = /** @class */ (function (_super) {
  117020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  117021. /**
  117022. * Creates the DisplayPassPostProcess
  117023. * @param name The name of the effect.
  117024. * @param options The required width/height ratio to downsize to before computing the render pass.
  117025. * @param camera The camera to apply the render pass to.
  117026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117027. * @param engine The engine which the post process will be applied. (default: current engine)
  117028. * @param reusable If the post process can be reused on the same frame. (default: false)
  117029. */
  117030. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  117031. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  117032. }
  117033. return DisplayPassPostProcess;
  117034. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117035. /***/ }),
  117036. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  117037. /*!*******************************************************!*\
  117038. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  117039. \*******************************************************/
  117040. /*! exports provided: ExtractHighlightsPostProcess */
  117041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117042. "use strict";
  117043. __webpack_require__.r(__webpack_exports__);
  117044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  117045. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117046. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117047. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117048. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117049. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  117050. /**
  117051. * 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.
  117052. */
  117053. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  117054. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  117055. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117056. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117057. if (blockCompilation === void 0) { blockCompilation = false; }
  117058. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117059. /**
  117060. * The luminance threshold, pixels below this value will be set to black.
  117061. */
  117062. _this.threshold = 0.9;
  117063. /** @hidden */
  117064. _this._exposure = 1;
  117065. /**
  117066. * Post process which has the input texture to be used when performing highlight extraction
  117067. * @hidden
  117068. */
  117069. _this._inputPostProcess = null;
  117070. _this.onApplyObservable.add(function (effect) {
  117071. if (_this._inputPostProcess) {
  117072. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  117073. }
  117074. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  117075. effect.setFloat('exposure', _this._exposure);
  117076. });
  117077. return _this;
  117078. }
  117079. return ExtractHighlightsPostProcess;
  117080. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117081. /***/ }),
  117082. /***/ "./PostProcesses/filterPostProcess.ts":
  117083. /*!********************************************!*\
  117084. !*** ./PostProcesses/filterPostProcess.ts ***!
  117085. \********************************************/
  117086. /*! exports provided: FilterPostProcess */
  117087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117088. "use strict";
  117089. __webpack_require__.r(__webpack_exports__);
  117090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  117091. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117092. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117093. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  117094. /**
  117095. * Applies a kernel filter to the image
  117096. */
  117097. var FilterPostProcess = /** @class */ (function (_super) {
  117098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  117099. /**
  117100. *
  117101. * @param name The name of the effect.
  117102. * @param kernelMatrix The matrix to be applied to the image
  117103. * @param options The required width/height ratio to downsize to before computing the render pass.
  117104. * @param camera The camera to apply the render pass to.
  117105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117106. * @param engine The engine which the post process will be applied. (default: current engine)
  117107. * @param reusable If the post process can be reused on the same frame. (default: false)
  117108. */
  117109. function FilterPostProcess(name,
  117110. /** The matrix to be applied to the image */
  117111. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  117112. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  117113. _this.kernelMatrix = kernelMatrix;
  117114. _this.onApply = function (effect) {
  117115. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  117116. };
  117117. return _this;
  117118. }
  117119. return FilterPostProcess;
  117120. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117121. /***/ }),
  117122. /***/ "./PostProcesses/fxaaPostProcess.ts":
  117123. /*!******************************************!*\
  117124. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  117125. \******************************************/
  117126. /*! exports provided: FxaaPostProcess */
  117127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117128. "use strict";
  117129. __webpack_require__.r(__webpack_exports__);
  117130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  117131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117132. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117133. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117134. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117135. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  117136. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  117137. /**
  117138. * Fxaa post process
  117139. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117140. */
  117141. var FxaaPostProcess = /** @class */ (function (_super) {
  117142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  117143. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117144. if (camera === void 0) { camera = null; }
  117145. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117146. 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;
  117147. var defines = _this._getDefines();
  117148. _this.updateEffect(defines);
  117149. _this.onApplyObservable.add(function (effect) {
  117150. var texelSize = _this.texelSize;
  117151. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  117152. });
  117153. return _this;
  117154. }
  117155. FxaaPostProcess.prototype._getDefines = function () {
  117156. var engine = this.getEngine();
  117157. if (!engine) {
  117158. return null;
  117159. }
  117160. var glInfo = engine.getGlInfo();
  117161. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  117162. return "#define MALI 1\n";
  117163. }
  117164. return null;
  117165. };
  117166. return FxaaPostProcess;
  117167. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117168. /***/ }),
  117169. /***/ "./PostProcesses/grainPostProcess.ts":
  117170. /*!*******************************************!*\
  117171. !*** ./PostProcesses/grainPostProcess.ts ***!
  117172. \*******************************************/
  117173. /*! exports provided: GrainPostProcess */
  117174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117175. "use strict";
  117176. __webpack_require__.r(__webpack_exports__);
  117177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  117178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117179. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117180. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117181. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  117182. /**
  117183. * The GrainPostProcess adds noise to the image at mid luminance levels
  117184. */
  117185. var GrainPostProcess = /** @class */ (function (_super) {
  117186. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  117187. /**
  117188. * Creates a new instance of @see GrainPostProcess
  117189. * @param name The name of the effect.
  117190. * @param options The required width/height ratio to downsize to before computing the render pass.
  117191. * @param camera The camera to apply the render pass to.
  117192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117193. * @param engine The engine which the post process will be applied. (default: current engine)
  117194. * @param reusable If the post process can be reused on the same frame. (default: false)
  117195. * @param textureType Type of textures used when performing the post process. (default: 0)
  117196. * @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)
  117197. */
  117198. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117199. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117200. if (blockCompilation === void 0) { blockCompilation = false; }
  117201. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117202. /**
  117203. * The intensity of the grain added (default: 30)
  117204. */
  117205. _this.intensity = 30;
  117206. /**
  117207. * If the grain should be randomized on every frame
  117208. */
  117209. _this.animated = false;
  117210. _this.onApplyObservable.add(function (effect) {
  117211. effect.setFloat('intensity', _this.intensity);
  117212. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  117213. });
  117214. return _this;
  117215. }
  117216. return GrainPostProcess;
  117217. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117218. /***/ }),
  117219. /***/ "./PostProcesses/highlightsPostProcess.ts":
  117220. /*!************************************************!*\
  117221. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  117222. \************************************************/
  117223. /*! exports provided: HighlightsPostProcess */
  117224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117225. "use strict";
  117226. __webpack_require__.r(__webpack_exports__);
  117227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  117228. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117229. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117230. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117231. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  117232. /**
  117233. * Extracts highlights from the image
  117234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117235. */
  117236. var HighlightsPostProcess = /** @class */ (function (_super) {
  117237. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  117238. /**
  117239. * Extracts highlights from the image
  117240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117241. * @param name The name of the effect.
  117242. * @param options The required width/height ratio to downsize to before computing the render pass.
  117243. * @param camera The camera to apply the render pass to.
  117244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117245. * @param engine The engine which the post process will be applied. (default: current engine)
  117246. * @param reusable If the post process can be reused on the same frame. (default: false)
  117247. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117248. */
  117249. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117250. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117251. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117252. }
  117253. return HighlightsPostProcess;
  117254. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117255. /***/ }),
  117256. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  117257. /*!*****************************************************!*\
  117258. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  117259. \*****************************************************/
  117260. /*! exports provided: ImageProcessingPostProcess */
  117261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117262. "use strict";
  117263. __webpack_require__.r(__webpack_exports__);
  117264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  117265. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117266. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  117267. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  117268. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117269. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117270. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117271. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  117272. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117273. /**
  117274. * ImageProcessingPostProcess
  117275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  117276. */
  117277. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  117278. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  117279. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  117280. if (camera === void 0) { camera = null; }
  117281. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117282. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  117283. _this._fromLinearSpace = true;
  117284. /**
  117285. * Defines cache preventing GC.
  117286. */
  117287. _this._defines = {
  117288. IMAGEPROCESSING: false,
  117289. VIGNETTE: false,
  117290. VIGNETTEBLENDMODEMULTIPLY: false,
  117291. VIGNETTEBLENDMODEOPAQUE: false,
  117292. TONEMAPPING: false,
  117293. TONEMAPPING_ACES: false,
  117294. CONTRAST: false,
  117295. COLORCURVES: false,
  117296. COLORGRADING: false,
  117297. COLORGRADING3D: false,
  117298. FROMLINEARSPACE: false,
  117299. SAMPLER3DGREENDEPTH: false,
  117300. SAMPLER3DBGRMAP: false,
  117301. IMAGEPROCESSINGPOSTPROCESS: false,
  117302. EXPOSURE: false,
  117303. };
  117304. // Setup the configuration as forced by the constructor. This would then not force the
  117305. // scene materials output in linear space and let untouched the default forward pass.
  117306. if (imageProcessingConfiguration) {
  117307. imageProcessingConfiguration.applyByPostProcess = true;
  117308. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  117309. // This will cause the shader to be compiled
  117310. _this.fromLinearSpace = false;
  117311. }
  117312. // Setup the default processing configuration to the scene.
  117313. else {
  117314. _this._attachImageProcessingConfiguration(null, true);
  117315. _this.imageProcessingConfiguration.applyByPostProcess = true;
  117316. }
  117317. _this.onApply = function (effect) {
  117318. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  117319. };
  117320. return _this;
  117321. }
  117322. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  117323. /**
  117324. * Gets the image processing configuration used either in this material.
  117325. */
  117326. get: function () {
  117327. return this._imageProcessingConfiguration;
  117328. },
  117329. /**
  117330. * Sets the Default image processing configuration used either in the this material.
  117331. *
  117332. * If sets to null, the scene one is in use.
  117333. */
  117334. set: function (value) {
  117335. this._attachImageProcessingConfiguration(value);
  117336. },
  117337. enumerable: true,
  117338. configurable: true
  117339. });
  117340. /**
  117341. * Attaches a new image processing configuration to the PBR Material.
  117342. * @param configuration
  117343. */
  117344. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  117345. var _this = this;
  117346. if (doNotBuild === void 0) { doNotBuild = false; }
  117347. if (configuration === this._imageProcessingConfiguration) {
  117348. return;
  117349. }
  117350. // Detaches observer.
  117351. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117352. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117353. }
  117354. // Pick the scene configuration if needed.
  117355. if (!configuration) {
  117356. var scene = null;
  117357. var engine = this.getEngine();
  117358. var camera = this.getCamera();
  117359. if (camera) {
  117360. scene = camera.getScene();
  117361. }
  117362. else if (engine && engine.scenes) {
  117363. var scenes = engine.scenes;
  117364. scene = scenes[scenes.length - 1];
  117365. }
  117366. else {
  117367. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  117368. }
  117369. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  117370. }
  117371. else {
  117372. this._imageProcessingConfiguration = configuration;
  117373. }
  117374. // Attaches observer.
  117375. if (this._imageProcessingConfiguration) {
  117376. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  117377. _this._updateParameters();
  117378. });
  117379. }
  117380. // Ensure the effect will be rebuilt.
  117381. if (!doNotBuild) {
  117382. this._updateParameters();
  117383. }
  117384. };
  117385. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  117386. /**
  117387. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117388. */
  117389. get: function () {
  117390. return this.imageProcessingConfiguration.colorCurves;
  117391. },
  117392. /**
  117393. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117394. */
  117395. set: function (value) {
  117396. this.imageProcessingConfiguration.colorCurves = value;
  117397. },
  117398. enumerable: true,
  117399. configurable: true
  117400. });
  117401. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  117402. /**
  117403. * Gets wether the color curves effect is enabled.
  117404. */
  117405. get: function () {
  117406. return this.imageProcessingConfiguration.colorCurvesEnabled;
  117407. },
  117408. /**
  117409. * Sets wether the color curves effect is enabled.
  117410. */
  117411. set: function (value) {
  117412. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  117413. },
  117414. enumerable: true,
  117415. configurable: true
  117416. });
  117417. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  117418. /**
  117419. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117420. */
  117421. get: function () {
  117422. return this.imageProcessingConfiguration.colorGradingTexture;
  117423. },
  117424. /**
  117425. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117426. */
  117427. set: function (value) {
  117428. this.imageProcessingConfiguration.colorGradingTexture = value;
  117429. },
  117430. enumerable: true,
  117431. configurable: true
  117432. });
  117433. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  117434. /**
  117435. * Gets wether the color grading effect is enabled.
  117436. */
  117437. get: function () {
  117438. return this.imageProcessingConfiguration.colorGradingEnabled;
  117439. },
  117440. /**
  117441. * Gets wether the color grading effect is enabled.
  117442. */
  117443. set: function (value) {
  117444. this.imageProcessingConfiguration.colorGradingEnabled = value;
  117445. },
  117446. enumerable: true,
  117447. configurable: true
  117448. });
  117449. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  117450. /**
  117451. * Gets exposure used in the effect.
  117452. */
  117453. get: function () {
  117454. return this.imageProcessingConfiguration.exposure;
  117455. },
  117456. /**
  117457. * Sets exposure used in the effect.
  117458. */
  117459. set: function (value) {
  117460. this.imageProcessingConfiguration.exposure = value;
  117461. },
  117462. enumerable: true,
  117463. configurable: true
  117464. });
  117465. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  117466. /**
  117467. * Gets wether tonemapping is enabled or not.
  117468. */
  117469. get: function () {
  117470. return this._imageProcessingConfiguration.toneMappingEnabled;
  117471. },
  117472. /**
  117473. * Sets wether tonemapping is enabled or not
  117474. */
  117475. set: function (value) {
  117476. this._imageProcessingConfiguration.toneMappingEnabled = value;
  117477. },
  117478. enumerable: true,
  117479. configurable: true
  117480. });
  117481. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  117482. /**
  117483. * Gets contrast used in the effect.
  117484. */
  117485. get: function () {
  117486. return this.imageProcessingConfiguration.contrast;
  117487. },
  117488. /**
  117489. * Sets contrast used in the effect.
  117490. */
  117491. set: function (value) {
  117492. this.imageProcessingConfiguration.contrast = value;
  117493. },
  117494. enumerable: true,
  117495. configurable: true
  117496. });
  117497. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  117498. /**
  117499. * Gets Vignette stretch size.
  117500. */
  117501. get: function () {
  117502. return this.imageProcessingConfiguration.vignetteStretch;
  117503. },
  117504. /**
  117505. * Sets Vignette stretch size.
  117506. */
  117507. set: function (value) {
  117508. this.imageProcessingConfiguration.vignetteStretch = value;
  117509. },
  117510. enumerable: true,
  117511. configurable: true
  117512. });
  117513. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  117514. /**
  117515. * Gets Vignette centre X Offset.
  117516. */
  117517. get: function () {
  117518. return this.imageProcessingConfiguration.vignetteCentreX;
  117519. },
  117520. /**
  117521. * Sets Vignette centre X Offset.
  117522. */
  117523. set: function (value) {
  117524. this.imageProcessingConfiguration.vignetteCentreX = value;
  117525. },
  117526. enumerable: true,
  117527. configurable: true
  117528. });
  117529. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  117530. /**
  117531. * Gets Vignette centre Y Offset.
  117532. */
  117533. get: function () {
  117534. return this.imageProcessingConfiguration.vignetteCentreY;
  117535. },
  117536. /**
  117537. * Sets Vignette centre Y Offset.
  117538. */
  117539. set: function (value) {
  117540. this.imageProcessingConfiguration.vignetteCentreY = value;
  117541. },
  117542. enumerable: true,
  117543. configurable: true
  117544. });
  117545. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  117546. /**
  117547. * Gets Vignette weight or intensity of the vignette effect.
  117548. */
  117549. get: function () {
  117550. return this.imageProcessingConfiguration.vignetteWeight;
  117551. },
  117552. /**
  117553. * Sets Vignette weight or intensity of the vignette effect.
  117554. */
  117555. set: function (value) {
  117556. this.imageProcessingConfiguration.vignetteWeight = value;
  117557. },
  117558. enumerable: true,
  117559. configurable: true
  117560. });
  117561. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  117562. /**
  117563. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117564. * if vignetteEnabled is set to true.
  117565. */
  117566. get: function () {
  117567. return this.imageProcessingConfiguration.vignetteColor;
  117568. },
  117569. /**
  117570. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117571. * if vignetteEnabled is set to true.
  117572. */
  117573. set: function (value) {
  117574. this.imageProcessingConfiguration.vignetteColor = value;
  117575. },
  117576. enumerable: true,
  117577. configurable: true
  117578. });
  117579. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  117580. /**
  117581. * Gets Camera field of view used by the Vignette effect.
  117582. */
  117583. get: function () {
  117584. return this.imageProcessingConfiguration.vignetteCameraFov;
  117585. },
  117586. /**
  117587. * Sets Camera field of view used by the Vignette effect.
  117588. */
  117589. set: function (value) {
  117590. this.imageProcessingConfiguration.vignetteCameraFov = value;
  117591. },
  117592. enumerable: true,
  117593. configurable: true
  117594. });
  117595. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  117596. /**
  117597. * Gets the vignette blend mode allowing different kind of effect.
  117598. */
  117599. get: function () {
  117600. return this.imageProcessingConfiguration.vignetteBlendMode;
  117601. },
  117602. /**
  117603. * Sets the vignette blend mode allowing different kind of effect.
  117604. */
  117605. set: function (value) {
  117606. this.imageProcessingConfiguration.vignetteBlendMode = value;
  117607. },
  117608. enumerable: true,
  117609. configurable: true
  117610. });
  117611. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  117612. /**
  117613. * Gets wether the vignette effect is enabled.
  117614. */
  117615. get: function () {
  117616. return this.imageProcessingConfiguration.vignetteEnabled;
  117617. },
  117618. /**
  117619. * Sets wether the vignette effect is enabled.
  117620. */
  117621. set: function (value) {
  117622. this.imageProcessingConfiguration.vignetteEnabled = value;
  117623. },
  117624. enumerable: true,
  117625. configurable: true
  117626. });
  117627. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  117628. /**
  117629. * Gets wether the input of the processing is in Gamma or Linear Space.
  117630. */
  117631. get: function () {
  117632. return this._fromLinearSpace;
  117633. },
  117634. /**
  117635. * Sets wether the input of the processing is in Gamma or Linear Space.
  117636. */
  117637. set: function (value) {
  117638. if (this._fromLinearSpace === value) {
  117639. return;
  117640. }
  117641. this._fromLinearSpace = value;
  117642. this._updateParameters();
  117643. },
  117644. enumerable: true,
  117645. configurable: true
  117646. });
  117647. /**
  117648. * "ImageProcessingPostProcess"
  117649. * @returns "ImageProcessingPostProcess"
  117650. */
  117651. ImageProcessingPostProcess.prototype.getClassName = function () {
  117652. return "ImageProcessingPostProcess";
  117653. };
  117654. ImageProcessingPostProcess.prototype._updateParameters = function () {
  117655. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  117656. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  117657. var defines = "";
  117658. for (var define in this._defines) {
  117659. if (this._defines[define]) {
  117660. defines += "#define " + define + ";\r\n";
  117661. }
  117662. }
  117663. var samplers = ["textureSampler"];
  117664. var uniforms = ["scale"];
  117665. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  117666. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  117667. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  117668. }
  117669. this.updateEffect(defines, uniforms, samplers);
  117670. };
  117671. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  117672. _super.prototype.dispose.call(this, camera);
  117673. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117674. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117675. }
  117676. if (this._imageProcessingConfiguration) {
  117677. this.imageProcessingConfiguration.applyByPostProcess = false;
  117678. }
  117679. };
  117680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  117681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  117682. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  117683. return ImageProcessingPostProcess;
  117684. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  117685. /***/ }),
  117686. /***/ "./PostProcesses/index.ts":
  117687. /*!********************************!*\
  117688. !*** ./PostProcesses/index.ts ***!
  117689. \********************************/
  117690. /*! 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, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  117691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117692. "use strict";
  117693. __webpack_require__.r(__webpack_exports__);
  117694. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  117695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  117696. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  117697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  117698. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  117699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  117700. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  117701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  117702. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  117704. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  117705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  117706. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  117708. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  117709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  117710. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  117711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  117712. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  117714. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  117715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  117716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  117717. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  117719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  117720. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  117721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  117722. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  117723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  117724. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  117725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  117726. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  117727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  117728. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  117729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  117730. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  117731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  117732. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  117733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  117734. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  117735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  117736. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  117737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  117738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  117739. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  117741. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  117742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  117743. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  117744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  117745. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  117746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  117747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  117748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  117749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  117750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  117751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  117752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  117753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  117754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  117755. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  117756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  117757. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  117758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  117759. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  117760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  117761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  117762. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  117763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  117764. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  117765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  117766. /***/ }),
  117767. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  117768. /*!************************************************!*\
  117769. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  117770. \************************************************/
  117771. /*! exports provided: MotionBlurPostProcess */
  117772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117773. "use strict";
  117774. __webpack_require__.r(__webpack_exports__);
  117775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  117776. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117777. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117779. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117780. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117781. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  117782. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  117783. /**
  117784. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117785. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117786. * As an example, all you have to do is to create the post-process:
  117787. * var mb = new BABYLON.MotionBlurPostProcess(
  117788. * 'mb', // The name of the effect.
  117789. * scene, // The scene containing the objects to blur according to their velocity.
  117790. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117791. * camera // The camera to apply the render pass to.
  117792. * );
  117793. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117794. */
  117795. var MotionBlurPostProcess = /** @class */ (function (_super) {
  117796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  117797. /**
  117798. * Creates a new instance MotionBlurPostProcess
  117799. * @param name The name of the effect.
  117800. * @param scene The scene containing the objects to blur according to their velocity.
  117801. * @param options The required width/height ratio to downsize to before computing the render pass.
  117802. * @param camera The camera to apply the render pass to.
  117803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117804. * @param engine The engine which the post process will be applied. (default: current engine)
  117805. * @param reusable If the post process can be reused on the same frame. (default: false)
  117806. * @param textureType Type of textures used when performing the post process. (default: 0)
  117807. * @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)
  117808. */
  117809. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117810. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117811. if (blockCompilation === void 0) { blockCompilation = false; }
  117812. 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;
  117813. /**
  117814. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117815. */
  117816. _this.motionStrength = 1;
  117817. _this._motionBlurSamples = 32;
  117818. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  117819. if (!_this._geometryBufferRenderer) {
  117820. // Geometry buffer renderer is not supported. So, work as a passthrough.
  117821. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  117822. _this.updateEffect();
  117823. }
  117824. else {
  117825. // Geometry buffer renderer is supported.
  117826. _this._geometryBufferRenderer.enableVelocity = true;
  117827. _this.onApply = function (effect) {
  117828. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  117829. effect.setFloat("motionScale", scene.getAnimationRatio());
  117830. effect.setFloat("motionStrength", _this.motionStrength);
  117831. if (_this._geometryBufferRenderer) {
  117832. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  117833. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  117834. }
  117835. };
  117836. }
  117837. return _this;
  117838. }
  117839. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  117840. /**
  117841. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117842. */
  117843. get: function () {
  117844. return this._motionBlurSamples;
  117845. },
  117846. /**
  117847. * Sets the number of iterations to be used for motion blur quality
  117848. */
  117849. set: function (samples) {
  117850. this._motionBlurSamples = samples;
  117851. if (this._geometryBufferRenderer) {
  117852. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  117853. }
  117854. },
  117855. enumerable: true,
  117856. configurable: true
  117857. });
  117858. /**
  117859. * Disposes the post process.
  117860. * @param camera The camera to dispose the post process on.
  117861. */
  117862. MotionBlurPostProcess.prototype.dispose = function (camera) {
  117863. if (this._geometryBufferRenderer) {
  117864. // Clear previous transformation matrices dictionary used to compute objects velocities
  117865. this._geometryBufferRenderer._previousTransformationMatrices = {};
  117866. }
  117867. _super.prototype.dispose.call(this, camera);
  117868. };
  117869. return MotionBlurPostProcess;
  117870. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  117871. /***/ }),
  117872. /***/ "./PostProcesses/passPostProcess.ts":
  117873. /*!******************************************!*\
  117874. !*** ./PostProcesses/passPostProcess.ts ***!
  117875. \******************************************/
  117876. /*! exports provided: PassPostProcess, PassCubePostProcess */
  117877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117878. "use strict";
  117879. __webpack_require__.r(__webpack_exports__);
  117880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  117881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  117882. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117883. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117884. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117885. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  117886. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  117887. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  117888. /**
  117889. * PassPostProcess which produces an output the same as it's input
  117890. */
  117891. var PassPostProcess = /** @class */ (function (_super) {
  117892. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  117893. /**
  117894. * Creates the PassPostProcess
  117895. * @param name The name of the effect.
  117896. * @param options The required width/height ratio to downsize to before computing the render pass.
  117897. * @param camera The camera to apply the render pass to.
  117898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117899. * @param engine The engine which the post process will be applied. (default: current engine)
  117900. * @param reusable If the post process can be reused on the same frame. (default: false)
  117901. * @param textureType The type of texture to be used when performing the post processing.
  117902. * @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)
  117903. */
  117904. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117905. if (camera === void 0) { camera = null; }
  117906. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117907. if (blockCompilation === void 0) { blockCompilation = false; }
  117908. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  117909. }
  117910. return PassPostProcess;
  117911. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117912. /**
  117913. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  117914. */
  117915. var PassCubePostProcess = /** @class */ (function (_super) {
  117916. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  117917. /**
  117918. * Creates the PassCubePostProcess
  117919. * @param name The name of the effect.
  117920. * @param options The required width/height ratio to downsize to before computing the render pass.
  117921. * @param camera The camera to apply the render pass to.
  117922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117923. * @param engine The engine which the post process will be applied. (default: current engine)
  117924. * @param reusable If the post process can be reused on the same frame. (default: false)
  117925. * @param textureType The type of texture to be used when performing the post processing.
  117926. * @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)
  117927. */
  117928. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117929. if (camera === void 0) { camera = null; }
  117930. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117931. if (blockCompilation === void 0) { blockCompilation = false; }
  117932. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  117933. _this._face = 0;
  117934. return _this;
  117935. }
  117936. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  117937. /**
  117938. * Gets or sets the cube face to display.
  117939. * * 0 is +X
  117940. * * 1 is -X
  117941. * * 2 is +Y
  117942. * * 3 is -Y
  117943. * * 4 is +Z
  117944. * * 5 is -Z
  117945. */
  117946. get: function () {
  117947. return this._face;
  117948. },
  117949. set: function (value) {
  117950. if (value < 0 || value > 5) {
  117951. return;
  117952. }
  117953. this._face = value;
  117954. switch (this._face) {
  117955. case 0:
  117956. this.updateEffect("#define POSITIVEX");
  117957. break;
  117958. case 1:
  117959. this.updateEffect("#define NEGATIVEX");
  117960. break;
  117961. case 2:
  117962. this.updateEffect("#define POSITIVEY");
  117963. break;
  117964. case 3:
  117965. this.updateEffect("#define NEGATIVEY");
  117966. break;
  117967. case 4:
  117968. this.updateEffect("#define POSITIVEZ");
  117969. break;
  117970. case 5:
  117971. this.updateEffect("#define NEGATIVEZ");
  117972. break;
  117973. }
  117974. },
  117975. enumerable: true,
  117976. configurable: true
  117977. });
  117978. return PassCubePostProcess;
  117979. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117980. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  117981. 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);
  117982. };
  117983. /***/ }),
  117984. /***/ "./PostProcesses/postProcess.ts":
  117985. /*!**************************************!*\
  117986. !*** ./PostProcesses/postProcess.ts ***!
  117987. \**************************************/
  117988. /*! exports provided: PostProcess */
  117989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117990. "use strict";
  117991. __webpack_require__.r(__webpack_exports__);
  117992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  117993. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  117994. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  117995. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  117996. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117997. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117998. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117999. /**
  118000. * PostProcess can be used to apply a shader to a texture after it has been rendered
  118001. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118002. */
  118003. var PostProcess = /** @class */ (function () {
  118004. /**
  118005. * Creates a new instance PostProcess
  118006. * @param name The name of the PostProcess.
  118007. * @param fragmentUrl The url of the fragment shader to be used.
  118008. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  118009. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  118010. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118011. * @param camera The camera to apply the render pass to.
  118012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118013. * @param engine The engine which the post process will be applied. (default: current engine)
  118014. * @param reusable If the post process can be reused on the same frame. (default: false)
  118015. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  118016. * @param textureType Type of textures used when performing the post process. (default: 0)
  118017. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  118018. * @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
  118019. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  118020. */
  118021. function PostProcess(
  118022. /** Name of the PostProcess. */
  118023. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  118024. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  118025. if (defines === void 0) { defines = null; }
  118026. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118027. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  118028. if (blockCompilation === void 0) { blockCompilation = false; }
  118029. this.name = name;
  118030. /**
  118031. * Width of the texture to apply the post process on
  118032. */
  118033. this.width = -1;
  118034. /**
  118035. * Height of the texture to apply the post process on
  118036. */
  118037. this.height = -1;
  118038. /**
  118039. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  118040. * @hidden
  118041. */
  118042. this._outputTexture = null;
  118043. /**
  118044. * If the buffer needs to be cleared before applying the post process. (default: true)
  118045. * Should be set to false if shader will overwrite all previous pixels.
  118046. */
  118047. this.autoClear = true;
  118048. /**
  118049. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  118050. */
  118051. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  118052. /**
  118053. * Animations to be used for the post processing
  118054. */
  118055. this.animations = new Array();
  118056. /**
  118057. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  118058. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  118059. */
  118060. this.enablePixelPerfectMode = false;
  118061. /**
  118062. * Force the postprocess to be applied without taking in account viewport
  118063. */
  118064. this.forceFullscreenViewport = true;
  118065. /**
  118066. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  118067. *
  118068. * | Value | Type | Description |
  118069. * | ----- | ----------------------------------- | ----------- |
  118070. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  118071. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  118072. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  118073. *
  118074. */
  118075. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  118076. /**
  118077. * Force textures to be a power of two (default: false)
  118078. */
  118079. this.alwaysForcePOT = false;
  118080. this._samples = 1;
  118081. /**
  118082. * Modify the scale of the post process to be the same as the viewport (default: false)
  118083. */
  118084. this.adaptScaleToCurrentViewport = false;
  118085. this._reusable = false;
  118086. /**
  118087. * Smart array of input and output textures for the post process.
  118088. * @hidden
  118089. */
  118090. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118091. /**
  118092. * The index in _textures that corresponds to the output texture.
  118093. * @hidden
  118094. */
  118095. this._currentRenderTextureInd = 0;
  118096. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  118097. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118098. // Events
  118099. /**
  118100. * An event triggered when the postprocess is activated.
  118101. */
  118102. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118103. /**
  118104. * An event triggered when the postprocess changes its size.
  118105. */
  118106. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118107. /**
  118108. * An event triggered when the postprocess applies its effect.
  118109. */
  118110. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118111. /**
  118112. * An event triggered before rendering the postprocess
  118113. */
  118114. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118115. /**
  118116. * An event triggered after rendering the postprocess
  118117. */
  118118. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118119. if (camera != null) {
  118120. this._camera = camera;
  118121. this._scene = camera.getScene();
  118122. camera.attachPostProcess(this);
  118123. this._engine = this._scene.getEngine();
  118124. this._scene.postProcesses.push(this);
  118125. }
  118126. else if (engine) {
  118127. this._engine = engine;
  118128. this._engine.postProcesses.push(this);
  118129. }
  118130. this._options = options;
  118131. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  118132. this._reusable = reusable || false;
  118133. this._textureType = textureType;
  118134. this._samplers = samplers || [];
  118135. this._samplers.push("textureSampler");
  118136. this._fragmentUrl = fragmentUrl;
  118137. this._vertexUrl = vertexUrl;
  118138. this._parameters = parameters || [];
  118139. this._parameters.push("scale");
  118140. this._indexParameters = indexParameters;
  118141. if (!blockCompilation) {
  118142. this.updateEffect(defines);
  118143. }
  118144. }
  118145. Object.defineProperty(PostProcess.prototype, "samples", {
  118146. /**
  118147. * Number of sample textures (default: 1)
  118148. */
  118149. get: function () {
  118150. return this._samples;
  118151. },
  118152. set: function (n) {
  118153. var _this = this;
  118154. this._samples = n;
  118155. this._textures.forEach(function (texture) {
  118156. if (texture.samples !== _this._samples) {
  118157. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  118158. }
  118159. });
  118160. },
  118161. enumerable: true,
  118162. configurable: true
  118163. });
  118164. /**
  118165. * Returns the fragment url or shader name used in the post process.
  118166. * @returns the fragment url or name in the shader store.
  118167. */
  118168. PostProcess.prototype.getEffectName = function () {
  118169. return this._fragmentUrl;
  118170. };
  118171. Object.defineProperty(PostProcess.prototype, "onActivate", {
  118172. /**
  118173. * A function that is added to the onActivateObservable
  118174. */
  118175. set: function (callback) {
  118176. if (this._onActivateObserver) {
  118177. this.onActivateObservable.remove(this._onActivateObserver);
  118178. }
  118179. if (callback) {
  118180. this._onActivateObserver = this.onActivateObservable.add(callback);
  118181. }
  118182. },
  118183. enumerable: true,
  118184. configurable: true
  118185. });
  118186. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  118187. /**
  118188. * A function that is added to the onSizeChangedObservable
  118189. */
  118190. set: function (callback) {
  118191. if (this._onSizeChangedObserver) {
  118192. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  118193. }
  118194. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  118195. },
  118196. enumerable: true,
  118197. configurable: true
  118198. });
  118199. Object.defineProperty(PostProcess.prototype, "onApply", {
  118200. /**
  118201. * A function that is added to the onApplyObservable
  118202. */
  118203. set: function (callback) {
  118204. if (this._onApplyObserver) {
  118205. this.onApplyObservable.remove(this._onApplyObserver);
  118206. }
  118207. this._onApplyObserver = this.onApplyObservable.add(callback);
  118208. },
  118209. enumerable: true,
  118210. configurable: true
  118211. });
  118212. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  118213. /**
  118214. * A function that is added to the onBeforeRenderObservable
  118215. */
  118216. set: function (callback) {
  118217. if (this._onBeforeRenderObserver) {
  118218. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  118219. }
  118220. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  118221. },
  118222. enumerable: true,
  118223. configurable: true
  118224. });
  118225. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  118226. /**
  118227. * A function that is added to the onAfterRenderObservable
  118228. */
  118229. set: function (callback) {
  118230. if (this._onAfterRenderObserver) {
  118231. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  118232. }
  118233. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  118234. },
  118235. enumerable: true,
  118236. configurable: true
  118237. });
  118238. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  118239. /**
  118240. * 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
  118241. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  118242. */
  118243. get: function () {
  118244. return this._textures.data[this._currentRenderTextureInd];
  118245. },
  118246. set: function (value) {
  118247. this._forcedOutputTexture = value;
  118248. },
  118249. enumerable: true,
  118250. configurable: true
  118251. });
  118252. /**
  118253. * Gets the camera which post process is applied to.
  118254. * @returns The camera the post process is applied to.
  118255. */
  118256. PostProcess.prototype.getCamera = function () {
  118257. return this._camera;
  118258. };
  118259. Object.defineProperty(PostProcess.prototype, "texelSize", {
  118260. /**
  118261. * Gets the texel size of the postprocess.
  118262. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  118263. */
  118264. get: function () {
  118265. if (this._shareOutputWithPostProcess) {
  118266. return this._shareOutputWithPostProcess.texelSize;
  118267. }
  118268. if (this._forcedOutputTexture) {
  118269. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  118270. }
  118271. return this._texelSize;
  118272. },
  118273. enumerable: true,
  118274. configurable: true
  118275. });
  118276. /**
  118277. * Gets the engine which this post process belongs to.
  118278. * @returns The engine the post process was enabled with.
  118279. */
  118280. PostProcess.prototype.getEngine = function () {
  118281. return this._engine;
  118282. };
  118283. /**
  118284. * The effect that is created when initializing the post process.
  118285. * @returns The created effect corrisponding the the postprocess.
  118286. */
  118287. PostProcess.prototype.getEffect = function () {
  118288. return this._effect;
  118289. };
  118290. /**
  118291. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  118292. * @param postProcess The post process to share the output with.
  118293. * @returns This post process.
  118294. */
  118295. PostProcess.prototype.shareOutputWith = function (postProcess) {
  118296. this._disposeTextures();
  118297. this._shareOutputWithPostProcess = postProcess;
  118298. return this;
  118299. };
  118300. /**
  118301. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  118302. * This should be called if the post process that shares output with this post process is disabled/disposed.
  118303. */
  118304. PostProcess.prototype.useOwnOutput = function () {
  118305. if (this._textures.length == 0) {
  118306. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118307. }
  118308. this._shareOutputWithPostProcess = null;
  118309. };
  118310. /**
  118311. * Updates the effect with the current post process compile time values and recompiles the shader.
  118312. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118313. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118314. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118315. * @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
  118316. * @param onCompiled Called when the shader has been compiled.
  118317. * @param onError Called if there is an error when compiling a shader.
  118318. */
  118319. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118320. if (defines === void 0) { defines = null; }
  118321. if (uniforms === void 0) { uniforms = null; }
  118322. if (samplers === void 0) { samplers = null; }
  118323. 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);
  118324. };
  118325. /**
  118326. * The post process is reusable if it can be used multiple times within one frame.
  118327. * @returns If the post process is reusable
  118328. */
  118329. PostProcess.prototype.isReusable = function () {
  118330. return this._reusable;
  118331. };
  118332. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  118333. PostProcess.prototype.markTextureDirty = function () {
  118334. this.width = -1;
  118335. };
  118336. /**
  118337. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  118338. * 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.
  118339. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  118340. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  118341. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  118342. * @returns The target texture that was bound to be written to.
  118343. */
  118344. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  118345. var _this = this;
  118346. if (sourceTexture === void 0) { sourceTexture = null; }
  118347. camera = camera || this._camera;
  118348. var scene = camera.getScene();
  118349. var engine = scene.getEngine();
  118350. var maxSize = engine.getCaps().maxTextureSize;
  118351. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  118352. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  118353. // 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
  118354. var webVRCamera = camera.parent;
  118355. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  118356. requiredWidth /= 2;
  118357. }
  118358. var desiredWidth = (this._options.width || requiredWidth);
  118359. var desiredHeight = this._options.height || requiredHeight;
  118360. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  118361. if (this.adaptScaleToCurrentViewport) {
  118362. var currentViewport = engine.currentViewport;
  118363. if (currentViewport) {
  118364. desiredWidth *= currentViewport.width;
  118365. desiredHeight *= currentViewport.height;
  118366. }
  118367. }
  118368. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  118369. if (!this._options.width) {
  118370. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  118371. }
  118372. if (!this._options.height) {
  118373. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  118374. }
  118375. }
  118376. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  118377. if (this._textures.length > 0) {
  118378. for (var i = 0; i < this._textures.length; i++) {
  118379. this._engine._releaseTexture(this._textures.data[i]);
  118380. }
  118381. this._textures.reset();
  118382. }
  118383. this.width = desiredWidth;
  118384. this.height = desiredHeight;
  118385. var textureSize = { width: this.width, height: this.height };
  118386. var textureOptions = {
  118387. generateMipMaps: false,
  118388. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  118389. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  118390. samplingMode: this.renderTargetSamplingMode,
  118391. type: this._textureType
  118392. };
  118393. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118394. if (this._reusable) {
  118395. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118396. }
  118397. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  118398. this.onSizeChangedObservable.notifyObservers(this);
  118399. }
  118400. this._textures.forEach(function (texture) {
  118401. if (texture.samples !== _this.samples) {
  118402. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  118403. }
  118404. });
  118405. }
  118406. var target;
  118407. if (this._shareOutputWithPostProcess) {
  118408. target = this._shareOutputWithPostProcess.inputTexture;
  118409. }
  118410. else if (this._forcedOutputTexture) {
  118411. target = this._forcedOutputTexture;
  118412. this.width = this._forcedOutputTexture.width;
  118413. this.height = this._forcedOutputTexture.height;
  118414. }
  118415. else {
  118416. target = this.inputTexture;
  118417. }
  118418. // Bind the input of this post process to be used as the output of the previous post process.
  118419. if (this.enablePixelPerfectMode) {
  118420. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  118421. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  118422. }
  118423. else {
  118424. this._scaleRatio.copyFromFloats(1, 1);
  118425. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  118426. }
  118427. this.onActivateObservable.notifyObservers(camera);
  118428. // Clear
  118429. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  118430. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  118431. }
  118432. if (this._reusable) {
  118433. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  118434. }
  118435. return target;
  118436. };
  118437. Object.defineProperty(PostProcess.prototype, "isSupported", {
  118438. /**
  118439. * If the post process is supported.
  118440. */
  118441. get: function () {
  118442. return this._effect.isSupported;
  118443. },
  118444. enumerable: true,
  118445. configurable: true
  118446. });
  118447. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  118448. /**
  118449. * The aspect ratio of the output texture.
  118450. */
  118451. get: function () {
  118452. if (this._shareOutputWithPostProcess) {
  118453. return this._shareOutputWithPostProcess.aspectRatio;
  118454. }
  118455. if (this._forcedOutputTexture) {
  118456. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  118457. }
  118458. return this.width / this.height;
  118459. },
  118460. enumerable: true,
  118461. configurable: true
  118462. });
  118463. /**
  118464. * Get a value indicating if the post-process is ready to be used
  118465. * @returns true if the post-process is ready (shader is compiled)
  118466. */
  118467. PostProcess.prototype.isReady = function () {
  118468. return this._effect && this._effect.isReady();
  118469. };
  118470. /**
  118471. * Binds all textures and uniforms to the shader, this will be run on every pass.
  118472. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  118473. */
  118474. PostProcess.prototype.apply = function () {
  118475. // Check
  118476. if (!this._effect || !this._effect.isReady()) {
  118477. return null;
  118478. }
  118479. // States
  118480. this._engine.enableEffect(this._effect);
  118481. this._engine.setState(false);
  118482. this._engine.setDepthBuffer(false);
  118483. this._engine.setDepthWrite(false);
  118484. // Alpha
  118485. this._engine.setAlphaMode(this.alphaMode);
  118486. if (this.alphaConstants) {
  118487. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  118488. }
  118489. // Bind the output texture of the preivous post process as the input to this post process.
  118490. var source;
  118491. if (this._shareOutputWithPostProcess) {
  118492. source = this._shareOutputWithPostProcess.inputTexture;
  118493. }
  118494. else if (this._forcedOutputTexture) {
  118495. source = this._forcedOutputTexture;
  118496. }
  118497. else {
  118498. source = this.inputTexture;
  118499. }
  118500. this._effect._bindTexture("textureSampler", source);
  118501. // Parameters
  118502. this._effect.setVector2("scale", this._scaleRatio);
  118503. this.onApplyObservable.notifyObservers(this._effect);
  118504. return this._effect;
  118505. };
  118506. PostProcess.prototype._disposeTextures = function () {
  118507. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  118508. return;
  118509. }
  118510. if (this._textures.length > 0) {
  118511. for (var i = 0; i < this._textures.length; i++) {
  118512. this._engine._releaseTexture(this._textures.data[i]);
  118513. }
  118514. }
  118515. this._textures.dispose();
  118516. };
  118517. /**
  118518. * Disposes the post process.
  118519. * @param camera The camera to dispose the post process on.
  118520. */
  118521. PostProcess.prototype.dispose = function (camera) {
  118522. camera = camera || this._camera;
  118523. this._disposeTextures();
  118524. if (this._scene) {
  118525. var index_1 = this._scene.postProcesses.indexOf(this);
  118526. if (index_1 !== -1) {
  118527. this._scene.postProcesses.splice(index_1, 1);
  118528. }
  118529. }
  118530. else {
  118531. var index_2 = this._engine.postProcesses.indexOf(this);
  118532. if (index_2 !== -1) {
  118533. this._engine.postProcesses.splice(index_2, 1);
  118534. }
  118535. }
  118536. if (!camera) {
  118537. return;
  118538. }
  118539. camera.detachPostProcess(this);
  118540. var index = camera._postProcesses.indexOf(this);
  118541. if (index === 0 && camera._postProcesses.length > 0) {
  118542. var firstPostProcess = this._camera._getFirstPostProcess();
  118543. if (firstPostProcess) {
  118544. firstPostProcess.markTextureDirty();
  118545. }
  118546. }
  118547. this.onActivateObservable.clear();
  118548. this.onAfterRenderObservable.clear();
  118549. this.onApplyObservable.clear();
  118550. this.onBeforeRenderObservable.clear();
  118551. this.onSizeChangedObservable.clear();
  118552. };
  118553. return PostProcess;
  118554. }());
  118555. /***/ }),
  118556. /***/ "./PostProcesses/postProcessManager.ts":
  118557. /*!*********************************************!*\
  118558. !*** ./PostProcesses/postProcessManager.ts ***!
  118559. \*********************************************/
  118560. /*! exports provided: PostProcessManager */
  118561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118562. "use strict";
  118563. __webpack_require__.r(__webpack_exports__);
  118564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  118565. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118566. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118567. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118568. /**
  118569. * PostProcessManager is used to manage one or more post processes or post process pipelines
  118570. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118571. */
  118572. var PostProcessManager = /** @class */ (function () {
  118573. /**
  118574. * Creates a new instance PostProcess
  118575. * @param scene The scene that the post process is associated with.
  118576. */
  118577. function PostProcessManager(scene) {
  118578. this._vertexBuffers = {};
  118579. this._scene = scene;
  118580. }
  118581. PostProcessManager.prototype._prepareBuffers = function () {
  118582. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  118583. return;
  118584. }
  118585. // VBO
  118586. var vertices = [];
  118587. vertices.push(1, 1);
  118588. vertices.push(-1, 1);
  118589. vertices.push(-1, -1);
  118590. vertices.push(1, -1);
  118591. 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);
  118592. this._buildIndexBuffer();
  118593. };
  118594. PostProcessManager.prototype._buildIndexBuffer = function () {
  118595. // Indices
  118596. var indices = [];
  118597. indices.push(0);
  118598. indices.push(1);
  118599. indices.push(2);
  118600. indices.push(0);
  118601. indices.push(2);
  118602. indices.push(3);
  118603. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  118604. };
  118605. /**
  118606. * Rebuilds the vertex buffers of the manager.
  118607. * @hidden
  118608. */
  118609. PostProcessManager.prototype._rebuild = function () {
  118610. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118611. if (!vb) {
  118612. return;
  118613. }
  118614. vb._rebuild();
  118615. this._buildIndexBuffer();
  118616. };
  118617. // Methods
  118618. /**
  118619. * Prepares a frame to be run through a post process.
  118620. * @param sourceTexture The input texture to the post procesess. (default: null)
  118621. * @param postProcesses An array of post processes to be run. (default: null)
  118622. * @returns True if the post processes were able to be run.
  118623. * @hidden
  118624. */
  118625. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  118626. if (sourceTexture === void 0) { sourceTexture = null; }
  118627. if (postProcesses === void 0) { postProcesses = null; }
  118628. var camera = this._scene.activeCamera;
  118629. if (!camera) {
  118630. return false;
  118631. }
  118632. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  118633. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  118634. return false;
  118635. }
  118636. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  118637. return true;
  118638. };
  118639. /**
  118640. * Manually render a set of post processes to a texture.
  118641. * @param postProcesses An array of post processes to be run.
  118642. * @param targetTexture The target texture to render to.
  118643. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  118644. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  118645. * @param lodLevel defines which lod of the texture to render to
  118646. */
  118647. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  118648. if (targetTexture === void 0) { targetTexture = null; }
  118649. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  118650. if (faceIndex === void 0) { faceIndex = 0; }
  118651. if (lodLevel === void 0) { lodLevel = 0; }
  118652. var engine = this._scene.getEngine();
  118653. for (var index = 0; index < postProcesses.length; index++) {
  118654. if (index < postProcesses.length - 1) {
  118655. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  118656. }
  118657. else {
  118658. if (targetTexture) {
  118659. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  118660. }
  118661. else {
  118662. engine.restoreDefaultFramebuffer();
  118663. }
  118664. }
  118665. var pp = postProcesses[index];
  118666. var effect = pp.apply();
  118667. if (effect) {
  118668. pp.onBeforeRenderObservable.notifyObservers(effect);
  118669. // VBOs
  118670. this._prepareBuffers();
  118671. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  118672. // Draw order
  118673. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  118674. pp.onAfterRenderObservable.notifyObservers(effect);
  118675. }
  118676. }
  118677. // Restore depth buffer
  118678. engine.setDepthBuffer(true);
  118679. engine.setDepthWrite(true);
  118680. };
  118681. /**
  118682. * Finalize the result of the output of the postprocesses.
  118683. * @param doNotPresent If true the result will not be displayed to the screen.
  118684. * @param targetTexture The target texture to render to.
  118685. * @param faceIndex The index of the face to bind the target texture to.
  118686. * @param postProcesses The array of post processes to render.
  118687. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  118688. * @hidden
  118689. */
  118690. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  118691. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  118692. var camera = this._scene.activeCamera;
  118693. if (!camera) {
  118694. return;
  118695. }
  118696. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  118697. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  118698. return;
  118699. }
  118700. var engine = this._scene.getEngine();
  118701. for (var index = 0, len = postProcesses.length; index < len; index++) {
  118702. var pp = postProcesses[index];
  118703. if (index < len - 1) {
  118704. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  118705. }
  118706. else {
  118707. if (targetTexture) {
  118708. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  118709. pp._outputTexture = targetTexture;
  118710. }
  118711. else {
  118712. engine.restoreDefaultFramebuffer();
  118713. pp._outputTexture = null;
  118714. }
  118715. }
  118716. if (doNotPresent) {
  118717. break;
  118718. }
  118719. var effect = pp.apply();
  118720. if (effect) {
  118721. pp.onBeforeRenderObservable.notifyObservers(effect);
  118722. // VBOs
  118723. this._prepareBuffers();
  118724. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  118725. // Draw order
  118726. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  118727. pp.onAfterRenderObservable.notifyObservers(effect);
  118728. }
  118729. }
  118730. // Restore states
  118731. engine.setDepthBuffer(true);
  118732. engine.setDepthWrite(true);
  118733. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  118734. };
  118735. /**
  118736. * Disposes of the post process manager.
  118737. */
  118738. PostProcessManager.prototype.dispose = function () {
  118739. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118740. if (buffer) {
  118741. buffer.dispose();
  118742. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  118743. }
  118744. if (this._indexBuffer) {
  118745. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  118746. this._indexBuffer = null;
  118747. }
  118748. };
  118749. return PostProcessManager;
  118750. }());
  118751. /***/ }),
  118752. /***/ "./PostProcesses/refractionPostProcess.ts":
  118753. /*!************************************************!*\
  118754. !*** ./PostProcesses/refractionPostProcess.ts ***!
  118755. \************************************************/
  118756. /*! exports provided: RefractionPostProcess */
  118757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118758. "use strict";
  118759. __webpack_require__.r(__webpack_exports__);
  118760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  118761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118762. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118763. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118764. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  118765. /**
  118766. * Post process which applies a refractin texture
  118767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118768. */
  118769. var RefractionPostProcess = /** @class */ (function (_super) {
  118770. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  118771. /**
  118772. * Initializes the RefractionPostProcess
  118773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118774. * @param name The name of the effect.
  118775. * @param refractionTextureUrl Url of the refraction texture to use
  118776. * @param color the base color of the refraction (used to taint the rendering)
  118777. * @param depth simulated refraction depth
  118778. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118779. * @param camera The camera to apply the render pass to.
  118780. * @param options The required width/height ratio to downsize to before computing the render pass.
  118781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118782. * @param engine The engine which the post process will be applied. (default: current engine)
  118783. * @param reusable If the post process can be reused on the same frame. (default: false)
  118784. */
  118785. function RefractionPostProcess(name, refractionTextureUrl,
  118786. /** the base color of the refraction (used to taint the rendering) */
  118787. color,
  118788. /** simulated refraction depth */
  118789. depth,
  118790. /** the coefficient of the base color (0 to remove base color tainting) */
  118791. colorLevel, options, camera, samplingMode, engine, reusable) {
  118792. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  118793. _this.color = color;
  118794. _this.depth = depth;
  118795. _this.colorLevel = colorLevel;
  118796. _this._ownRefractionTexture = true;
  118797. _this.onActivateObservable.add(function (cam) {
  118798. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  118799. });
  118800. _this.onApplyObservable.add(function (effect) {
  118801. effect.setColor3("baseColor", _this.color);
  118802. effect.setFloat("depth", _this.depth);
  118803. effect.setFloat("colorLevel", _this.colorLevel);
  118804. effect.setTexture("refractionSampler", _this._refTexture);
  118805. });
  118806. return _this;
  118807. }
  118808. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  118809. /**
  118810. * Gets or sets the refraction texture
  118811. * Please note that you are responsible for disposing the texture if you set it manually
  118812. */
  118813. get: function () {
  118814. return this._refTexture;
  118815. },
  118816. set: function (value) {
  118817. if (this._refTexture && this._ownRefractionTexture) {
  118818. this._refTexture.dispose();
  118819. }
  118820. this._refTexture = value;
  118821. this._ownRefractionTexture = false;
  118822. },
  118823. enumerable: true,
  118824. configurable: true
  118825. });
  118826. // Methods
  118827. /**
  118828. * Disposes of the post process
  118829. * @param camera Camera to dispose post process on
  118830. */
  118831. RefractionPostProcess.prototype.dispose = function (camera) {
  118832. if (this._refTexture && this._ownRefractionTexture) {
  118833. this._refTexture.dispose();
  118834. this._refTexture = null;
  118835. }
  118836. _super.prototype.dispose.call(this, camera);
  118837. };
  118838. return RefractionPostProcess;
  118839. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118840. /***/ }),
  118841. /***/ "./PostProcesses/sharpenPostProcess.ts":
  118842. /*!*********************************************!*\
  118843. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  118844. \*********************************************/
  118845. /*! exports provided: SharpenPostProcess */
  118846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118847. "use strict";
  118848. __webpack_require__.r(__webpack_exports__);
  118849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  118850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118851. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118852. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118853. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  118854. /**
  118855. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118856. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118857. */
  118858. var SharpenPostProcess = /** @class */ (function (_super) {
  118859. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  118860. /**
  118861. * Creates a new instance ConvolutionPostProcess
  118862. * @param name The name of the effect.
  118863. * @param options The required width/height ratio to downsize to before computing the render pass.
  118864. * @param camera The camera to apply the render pass to.
  118865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118866. * @param engine The engine which the post process will be applied. (default: current engine)
  118867. * @param reusable If the post process can be reused on the same frame. (default: false)
  118868. * @param textureType Type of textures used when performing the post process. (default: 0)
  118869. * @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)
  118870. */
  118871. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118872. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118873. if (blockCompilation === void 0) { blockCompilation = false; }
  118874. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  118875. /**
  118876. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118877. */
  118878. _this.colorAmount = 1.0;
  118879. /**
  118880. * How much sharpness should be applied (default: 0.3)
  118881. */
  118882. _this.edgeAmount = 0.3;
  118883. _this.onApply = function (effect) {
  118884. effect.setFloat2("screenSize", _this.width, _this.height);
  118885. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  118886. };
  118887. return _this;
  118888. }
  118889. return SharpenPostProcess;
  118890. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118891. /***/ }),
  118892. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  118893. /*!***********************************************************!*\
  118894. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  118895. \***********************************************************/
  118896. /*! exports provided: StereoscopicInterlacePostProcess */
  118897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118898. "use strict";
  118899. __webpack_require__.r(__webpack_exports__);
  118900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  118901. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118903. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118904. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  118905. /**
  118906. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  118907. */
  118908. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  118909. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  118910. /**
  118911. * Initializes a StereoscopicInterlacePostProcess
  118912. * @param name The name of the effect.
  118913. * @param rigCameras The rig cameras to be appled to the post process
  118914. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  118915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118916. * @param engine The engine which the post process will be applied. (default: current engine)
  118917. * @param reusable If the post process can be reused on the same frame. (default: false)
  118918. */
  118919. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  118920. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  118921. _this._passedProcess = rigCameras[0]._rigPostProcess;
  118922. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  118923. _this.onSizeChangedObservable.add(function () {
  118924. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  118925. });
  118926. _this.onApplyObservable.add(function (effect) {
  118927. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  118928. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  118929. });
  118930. return _this;
  118931. }
  118932. return StereoscopicInterlacePostProcess;
  118933. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118934. /***/ }),
  118935. /***/ "./PostProcesses/tonemapPostProcess.ts":
  118936. /*!*********************************************!*\
  118937. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  118938. \*********************************************/
  118939. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  118940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118941. "use strict";
  118942. __webpack_require__.r(__webpack_exports__);
  118943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  118944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  118945. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118946. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118947. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118948. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  118949. /** Defines operator used for tonemapping */
  118950. var TonemappingOperator;
  118951. (function (TonemappingOperator) {
  118952. /** Hable */
  118953. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  118954. /** Reinhard */
  118955. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  118956. /** HejiDawson */
  118957. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  118958. /** Photographic */
  118959. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  118960. })(TonemappingOperator || (TonemappingOperator = {}));
  118961. /**
  118962. * Defines a post process to apply tone mapping
  118963. */
  118964. var TonemapPostProcess = /** @class */ (function (_super) {
  118965. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  118966. /**
  118967. * Creates a new TonemapPostProcess
  118968. * @param name defines the name of the postprocess
  118969. * @param _operator defines the operator to use
  118970. * @param exposureAdjustment defines the required exposure adjustement
  118971. * @param camera defines the camera to use (can be null)
  118972. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  118973. * @param engine defines the hosting engine (can be ignore if camera is set)
  118974. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118975. */
  118976. function TonemapPostProcess(name, _operator,
  118977. /** Defines the required exposure adjustement */
  118978. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  118979. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  118980. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118981. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  118982. _this._operator = _operator;
  118983. _this.exposureAdjustment = exposureAdjustment;
  118984. var defines = "#define ";
  118985. if (_this._operator === TonemappingOperator.Hable) {
  118986. defines += "HABLE_TONEMAPPING";
  118987. }
  118988. else if (_this._operator === TonemappingOperator.Reinhard) {
  118989. defines += "REINHARD_TONEMAPPING";
  118990. }
  118991. else if (_this._operator === TonemappingOperator.HejiDawson) {
  118992. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  118993. }
  118994. else if (_this._operator === TonemappingOperator.Photographic) {
  118995. defines += "PHOTOGRAPHIC_TONEMAPPING";
  118996. }
  118997. //sadly a second call to create the effect.
  118998. _this.updateEffect(defines);
  118999. _this.onApply = function (effect) {
  119000. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  119001. };
  119002. return _this;
  119003. }
  119004. return TonemapPostProcess;
  119005. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119006. /***/ }),
  119007. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  119008. /*!***************************************************************!*\
  119009. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  119010. \***************************************************************/
  119011. /*! exports provided: VolumetricLightScatteringPostProcess */
  119012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119013. "use strict";
  119014. __webpack_require__.r(__webpack_exports__);
  119015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  119016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119017. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119018. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119019. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119020. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119021. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119022. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  119023. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119024. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  119025. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119026. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119027. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119028. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119029. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  119030. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119031. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  119032. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  119033. /**
  119034. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119035. */
  119036. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  119037. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  119038. /**
  119039. * @constructor
  119040. * @param name The post-process name
  119041. * @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)
  119042. * @param camera The camera that the post-process will be attached to
  119043. * @param mesh The mesh used to create the light scattering
  119044. * @param samples The post-process quality, default 100
  119045. * @param samplingModeThe post-process filtering mode
  119046. * @param engine The babylon engine
  119047. * @param reusable If the post-process is reusable
  119048. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119049. */
  119050. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  119051. if (samples === void 0) { samples = 100; }
  119052. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  119053. 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;
  119054. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119055. /**
  119056. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119057. */
  119058. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119059. /**
  119060. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119061. */
  119062. _this.useCustomMeshPosition = false;
  119063. /**
  119064. * If the post-process should inverse the light scattering direction
  119065. */
  119066. _this.invert = true;
  119067. /**
  119068. * Array containing the excluded meshes not rendered in the internal pass
  119069. */
  119070. _this.excludedMeshes = new Array();
  119071. /**
  119072. * Controls the overall intensity of the post-process
  119073. */
  119074. _this.exposure = 0.3;
  119075. /**
  119076. * Dissipates each sample's contribution in range [0, 1]
  119077. */
  119078. _this.decay = 0.96815;
  119079. /**
  119080. * Controls the overall intensity of each sample
  119081. */
  119082. _this.weight = 0.58767;
  119083. /**
  119084. * Controls the density of each sample
  119085. */
  119086. _this.density = 0.926;
  119087. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  119088. engine = scene.getEngine();
  119089. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  119090. // Configure mesh
  119091. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  119092. // Configure
  119093. _this._createPass(scene, ratio.passRatio || ratio);
  119094. _this.onActivate = function (camera) {
  119095. if (!_this.isSupported) {
  119096. _this.dispose(camera);
  119097. }
  119098. _this.onActivate = null;
  119099. };
  119100. _this.onApplyObservable.add(function (effect) {
  119101. _this._updateMeshScreenCoordinates(scene);
  119102. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  119103. effect.setFloat("exposure", _this.exposure);
  119104. effect.setFloat("decay", _this.decay);
  119105. effect.setFloat("weight", _this.weight);
  119106. effect.setFloat("density", _this.density);
  119107. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  119108. });
  119109. return _this;
  119110. }
  119111. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  119112. /**
  119113. * @hidden
  119114. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119115. */
  119116. get: function () {
  119117. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119118. return false;
  119119. },
  119120. set: function (useDiffuseColor) {
  119121. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119122. },
  119123. enumerable: true,
  119124. configurable: true
  119125. });
  119126. /**
  119127. * Returns the string "VolumetricLightScatteringPostProcess"
  119128. * @returns "VolumetricLightScatteringPostProcess"
  119129. */
  119130. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  119131. return "VolumetricLightScatteringPostProcess";
  119132. };
  119133. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  119134. var mesh = subMesh.getMesh();
  119135. // Render this.mesh as default
  119136. if (mesh === this.mesh && mesh.material) {
  119137. return mesh.material.isReady(mesh);
  119138. }
  119139. var defines = [];
  119140. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  119141. var material = subMesh.getMaterial();
  119142. // Alpha test
  119143. if (material) {
  119144. if (material.needAlphaTesting()) {
  119145. defines.push("#define ALPHATEST");
  119146. }
  119147. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  119148. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  119149. defines.push("#define UV1");
  119150. }
  119151. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  119152. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  119153. defines.push("#define UV2");
  119154. }
  119155. }
  119156. // Bones
  119157. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119158. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  119159. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  119160. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119161. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  119162. }
  119163. else {
  119164. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119165. }
  119166. // Instances
  119167. if (useInstances) {
  119168. defines.push("#define INSTANCES");
  119169. attribs.push("world0");
  119170. attribs.push("world1");
  119171. attribs.push("world2");
  119172. attribs.push("world3");
  119173. }
  119174. // Get correct effect
  119175. var join = defines.join("\n");
  119176. if (this._cachedDefines !== join) {
  119177. this._cachedDefines = join;
  119178. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  119179. }
  119180. return this._volumetricLightScatteringPass.isReady();
  119181. };
  119182. /**
  119183. * Sets the new light position for light scattering effect
  119184. * @param position The new custom light position
  119185. */
  119186. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  119187. this.customMeshPosition = position;
  119188. };
  119189. /**
  119190. * Returns the light position for light scattering effect
  119191. * @return Vector3 The custom light position
  119192. */
  119193. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  119194. return this.customMeshPosition;
  119195. };
  119196. /**
  119197. * Disposes the internal assets and detaches the post-process from the camera
  119198. */
  119199. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  119200. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  119201. if (rttIndex !== -1) {
  119202. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  119203. }
  119204. this._volumetricLightScatteringRTT.dispose();
  119205. _super.prototype.dispose.call(this, camera);
  119206. };
  119207. /**
  119208. * Returns the render target texture used by the post-process
  119209. * @return the render target texture used by the post-process
  119210. */
  119211. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  119212. return this._volumetricLightScatteringRTT;
  119213. };
  119214. // Private methods
  119215. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  119216. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  119217. return true;
  119218. }
  119219. return false;
  119220. };
  119221. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  119222. var _this = this;
  119223. var engine = scene.getEngine();
  119224. 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);
  119225. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119226. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119227. this._volumetricLightScatteringRTT.renderList = null;
  119228. this._volumetricLightScatteringRTT.renderParticles = false;
  119229. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  119230. var camera = this.getCamera();
  119231. if (camera) {
  119232. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119233. }
  119234. else {
  119235. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119236. }
  119237. // Custom render function for submeshes
  119238. var renderSubMesh = function (subMesh) {
  119239. var mesh = subMesh.getRenderingMesh();
  119240. if (_this._meshExcluded(mesh)) {
  119241. return;
  119242. }
  119243. var material = subMesh.getMaterial();
  119244. if (!material) {
  119245. return;
  119246. }
  119247. var scene = mesh.getScene();
  119248. var engine = scene.getEngine();
  119249. // Culling
  119250. engine.setState(material.backFaceCulling);
  119251. // Managing instances
  119252. var batch = mesh._getInstancesRenderList(subMesh._id);
  119253. if (batch.mustReturn) {
  119254. return;
  119255. }
  119256. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119257. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  119258. var effect = _this._volumetricLightScatteringPass;
  119259. if (mesh === _this.mesh) {
  119260. if (subMesh.effect) {
  119261. effect = subMesh.effect;
  119262. }
  119263. else {
  119264. effect = material.getEffect();
  119265. }
  119266. }
  119267. engine.enableEffect(effect);
  119268. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  119269. if (mesh === _this.mesh) {
  119270. material.bind(mesh.getWorldMatrix(), mesh);
  119271. }
  119272. else {
  119273. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  119274. // Alpha test
  119275. if (material && material.needAlphaTesting()) {
  119276. var alphaTexture = material.getAlphaTestTexture();
  119277. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  119278. if (alphaTexture) {
  119279. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119280. }
  119281. }
  119282. // Bones
  119283. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119284. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119285. }
  119286. }
  119287. // Draw
  119288. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  119289. }
  119290. };
  119291. // Render target texture callbacks
  119292. var savedSceneClearColor;
  119293. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  119294. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  119295. savedSceneClearColor = scene.clearColor;
  119296. scene.clearColor = sceneClearColor;
  119297. });
  119298. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  119299. scene.clearColor = savedSceneClearColor;
  119300. });
  119301. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119302. var engine = scene.getEngine();
  119303. var index;
  119304. if (depthOnlySubMeshes.length) {
  119305. engine.setColorWrite(false);
  119306. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119307. renderSubMesh(depthOnlySubMeshes.data[index]);
  119308. }
  119309. engine.setColorWrite(true);
  119310. }
  119311. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119312. renderSubMesh(opaqueSubMeshes.data[index]);
  119313. }
  119314. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119315. renderSubMesh(alphaTestSubMeshes.data[index]);
  119316. }
  119317. if (transparentSubMeshes.length) {
  119318. // Sort sub meshes
  119319. for (index = 0; index < transparentSubMeshes.length; index++) {
  119320. var submesh = transparentSubMeshes.data[index];
  119321. var boundingInfo = submesh.getBoundingInfo();
  119322. if (boundingInfo && scene.activeCamera) {
  119323. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  119324. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  119325. }
  119326. }
  119327. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  119328. sortedArray.sort(function (a, b) {
  119329. // Alpha index first
  119330. if (a._alphaIndex > b._alphaIndex) {
  119331. return 1;
  119332. }
  119333. if (a._alphaIndex < b._alphaIndex) {
  119334. return -1;
  119335. }
  119336. // Then distance to camera
  119337. if (a._distanceToCamera < b._distanceToCamera) {
  119338. return 1;
  119339. }
  119340. if (a._distanceToCamera > b._distanceToCamera) {
  119341. return -1;
  119342. }
  119343. return 0;
  119344. });
  119345. // Render sub meshes
  119346. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  119347. for (index = 0; index < sortedArray.length; index++) {
  119348. renderSubMesh(sortedArray[index]);
  119349. }
  119350. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  119351. }
  119352. };
  119353. };
  119354. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  119355. var transform = scene.getTransformMatrix();
  119356. var meshPosition;
  119357. if (this.useCustomMeshPosition) {
  119358. meshPosition = this.customMeshPosition;
  119359. }
  119360. else if (this.attachedNode) {
  119361. meshPosition = this.attachedNode.position;
  119362. }
  119363. else {
  119364. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  119365. }
  119366. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  119367. this._screenCoordinates.x = pos.x / this._viewPort.width;
  119368. this._screenCoordinates.y = pos.y / this._viewPort.height;
  119369. if (this.invert) {
  119370. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  119371. }
  119372. };
  119373. // Static methods
  119374. /**
  119375. * Creates a default mesh for the Volumeric Light Scattering post-process
  119376. * @param name The mesh name
  119377. * @param scene The scene where to create the mesh
  119378. * @return the default mesh
  119379. */
  119380. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  119381. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  119382. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  119383. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  119384. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  119385. mesh.material = material;
  119386. return mesh;
  119387. };
  119388. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119390. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  119391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119393. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  119394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119396. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  119397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119399. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  119400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119402. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  119403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119405. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  119406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119408. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  119409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119411. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  119412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119414. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  119415. return VolumetricLightScatteringPostProcess;
  119416. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  119417. /***/ }),
  119418. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  119419. /*!************************************************************!*\
  119420. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  119421. \************************************************************/
  119422. /*! exports provided: VRDistortionCorrectionPostProcess */
  119423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119424. "use strict";
  119425. __webpack_require__.r(__webpack_exports__);
  119426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  119427. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119428. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119429. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119430. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119431. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  119432. /**
  119433. * VRDistortionCorrectionPostProcess used for mobile VR
  119434. */
  119435. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  119436. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  119437. /**
  119438. * Initializes the VRDistortionCorrectionPostProcess
  119439. * @param name The name of the effect.
  119440. * @param camera The camera to apply the render pass to.
  119441. * @param isRightEye If this is for the right eye distortion
  119442. * @param vrMetrics All the required metrics for the VR camera
  119443. */
  119444. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  119445. var _this = _super.call(this, name, "vrDistortionCorrection", [
  119446. 'LensCenter',
  119447. 'Scale',
  119448. 'ScaleIn',
  119449. 'HmdWarpParam'
  119450. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  119451. _this._isRightEye = isRightEye;
  119452. _this._distortionFactors = vrMetrics.distortionK;
  119453. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  119454. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  119455. _this.adaptScaleToCurrentViewport = true;
  119456. _this.onSizeChangedObservable.add(function () {
  119457. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  119458. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  119459. _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);
  119460. });
  119461. _this.onApplyObservable.add(function (effect) {
  119462. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  119463. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  119464. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  119465. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  119466. });
  119467. return _this;
  119468. }
  119469. return VRDistortionCorrectionPostProcess;
  119470. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119471. /***/ }),
  119472. /***/ "./Probes/index.ts":
  119473. /*!*************************!*\
  119474. !*** ./Probes/index.ts ***!
  119475. \*************************/
  119476. /*! exports provided: ReflectionProbe */
  119477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119478. "use strict";
  119479. __webpack_require__.r(__webpack_exports__);
  119480. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  119481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  119482. /***/ }),
  119483. /***/ "./Probes/reflectionProbe.ts":
  119484. /*!***********************************!*\
  119485. !*** ./Probes/reflectionProbe.ts ***!
  119486. \***********************************/
  119487. /*! exports provided: ReflectionProbe */
  119488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119489. "use strict";
  119490. __webpack_require__.r(__webpack_exports__);
  119491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  119492. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119493. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119494. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119495. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119496. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  119497. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119498. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  119499. if (!this.reflectionProbes) {
  119500. return -1;
  119501. }
  119502. var index = this.reflectionProbes.indexOf(toRemove);
  119503. if (index !== -1) {
  119504. this.reflectionProbes.splice(index, 1);
  119505. }
  119506. return index;
  119507. };
  119508. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  119509. if (!this.reflectionProbes) {
  119510. this.reflectionProbes = [];
  119511. }
  119512. this.reflectionProbes.push(newReflectionProbe);
  119513. };
  119514. /**
  119515. * Class used to generate realtime reflection / refraction cube textures
  119516. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119517. */
  119518. var ReflectionProbe = /** @class */ (function () {
  119519. /**
  119520. * Creates a new reflection probe
  119521. * @param name defines the name of the probe
  119522. * @param size defines the texture resolution (for each face)
  119523. * @param scene defines the hosting scene
  119524. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119525. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119526. */
  119527. function ReflectionProbe(
  119528. /** defines the name of the probe */
  119529. name, size, scene, generateMipMaps, useFloat) {
  119530. if (generateMipMaps === void 0) { generateMipMaps = true; }
  119531. if (useFloat === void 0) { useFloat = false; }
  119532. var _this = this;
  119533. this.name = name;
  119534. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  119535. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119536. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119537. this._invertYAxis = false;
  119538. /** Gets or sets probe position (center of the cube map) */
  119539. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119540. this._scene = scene;
  119541. // Create the scene field if not exist.
  119542. if (!this._scene.reflectionProbes) {
  119543. this._scene.reflectionProbes = new Array();
  119544. }
  119545. this._scene.reflectionProbes.push(this);
  119546. 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);
  119547. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  119548. switch (faceIndex) {
  119549. case 0:
  119550. _this._add.copyFromFloats(1, 0, 0);
  119551. break;
  119552. case 1:
  119553. _this._add.copyFromFloats(-1, 0, 0);
  119554. break;
  119555. case 2:
  119556. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  119557. break;
  119558. case 3:
  119559. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  119560. break;
  119561. case 4:
  119562. _this._add.copyFromFloats(0, 0, 1);
  119563. break;
  119564. case 5:
  119565. _this._add.copyFromFloats(0, 0, -1);
  119566. break;
  119567. }
  119568. if (_this._attachedMesh) {
  119569. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  119570. }
  119571. _this.position.addToRef(_this._add, _this._target);
  119572. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  119573. if (scene.activeCamera) {
  119574. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  119575. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  119576. }
  119577. scene._forcedViewPosition = _this.position;
  119578. });
  119579. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  119580. scene._forcedViewPosition = null;
  119581. scene.updateTransformMatrix(true);
  119582. });
  119583. }
  119584. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  119585. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119586. get: function () {
  119587. return this._renderTargetTexture.samples;
  119588. },
  119589. set: function (value) {
  119590. this._renderTargetTexture.samples = value;
  119591. },
  119592. enumerable: true,
  119593. configurable: true
  119594. });
  119595. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  119596. /** Gets or sets the refresh rate to use (on every frame by default) */
  119597. get: function () {
  119598. return this._renderTargetTexture.refreshRate;
  119599. },
  119600. set: function (value) {
  119601. this._renderTargetTexture.refreshRate = value;
  119602. },
  119603. enumerable: true,
  119604. configurable: true
  119605. });
  119606. /**
  119607. * Gets the hosting scene
  119608. * @returns a Scene
  119609. */
  119610. ReflectionProbe.prototype.getScene = function () {
  119611. return this._scene;
  119612. };
  119613. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  119614. /** Gets the internal CubeTexture used to render to */
  119615. get: function () {
  119616. return this._renderTargetTexture;
  119617. },
  119618. enumerable: true,
  119619. configurable: true
  119620. });
  119621. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  119622. /** Gets the list of meshes to render */
  119623. get: function () {
  119624. return this._renderTargetTexture.renderList;
  119625. },
  119626. enumerable: true,
  119627. configurable: true
  119628. });
  119629. /**
  119630. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119631. * @param mesh defines the mesh to attach to
  119632. */
  119633. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  119634. this._attachedMesh = mesh;
  119635. };
  119636. /**
  119637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119638. * @param renderingGroupId The rendering group id corresponding to its index
  119639. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119640. */
  119641. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  119642. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  119643. };
  119644. /**
  119645. * Clean all associated resources
  119646. */
  119647. ReflectionProbe.prototype.dispose = function () {
  119648. var index = this._scene.reflectionProbes.indexOf(this);
  119649. if (index !== -1) {
  119650. // Remove from the scene if found
  119651. this._scene.reflectionProbes.splice(index, 1);
  119652. }
  119653. if (this._renderTargetTexture) {
  119654. this._renderTargetTexture.dispose();
  119655. this._renderTargetTexture = null;
  119656. }
  119657. };
  119658. /**
  119659. * Converts the reflection probe information to a readable string for debug purpose.
  119660. * @param fullDetails Supports for multiple levels of logging within scene loading
  119661. * @returns the human readable reflection probe info
  119662. */
  119663. ReflectionProbe.prototype.toString = function (fullDetails) {
  119664. var ret = "Name: " + this.name;
  119665. if (fullDetails) {
  119666. ret += ", position: " + this.position.toString();
  119667. if (this._attachedMesh) {
  119668. ret += ", attached mesh: " + this._attachedMesh.name;
  119669. }
  119670. }
  119671. return ret;
  119672. };
  119673. /**
  119674. * Get the class name of the relfection probe.
  119675. * @returns "ReflectionProbe"
  119676. */
  119677. ReflectionProbe.prototype.getClassName = function () {
  119678. return "ReflectionProbe";
  119679. };
  119680. /**
  119681. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119682. * @returns The JSON representation of the texture
  119683. */
  119684. ReflectionProbe.prototype.serialize = function () {
  119685. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  119686. serializationObject.isReflectionProbe = true;
  119687. return serializationObject;
  119688. };
  119689. /**
  119690. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119691. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119692. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119693. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119694. * @returns The parsed reflection probe if successful
  119695. */
  119696. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  119697. var reflectionProbe = null;
  119698. if (scene.reflectionProbes) {
  119699. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  119700. var rp = scene.reflectionProbes[index];
  119701. if (rp.name === parsedReflectionProbe.name) {
  119702. reflectionProbe = rp;
  119703. break;
  119704. }
  119705. }
  119706. }
  119707. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  119708. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  119709. if (parsedReflectionProbe._attachedMesh) {
  119710. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  119711. }
  119712. return reflectionProbe;
  119713. };
  119714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119716. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  119717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119719. ], ReflectionProbe.prototype, "position", void 0);
  119720. return ReflectionProbe;
  119721. }());
  119722. /***/ }),
  119723. /***/ "./Rendering/boundingBoxRenderer.ts":
  119724. /*!******************************************!*\
  119725. !*** ./Rendering/boundingBoxRenderer.ts ***!
  119726. \******************************************/
  119727. /*! exports provided: BoundingBoxRenderer */
  119728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119729. "use strict";
  119730. __webpack_require__.r(__webpack_exports__);
  119731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  119732. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  119733. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119734. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119735. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  119736. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119737. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  119738. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  119739. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119740. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  119741. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  119742. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  119743. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  119744. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  119745. get: function () {
  119746. return this._forceShowBoundingBoxes || false;
  119747. },
  119748. set: function (value) {
  119749. this._forceShowBoundingBoxes = value;
  119750. // Lazyly creates a BB renderer if needed.
  119751. if (value) {
  119752. this.getBoundingBoxRenderer();
  119753. }
  119754. },
  119755. enumerable: true,
  119756. configurable: true
  119757. });
  119758. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  119759. if (!this._boundingBoxRenderer) {
  119760. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  119761. }
  119762. return this._boundingBoxRenderer;
  119763. };
  119764. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  119765. get: function () {
  119766. return this._showBoundingBox || false;
  119767. },
  119768. set: function (value) {
  119769. this._showBoundingBox = value;
  119770. // Lazyly creates a BB renderer if needed.
  119771. if (value) {
  119772. this.getScene().getBoundingBoxRenderer();
  119773. }
  119774. },
  119775. enumerable: true,
  119776. configurable: true
  119777. });
  119778. /**
  119779. * Component responsible of rendering the bounding box of the meshes in a scene.
  119780. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119781. */
  119782. var BoundingBoxRenderer = /** @class */ (function () {
  119783. /**
  119784. * Instantiates a new bounding box renderer in a scene.
  119785. * @param scene the scene the renderer renders in
  119786. */
  119787. function BoundingBoxRenderer(scene) {
  119788. /**
  119789. * The component name helpfull to identify the component in the list of scene components.
  119790. */
  119791. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  119792. /**
  119793. * Color of the bounding box lines placed in front of an object
  119794. */
  119795. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  119796. /**
  119797. * Color of the bounding box lines placed behind an object
  119798. */
  119799. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  119800. /**
  119801. * Defines if the renderer should show the back lines or not
  119802. */
  119803. this.showBackLines = true;
  119804. /**
  119805. * @hidden
  119806. */
  119807. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  119808. this._vertexBuffers = {};
  119809. this.scene = scene;
  119810. scene._addComponent(this);
  119811. }
  119812. /**
  119813. * Registers the component in a given scene
  119814. */
  119815. BoundingBoxRenderer.prototype.register = function () {
  119816. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  119817. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  119818. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  119819. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  119820. };
  119821. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  119822. if (mesh.showSubMeshesBoundingBox) {
  119823. var boundingInfo = subMesh.getBoundingInfo();
  119824. if (boundingInfo !== null && boundingInfo !== undefined) {
  119825. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  119826. this.renderList.push(boundingInfo.boundingBox);
  119827. }
  119828. }
  119829. };
  119830. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  119831. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  119832. var boundingInfo = sourceMesh.getBoundingInfo();
  119833. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  119834. this.renderList.push(boundingInfo.boundingBox);
  119835. }
  119836. };
  119837. BoundingBoxRenderer.prototype._prepareRessources = function () {
  119838. if (this._colorShader) {
  119839. return;
  119840. }
  119841. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  119842. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  119843. uniforms: ["world", "viewProjection", "color"]
  119844. });
  119845. var engine = this.scene.getEngine();
  119846. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  119847. 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);
  119848. this._createIndexBuffer();
  119849. };
  119850. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  119851. var engine = this.scene.getEngine();
  119852. 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]);
  119853. };
  119854. /**
  119855. * Rebuilds the elements related to this component in case of
  119856. * context lost for instance.
  119857. */
  119858. BoundingBoxRenderer.prototype.rebuild = function () {
  119859. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119860. if (vb) {
  119861. vb._rebuild();
  119862. }
  119863. this._createIndexBuffer();
  119864. };
  119865. /**
  119866. * @hidden
  119867. */
  119868. BoundingBoxRenderer.prototype.reset = function () {
  119869. this.renderList.reset();
  119870. };
  119871. /**
  119872. * Render the bounding boxes of a specific rendering group
  119873. * @param renderingGroupId defines the rendering group to render
  119874. */
  119875. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  119876. if (this.renderList.length === 0) {
  119877. return;
  119878. }
  119879. this._prepareRessources();
  119880. if (!this._colorShader.isReady()) {
  119881. return;
  119882. }
  119883. var engine = this.scene.getEngine();
  119884. engine.setDepthWrite(false);
  119885. this._colorShader._preBind();
  119886. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  119887. var boundingBox = this.renderList.data[boundingBoxIndex];
  119888. if (boundingBox._tag !== renderingGroupId) {
  119889. continue;
  119890. }
  119891. var min = boundingBox.minimum;
  119892. var max = boundingBox.maximum;
  119893. var diff = max.subtract(min);
  119894. var median = min.add(diff.scale(0.5));
  119895. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  119896. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  119897. .multiply(boundingBox.getWorldMatrix());
  119898. // VBOs
  119899. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  119900. if (this.showBackLines) {
  119901. // Back
  119902. engine.setDepthFunctionToGreaterOrEqual();
  119903. this.scene.resetCachedMaterial();
  119904. this._colorShader.setColor4("color", this.backColor.toColor4());
  119905. this._colorShader.bind(worldMatrix);
  119906. // Draw order
  119907. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119908. }
  119909. // Front
  119910. engine.setDepthFunctionToLess();
  119911. this.scene.resetCachedMaterial();
  119912. this._colorShader.setColor4("color", this.frontColor.toColor4());
  119913. this._colorShader.bind(worldMatrix);
  119914. // Draw order
  119915. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119916. }
  119917. this._colorShader.unbind();
  119918. engine.setDepthFunctionToLessOrEqual();
  119919. engine.setDepthWrite(true);
  119920. };
  119921. /**
  119922. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119923. * @param mesh Define the mesh to render the occlusion bounding box for
  119924. */
  119925. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  119926. this._prepareRessources();
  119927. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  119928. return;
  119929. }
  119930. var engine = this.scene.getEngine();
  119931. engine.setDepthWrite(false);
  119932. engine.setColorWrite(false);
  119933. this._colorShader._preBind();
  119934. var boundingBox = mesh._boundingInfo.boundingBox;
  119935. var min = boundingBox.minimum;
  119936. var max = boundingBox.maximum;
  119937. var diff = max.subtract(min);
  119938. var median = min.add(diff.scale(0.5));
  119939. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  119940. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  119941. .multiply(boundingBox.getWorldMatrix());
  119942. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  119943. engine.setDepthFunctionToLess();
  119944. this.scene.resetCachedMaterial();
  119945. this._colorShader.bind(worldMatrix);
  119946. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119947. this._colorShader.unbind();
  119948. engine.setDepthFunctionToLessOrEqual();
  119949. engine.setDepthWrite(true);
  119950. engine.setColorWrite(true);
  119951. };
  119952. /**
  119953. * Dispose and release the resources attached to this renderer.
  119954. */
  119955. BoundingBoxRenderer.prototype.dispose = function () {
  119956. if (!this._colorShader) {
  119957. return;
  119958. }
  119959. this.renderList.dispose();
  119960. this._colorShader.dispose();
  119961. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119962. if (buffer) {
  119963. buffer.dispose();
  119964. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119965. }
  119966. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  119967. };
  119968. return BoundingBoxRenderer;
  119969. }());
  119970. /***/ }),
  119971. /***/ "./Rendering/depthRenderer.ts":
  119972. /*!************************************!*\
  119973. !*** ./Rendering/depthRenderer.ts ***!
  119974. \************************************/
  119975. /*! exports provided: DepthRenderer */
  119976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119977. "use strict";
  119978. __webpack_require__.r(__webpack_exports__);
  119979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  119980. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119981. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119982. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119983. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119984. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119985. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119986. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  119987. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119988. /**
  119989. * This represents a depth renderer in Babylon.
  119990. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119991. */
  119992. var DepthRenderer = /** @class */ (function () {
  119993. /**
  119994. * Instantiates a depth renderer
  119995. * @param scene The scene the renderer belongs to
  119996. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119997. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119998. */
  119999. function DepthRenderer(scene, type, camera) {
  120000. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  120001. if (camera === void 0) { camera = null; }
  120002. var _this = this;
  120003. /**
  120004. * Specifiess that the depth renderer will only be used within
  120005. * the camera it is created for.
  120006. * This can help forcing its rendering during the camera processing.
  120007. */
  120008. this.useOnlyInActiveCamera = false;
  120009. this._scene = scene;
  120010. DepthRenderer._SceneComponentInitialization(this._scene);
  120011. this._camera = camera;
  120012. var engine = scene.getEngine();
  120013. // Render target
  120014. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  120015. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120016. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120017. this._depthMap.refreshRate = 1;
  120018. this._depthMap.renderParticles = false;
  120019. this._depthMap.renderList = null;
  120020. // Camera to get depth map from to support multiple concurrent cameras
  120021. this._depthMap.activeCamera = this._camera;
  120022. this._depthMap.ignoreCameraViewport = true;
  120023. this._depthMap.useCameraPostProcesses = false;
  120024. // set default depth value to 1.0 (far away)
  120025. this._depthMap.onClearObservable.add(function (engine) {
  120026. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  120027. });
  120028. // Custom render function
  120029. var renderSubMesh = function (subMesh) {
  120030. var mesh = subMesh.getRenderingMesh();
  120031. var scene = _this._scene;
  120032. var engine = scene.getEngine();
  120033. var material = subMesh.getMaterial();
  120034. if (!material) {
  120035. return;
  120036. }
  120037. // Culling and reverse (right handed system)
  120038. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120039. // Managing instances
  120040. var batch = mesh._getInstancesRenderList(subMesh._id);
  120041. if (batch.mustReturn) {
  120042. return;
  120043. }
  120044. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120045. var camera = _this._camera || scene.activeCamera;
  120046. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  120047. engine.enableEffect(_this._effect);
  120048. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  120049. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120050. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  120051. // Alpha test
  120052. if (material && material.needAlphaTesting()) {
  120053. var alphaTexture = material.getAlphaTestTexture();
  120054. if (alphaTexture) {
  120055. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120056. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120057. }
  120058. }
  120059. // Bones
  120060. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120061. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120062. }
  120063. // Draw
  120064. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120065. }
  120066. };
  120067. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120068. var index;
  120069. if (depthOnlySubMeshes.length) {
  120070. engine.setColorWrite(false);
  120071. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120072. renderSubMesh(depthOnlySubMeshes.data[index]);
  120073. }
  120074. engine.setColorWrite(true);
  120075. }
  120076. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120077. renderSubMesh(opaqueSubMeshes.data[index]);
  120078. }
  120079. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120080. renderSubMesh(alphaTestSubMeshes.data[index]);
  120081. }
  120082. };
  120083. }
  120084. /**
  120085. * Creates the depth rendering effect and checks if the effect is ready.
  120086. * @param subMesh The submesh to be used to render the depth map of
  120087. * @param useInstances If multiple world instances should be used
  120088. * @returns if the depth renderer is ready to render the depth map
  120089. */
  120090. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  120091. var material = subMesh.getMaterial();
  120092. if (material.disableDepthWrite) {
  120093. return false;
  120094. }
  120095. var defines = [];
  120096. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120097. var mesh = subMesh.getMesh();
  120098. // Alpha test
  120099. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  120100. defines.push("#define ALPHATEST");
  120101. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120102. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120103. defines.push("#define UV1");
  120104. }
  120105. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120106. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120107. defines.push("#define UV2");
  120108. }
  120109. }
  120110. // Bones
  120111. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120112. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120113. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120114. if (mesh.numBoneInfluencers > 4) {
  120115. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120116. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120117. }
  120118. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120119. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120120. }
  120121. else {
  120122. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120123. }
  120124. // Instances
  120125. if (useInstances) {
  120126. defines.push("#define INSTANCES");
  120127. attribs.push("world0");
  120128. attribs.push("world1");
  120129. attribs.push("world2");
  120130. attribs.push("world3");
  120131. }
  120132. // Get correct effect
  120133. var join = defines.join("\n");
  120134. if (this._cachedDefines !== join) {
  120135. this._cachedDefines = join;
  120136. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  120137. }
  120138. return this._effect.isReady();
  120139. };
  120140. /**
  120141. * Gets the texture which the depth map will be written to.
  120142. * @returns The depth map texture
  120143. */
  120144. DepthRenderer.prototype.getDepthMap = function () {
  120145. return this._depthMap;
  120146. };
  120147. /**
  120148. * Disposes of the depth renderer.
  120149. */
  120150. DepthRenderer.prototype.dispose = function () {
  120151. this._depthMap.dispose();
  120152. };
  120153. /** @hidden */
  120154. DepthRenderer._SceneComponentInitialization = function (_) {
  120155. throw "Import DepthRendererSceneComponent before creating DepthRenderer.";
  120156. };
  120157. return DepthRenderer;
  120158. }());
  120159. /***/ }),
  120160. /***/ "./Rendering/depthRendererSceneComponent.ts":
  120161. /*!**************************************************!*\
  120162. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  120163. \**************************************************/
  120164. /*! exports provided: DepthRendererSceneComponent */
  120165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120166. "use strict";
  120167. __webpack_require__.r(__webpack_exports__);
  120168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  120169. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120170. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120171. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120172. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120173. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  120174. camera = camera || this.activeCamera;
  120175. if (!camera) {
  120176. throw "No camera available to enable depth renderer";
  120177. }
  120178. if (!this._depthRenderer) {
  120179. this._depthRenderer = {};
  120180. }
  120181. if (!this._depthRenderer[camera.id]) {
  120182. var textureType = 0;
  120183. if (this.getEngine().getCaps().textureHalfFloatRender) {
  120184. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  120185. }
  120186. else if (this.getEngine().getCaps().textureFloatRender) {
  120187. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  120188. }
  120189. else {
  120190. throw "Depth renderer does not support int texture type";
  120191. }
  120192. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  120193. }
  120194. return this._depthRenderer[camera.id];
  120195. };
  120196. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  120197. camera = camera || this.activeCamera;
  120198. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  120199. return;
  120200. }
  120201. this._depthRenderer[camera.id].dispose();
  120202. delete this._depthRenderer[camera.id];
  120203. };
  120204. /**
  120205. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120206. * in several rendering techniques.
  120207. */
  120208. var DepthRendererSceneComponent = /** @class */ (function () {
  120209. /**
  120210. * Creates a new instance of the component for the given scene
  120211. * @param scene Defines the scene to register the component in
  120212. */
  120213. function DepthRendererSceneComponent(scene) {
  120214. /**
  120215. * The component name helpfull to identify the component in the list of scene components.
  120216. */
  120217. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  120218. this.scene = scene;
  120219. }
  120220. /**
  120221. * Registers the component in a given scene
  120222. */
  120223. DepthRendererSceneComponent.prototype.register = function () {
  120224. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  120225. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  120226. };
  120227. /**
  120228. * Rebuilds the elements related to this component in case of
  120229. * context lost for instance.
  120230. */
  120231. DepthRendererSceneComponent.prototype.rebuild = function () {
  120232. // Nothing to do for this component
  120233. };
  120234. /**
  120235. * Disposes the component and the associated ressources
  120236. */
  120237. DepthRendererSceneComponent.prototype.dispose = function () {
  120238. for (var key in this.scene._depthRenderer) {
  120239. this.scene._depthRenderer[key].dispose();
  120240. }
  120241. };
  120242. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120243. if (this.scene._depthRenderer) {
  120244. for (var key in this.scene._depthRenderer) {
  120245. var depthRenderer = this.scene._depthRenderer[key];
  120246. if (!depthRenderer.useOnlyInActiveCamera) {
  120247. renderTargets.push(depthRenderer.getDepthMap());
  120248. }
  120249. }
  120250. }
  120251. };
  120252. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  120253. if (this.scene._depthRenderer) {
  120254. for (var key in this.scene._depthRenderer) {
  120255. var depthRenderer = this.scene._depthRenderer[key];
  120256. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  120257. renderTargets.push(depthRenderer.getDepthMap());
  120258. }
  120259. }
  120260. }
  120261. };
  120262. return DepthRendererSceneComponent;
  120263. }());
  120264. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  120265. // Register the G Buffer component to the scene.
  120266. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  120267. if (!component) {
  120268. component = new DepthRendererSceneComponent(scene);
  120269. scene._addComponent(component);
  120270. }
  120271. };
  120272. /***/ }),
  120273. /***/ "./Rendering/edgesRenderer.ts":
  120274. /*!************************************!*\
  120275. !*** ./Rendering/edgesRenderer.ts ***!
  120276. \************************************/
  120277. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  120278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120279. "use strict";
  120280. __webpack_require__.r(__webpack_exports__);
  120281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  120282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  120283. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120284. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120285. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120286. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  120287. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120288. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120289. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120290. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  120291. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120292. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  120293. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  120294. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  120295. if (this._edgesRenderer) {
  120296. this._edgesRenderer.dispose();
  120297. this._edgesRenderer = null;
  120298. }
  120299. return this;
  120300. };
  120301. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120302. if (epsilon === void 0) { epsilon = 0.95; }
  120303. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120304. this.disableEdgesRendering();
  120305. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120306. return this;
  120307. };
  120308. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  120309. get: function () {
  120310. return this._edgesRenderer;
  120311. },
  120312. enumerable: true,
  120313. configurable: true
  120314. });
  120315. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120316. if (epsilon === void 0) { epsilon = 0.95; }
  120317. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120318. this.disableEdgesRendering();
  120319. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120320. return this;
  120321. };
  120322. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120323. if (epsilon === void 0) { epsilon = 0.95; }
  120324. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120325. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  120326. return this;
  120327. };
  120328. /**
  120329. * FaceAdjacencies Helper class to generate edges
  120330. */
  120331. var FaceAdjacencies = /** @class */ (function () {
  120332. function FaceAdjacencies() {
  120333. this.edges = new Array();
  120334. this.edgesConnectedCount = 0;
  120335. }
  120336. return FaceAdjacencies;
  120337. }());
  120338. /**
  120339. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  120340. */
  120341. var EdgesRenderer = /** @class */ (function () {
  120342. /**
  120343. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  120344. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  120345. * @param source Mesh used to create edges
  120346. * @param epsilon sum of angles in adjacency to check for edge
  120347. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  120348. * @param generateEdgesLines - should generate Lines or only prepare resources.
  120349. */
  120350. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  120351. if (epsilon === void 0) { epsilon = 0.95; }
  120352. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120353. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  120354. var _this = this;
  120355. /**
  120356. * Define the size of the edges with an orthographic camera
  120357. */
  120358. this.edgesWidthScalerForOrthographic = 1000.0;
  120359. /**
  120360. * Define the size of the edges with a perspective camera
  120361. */
  120362. this.edgesWidthScalerForPerspective = 50.0;
  120363. this._linesPositions = new Array();
  120364. this._linesNormals = new Array();
  120365. this._linesIndices = new Array();
  120366. this._buffers = {};
  120367. this._checkVerticesInsteadOfIndices = false;
  120368. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  120369. this.isEnabled = true;
  120370. this._source = source;
  120371. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  120372. this._epsilon = epsilon;
  120373. this._prepareRessources();
  120374. if (generateEdgesLines) {
  120375. this._generateEdgesLines();
  120376. }
  120377. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  120378. _this._rebuild();
  120379. });
  120380. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  120381. _this.dispose();
  120382. });
  120383. }
  120384. EdgesRenderer.prototype._prepareRessources = function () {
  120385. if (this._lineShader) {
  120386. return;
  120387. }
  120388. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  120389. attributes: ["position", "normal"],
  120390. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  120391. });
  120392. this._lineShader.disableDepthWrite = true;
  120393. this._lineShader.backFaceCulling = false;
  120394. };
  120395. /** @hidden */
  120396. EdgesRenderer.prototype._rebuild = function () {
  120397. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120398. if (buffer) {
  120399. buffer._rebuild();
  120400. }
  120401. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120402. if (buffer) {
  120403. buffer._rebuild();
  120404. }
  120405. var scene = this._source.getScene();
  120406. var engine = scene.getEngine();
  120407. this._ib = engine.createIndexBuffer(this._linesIndices);
  120408. };
  120409. /**
  120410. * Releases the required resources for the edges renderer
  120411. */
  120412. EdgesRenderer.prototype.dispose = function () {
  120413. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  120414. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  120415. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120416. if (buffer) {
  120417. buffer.dispose();
  120418. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120419. }
  120420. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120421. if (buffer) {
  120422. buffer.dispose();
  120423. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  120424. }
  120425. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  120426. this._lineShader.dispose();
  120427. };
  120428. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  120429. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  120430. return 0;
  120431. }
  120432. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  120433. return 1;
  120434. }
  120435. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  120436. return 2;
  120437. }
  120438. return -1;
  120439. };
  120440. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  120441. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  120442. return 0;
  120443. }
  120444. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  120445. return 1;
  120446. }
  120447. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  120448. return 2;
  120449. }
  120450. return -1;
  120451. };
  120452. /**
  120453. * Checks if the pair of p0 and p1 is en edge
  120454. * @param faceIndex
  120455. * @param edge
  120456. * @param faceNormals
  120457. * @param p0
  120458. * @param p1
  120459. * @private
  120460. */
  120461. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  120462. var needToCreateLine;
  120463. if (edge === undefined) {
  120464. needToCreateLine = true;
  120465. }
  120466. else {
  120467. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  120468. needToCreateLine = dotProduct < this._epsilon;
  120469. }
  120470. if (needToCreateLine) {
  120471. this.createLine(p0, p1, this._linesPositions.length / 3);
  120472. }
  120473. };
  120474. /**
  120475. * push line into the position, normal and index buffer
  120476. * @protected
  120477. */
  120478. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  120479. // Positions
  120480. 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);
  120481. // Normals
  120482. 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);
  120483. // Indices
  120484. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  120485. };
  120486. /**
  120487. * Generates lines edges from adjacencjes
  120488. * @private
  120489. */
  120490. EdgesRenderer.prototype._generateEdgesLines = function () {
  120491. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120492. var indices = this._source.getIndices();
  120493. if (!indices || !positions) {
  120494. return;
  120495. }
  120496. // First let's find adjacencies
  120497. var adjacencies = new Array();
  120498. var faceNormals = new Array();
  120499. var index;
  120500. var faceAdjacencies;
  120501. // Prepare faces
  120502. for (index = 0; index < indices.length; index += 3) {
  120503. faceAdjacencies = new FaceAdjacencies();
  120504. var p0Index = indices[index];
  120505. var p1Index = indices[index + 1];
  120506. var p2Index = indices[index + 2];
  120507. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  120508. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  120509. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  120510. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  120511. faceNormal.normalize();
  120512. faceNormals.push(faceNormal);
  120513. adjacencies.push(faceAdjacencies);
  120514. }
  120515. // Scan
  120516. for (index = 0; index < adjacencies.length; index++) {
  120517. faceAdjacencies = adjacencies[index];
  120518. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  120519. var otherFaceAdjacencies = adjacencies[otherIndex];
  120520. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  120521. break;
  120522. }
  120523. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  120524. continue;
  120525. }
  120526. var otherP0 = indices[otherIndex * 3];
  120527. var otherP1 = indices[otherIndex * 3 + 1];
  120528. var otherP2 = indices[otherIndex * 3 + 2];
  120529. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  120530. var otherEdgeIndex = 0;
  120531. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  120532. continue;
  120533. }
  120534. switch (edgeIndex) {
  120535. case 0:
  120536. if (this._checkVerticesInsteadOfIndices) {
  120537. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120538. }
  120539. else {
  120540. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  120541. }
  120542. break;
  120543. case 1:
  120544. if (this._checkVerticesInsteadOfIndices) {
  120545. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120546. }
  120547. else {
  120548. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  120549. }
  120550. break;
  120551. case 2:
  120552. if (this._checkVerticesInsteadOfIndices) {
  120553. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  120554. }
  120555. else {
  120556. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  120557. }
  120558. break;
  120559. }
  120560. if (otherEdgeIndex === -1) {
  120561. continue;
  120562. }
  120563. faceAdjacencies.edges[edgeIndex] = otherIndex;
  120564. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  120565. faceAdjacencies.edgesConnectedCount++;
  120566. otherFaceAdjacencies.edgesConnectedCount++;
  120567. if (faceAdjacencies.edgesConnectedCount === 3) {
  120568. break;
  120569. }
  120570. }
  120571. }
  120572. }
  120573. // Create lines
  120574. for (index = 0; index < adjacencies.length; index++) {
  120575. // 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
  120576. var current = adjacencies[index];
  120577. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  120578. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  120579. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  120580. }
  120581. // Merge into a single mesh
  120582. var engine = this._source.getScene().getEngine();
  120583. 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);
  120584. 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);
  120585. this._ib = engine.createIndexBuffer(this._linesIndices);
  120586. this._indicesCount = this._linesIndices.length;
  120587. };
  120588. /**
  120589. * Checks wether or not the edges renderer is ready to render.
  120590. * @return true if ready, otherwise false.
  120591. */
  120592. EdgesRenderer.prototype.isReady = function () {
  120593. return this._lineShader.isReady();
  120594. };
  120595. /**
  120596. * Renders the edges of the attached mesh,
  120597. */
  120598. EdgesRenderer.prototype.render = function () {
  120599. var scene = this._source.getScene();
  120600. if (!this.isReady() || !scene.activeCamera) {
  120601. return;
  120602. }
  120603. var engine = scene.getEngine();
  120604. this._lineShader._preBind();
  120605. if (this._source.edgesColor.a !== 1) {
  120606. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  120607. }
  120608. else {
  120609. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  120610. }
  120611. // VBOs
  120612. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  120613. scene.resetCachedMaterial();
  120614. this._lineShader.setColor4("color", this._source.edgesColor);
  120615. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  120616. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  120617. }
  120618. else {
  120619. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  120620. }
  120621. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  120622. this._lineShader.bind(this._source.getWorldMatrix());
  120623. // Draw order
  120624. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  120625. this._lineShader.unbind();
  120626. };
  120627. return EdgesRenderer;
  120628. }());
  120629. /**
  120630. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  120631. */
  120632. var LineEdgesRenderer = /** @class */ (function (_super) {
  120633. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  120634. /**
  120635. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  120636. * @param source LineMesh used to generate edges
  120637. * @param epsilon not important (specified angle for edge detection)
  120638. * @param checkVerticesInsteadOfIndices not important for LineMesh
  120639. */
  120640. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  120641. if (epsilon === void 0) { epsilon = 0.95; }
  120642. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120643. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  120644. _this._generateEdgesLines();
  120645. return _this;
  120646. }
  120647. /**
  120648. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  120649. */
  120650. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  120651. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120652. var indices = this._source.getIndices();
  120653. if (!indices || !positions) {
  120654. return;
  120655. }
  120656. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  120657. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  120658. var len = indices.length - 1;
  120659. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  120660. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  120661. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  120662. this.createLine(p0, p1, offset);
  120663. }
  120664. // Merge into a single mesh
  120665. var engine = this._source.getScene().getEngine();
  120666. 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);
  120667. 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);
  120668. this._ib = engine.createIndexBuffer(this._linesIndices);
  120669. this._indicesCount = this._linesIndices.length;
  120670. };
  120671. return LineEdgesRenderer;
  120672. }(EdgesRenderer));
  120673. /***/ }),
  120674. /***/ "./Rendering/geometryBufferRenderer.ts":
  120675. /*!*********************************************!*\
  120676. !*** ./Rendering/geometryBufferRenderer.ts ***!
  120677. \*********************************************/
  120678. /*! exports provided: GeometryBufferRenderer */
  120679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120680. "use strict";
  120681. __webpack_require__.r(__webpack_exports__);
  120682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  120683. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120684. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120685. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120686. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120687. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  120688. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120689. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  120690. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  120691. /**
  120692. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120693. */
  120694. var GeometryBufferRenderer = /** @class */ (function () {
  120695. /**
  120696. * Creates a new G Buffer for the scene
  120697. * @param scene The scene the buffer belongs to
  120698. * @param ratio How big is the buffer related to the main canvas.
  120699. */
  120700. function GeometryBufferRenderer(scene, ratio) {
  120701. if (ratio === void 0) { ratio = 1; }
  120702. /**
  120703. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120704. * in order to compute objects velocities when enableVelocity is set to "true"
  120705. * @hidden
  120706. */
  120707. this._previousTransformationMatrices = {};
  120708. this._enablePosition = false;
  120709. this._enableVelocity = false;
  120710. this._positionIndex = -1;
  120711. this._velocityIndex = -1;
  120712. this._scene = scene;
  120713. this._ratio = ratio;
  120714. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  120715. // Render target
  120716. this._createRenderTargets();
  120717. }
  120718. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  120719. /**
  120720. * Set the render list (meshes to be rendered) used in the G buffer.
  120721. */
  120722. set: function (meshes) {
  120723. this._multiRenderTarget.renderList = meshes;
  120724. },
  120725. enumerable: true,
  120726. configurable: true
  120727. });
  120728. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  120729. /**
  120730. * Gets wether or not G buffer are supported by the running hardware.
  120731. * This requires draw buffer supports
  120732. */
  120733. get: function () {
  120734. return this._multiRenderTarget.isSupported;
  120735. },
  120736. enumerable: true,
  120737. configurable: true
  120738. });
  120739. /**
  120740. * Returns the index of the given texture type in the G-Buffer textures array
  120741. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120742. * @returns the index of the given texture type in the G-Buffer textures array
  120743. */
  120744. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  120745. switch (textureType) {
  120746. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  120747. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  120748. default: return -1;
  120749. }
  120750. };
  120751. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  120752. /**
  120753. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120754. */
  120755. get: function () {
  120756. return this._enablePosition;
  120757. },
  120758. /**
  120759. * Sets whether or not objects positions are enabled for the G buffer.
  120760. */
  120761. set: function (enable) {
  120762. this._enablePosition = enable;
  120763. this.dispose();
  120764. this._createRenderTargets();
  120765. },
  120766. enumerable: true,
  120767. configurable: true
  120768. });
  120769. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  120770. /**
  120771. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120772. */
  120773. get: function () {
  120774. return this._enableVelocity;
  120775. },
  120776. /**
  120777. * Sets wether or not objects velocities are enabled for the G buffer.
  120778. */
  120779. set: function (enable) {
  120780. this._enableVelocity = enable;
  120781. this.dispose();
  120782. this._createRenderTargets();
  120783. },
  120784. enumerable: true,
  120785. configurable: true
  120786. });
  120787. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  120788. /**
  120789. * Gets the scene associated with the buffer.
  120790. */
  120791. get: function () {
  120792. return this._scene;
  120793. },
  120794. enumerable: true,
  120795. configurable: true
  120796. });
  120797. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  120798. /**
  120799. * Gets the ratio used by the buffer during its creation.
  120800. * How big is the buffer related to the main canvas.
  120801. */
  120802. get: function () {
  120803. return this._ratio;
  120804. },
  120805. enumerable: true,
  120806. configurable: true
  120807. });
  120808. /**
  120809. * Checks wether everything is ready to render a submesh to the G buffer.
  120810. * @param subMesh the submesh to check readiness for
  120811. * @param useInstances is the mesh drawn using instance or not
  120812. * @returns true if ready otherwise false
  120813. */
  120814. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  120815. var material = subMesh.getMaterial();
  120816. if (material && material.disableDepthWrite) {
  120817. return false;
  120818. }
  120819. var defines = [];
  120820. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120821. var mesh = subMesh.getMesh();
  120822. // Alpha test
  120823. if (material && material.needAlphaTesting()) {
  120824. defines.push("#define ALPHATEST");
  120825. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120826. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120827. defines.push("#define UV1");
  120828. }
  120829. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120830. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120831. defines.push("#define UV2");
  120832. }
  120833. }
  120834. // Buffers
  120835. if (this._enablePosition) {
  120836. defines.push("#define POSITION");
  120837. defines.push("#define POSITION_INDEX " + this._positionIndex);
  120838. }
  120839. if (this._enableVelocity) {
  120840. defines.push("#define VELOCITY");
  120841. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  120842. }
  120843. // Bones
  120844. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120845. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120846. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120847. if (mesh.numBoneInfluencers > 4) {
  120848. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120849. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120850. }
  120851. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120852. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120853. }
  120854. else {
  120855. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120856. }
  120857. // Instances
  120858. if (useInstances) {
  120859. defines.push("#define INSTANCES");
  120860. attribs.push("world0");
  120861. attribs.push("world1");
  120862. attribs.push("world2");
  120863. attribs.push("world3");
  120864. }
  120865. // Setup textures count
  120866. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  120867. // Get correct effect
  120868. var join = defines.join("\n");
  120869. if (this._cachedDefines !== join) {
  120870. this._cachedDefines = join;
  120871. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  120872. }
  120873. return this._effect.isReady();
  120874. };
  120875. /**
  120876. * Gets the current underlying G Buffer.
  120877. * @returns the buffer
  120878. */
  120879. GeometryBufferRenderer.prototype.getGBuffer = function () {
  120880. return this._multiRenderTarget;
  120881. };
  120882. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  120883. /**
  120884. * Gets the number of samples used to render the buffer (anti aliasing).
  120885. */
  120886. get: function () {
  120887. return this._multiRenderTarget.samples;
  120888. },
  120889. /**
  120890. * Sets the number of samples used to render the buffer (anti aliasing).
  120891. */
  120892. set: function (value) {
  120893. this._multiRenderTarget.samples = value;
  120894. },
  120895. enumerable: true,
  120896. configurable: true
  120897. });
  120898. /**
  120899. * Disposes the renderer and frees up associated resources.
  120900. */
  120901. GeometryBufferRenderer.prototype.dispose = function () {
  120902. this.getGBuffer().dispose();
  120903. };
  120904. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  120905. var _this = this;
  120906. var engine = this._scene.getEngine();
  120907. var count = 2;
  120908. if (this._enablePosition) {
  120909. this._positionIndex = count;
  120910. count++;
  120911. }
  120912. if (this._enableVelocity) {
  120913. this._velocityIndex = count;
  120914. count++;
  120915. }
  120916. 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 });
  120917. if (!this.isSupported) {
  120918. return;
  120919. }
  120920. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  120921. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  120922. this._multiRenderTarget.refreshRate = 1;
  120923. this._multiRenderTarget.renderParticles = false;
  120924. this._multiRenderTarget.renderList = null;
  120925. // set default depth value to 1.0 (far away)
  120926. this._multiRenderTarget.onClearObservable.add(function (engine) {
  120927. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  120928. });
  120929. // Custom render function
  120930. var renderSubMesh = function (subMesh) {
  120931. var mesh = subMesh.getRenderingMesh();
  120932. var scene = _this._scene;
  120933. var engine = scene.getEngine();
  120934. var material = subMesh.getMaterial();
  120935. if (!material) {
  120936. return;
  120937. }
  120938. // Velocity
  120939. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  120940. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  120941. }
  120942. // Culling
  120943. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120944. // Managing instances
  120945. var batch = mesh._getInstancesRenderList(subMesh._id);
  120946. if (batch.mustReturn) {
  120947. return;
  120948. }
  120949. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120950. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  120951. engine.enableEffect(_this._effect);
  120952. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  120953. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120954. _this._effect.setMatrix("view", scene.getViewMatrix());
  120955. // Alpha test
  120956. if (material && material.needAlphaTesting()) {
  120957. var alphaTexture = material.getAlphaTestTexture();
  120958. if (alphaTexture) {
  120959. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120960. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120961. }
  120962. }
  120963. // Bones
  120964. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120965. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120966. }
  120967. // Velocity
  120968. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  120969. // Draw
  120970. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120971. }
  120972. // Velocity
  120973. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  120974. };
  120975. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120976. var index;
  120977. if (depthOnlySubMeshes.length) {
  120978. engine.setColorWrite(false);
  120979. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120980. renderSubMesh(depthOnlySubMeshes.data[index]);
  120981. }
  120982. engine.setColorWrite(true);
  120983. }
  120984. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120985. renderSubMesh(opaqueSubMeshes.data[index]);
  120986. }
  120987. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120988. renderSubMesh(alphaTestSubMeshes.data[index]);
  120989. }
  120990. };
  120991. };
  120992. /**
  120993. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120994. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120995. */
  120996. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  120997. /**
  120998. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120999. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121000. */
  121001. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  121002. /** @hidden */
  121003. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  121004. throw "Import GeometryBufferRendererSceneComponent before creating GeometryBufferRenderer.";
  121005. };
  121006. return GeometryBufferRenderer;
  121007. }());
  121008. /***/ }),
  121009. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  121010. /*!***********************************************************!*\
  121011. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  121012. \***********************************************************/
  121013. /*! exports provided: GeometryBufferRendererSceneComponent */
  121014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121015. "use strict";
  121016. __webpack_require__.r(__webpack_exports__);
  121017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  121018. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121019. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121020. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121021. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  121022. get: function () {
  121023. this._geometryBufferRenderer;
  121024. },
  121025. set: function (value) {
  121026. if (value && value.isSupported) {
  121027. this._geometryBufferRenderer = value;
  121028. }
  121029. },
  121030. enumerable: true,
  121031. configurable: true
  121032. });
  121033. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  121034. if (ratio === void 0) { ratio = 1; }
  121035. if (this._geometryBufferRenderer) {
  121036. return this._geometryBufferRenderer;
  121037. }
  121038. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  121039. if (!this._geometryBufferRenderer.isSupported) {
  121040. this._geometryBufferRenderer = null;
  121041. }
  121042. return this._geometryBufferRenderer;
  121043. };
  121044. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  121045. if (!this._geometryBufferRenderer) {
  121046. return;
  121047. }
  121048. this._geometryBufferRenderer.dispose();
  121049. this._geometryBufferRenderer = null;
  121050. };
  121051. /**
  121052. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121053. * in several rendering techniques.
  121054. */
  121055. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  121056. /**
  121057. * Creates a new instance of the component for the given scene
  121058. * @param scene Defines the scene to register the component in
  121059. */
  121060. function GeometryBufferRendererSceneComponent(scene) {
  121061. /**
  121062. * The component name helpful to identify the component in the list of scene components.
  121063. */
  121064. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  121065. this.scene = scene;
  121066. }
  121067. /**
  121068. * Registers the component in a given scene
  121069. */
  121070. GeometryBufferRendererSceneComponent.prototype.register = function () {
  121071. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  121072. };
  121073. /**
  121074. * Rebuilds the elements related to this component in case of
  121075. * context lost for instance.
  121076. */
  121077. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  121078. // Nothing to do for this component
  121079. };
  121080. /**
  121081. * Disposes the component and the associated ressources
  121082. */
  121083. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  121084. // Nothing to do for this component
  121085. };
  121086. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  121087. if (this.scene._geometryBufferRenderer) {
  121088. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  121089. }
  121090. };
  121091. return GeometryBufferRendererSceneComponent;
  121092. }());
  121093. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  121094. // Register the G Buffer component to the scene.
  121095. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  121096. if (!component) {
  121097. component = new GeometryBufferRendererSceneComponent(scene);
  121098. scene._addComponent(component);
  121099. }
  121100. };
  121101. /***/ }),
  121102. /***/ "./Rendering/index.ts":
  121103. /*!****************************!*\
  121104. !*** ./Rendering/index.ts ***!
  121105. \****************************/
  121106. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  121107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121108. "use strict";
  121109. __webpack_require__.r(__webpack_exports__);
  121110. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  121111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  121112. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  121113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  121114. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  121115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  121116. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  121117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  121118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  121119. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  121121. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  121122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  121123. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  121124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  121125. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  121127. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  121128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  121129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  121130. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  121131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  121132. /***/ }),
  121133. /***/ "./Rendering/outlineRenderer.ts":
  121134. /*!**************************************!*\
  121135. !*** ./Rendering/outlineRenderer.ts ***!
  121136. \**************************************/
  121137. /*! exports provided: OutlineRenderer */
  121138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121139. "use strict";
  121140. __webpack_require__.r(__webpack_exports__);
  121141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  121142. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121143. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121144. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121145. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121146. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121147. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121148. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  121149. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  121150. /**
  121151. * Gets the outline renderer associated with the scene
  121152. * @returns a OutlineRenderer
  121153. */
  121154. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  121155. if (!this._outlineRenderer) {
  121156. this._outlineRenderer = new OutlineRenderer(this);
  121157. }
  121158. return this._outlineRenderer;
  121159. };
  121160. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  121161. get: function () {
  121162. return this._renderOutline;
  121163. },
  121164. set: function (value) {
  121165. if (value) {
  121166. // Lazy Load the component.
  121167. this.getScene().getOutlineRenderer();
  121168. }
  121169. this._renderOutline = value;
  121170. },
  121171. enumerable: true,
  121172. configurable: true
  121173. });
  121174. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  121175. get: function () {
  121176. return this._renderOverlay;
  121177. },
  121178. set: function (value) {
  121179. if (value) {
  121180. // Lazy Load the component.
  121181. this.getScene().getOutlineRenderer();
  121182. }
  121183. this._renderOverlay = value;
  121184. },
  121185. enumerable: true,
  121186. configurable: true
  121187. });
  121188. /**
  121189. * This class is responsible to draw bothe outline/overlay of meshes.
  121190. * It should not be used directly but through the available method on mesh.
  121191. */
  121192. var OutlineRenderer = /** @class */ (function () {
  121193. /**
  121194. * Instantiates a new outline renderer. (There could be only one per scene).
  121195. * @param scene Defines the scene it belongs to
  121196. */
  121197. function OutlineRenderer(scene) {
  121198. /**
  121199. * The name of the component. Each component must have a unique name.
  121200. */
  121201. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  121202. /**
  121203. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  121204. */
  121205. this.zOffset = 1;
  121206. this.scene = scene;
  121207. this._engine = scene.getEngine();
  121208. this.scene._addComponent(this);
  121209. }
  121210. /**
  121211. * Register the component to one instance of a scene.
  121212. */
  121213. OutlineRenderer.prototype.register = function () {
  121214. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  121215. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  121216. };
  121217. /**
  121218. * Rebuilds the elements related to this component in case of
  121219. * context lost for instance.
  121220. */
  121221. OutlineRenderer.prototype.rebuild = function () {
  121222. // Nothing to do here.
  121223. };
  121224. /**
  121225. * Disposes the component and the associated ressources.
  121226. */
  121227. OutlineRenderer.prototype.dispose = function () {
  121228. // Nothing to do here.
  121229. };
  121230. /**
  121231. * Renders the outline in the canvas.
  121232. * @param subMesh Defines the sumesh to render
  121233. * @param batch Defines the batch of meshes in case of instances
  121234. * @param useOverlay Defines if the rendering is for the overlay or the outline
  121235. */
  121236. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  121237. var _this = this;
  121238. if (useOverlay === void 0) { useOverlay = false; }
  121239. var scene = this.scene;
  121240. var engine = scene.getEngine();
  121241. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  121242. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  121243. return;
  121244. }
  121245. var mesh = subMesh.getRenderingMesh();
  121246. var material = subMesh.getMaterial();
  121247. if (!material || !scene.activeCamera) {
  121248. return;
  121249. }
  121250. engine.enableEffect(this._effect);
  121251. // Logarithmic depth
  121252. if (material.useLogarithmicDepth) {
  121253. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  121254. }
  121255. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  121256. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  121257. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121258. // Bones
  121259. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121260. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121261. }
  121262. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121263. // Alpha test
  121264. if (material && material.needAlphaTesting()) {
  121265. var alphaTexture = material.getAlphaTestTexture();
  121266. if (alphaTexture) {
  121267. this._effect.setTexture("diffuseSampler", alphaTexture);
  121268. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121269. }
  121270. }
  121271. engine.setZOffset(-this.zOffset);
  121272. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  121273. engine.setZOffset(0);
  121274. };
  121275. /**
  121276. * Returns whether or not the outline renderer is ready for a given submesh.
  121277. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  121278. * @param subMesh Defines the submesh to check readyness for
  121279. * @param useInstances Defines wheter wee are trying to render instances or not
  121280. * @returns true if ready otherwise false
  121281. */
  121282. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  121283. var defines = [];
  121284. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  121285. var mesh = subMesh.getMesh();
  121286. var material = subMesh.getMaterial();
  121287. if (material) {
  121288. // Alpha test
  121289. if (material.needAlphaTesting()) {
  121290. defines.push("#define ALPHATEST");
  121291. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  121292. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  121293. defines.push("#define UV1");
  121294. }
  121295. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  121296. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  121297. defines.push("#define UV2");
  121298. }
  121299. }
  121300. //Logarithmic depth
  121301. if (material.useLogarithmicDepth) {
  121302. defines.push("#define LOGARITHMICDEPTH");
  121303. }
  121304. }
  121305. // Bones
  121306. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121307. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  121308. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  121309. if (mesh.numBoneInfluencers > 4) {
  121310. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  121311. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  121312. }
  121313. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121314. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121315. }
  121316. else {
  121317. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121318. }
  121319. // Instances
  121320. if (useInstances) {
  121321. defines.push("#define INSTANCES");
  121322. attribs.push("world0");
  121323. attribs.push("world1");
  121324. attribs.push("world2");
  121325. attribs.push("world3");
  121326. }
  121327. // Get correct effect
  121328. var join = defines.join("\n");
  121329. if (this._cachedDefines !== join) {
  121330. this._cachedDefines = join;
  121331. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  121332. }
  121333. return this._effect.isReady();
  121334. };
  121335. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  121336. // Outline - step 1
  121337. this._savedDepthWrite = this._engine.getDepthWrite();
  121338. if (mesh.renderOutline) {
  121339. this._engine.setDepthWrite(false);
  121340. this.render(subMesh, batch);
  121341. this._engine.setDepthWrite(this._savedDepthWrite);
  121342. }
  121343. };
  121344. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  121345. // Outline - step 2
  121346. if (mesh.renderOutline && this._savedDepthWrite) {
  121347. this._engine.setDepthWrite(true);
  121348. this._engine.setColorWrite(false);
  121349. this.render(subMesh, batch);
  121350. this._engine.setColorWrite(true);
  121351. }
  121352. // Overlay
  121353. if (mesh.renderOverlay) {
  121354. var currentMode = this._engine.getAlphaMode();
  121355. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  121356. this.render(subMesh, batch, true);
  121357. this._engine.setAlphaMode(currentMode);
  121358. }
  121359. };
  121360. return OutlineRenderer;
  121361. }());
  121362. /***/ }),
  121363. /***/ "./Rendering/renderingGroup.ts":
  121364. /*!*************************************!*\
  121365. !*** ./Rendering/renderingGroup.ts ***!
  121366. \*************************************/
  121367. /*! exports provided: RenderingGroup */
  121368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121369. "use strict";
  121370. __webpack_require__.r(__webpack_exports__);
  121371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  121372. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  121373. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121374. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121375. /**
  121376. * This represents the object necessary to create a rendering group.
  121377. * This is exclusively used and created by the rendering manager.
  121378. * To modify the behavior, you use the available helpers in your scene or meshes.
  121379. * @hidden
  121380. */
  121381. var RenderingGroup = /** @class */ (function () {
  121382. /**
  121383. * Creates a new rendering group.
  121384. * @param index The rendering group index
  121385. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  121386. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  121387. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  121388. */
  121389. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121390. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121391. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121392. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121393. this.index = index;
  121394. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121395. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121396. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121397. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121398. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121399. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121400. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  121401. this._scene = scene;
  121402. this.opaqueSortCompareFn = opaqueSortCompareFn;
  121403. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  121404. this.transparentSortCompareFn = transparentSortCompareFn;
  121405. }
  121406. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  121407. /**
  121408. * Set the opaque sort comparison function.
  121409. * If null the sub meshes will be render in the order they were created
  121410. */
  121411. set: function (value) {
  121412. this._opaqueSortCompareFn = value;
  121413. if (value) {
  121414. this._renderOpaque = this.renderOpaqueSorted;
  121415. }
  121416. else {
  121417. this._renderOpaque = RenderingGroup.renderUnsorted;
  121418. }
  121419. },
  121420. enumerable: true,
  121421. configurable: true
  121422. });
  121423. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  121424. /**
  121425. * Set the alpha test sort comparison function.
  121426. * If null the sub meshes will be render in the order they were created
  121427. */
  121428. set: function (value) {
  121429. this._alphaTestSortCompareFn = value;
  121430. if (value) {
  121431. this._renderAlphaTest = this.renderAlphaTestSorted;
  121432. }
  121433. else {
  121434. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  121435. }
  121436. },
  121437. enumerable: true,
  121438. configurable: true
  121439. });
  121440. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  121441. /**
  121442. * Set the transparent sort comparison function.
  121443. * If null the sub meshes will be render in the order they were created
  121444. */
  121445. set: function (value) {
  121446. if (value) {
  121447. this._transparentSortCompareFn = value;
  121448. }
  121449. else {
  121450. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  121451. }
  121452. this._renderTransparent = this.renderTransparentSorted;
  121453. },
  121454. enumerable: true,
  121455. configurable: true
  121456. });
  121457. /**
  121458. * Render all the sub meshes contained in the group.
  121459. * @param customRenderFunction Used to override the default render behaviour of the group.
  121460. * @returns true if rendered some submeshes.
  121461. */
  121462. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  121463. if (customRenderFunction) {
  121464. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  121465. return;
  121466. }
  121467. var engine = this._scene.getEngine();
  121468. // Depth only
  121469. if (this._depthOnlySubMeshes.length !== 0) {
  121470. engine.setColorWrite(false);
  121471. this._renderAlphaTest(this._depthOnlySubMeshes);
  121472. engine.setColorWrite(true);
  121473. }
  121474. // Opaque
  121475. if (this._opaqueSubMeshes.length !== 0) {
  121476. this._renderOpaque(this._opaqueSubMeshes);
  121477. }
  121478. // Alpha test
  121479. if (this._alphaTestSubMeshes.length !== 0) {
  121480. this._renderAlphaTest(this._alphaTestSubMeshes);
  121481. }
  121482. var stencilState = engine.getStencilBuffer();
  121483. engine.setStencilBuffer(false);
  121484. // Sprites
  121485. if (renderSprites) {
  121486. this._renderSprites();
  121487. }
  121488. // Particles
  121489. if (renderParticles) {
  121490. this._renderParticles(activeMeshes);
  121491. }
  121492. if (this.onBeforeTransparentRendering) {
  121493. this.onBeforeTransparentRendering();
  121494. }
  121495. // Transparent
  121496. if (this._transparentSubMeshes.length !== 0) {
  121497. this._renderTransparent(this._transparentSubMeshes);
  121498. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121499. }
  121500. // Set back stencil to false in case it changes before the edge renderer.
  121501. engine.setStencilBuffer(false);
  121502. // Edges
  121503. if (this._edgesRenderers.length) {
  121504. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  121505. this._edgesRenderers.data[edgesRendererIndex].render();
  121506. }
  121507. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121508. }
  121509. // Restore Stencil state.
  121510. engine.setStencilBuffer(stencilState);
  121511. };
  121512. /**
  121513. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  121514. * @param subMeshes The submeshes to render
  121515. */
  121516. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  121517. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  121518. };
  121519. /**
  121520. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  121521. * @param subMeshes The submeshes to render
  121522. */
  121523. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  121524. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  121525. };
  121526. /**
  121527. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  121528. * @param subMeshes The submeshes to render
  121529. */
  121530. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  121531. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  121532. };
  121533. /**
  121534. * Renders the submeshes in a specified order.
  121535. * @param subMeshes The submeshes to sort before render
  121536. * @param sortCompareFn The comparison function use to sort
  121537. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  121538. * @param transparent Specifies to activate blending if true
  121539. */
  121540. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  121541. var subIndex = 0;
  121542. var subMesh;
  121543. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  121544. for (; subIndex < subMeshes.length; subIndex++) {
  121545. subMesh = subMeshes.data[subIndex];
  121546. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  121547. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  121548. }
  121549. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  121550. if (sortCompareFn) {
  121551. sortedArray.sort(sortCompareFn);
  121552. }
  121553. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  121554. subMesh = sortedArray[subIndex];
  121555. if (transparent) {
  121556. var material = subMesh.getMaterial();
  121557. if (material && material.needDepthPrePass) {
  121558. var engine = material.getScene().getEngine();
  121559. engine.setColorWrite(false);
  121560. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121561. subMesh.render(false);
  121562. engine.setColorWrite(true);
  121563. }
  121564. }
  121565. subMesh.render(transparent);
  121566. }
  121567. };
  121568. /**
  121569. * Renders the submeshes in the order they were dispatched (no sort applied).
  121570. * @param subMeshes The submeshes to render
  121571. */
  121572. RenderingGroup.renderUnsorted = function (subMeshes) {
  121573. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  121574. var submesh = subMeshes.data[subIndex];
  121575. submesh.render(false);
  121576. }
  121577. };
  121578. /**
  121579. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121580. * are rendered back to front if in the same alpha index.
  121581. *
  121582. * @param a The first submesh
  121583. * @param b The second submesh
  121584. * @returns The result of the comparison
  121585. */
  121586. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  121587. // Alpha index first
  121588. if (a._alphaIndex > b._alphaIndex) {
  121589. return 1;
  121590. }
  121591. if (a._alphaIndex < b._alphaIndex) {
  121592. return -1;
  121593. }
  121594. // Then distance to camera
  121595. return RenderingGroup.backToFrontSortCompare(a, b);
  121596. };
  121597. /**
  121598. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121599. * are rendered back to front.
  121600. *
  121601. * @param a The first submesh
  121602. * @param b The second submesh
  121603. * @returns The result of the comparison
  121604. */
  121605. RenderingGroup.backToFrontSortCompare = function (a, b) {
  121606. // Then distance to camera
  121607. if (a._distanceToCamera < b._distanceToCamera) {
  121608. return 1;
  121609. }
  121610. if (a._distanceToCamera > b._distanceToCamera) {
  121611. return -1;
  121612. }
  121613. return 0;
  121614. };
  121615. /**
  121616. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  121617. * are rendered front to back (prevent overdraw).
  121618. *
  121619. * @param a The first submesh
  121620. * @param b The second submesh
  121621. * @returns The result of the comparison
  121622. */
  121623. RenderingGroup.frontToBackSortCompare = function (a, b) {
  121624. // Then distance to camera
  121625. if (a._distanceToCamera < b._distanceToCamera) {
  121626. return -1;
  121627. }
  121628. if (a._distanceToCamera > b._distanceToCamera) {
  121629. return 1;
  121630. }
  121631. return 0;
  121632. };
  121633. /**
  121634. * Resets the different lists of submeshes to prepare a new frame.
  121635. */
  121636. RenderingGroup.prototype.prepare = function () {
  121637. this._opaqueSubMeshes.reset();
  121638. this._transparentSubMeshes.reset();
  121639. this._alphaTestSubMeshes.reset();
  121640. this._depthOnlySubMeshes.reset();
  121641. this._particleSystems.reset();
  121642. this._spriteManagers.reset();
  121643. this._edgesRenderers.reset();
  121644. };
  121645. RenderingGroup.prototype.dispose = function () {
  121646. this._opaqueSubMeshes.dispose();
  121647. this._transparentSubMeshes.dispose();
  121648. this._alphaTestSubMeshes.dispose();
  121649. this._depthOnlySubMeshes.dispose();
  121650. this._particleSystems.dispose();
  121651. this._spriteManagers.dispose();
  121652. this._edgesRenderers.dispose();
  121653. };
  121654. /**
  121655. * Inserts the submesh in its correct queue depending on its material.
  121656. * @param subMesh The submesh to dispatch
  121657. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  121658. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  121659. */
  121660. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  121661. // Get mesh and materials if not provided
  121662. if (mesh === undefined) {
  121663. mesh = subMesh.getMesh();
  121664. }
  121665. if (material === undefined) {
  121666. material = subMesh.getMaterial();
  121667. }
  121668. if (material === null || material === undefined) {
  121669. return;
  121670. }
  121671. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  121672. this._transparentSubMeshes.push(subMesh);
  121673. }
  121674. else if (material.needAlphaTesting()) { // Alpha test
  121675. if (material.needDepthPrePass) {
  121676. this._depthOnlySubMeshes.push(subMesh);
  121677. }
  121678. this._alphaTestSubMeshes.push(subMesh);
  121679. }
  121680. else {
  121681. if (material.needDepthPrePass) {
  121682. this._depthOnlySubMeshes.push(subMesh);
  121683. }
  121684. this._opaqueSubMeshes.push(subMesh); // Opaque
  121685. }
  121686. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  121687. this._edgesRenderers.push(mesh._edgesRenderer);
  121688. }
  121689. };
  121690. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  121691. this._spriteManagers.push(spriteManager);
  121692. };
  121693. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  121694. this._particleSystems.push(particleSystem);
  121695. };
  121696. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  121697. if (this._particleSystems.length === 0) {
  121698. return;
  121699. }
  121700. // Particles
  121701. var activeCamera = this._scene.activeCamera;
  121702. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  121703. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  121704. var particleSystem = this._particleSystems.data[particleIndex];
  121705. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  121706. continue;
  121707. }
  121708. var emitter = particleSystem.emitter;
  121709. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  121710. this._scene._activeParticles.addCount(particleSystem.render(), false);
  121711. }
  121712. }
  121713. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  121714. };
  121715. RenderingGroup.prototype._renderSprites = function () {
  121716. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  121717. return;
  121718. }
  121719. // Sprites
  121720. var activeCamera = this._scene.activeCamera;
  121721. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  121722. for (var id = 0; id < this._spriteManagers.length; id++) {
  121723. var spriteManager = this._spriteManagers.data[id];
  121724. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  121725. spriteManager.render();
  121726. }
  121727. }
  121728. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  121729. };
  121730. return RenderingGroup;
  121731. }());
  121732. /***/ }),
  121733. /***/ "./Rendering/renderingManager.ts":
  121734. /*!***************************************!*\
  121735. !*** ./Rendering/renderingManager.ts ***!
  121736. \***************************************/
  121737. /*! exports provided: RenderingGroupInfo, RenderingManager */
  121738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121739. "use strict";
  121740. __webpack_require__.r(__webpack_exports__);
  121741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  121742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  121743. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121744. /**
  121745. * This class is used by the onRenderingGroupObservable
  121746. */
  121747. var RenderingGroupInfo = /** @class */ (function () {
  121748. function RenderingGroupInfo() {
  121749. }
  121750. return RenderingGroupInfo;
  121751. }());
  121752. /**
  121753. * This is the manager responsible of all the rendering for meshes sprites and particles.
  121754. * It is enable to manage the different groups as well as the different necessary sort functions.
  121755. * This should not be used directly aside of the few static configurations
  121756. */
  121757. var RenderingManager = /** @class */ (function () {
  121758. /**
  121759. * Instantiates a new rendering group for a particular scene
  121760. * @param scene Defines the scene the groups belongs to
  121761. */
  121762. function RenderingManager(scene) {
  121763. /**
  121764. * @hidden
  121765. */
  121766. this._useSceneAutoClearSetup = false;
  121767. this._renderingGroups = new Array();
  121768. this._autoClearDepthStencil = {};
  121769. this._customOpaqueSortCompareFn = {};
  121770. this._customAlphaTestSortCompareFn = {};
  121771. this._customTransparentSortCompareFn = {};
  121772. this._renderingGroupInfo = new RenderingGroupInfo();
  121773. this._scene = scene;
  121774. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  121775. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  121776. }
  121777. }
  121778. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  121779. if (depth === void 0) { depth = true; }
  121780. if (stencil === void 0) { stencil = true; }
  121781. if (this._depthStencilBufferAlreadyCleaned) {
  121782. return;
  121783. }
  121784. this._scene.getEngine().clear(null, false, depth, stencil);
  121785. this._depthStencilBufferAlreadyCleaned = true;
  121786. };
  121787. /**
  121788. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  121789. * @hidden
  121790. */
  121791. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  121792. // Update the observable context (not null as it only goes away on dispose)
  121793. var info = this._renderingGroupInfo;
  121794. info.scene = this._scene;
  121795. info.camera = this._scene.activeCamera;
  121796. // Dispatch sprites
  121797. if (this._scene.spriteManagers && renderSprites) {
  121798. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  121799. var manager = this._scene.spriteManagers[index];
  121800. this.dispatchSprites(manager);
  121801. }
  121802. }
  121803. // Render
  121804. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121805. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  121806. var renderingGroup = this._renderingGroups[index];
  121807. if (!renderingGroup) {
  121808. continue;
  121809. }
  121810. var renderingGroupMask = Math.pow(2, index);
  121811. info.renderingGroupId = index;
  121812. // Before Observable
  121813. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  121814. // Clear depth/stencil if needed
  121815. if (RenderingManager.AUTOCLEAR) {
  121816. var autoClear = this._useSceneAutoClearSetup ?
  121817. this._scene.getAutoClearDepthStencilSetup(index) :
  121818. this._autoClearDepthStencil[index];
  121819. if (autoClear && autoClear.autoClear) {
  121820. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  121821. }
  121822. }
  121823. // Render
  121824. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  121825. var step = _a[_i];
  121826. step.action(index);
  121827. }
  121828. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  121829. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  121830. var step = _c[_b];
  121831. step.action(index);
  121832. }
  121833. // After Observable
  121834. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  121835. }
  121836. };
  121837. /**
  121838. * Resets the different information of the group to prepare a new frame
  121839. * @hidden
  121840. */
  121841. RenderingManager.prototype.reset = function () {
  121842. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121843. var renderingGroup = this._renderingGroups[index];
  121844. if (renderingGroup) {
  121845. renderingGroup.prepare();
  121846. }
  121847. }
  121848. };
  121849. /**
  121850. * Dispose and release the group and its associated resources.
  121851. * @hidden
  121852. */
  121853. RenderingManager.prototype.dispose = function () {
  121854. this.freeRenderingGroups();
  121855. this._renderingGroups.length = 0;
  121856. this._renderingGroupInfo = null;
  121857. };
  121858. /**
  121859. * Clear the info related to rendering groups preventing retention points during dispose.
  121860. */
  121861. RenderingManager.prototype.freeRenderingGroups = function () {
  121862. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121863. var renderingGroup = this._renderingGroups[index];
  121864. if (renderingGroup) {
  121865. renderingGroup.dispose();
  121866. }
  121867. }
  121868. };
  121869. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  121870. if (this._renderingGroups[renderingGroupId] === undefined) {
  121871. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  121872. }
  121873. };
  121874. /**
  121875. * Add a sprite manager to the rendering manager in order to render it this frame.
  121876. * @param spriteManager Define the sprite manager to render
  121877. */
  121878. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  121879. var renderingGroupId = spriteManager.renderingGroupId || 0;
  121880. this._prepareRenderingGroup(renderingGroupId);
  121881. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  121882. };
  121883. /**
  121884. * Add a particle system to the rendering manager in order to render it this frame.
  121885. * @param particleSystem Define the particle system to render
  121886. */
  121887. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  121888. var renderingGroupId = particleSystem.renderingGroupId || 0;
  121889. this._prepareRenderingGroup(renderingGroupId);
  121890. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  121891. };
  121892. /**
  121893. * Add a submesh to the manager in order to render it this frame
  121894. * @param subMesh The submesh to dispatch
  121895. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  121896. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  121897. */
  121898. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  121899. if (mesh === undefined) {
  121900. mesh = subMesh.getMesh();
  121901. }
  121902. var renderingGroupId = mesh.renderingGroupId || 0;
  121903. this._prepareRenderingGroup(renderingGroupId);
  121904. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  121905. };
  121906. /**
  121907. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121908. * This allowed control for front to back rendering or reversly depending of the special needs.
  121909. *
  121910. * @param renderingGroupId The rendering group id corresponding to its index
  121911. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121912. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121913. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121914. */
  121915. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121916. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121917. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121918. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121919. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  121920. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  121921. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  121922. if (this._renderingGroups[renderingGroupId]) {
  121923. var group = this._renderingGroups[renderingGroupId];
  121924. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  121925. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  121926. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  121927. }
  121928. };
  121929. /**
  121930. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121931. *
  121932. * @param renderingGroupId The rendering group id corresponding to its index
  121933. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121934. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121935. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121936. */
  121937. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  121938. if (depth === void 0) { depth = true; }
  121939. if (stencil === void 0) { stencil = true; }
  121940. this._autoClearDepthStencil[renderingGroupId] = {
  121941. autoClear: autoClearDepthStencil,
  121942. depth: depth,
  121943. stencil: stencil
  121944. };
  121945. };
  121946. /**
  121947. * Gets the current auto clear configuration for one rendering group of the rendering
  121948. * manager.
  121949. * @param index the rendering group index to get the information for
  121950. * @returns The auto clear setup for the requested rendering group
  121951. */
  121952. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  121953. return this._autoClearDepthStencil[index];
  121954. };
  121955. /**
  121956. * The max id used for rendering groups (not included)
  121957. */
  121958. RenderingManager.MAX_RENDERINGGROUPS = 4;
  121959. /**
  121960. * The min id used for rendering groups (included)
  121961. */
  121962. RenderingManager.MIN_RENDERINGGROUPS = 0;
  121963. /**
  121964. * Used to globally prevent autoclearing scenes.
  121965. */
  121966. RenderingManager.AUTOCLEAR = true;
  121967. return RenderingManager;
  121968. }());
  121969. /***/ }),
  121970. /***/ "./Rendering/utilityLayerRenderer.ts":
  121971. /*!*******************************************!*\
  121972. !*** ./Rendering/utilityLayerRenderer.ts ***!
  121973. \*******************************************/
  121974. /*! exports provided: UtilityLayerRenderer */
  121975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121976. "use strict";
  121977. __webpack_require__.r(__webpack_exports__);
  121978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  121979. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121980. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  121981. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  121982. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  121983. /**
  121984. * Renders a layer on top of an existing scene
  121985. */
  121986. var UtilityLayerRenderer = /** @class */ (function () {
  121987. /**
  121988. * Instantiates a UtilityLayerRenderer
  121989. * @param originalScene the original scene that will be rendered on top of
  121990. * @param handleEvents boolean indicating if the utility layer should handle events
  121991. */
  121992. function UtilityLayerRenderer(
  121993. /** the original scene that will be rendered on top of */
  121994. originalScene, handleEvents) {
  121995. if (handleEvents === void 0) { handleEvents = true; }
  121996. var _this = this;
  121997. this.originalScene = originalScene;
  121998. this._pointerCaptures = {};
  121999. this._lastPointerEvents = {};
  122000. /**
  122001. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  122002. */
  122003. this.pickUtilitySceneFirst = true;
  122004. /**
  122005. * If the utility layer should automatically be rendered on top of existing scene
  122006. */
  122007. this.shouldRender = true;
  122008. /**
  122009. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  122010. */
  122011. this.onlyCheckPointerDownEvents = true;
  122012. /**
  122013. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  122014. */
  122015. this.processAllEvents = false;
  122016. /**
  122017. * Observable raised when the pointer move from the utility layer scene to the main scene
  122018. */
  122019. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  122020. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  122021. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  122022. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  122023. this.utilityLayerScene._allowPostProcessClearColor = false;
  122024. originalScene.getEngine().scenes.pop();
  122025. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  122026. this.utilityLayerScene.detachControl();
  122027. if (handleEvents) {
  122028. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  122029. if (!_this.utilityLayerScene.activeCamera) {
  122030. return;
  122031. }
  122032. if (!_this.processAllEvents) {
  122033. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  122034. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  122035. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122036. return;
  122037. }
  122038. }
  122039. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  122040. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  122041. var pointerEvent = (prePointerInfo.event);
  122042. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  122043. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122044. return;
  122045. }
  122046. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  122047. if (!prePointerInfo.ray && utilityScenePick) {
  122048. prePointerInfo.ray = utilityScenePick.ray;
  122049. }
  122050. // always fire the prepointer oversvable
  122051. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  122052. // allow every non pointer down event to flow to the utility layer
  122053. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122054. if (!prePointerInfo.skipOnPointerObservable) {
  122055. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122056. }
  122057. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  122058. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122059. }
  122060. return;
  122061. }
  122062. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  122063. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  122064. if (utilityScenePick && utilityScenePick.hit) {
  122065. if (!prePointerInfo.skipOnPointerObservable) {
  122066. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122067. }
  122068. prePointerInfo.skipOnPointerObservable = true;
  122069. }
  122070. }
  122071. else {
  122072. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  122073. var pointerEvent_1 = (prePointerInfo.event);
  122074. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  122075. if (originalScenePick && utilityScenePick) {
  122076. // No pick in utility scene
  122077. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  122078. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122079. // We touched an utility mesh present in the main scene
  122080. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122081. prePointerInfo.skipOnPointerObservable = true;
  122082. }
  122083. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122084. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  122085. }
  122086. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122087. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122088. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122089. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122090. }
  122091. }
  122092. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  122093. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  122094. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  122095. // If a previous utility layer set this, do not unset this
  122096. if (!prePointerInfo.skipOnPointerObservable) {
  122097. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  122098. }
  122099. }
  122100. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  122101. // We have a pick in both scenes but main is closer than utility
  122102. // We touched an utility mesh present in the main scene
  122103. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122104. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122105. prePointerInfo.skipOnPointerObservable = true;
  122106. }
  122107. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122108. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122109. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122110. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122111. }
  122112. }
  122113. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  122114. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  122115. }
  122116. }
  122117. }
  122118. });
  122119. }
  122120. // Render directly on top of existing scene without clearing
  122121. this.utilityLayerScene.autoClear = false;
  122122. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  122123. if (_this.shouldRender) {
  122124. _this.render();
  122125. }
  122126. });
  122127. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  122128. _this.dispose();
  122129. });
  122130. this._updateCamera();
  122131. }
  122132. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  122133. /**
  122134. * 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)
  122135. */
  122136. get: function () {
  122137. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  122138. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122139. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122140. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122141. });
  122142. }
  122143. return UtilityLayerRenderer._DefaultUtilityLayer;
  122144. },
  122145. enumerable: true,
  122146. configurable: true
  122147. });
  122148. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  122149. /**
  122150. * 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)
  122151. */
  122152. get: function () {
  122153. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  122154. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122155. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  122156. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122157. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122158. });
  122159. }
  122160. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  122161. },
  122162. enumerable: true,
  122163. configurable: true
  122164. });
  122165. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  122166. if (!prePointerInfo.skipOnPointerObservable) {
  122167. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  122168. this._lastPointerEvents[pointerEvent.pointerId] = true;
  122169. }
  122170. };
  122171. /**
  122172. * Renders the utility layers scene on top of the original scene
  122173. */
  122174. UtilityLayerRenderer.prototype.render = function () {
  122175. this._updateCamera();
  122176. if (this.utilityLayerScene.activeCamera) {
  122177. // Set the camera's scene to utility layers scene
  122178. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  122179. var camera = this.utilityLayerScene.activeCamera;
  122180. camera._scene = this.utilityLayerScene;
  122181. if (camera.leftCamera) {
  122182. camera.leftCamera._scene = this.utilityLayerScene;
  122183. }
  122184. if (camera.rightCamera) {
  122185. camera.rightCamera._scene = this.utilityLayerScene;
  122186. }
  122187. this.utilityLayerScene.render(false);
  122188. // Reset camera's scene back to original
  122189. camera._scene = oldScene;
  122190. if (camera.leftCamera) {
  122191. camera.leftCamera._scene = oldScene;
  122192. }
  122193. if (camera.rightCamera) {
  122194. camera.rightCamera._scene = oldScene;
  122195. }
  122196. }
  122197. };
  122198. /**
  122199. * Disposes of the renderer
  122200. */
  122201. UtilityLayerRenderer.prototype.dispose = function () {
  122202. this.onPointerOutObservable.clear();
  122203. if (this._afterRenderObserver) {
  122204. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  122205. }
  122206. if (this._sceneDisposeObserver) {
  122207. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  122208. }
  122209. if (this._originalPointerObserver) {
  122210. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  122211. }
  122212. this.utilityLayerScene.dispose();
  122213. };
  122214. UtilityLayerRenderer.prototype._updateCamera = function () {
  122215. if (this.originalScene.activeCameras.length > 1) {
  122216. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  122217. }
  122218. else {
  122219. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  122220. }
  122221. };
  122222. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122223. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122224. return UtilityLayerRenderer;
  122225. }());
  122226. /***/ }),
  122227. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  122228. /*!*****************************************************************!*\
  122229. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  122230. \*****************************************************************/
  122231. /*! exports provided: backgroundFragmentDeclaration */
  122232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122233. "use strict";
  122234. __webpack_require__.r(__webpack_exports__);
  122235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  122236. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122237. var name = 'backgroundFragmentDeclaration';
  122238. 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";
  122239. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122240. /** @hidden */
  122241. var backgroundFragmentDeclaration = { name: name, shader: shader };
  122242. /***/ }),
  122243. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  122244. /*!************************************************************!*\
  122245. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  122246. \************************************************************/
  122247. /*! exports provided: backgroundUboDeclaration */
  122248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122249. "use strict";
  122250. __webpack_require__.r(__webpack_exports__);
  122251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  122252. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122253. var name = 'backgroundUboDeclaration';
  122254. 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;\nmat4 view;\n};";
  122255. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122256. /** @hidden */
  122257. var backgroundUboDeclaration = { name: name, shader: shader };
  122258. /***/ }),
  122259. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  122260. /*!***************************************************************!*\
  122261. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  122262. \***************************************************************/
  122263. /*! exports provided: backgroundVertexDeclaration */
  122264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122265. "use strict";
  122266. __webpack_require__.r(__webpack_exports__);
  122267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  122268. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122269. var name = 'backgroundVertexDeclaration';
  122270. 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";
  122271. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122272. /** @hidden */
  122273. var backgroundVertexDeclaration = { name: name, shader: shader };
  122274. /***/ }),
  122275. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  122276. /*!****************************************************!*\
  122277. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  122278. \****************************************************/
  122279. /*! exports provided: bonesDeclaration */
  122280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122281. "use strict";
  122282. __webpack_require__.r(__webpack_exports__);
  122283. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  122284. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122285. var name = 'bonesDeclaration';
  122286. 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";
  122287. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122288. /** @hidden */
  122289. var bonesDeclaration = { name: name, shader: shader };
  122290. /***/ }),
  122291. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  122292. /*!***********************************************!*\
  122293. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  122294. \***********************************************/
  122295. /*! exports provided: bonesVertex */
  122296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122297. "use strict";
  122298. __webpack_require__.r(__webpack_exports__);
  122299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  122300. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122301. var name = 'bonesVertex';
  122302. 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";
  122303. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122304. /** @hidden */
  122305. var bonesVertex = { name: name, shader: shader };
  122306. /***/ }),
  122307. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  122308. /*!************************************************!*\
  122309. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  122310. \************************************************/
  122311. /*! exports provided: bumpFragment */
  122312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122313. "use strict";
  122314. __webpack_require__.r(__webpack_exports__);
  122315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  122316. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122317. var name = 'bumpFragment';
  122318. 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#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";
  122319. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122320. /** @hidden */
  122321. var bumpFragment = { name: name, shader: shader };
  122322. /***/ }),
  122323. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  122324. /*!*********************************************************!*\
  122325. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  122326. \*********************************************************/
  122327. /*! exports provided: bumpFragmentFunctions */
  122328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122329. "use strict";
  122330. __webpack_require__.r(__webpack_exports__);
  122331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  122332. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122333. var name = 'bumpFragmentFunctions';
  122334. var shader = "#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;\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\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*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef 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\n#endif";
  122335. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122336. /** @hidden */
  122337. var bumpFragmentFunctions = { name: name, shader: shader };
  122338. /***/ }),
  122339. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  122340. /*!**********************************************!*\
  122341. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  122342. \**********************************************/
  122343. /*! exports provided: bumpVertex */
  122344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122345. "use strict";
  122346. __webpack_require__.r(__webpack_exports__);
  122347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  122348. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122349. var name = 'bumpVertex';
  122350. var shader = "#if defined(BUMP) || defined(PARALLAX)\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";
  122351. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122352. /** @hidden */
  122353. var bumpVertex = { name: name, shader: shader };
  122354. /***/ }),
  122355. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  122356. /*!*********************************************************!*\
  122357. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  122358. \*********************************************************/
  122359. /*! exports provided: bumpVertexDeclaration */
  122360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122361. "use strict";
  122362. __webpack_require__.r(__webpack_exports__);
  122363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  122364. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122365. var name = 'bumpVertexDeclaration';
  122366. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  122367. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122368. /** @hidden */
  122369. var bumpVertexDeclaration = { name: name, shader: shader };
  122370. /***/ }),
  122371. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  122372. /*!*****************************************************!*\
  122373. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  122374. \*****************************************************/
  122375. /*! exports provided: clipPlaneFragment */
  122376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122377. "use strict";
  122378. __webpack_require__.r(__webpack_exports__);
  122379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  122380. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122381. var name = 'clipPlaneFragment';
  122382. 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";
  122383. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122384. /** @hidden */
  122385. var clipPlaneFragment = { name: name, shader: shader };
  122386. /***/ }),
  122387. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  122388. /*!****************************************************************!*\
  122389. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  122390. \****************************************************************/
  122391. /*! exports provided: clipPlaneFragmentDeclaration */
  122392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122393. "use strict";
  122394. __webpack_require__.r(__webpack_exports__);
  122395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  122396. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122397. var name = 'clipPlaneFragmentDeclaration';
  122398. 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";
  122399. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122400. /** @hidden */
  122401. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  122402. /***/ }),
  122403. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  122404. /*!*****************************************************************!*\
  122405. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  122406. \*****************************************************************/
  122407. /*! exports provided: clipPlaneFragmentDeclaration2 */
  122408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122409. "use strict";
  122410. __webpack_require__.r(__webpack_exports__);
  122411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  122412. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122413. var name = 'clipPlaneFragmentDeclaration2';
  122414. 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";
  122415. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122416. /** @hidden */
  122417. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  122418. /***/ }),
  122419. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  122420. /*!***************************************************!*\
  122421. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  122422. \***************************************************/
  122423. /*! exports provided: clipPlaneVertex */
  122424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122425. "use strict";
  122426. __webpack_require__.r(__webpack_exports__);
  122427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  122428. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122429. var name = 'clipPlaneVertex';
  122430. 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";
  122431. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122432. /** @hidden */
  122433. var clipPlaneVertex = { name: name, shader: shader };
  122434. /***/ }),
  122435. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  122436. /*!**************************************************************!*\
  122437. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  122438. \**************************************************************/
  122439. /*! exports provided: clipPlaneVertexDeclaration */
  122440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122441. "use strict";
  122442. __webpack_require__.r(__webpack_exports__);
  122443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  122444. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122445. var name = 'clipPlaneVertexDeclaration';
  122446. 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";
  122447. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122448. /** @hidden */
  122449. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  122450. /***/ }),
  122451. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  122452. /*!***************************************************************!*\
  122453. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  122454. \***************************************************************/
  122455. /*! exports provided: clipPlaneVertexDeclaration2 */
  122456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122457. "use strict";
  122458. __webpack_require__.r(__webpack_exports__);
  122459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  122460. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122461. var name = 'clipPlaneVertexDeclaration2';
  122462. 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";
  122463. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122464. /** @hidden */
  122465. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  122466. /***/ }),
  122467. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  122468. /*!**************************************************************!*\
  122469. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  122470. \**************************************************************/
  122471. /*! exports provided: defaultFragmentDeclaration */
  122472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122473. "use strict";
  122474. __webpack_require__.r(__webpack_exports__);
  122475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  122476. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122477. var name = 'defaultFragmentDeclaration';
  122478. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  122479. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122480. /** @hidden */
  122481. var defaultFragmentDeclaration = { name: name, shader: shader };
  122482. /***/ }),
  122483. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  122484. /*!*********************************************************!*\
  122485. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  122486. \*********************************************************/
  122487. /*! exports provided: defaultUboDeclaration */
  122488. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122489. "use strict";
  122490. __webpack_require__.r(__webpack_exports__);
  122491. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  122492. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122493. var name = 'defaultUboDeclaration';
  122494. 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;\nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  122495. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122496. /** @hidden */
  122497. var defaultUboDeclaration = { name: name, shader: shader };
  122498. /***/ }),
  122499. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  122500. /*!************************************************************!*\
  122501. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  122502. \************************************************************/
  122503. /*! exports provided: defaultVertexDeclaration */
  122504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122505. "use strict";
  122506. __webpack_require__.r(__webpack_exports__);
  122507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  122508. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122509. var name = 'defaultVertexDeclaration';
  122510. 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";
  122511. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122512. /** @hidden */
  122513. var defaultVertexDeclaration = { name: name, shader: shader };
  122514. /***/ }),
  122515. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  122516. /*!************************************************!*\
  122517. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  122518. \************************************************/
  122519. /*! exports provided: depthPrePass */
  122520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122521. "use strict";
  122522. __webpack_require__.r(__webpack_exports__);
  122523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  122524. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122525. var name = 'depthPrePass';
  122526. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  122527. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122528. /** @hidden */
  122529. var depthPrePass = { name: name, shader: shader };
  122530. /***/ }),
  122531. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  122532. /*!***********************************************!*\
  122533. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  122534. \***********************************************/
  122535. /*! exports provided: fogFragment */
  122536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122537. "use strict";
  122538. __webpack_require__.r(__webpack_exports__);
  122539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  122540. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122541. var name = 'fogFragment';
  122542. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  122543. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122544. /** @hidden */
  122545. var fogFragment = { name: name, shader: shader };
  122546. /***/ }),
  122547. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  122548. /*!**********************************************************!*\
  122549. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  122550. \**********************************************************/
  122551. /*! exports provided: fogFragmentDeclaration */
  122552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122553. "use strict";
  122554. __webpack_require__.r(__webpack_exports__);
  122555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  122556. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122557. var name = 'fogFragmentDeclaration';
  122558. 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";
  122559. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122560. /** @hidden */
  122561. var fogFragmentDeclaration = { name: name, shader: shader };
  122562. /***/ }),
  122563. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  122564. /*!*********************************************!*\
  122565. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  122566. \*********************************************/
  122567. /*! exports provided: fogVertex */
  122568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122569. "use strict";
  122570. __webpack_require__.r(__webpack_exports__);
  122571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  122572. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122573. var name = 'fogVertex';
  122574. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  122575. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122576. /** @hidden */
  122577. var fogVertex = { name: name, shader: shader };
  122578. /***/ }),
  122579. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  122580. /*!********************************************************!*\
  122581. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  122582. \********************************************************/
  122583. /*! exports provided: fogVertexDeclaration */
  122584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122585. "use strict";
  122586. __webpack_require__.r(__webpack_exports__);
  122587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  122588. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122589. var name = 'fogVertexDeclaration';
  122590. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  122591. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122592. /** @hidden */
  122593. var fogVertexDeclaration = { name: name, shader: shader };
  122594. /***/ }),
  122595. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  122596. /*!***************************************************!*\
  122597. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  122598. \***************************************************/
  122599. /*! exports provided: fresnelFunction */
  122600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122601. "use strict";
  122602. __webpack_require__.r(__webpack_exports__);
  122603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  122604. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122605. var name = 'fresnelFunction';
  122606. 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";
  122607. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122608. /** @hidden */
  122609. var fresnelFunction = { name: name, shader: shader };
  122610. /***/ }),
  122611. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  122612. /*!******************************************************!*\
  122613. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  122614. \******************************************************/
  122615. /*! exports provided: harmonicsFunctions */
  122616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122617. "use strict";
  122618. __webpack_require__.r(__webpack_exports__);
  122619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  122620. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122621. var name = 'harmonicsFunctions';
  122622. var shader = "#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif";
  122623. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122624. /** @hidden */
  122625. var harmonicsFunctions = { name: name, shader: shader };
  122626. /***/ }),
  122627. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  122628. /*!***************************************************!*\
  122629. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  122630. \***************************************************/
  122631. /*! exports provided: helperFunctions */
  122632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122633. "use strict";
  122634. __webpack_require__.r(__webpack_exports__);
  122635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  122636. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122637. var name = 'helperFunctions';
  122638. 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);\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}\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}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\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 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=max(0.0000001,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}";
  122639. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122640. /** @hidden */
  122641. var helperFunctions = { name: name, shader: shader };
  122642. /***/ }),
  122643. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  122644. /*!**************************************************************!*\
  122645. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  122646. \**************************************************************/
  122647. /*! exports provided: imageProcessingDeclaration */
  122648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122649. "use strict";
  122650. __webpack_require__.r(__webpack_exports__);
  122651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  122652. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122653. var name = 'imageProcessingDeclaration';
  122654. 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";
  122655. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122656. /** @hidden */
  122657. var imageProcessingDeclaration = { name: name, shader: shader };
  122658. /***/ }),
  122659. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  122660. /*!************************************************************!*\
  122661. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  122662. \************************************************************/
  122663. /*! exports provided: imageProcessingFunctions */
  122664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122665. "use strict";
  122666. __webpack_require__.r(__webpack_exports__);
  122667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  122668. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122669. var name = 'imageProcessingFunctions';
  122670. 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=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\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=clamp(color,0.0,1.0);\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=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(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}";
  122671. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122672. /** @hidden */
  122673. var imageProcessingFunctions = { name: name, shader: shader };
  122674. /***/ }),
  122675. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  122676. /*!********************************************************!*\
  122677. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  122678. \********************************************************/
  122679. /*! exports provided: instancesDeclaration */
  122680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122681. "use strict";
  122682. __webpack_require__.r(__webpack_exports__);
  122683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  122684. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122685. var name = 'instancesDeclaration';
  122686. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  122687. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122688. /** @hidden */
  122689. var instancesDeclaration = { name: name, shader: shader };
  122690. /***/ }),
  122691. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  122692. /*!***************************************************!*\
  122693. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  122694. \***************************************************/
  122695. /*! exports provided: instancesVertex */
  122696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122697. "use strict";
  122698. __webpack_require__.r(__webpack_exports__);
  122699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  122700. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122701. var name = 'instancesVertex';
  122702. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  122703. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122704. /** @hidden */
  122705. var instancesVertex = { name: name, shader: shader };
  122706. /***/ }),
  122707. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  122708. /*!******************************************************!*\
  122709. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  122710. \******************************************************/
  122711. /*! exports provided: kernelBlurFragment */
  122712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122713. "use strict";
  122714. __webpack_require__.r(__webpack_exports__);
  122715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  122716. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122717. var name = 'kernelBlurFragment';
  122718. 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";
  122719. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122720. /** @hidden */
  122721. var kernelBlurFragment = { name: name, shader: shader };
  122722. /***/ }),
  122723. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  122724. /*!*******************************************************!*\
  122725. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  122726. \*******************************************************/
  122727. /*! exports provided: kernelBlurFragment2 */
  122728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122729. "use strict";
  122730. __webpack_require__.r(__webpack_exports__);
  122731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  122732. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122733. var name = 'kernelBlurFragment2';
  122734. 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";
  122735. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122736. /** @hidden */
  122737. var kernelBlurFragment2 = { name: name, shader: shader };
  122738. /***/ }),
  122739. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  122740. /*!****************************************************************!*\
  122741. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  122742. \****************************************************************/
  122743. /*! exports provided: kernelBlurVaryingDeclaration */
  122744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122745. "use strict";
  122746. __webpack_require__.r(__webpack_exports__);
  122747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  122748. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122749. var name = 'kernelBlurVaryingDeclaration';
  122750. var shader = "varying vec2 sampleCoord{X};";
  122751. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122752. /** @hidden */
  122753. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  122754. /***/ }),
  122755. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  122756. /*!****************************************************!*\
  122757. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  122758. \****************************************************/
  122759. /*! exports provided: kernelBlurVertex */
  122760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122761. "use strict";
  122762. __webpack_require__.r(__webpack_exports__);
  122763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  122764. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122765. var name = 'kernelBlurVertex';
  122766. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  122767. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122768. /** @hidden */
  122769. var kernelBlurVertex = { name: name, shader: shader };
  122770. /***/ }),
  122771. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  122772. /*!*************************************************!*\
  122773. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  122774. \*************************************************/
  122775. /*! exports provided: lightFragment */
  122776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122777. "use strict";
  122778. __webpack_require__.r(__webpack_exports__);
  122779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  122780. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122781. var name = 'lightFragment';
  122782. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\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#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  122783. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122784. /** @hidden */
  122785. var lightFragment = { name: name, shader: shader };
  122786. /***/ }),
  122787. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  122788. /*!************************************************************!*\
  122789. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  122790. \************************************************************/
  122791. /*! exports provided: lightFragmentDeclaration */
  122792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122793. "use strict";
  122794. __webpack_require__.r(__webpack_exports__);
  122795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  122796. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122797. var name = 'lightFragmentDeclaration';
  122798. 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";
  122799. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122800. /** @hidden */
  122801. var lightFragmentDeclaration = { name: name, shader: shader };
  122802. /***/ }),
  122803. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  122804. /*!*******************************************************!*\
  122805. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  122806. \*******************************************************/
  122807. /*! exports provided: lightUboDeclaration */
  122808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122809. "use strict";
  122810. __webpack_require__.r(__webpack_exports__);
  122811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  122812. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122813. var name = 'lightUboDeclaration';
  122814. 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";
  122815. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122816. /** @hidden */
  122817. var lightUboDeclaration = { name: name, shader: shader };
  122818. /***/ }),
  122819. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  122820. /*!***********************************************************!*\
  122821. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  122822. \***********************************************************/
  122823. /*! exports provided: lightsFragmentFunctions */
  122824. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122825. "use strict";
  122826. __webpack_require__.r(__webpack_exports__);
  122827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  122828. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122829. var name = 'lightsFragmentFunctions';
  122830. 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}";
  122831. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122832. /** @hidden */
  122833. var lightsFragmentFunctions = { name: name, shader: shader };
  122834. /***/ }),
  122835. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  122836. /*!*******************************************************!*\
  122837. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  122838. \*******************************************************/
  122839. /*! exports provided: logDepthDeclaration */
  122840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122841. "use strict";
  122842. __webpack_require__.r(__webpack_exports__);
  122843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  122844. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122845. var name = 'logDepthDeclaration';
  122846. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  122847. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122848. /** @hidden */
  122849. var logDepthDeclaration = { name: name, shader: shader };
  122850. /***/ }),
  122851. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  122852. /*!****************************************************!*\
  122853. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  122854. \****************************************************/
  122855. /*! exports provided: logDepthFragment */
  122856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122857. "use strict";
  122858. __webpack_require__.r(__webpack_exports__);
  122859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  122860. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122861. var name = 'logDepthFragment';
  122862. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  122863. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122864. /** @hidden */
  122865. var logDepthFragment = { name: name, shader: shader };
  122866. /***/ }),
  122867. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  122868. /*!**************************************************!*\
  122869. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  122870. \**************************************************/
  122871. /*! exports provided: logDepthVertex */
  122872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122873. "use strict";
  122874. __webpack_require__.r(__webpack_exports__);
  122875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  122876. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122877. var name = 'logDepthVertex';
  122878. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  122879. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122880. /** @hidden */
  122881. var logDepthVertex = { name: name, shader: shader };
  122882. /***/ }),
  122883. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  122884. /*!******************************************************!*\
  122885. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  122886. \******************************************************/
  122887. /*! exports provided: morphTargetsVertex */
  122888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122889. "use strict";
  122890. __webpack_require__.r(__webpack_exports__);
  122891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  122892. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122893. var name = 'morphTargetsVertex';
  122894. 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";
  122895. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122896. /** @hidden */
  122897. var morphTargetsVertex = { name: name, shader: shader };
  122898. /***/ }),
  122899. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  122900. /*!*****************************************************************!*\
  122901. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  122902. \*****************************************************************/
  122903. /*! exports provided: morphTargetsVertexDeclaration */
  122904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122905. "use strict";
  122906. __webpack_require__.r(__webpack_exports__);
  122907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  122908. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122909. var name = 'morphTargetsVertexDeclaration';
  122910. 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";
  122911. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122912. /** @hidden */
  122913. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  122914. /***/ }),
  122915. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  122916. /*!***********************************************************************!*\
  122917. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  122918. \***********************************************************************/
  122919. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  122920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122921. "use strict";
  122922. __webpack_require__.r(__webpack_exports__);
  122923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  122924. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122925. var name = 'morphTargetsVertexGlobalDeclaration';
  122926. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  122927. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122928. /** @hidden */
  122929. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  122930. /***/ }),
  122931. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  122932. /*!**********************************************************!*\
  122933. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  122934. \**********************************************************/
  122935. /*! exports provided: mrtFragmentDeclaration */
  122936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122937. "use strict";
  122938. __webpack_require__.r(__webpack_exports__);
  122939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  122940. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122941. var name = 'mrtFragmentDeclaration';
  122942. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  122943. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122944. /** @hidden */
  122945. var mrtFragmentDeclaration = { name: name, shader: shader };
  122946. /***/ }),
  122947. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  122948. /*!**********************************************************!*\
  122949. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  122950. \**********************************************************/
  122951. /*! exports provided: pbrFragmentDeclaration */
  122952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122953. "use strict";
  122954. __webpack_require__.r(__webpack_exports__);
  122955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  122956. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122957. var name = 'pbrFragmentDeclaration';
  122958. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\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(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\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";
  122959. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122960. /** @hidden */
  122961. var pbrFragmentDeclaration = { name: name, shader: shader };
  122962. /***/ }),
  122963. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  122964. /*!************************************************!*\
  122965. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  122966. \************************************************/
  122967. /*! exports provided: pbrFunctions */
  122968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122969. "use strict";
  122970. __webpack_require__.r(__webpack_exports__);
  122971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  122972. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122973. var name = 'pbrFunctions';
  122974. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\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}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\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)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\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*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\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\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\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));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";
  122975. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122976. /** @hidden */
  122977. var pbrFunctions = { name: name, shader: shader };
  122978. /***/ }),
  122979. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  122980. /*!*****************************************************!*\
  122981. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  122982. \*****************************************************/
  122983. /*! exports provided: pbrLightFunctions */
  122984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122985. "use strict";
  122986. __webpack_require__.r(__webpack_exports__);
  122987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  122988. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122989. var name = 'pbrLightFunctions';
  122990. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat 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/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\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=max(0.000000000000001,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=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\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}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\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 toLinearSpace(textureColor);\n}";
  122991. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122992. /** @hidden */
  122993. var pbrLightFunctions = { name: name, shader: shader };
  122994. /***/ }),
  122995. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  122996. /*!*****************************************************!*\
  122997. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  122998. \*****************************************************/
  122999. /*! exports provided: pbrUboDeclaration */
  123000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123001. "use strict";
  123002. __webpack_require__.r(__webpack_exports__);
  123003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  123004. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123005. var name = 'pbrUboDeclaration';
  123006. 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 vec4 vRefractionInfos;\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 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  123007. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123008. /** @hidden */
  123009. var pbrUboDeclaration = { name: name, shader: shader };
  123010. /***/ }),
  123011. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  123012. /*!********************************************************!*\
  123013. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  123014. \********************************************************/
  123015. /*! exports provided: pbrVertexDeclaration */
  123016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123017. "use strict";
  123018. __webpack_require__.r(__webpack_exports__);
  123019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  123020. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123021. var name = 'pbrVertexDeclaration';
  123022. 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 REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n";
  123023. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123024. /** @hidden */
  123025. var pbrVertexDeclaration = { name: name, shader: shader };
  123026. /***/ }),
  123027. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  123028. /*!****************************************************!*\
  123029. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  123030. \****************************************************/
  123031. /*! exports provided: pointCloudVertex */
  123032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123033. "use strict";
  123034. __webpack_require__.r(__webpack_exports__);
  123035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  123036. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123037. var name = 'pointCloudVertex';
  123038. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  123039. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123040. /** @hidden */
  123041. var pointCloudVertex = { name: name, shader: shader };
  123042. /***/ }),
  123043. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  123044. /*!******************************************************!*\
  123045. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  123046. \******************************************************/
  123047. /*! exports provided: reflectionFunction */
  123048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123049. "use strict";
  123050. __webpack_require__.r(__webpack_exports__);
  123051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  123052. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123053. var name = 'reflectionFunction';
  123054. var shader = "#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\n#endif\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=normalize(worldPos.xyz-vEyePosition.xyz);\n\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,vReflectionSize,vReflectionPosition);\n#endif\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  123055. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123056. /** @hidden */
  123057. var reflectionFunction = { name: name, shader: shader };
  123058. /***/ }),
  123059. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  123060. /*!************************************************************!*\
  123061. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  123062. \************************************************************/
  123063. /*! exports provided: shadowsFragmentFunctions */
  123064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123065. "use strict";
  123066. __webpack_require__.r(__webpack_exports__);
  123067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  123068. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123069. var name = 'shadowsFragmentFunctions';
  123070. 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 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";
  123071. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123072. /** @hidden */
  123073. var shadowsFragmentFunctions = { name: name, shader: shader };
  123074. /***/ }),
  123075. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  123076. /*!*************************************************!*\
  123077. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  123078. \*************************************************/
  123079. /*! exports provided: shadowsVertex */
  123080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123081. "use strict";
  123082. __webpack_require__.r(__webpack_exports__);
  123083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  123084. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123085. var name = 'shadowsVertex';
  123086. 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";
  123087. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123088. /** @hidden */
  123089. var shadowsVertex = { name: name, shader: shader };
  123090. /***/ }),
  123091. /***/ "./Shaders/anaglyph.fragment.ts":
  123092. /*!**************************************!*\
  123093. !*** ./Shaders/anaglyph.fragment.ts ***!
  123094. \**************************************/
  123095. /*! exports provided: anaglyphPixelShader */
  123096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123097. "use strict";
  123098. __webpack_require__.r(__webpack_exports__);
  123099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  123100. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123101. var name = 'anaglyphPixelShader';
  123102. 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}";
  123103. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123104. /** @hidden */
  123105. var anaglyphPixelShader = { name: name, shader: shader };
  123106. /***/ }),
  123107. /***/ "./Shaders/background.fragment.ts":
  123108. /*!****************************************!*\
  123109. !*** ./Shaders/background.fragment.ts ***!
  123110. \****************************************/
  123111. /*! exports provided: backgroundPixelShader */
  123112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123113. "use strict";
  123114. __webpack_require__.r(__webpack_exports__);
  123115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  123116. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123117. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  123118. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123119. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123120. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123121. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123122. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123123. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123124. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123125. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123126. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123127. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123128. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123129. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123130. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123131. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123132. var name = 'backgroundPixelShader';
  123133. 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)*pow(clamp(1.0-VdotN,0.,1.),5.0);\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=clamp(reflectionLOD,0.,1.);\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(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\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";
  123134. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123135. /** @hidden */
  123136. var backgroundPixelShader = { name: name, shader: shader };
  123137. /***/ }),
  123138. /***/ "./Shaders/background.vertex.ts":
  123139. /*!**************************************!*\
  123140. !*** ./Shaders/background.vertex.ts ***!
  123141. \**************************************/
  123142. /*! exports provided: backgroundVertexShader */
  123143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123144. "use strict";
  123145. __webpack_require__.r(__webpack_exports__);
  123146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  123147. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123148. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  123149. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123150. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123151. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123152. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123153. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123154. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123155. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123156. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123157. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123158. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123159. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123160. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123161. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123162. var name = 'backgroundVertexShader';
  123163. 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>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\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";
  123164. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123165. /** @hidden */
  123166. var backgroundVertexShader = { name: name, shader: shader };
  123167. /***/ }),
  123168. /***/ "./Shaders/blackAndWhite.fragment.ts":
  123169. /*!*******************************************!*\
  123170. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  123171. \*******************************************/
  123172. /*! exports provided: blackAndWhitePixelShader */
  123173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123174. "use strict";
  123175. __webpack_require__.r(__webpack_exports__);
  123176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  123177. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123178. var name = 'blackAndWhitePixelShader';
  123179. 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}";
  123180. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123181. /** @hidden */
  123182. var blackAndWhitePixelShader = { name: name, shader: shader };
  123183. /***/ }),
  123184. /***/ "./Shaders/bloomMerge.fragment.ts":
  123185. /*!****************************************!*\
  123186. !*** ./Shaders/bloomMerge.fragment.ts ***!
  123187. \****************************************/
  123188. /*! exports provided: bloomMergePixelShader */
  123189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123190. "use strict";
  123191. __webpack_require__.r(__webpack_exports__);
  123192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  123193. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123194. var name = 'bloomMergePixelShader';
  123195. 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";
  123196. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123197. /** @hidden */
  123198. var bloomMergePixelShader = { name: name, shader: shader };
  123199. /***/ }),
  123200. /***/ "./Shaders/chromaticAberration.fragment.ts":
  123201. /*!*************************************************!*\
  123202. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  123203. \*************************************************/
  123204. /*! exports provided: chromaticAberrationPixelShader */
  123205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123206. "use strict";
  123207. __webpack_require__.r(__webpack_exports__);
  123208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  123209. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123210. var name = 'chromaticAberrationPixelShader';
  123211. 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}";
  123212. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123213. /** @hidden */
  123214. var chromaticAberrationPixelShader = { name: name, shader: shader };
  123215. /***/ }),
  123216. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  123217. /*!***********************************************!*\
  123218. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  123219. \***********************************************/
  123220. /*! exports provided: circleOfConfusionPixelShader */
  123221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123222. "use strict";
  123223. __webpack_require__.r(__webpack_exports__);
  123224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  123225. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123226. var name = 'circleOfConfusionPixelShader';
  123227. 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";
  123228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123229. /** @hidden */
  123230. var circleOfConfusionPixelShader = { name: name, shader: shader };
  123231. /***/ }),
  123232. /***/ "./Shaders/color.fragment.ts":
  123233. /*!***********************************!*\
  123234. !*** ./Shaders/color.fragment.ts ***!
  123235. \***********************************/
  123236. /*! exports provided: colorPixelShader */
  123237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123238. "use strict";
  123239. __webpack_require__.r(__webpack_exports__);
  123240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  123241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123242. var name = 'colorPixelShader';
  123243. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  123244. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123245. /** @hidden */
  123246. var colorPixelShader = { name: name, shader: shader };
  123247. /***/ }),
  123248. /***/ "./Shaders/color.vertex.ts":
  123249. /*!*********************************!*\
  123250. !*** ./Shaders/color.vertex.ts ***!
  123251. \*********************************/
  123252. /*! exports provided: colorVertexShader */
  123253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123254. "use strict";
  123255. __webpack_require__.r(__webpack_exports__);
  123256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  123257. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123258. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123259. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123260. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123261. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123262. var name = 'colorVertexShader';
  123263. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\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>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  123264. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123265. /** @hidden */
  123266. var colorVertexShader = { name: name, shader: shader };
  123267. /***/ }),
  123268. /***/ "./Shaders/colorCorrection.fragment.ts":
  123269. /*!*********************************************!*\
  123270. !*** ./Shaders/colorCorrection.fragment.ts ***!
  123271. \*********************************************/
  123272. /*! exports provided: colorCorrectionPixelShader */
  123273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123274. "use strict";
  123275. __webpack_require__.r(__webpack_exports__);
  123276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  123277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123278. var name = 'colorCorrectionPixelShader';
  123279. 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}";
  123280. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123281. /** @hidden */
  123282. var colorCorrectionPixelShader = { name: name, shader: shader };
  123283. /***/ }),
  123284. /***/ "./Shaders/convolution.fragment.ts":
  123285. /*!*****************************************!*\
  123286. !*** ./Shaders/convolution.fragment.ts ***!
  123287. \*****************************************/
  123288. /*! exports provided: convolutionPixelShader */
  123289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123290. "use strict";
  123291. __webpack_require__.r(__webpack_exports__);
  123292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  123293. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123294. var name = 'convolutionPixelShader';
  123295. 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}";
  123296. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123297. /** @hidden */
  123298. var convolutionPixelShader = { name: name, shader: shader };
  123299. /***/ }),
  123300. /***/ "./Shaders/default.fragment.ts":
  123301. /*!*************************************!*\
  123302. !*** ./Shaders/default.fragment.ts ***!
  123303. \*************************************/
  123304. /*! exports provided: defaultPixelShader */
  123305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123306. "use strict";
  123307. __webpack_require__.r(__webpack_exports__);
  123308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  123309. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123310. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  123311. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123312. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123313. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123314. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123315. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123316. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123317. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  123318. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123319. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123320. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123321. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123322. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123323. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123324. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123325. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123326. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123327. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123328. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123329. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123330. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123331. var name = 'defaultPixelShader';
  123332. 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\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  123333. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123334. /** @hidden */
  123335. var defaultPixelShader = { name: name, shader: shader };
  123336. /***/ }),
  123337. /***/ "./Shaders/default.vertex.ts":
  123338. /*!***********************************!*\
  123339. !*** ./Shaders/default.vertex.ts ***!
  123340. \***********************************/
  123341. /*! exports provided: defaultVertexShader */
  123342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123343. "use strict";
  123344. __webpack_require__.r(__webpack_exports__);
  123345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  123346. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123347. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  123348. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123349. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123350. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123351. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123352. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123353. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123354. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123355. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123356. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123357. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123358. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123359. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123360. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123361. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123362. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123363. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123364. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123365. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123366. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123367. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  123368. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123369. var name = 'defaultVertexShader';
  123370. 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>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\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";
  123371. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123372. /** @hidden */
  123373. var defaultVertexShader = { name: name, shader: shader };
  123374. /***/ }),
  123375. /***/ "./Shaders/depth.fragment.ts":
  123376. /*!***********************************!*\
  123377. !*** ./Shaders/depth.fragment.ts ***!
  123378. \***********************************/
  123379. /*! exports provided: depthPixelShader */
  123380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123381. "use strict";
  123382. __webpack_require__.r(__webpack_exports__);
  123383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  123384. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123385. var name = 'depthPixelShader';
  123386. 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}";
  123387. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123388. /** @hidden */
  123389. var depthPixelShader = { name: name, shader: shader };
  123390. /***/ }),
  123391. /***/ "./Shaders/depth.vertex.ts":
  123392. /*!*********************************!*\
  123393. !*** ./Shaders/depth.vertex.ts ***!
  123394. \*********************************/
  123395. /*! exports provided: depthVertexShader */
  123396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123397. "use strict";
  123398. __webpack_require__.r(__webpack_exports__);
  123399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  123400. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123401. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123402. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123403. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123404. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123405. var name = 'depthVertexShader';
  123406. 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}";
  123407. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123408. /** @hidden */
  123409. var depthVertexShader = { name: name, shader: shader };
  123410. /***/ }),
  123411. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  123412. /*!******************************************!*\
  123413. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  123414. \******************************************/
  123415. /*! exports provided: depthBoxBlurPixelShader */
  123416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123417. "use strict";
  123418. __webpack_require__.r(__webpack_exports__);
  123419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  123420. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123421. var name = 'depthBoxBlurPixelShader';
  123422. 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}";
  123423. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123424. /** @hidden */
  123425. var depthBoxBlurPixelShader = { name: name, shader: shader };
  123426. /***/ }),
  123427. /***/ "./Shaders/depthOfField.fragment.ts":
  123428. /*!******************************************!*\
  123429. !*** ./Shaders/depthOfField.fragment.ts ***!
  123430. \******************************************/
  123431. /*! exports provided: depthOfFieldPixelShader */
  123432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123433. "use strict";
  123434. __webpack_require__.r(__webpack_exports__);
  123435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  123436. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123437. var name = 'depthOfFieldPixelShader';
  123438. 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";
  123439. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123440. /** @hidden */
  123441. var depthOfFieldPixelShader = { name: name, shader: shader };
  123442. /***/ }),
  123443. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  123444. /*!***********************************************!*\
  123445. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  123446. \***********************************************/
  123447. /*! exports provided: depthOfFieldMergePixelShader */
  123448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123449. "use strict";
  123450. __webpack_require__.r(__webpack_exports__);
  123451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  123452. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123453. var name = 'depthOfFieldMergePixelShader';
  123454. 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";
  123455. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123456. /** @hidden */
  123457. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  123458. /***/ }),
  123459. /***/ "./Shaders/displayPass.fragment.ts":
  123460. /*!*****************************************!*\
  123461. !*** ./Shaders/displayPass.fragment.ts ***!
  123462. \*****************************************/
  123463. /*! exports provided: displayPassPixelShader */
  123464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123465. "use strict";
  123466. __webpack_require__.r(__webpack_exports__);
  123467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  123468. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123469. var name = 'displayPassPixelShader';
  123470. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  123471. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123472. /** @hidden */
  123473. var displayPassPixelShader = { name: name, shader: shader };
  123474. /***/ }),
  123475. /***/ "./Shaders/extractHighlights.fragment.ts":
  123476. /*!***********************************************!*\
  123477. !*** ./Shaders/extractHighlights.fragment.ts ***!
  123478. \***********************************************/
  123479. /*! exports provided: extractHighlightsPixelShader */
  123480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123481. "use strict";
  123482. __webpack_require__.r(__webpack_exports__);
  123483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  123484. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123485. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123486. var name = 'extractHighlightsPixelShader';
  123487. 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}";
  123488. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123489. /** @hidden */
  123490. var extractHighlightsPixelShader = { name: name, shader: shader };
  123491. /***/ }),
  123492. /***/ "./Shaders/filter.fragment.ts":
  123493. /*!************************************!*\
  123494. !*** ./Shaders/filter.fragment.ts ***!
  123495. \************************************/
  123496. /*! exports provided: filterPixelShader */
  123497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123498. "use strict";
  123499. __webpack_require__.r(__webpack_exports__);
  123500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  123501. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123502. var name = 'filterPixelShader';
  123503. 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}";
  123504. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123505. /** @hidden */
  123506. var filterPixelShader = { name: name, shader: shader };
  123507. /***/ }),
  123508. /***/ "./Shaders/fxaa.fragment.ts":
  123509. /*!**********************************!*\
  123510. !*** ./Shaders/fxaa.fragment.ts ***!
  123511. \**********************************/
  123512. /*! exports provided: fxaaPixelShader */
  123513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123514. "use strict";
  123515. __webpack_require__.r(__webpack_exports__);
  123516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  123517. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123518. var name = 'fxaaPixelShader';
  123519. 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}";
  123520. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123521. /** @hidden */
  123522. var fxaaPixelShader = { name: name, shader: shader };
  123523. /***/ }),
  123524. /***/ "./Shaders/fxaa.vertex.ts":
  123525. /*!********************************!*\
  123526. !*** ./Shaders/fxaa.vertex.ts ***!
  123527. \********************************/
  123528. /*! exports provided: fxaaVertexShader */
  123529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123530. "use strict";
  123531. __webpack_require__.r(__webpack_exports__);
  123532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  123533. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123534. var name = 'fxaaVertexShader';
  123535. 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}";
  123536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123537. /** @hidden */
  123538. var fxaaVertexShader = { name: name, shader: shader };
  123539. /***/ }),
  123540. /***/ "./Shaders/geometry.fragment.ts":
  123541. /*!**************************************!*\
  123542. !*** ./Shaders/geometry.fragment.ts ***!
  123543. \**************************************/
  123544. /*! exports provided: geometryPixelShader */
  123545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123546. "use strict";
  123547. __webpack_require__.r(__webpack_exports__);
  123548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  123549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123550. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  123551. var name = 'geometryPixelShader';
  123552. var shader = "#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPosition,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=(a-b)*0.5+0.5;\nvelocity*=0.5+0.5;\nvelocity=vec2(pow(velocity.x,3.0),pow(velocity.y,3.0));\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n}";
  123553. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123554. /** @hidden */
  123555. var geometryPixelShader = { name: name, shader: shader };
  123556. /***/ }),
  123557. /***/ "./Shaders/geometry.vertex.ts":
  123558. /*!************************************!*\
  123559. !*** ./Shaders/geometry.vertex.ts ***!
  123560. \************************************/
  123561. /*! exports provided: geometryVertexShader */
  123562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123563. "use strict";
  123564. __webpack_require__.r(__webpack_exports__);
  123565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  123566. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123567. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123568. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123569. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123570. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123571. var name = 'geometryVertexShader';
  123572. var shader = "precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorldViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\n#ifdef VELOCITY\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\nvPreviousPosition=previousWorldViewProjection*vec4(position,1.0);\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";
  123573. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123574. /** @hidden */
  123575. var geometryVertexShader = { name: name, shader: shader };
  123576. /***/ }),
  123577. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  123578. /*!*************************************************!*\
  123579. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  123580. \*************************************************/
  123581. /*! exports provided: glowBlurPostProcessPixelShader */
  123582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123583. "use strict";
  123584. __webpack_require__.r(__webpack_exports__);
  123585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  123586. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123587. var name = 'glowBlurPostProcessPixelShader';
  123588. 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}";
  123589. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123590. /** @hidden */
  123591. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  123592. /***/ }),
  123593. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  123594. /*!***********************************************!*\
  123595. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  123596. \***********************************************/
  123597. /*! exports provided: glowMapGenerationPixelShader */
  123598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123599. "use strict";
  123600. __webpack_require__.r(__webpack_exports__);
  123601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  123602. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123603. var name = 'glowMapGenerationPixelShader';
  123604. var shader = "#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\nvec4 finalColor=color;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a<ALPHATESTVALUE)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive)*finalColor;\n#else\ngl_FragColor=finalColor;\n#endif\n#ifdef GLOW\ngl_FragColor.rgb*=gl_FragColor.a;\ngl_FragColor.a=1.0;\n#endif\n}";
  123605. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123606. /** @hidden */
  123607. var glowMapGenerationPixelShader = { name: name, shader: shader };
  123608. /***/ }),
  123609. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  123610. /*!*********************************************!*\
  123611. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  123612. \*********************************************/
  123613. /*! exports provided: glowMapGenerationVertexShader */
  123614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123615. "use strict";
  123616. __webpack_require__.r(__webpack_exports__);
  123617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  123618. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123619. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123620. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123621. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123622. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123623. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123624. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123625. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123626. var name = 'glowMapGenerationVertexShader';
  123627. 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}";
  123628. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123629. /** @hidden */
  123630. var glowMapGenerationVertexShader = { name: name, shader: shader };
  123631. /***/ }),
  123632. /***/ "./Shaders/glowMapMerge.fragment.ts":
  123633. /*!******************************************!*\
  123634. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  123635. \******************************************/
  123636. /*! exports provided: glowMapMergePixelShader */
  123637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123638. "use strict";
  123639. __webpack_require__.r(__webpack_exports__);
  123640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  123641. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123642. var name = 'glowMapMergePixelShader';
  123643. 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}";
  123644. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123645. /** @hidden */
  123646. var glowMapMergePixelShader = { name: name, shader: shader };
  123647. /***/ }),
  123648. /***/ "./Shaders/glowMapMerge.vertex.ts":
  123649. /*!****************************************!*\
  123650. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  123651. \****************************************/
  123652. /*! exports provided: glowMapMergeVertexShader */
  123653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123654. "use strict";
  123655. __webpack_require__.r(__webpack_exports__);
  123656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  123657. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123658. var name = 'glowMapMergeVertexShader';
  123659. 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}";
  123660. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123661. /** @hidden */
  123662. var glowMapMergeVertexShader = { name: name, shader: shader };
  123663. /***/ }),
  123664. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  123665. /*!************************************************!*\
  123666. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  123667. \************************************************/
  123668. /*! exports provided: gpuRenderParticlesPixelShader */
  123669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123670. "use strict";
  123671. __webpack_require__.r(__webpack_exports__);
  123672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  123673. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123674. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  123675. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123676. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123677. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123678. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123679. var name = 'gpuRenderParticlesPixelShader';
  123680. 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";
  123681. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123682. /** @hidden */
  123683. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  123684. /***/ }),
  123685. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  123686. /*!**********************************************!*\
  123687. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  123688. \**********************************************/
  123689. /*! exports provided: gpuRenderParticlesVertexShader */
  123690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123691. "use strict";
  123692. __webpack_require__.r(__webpack_exports__);
  123693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  123694. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123695. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  123696. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123697. var name = 'gpuRenderParticlesVertexShader';
  123698. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\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+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() {\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-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-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,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}";
  123699. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123700. /** @hidden */
  123701. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  123702. /***/ }),
  123703. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  123704. /*!************************************************!*\
  123705. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  123706. \************************************************/
  123707. /*! exports provided: gpuUpdateParticlesPixelShader */
  123708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123709. "use strict";
  123710. __webpack_require__.r(__webpack_exports__);
  123711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  123712. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123713. var name = 'gpuUpdateParticlesPixelShader';
  123714. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  123715. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123716. /** @hidden */
  123717. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  123718. /***/ }),
  123719. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  123720. /*!**********************************************!*\
  123721. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  123722. \**********************************************/
  123723. /*! exports provided: gpuUpdateParticlesVertexShader */
  123724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123725. "use strict";
  123726. __webpack_require__.r(__webpack_exports__);
  123727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  123728. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123729. var name = 'gpuUpdateParticlesVertexShader';
  123730. 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}";
  123731. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123732. /** @hidden */
  123733. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  123734. /***/ }),
  123735. /***/ "./Shaders/grain.fragment.ts":
  123736. /*!***********************************!*\
  123737. !*** ./Shaders/grain.fragment.ts ***!
  123738. \***********************************/
  123739. /*! exports provided: grainPixelShader */
  123740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123741. "use strict";
  123742. __webpack_require__.r(__webpack_exports__);
  123743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  123744. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123745. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123746. var name = 'grainPixelShader';
  123747. 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}";
  123748. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123749. /** @hidden */
  123750. var grainPixelShader = { name: name, shader: shader };
  123751. /***/ }),
  123752. /***/ "./Shaders/highlights.fragment.ts":
  123753. /*!****************************************!*\
  123754. !*** ./Shaders/highlights.fragment.ts ***!
  123755. \****************************************/
  123756. /*! exports provided: highlightsPixelShader */
  123757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123758. "use strict";
  123759. __webpack_require__.r(__webpack_exports__);
  123760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  123761. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123762. var name = 'highlightsPixelShader';
  123763. 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}";
  123764. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123765. /** @hidden */
  123766. var highlightsPixelShader = { name: name, shader: shader };
  123767. /***/ }),
  123768. /***/ "./Shaders/imageProcessing.fragment.ts":
  123769. /*!*********************************************!*\
  123770. !*** ./Shaders/imageProcessing.fragment.ts ***!
  123771. \*********************************************/
  123772. /*! exports provided: imageProcessingPixelShader */
  123773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123774. "use strict";
  123775. __webpack_require__.r(__webpack_exports__);
  123776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  123777. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123778. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123779. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123780. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123781. var name = 'imageProcessingPixelShader';
  123782. 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}";
  123783. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123784. /** @hidden */
  123785. var imageProcessingPixelShader = { name: name, shader: shader };
  123786. /***/ }),
  123787. /***/ "./Shaders/kernelBlur.fragment.ts":
  123788. /*!****************************************!*\
  123789. !*** ./Shaders/kernelBlur.fragment.ts ***!
  123790. \****************************************/
  123791. /*! exports provided: kernelBlurPixelShader */
  123792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123793. "use strict";
  123794. __webpack_require__.r(__webpack_exports__);
  123795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  123796. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123797. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  123798. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  123799. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  123800. var name = 'kernelBlurPixelShader';
  123801. 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}";
  123802. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123803. /** @hidden */
  123804. var kernelBlurPixelShader = { name: name, shader: shader };
  123805. /***/ }),
  123806. /***/ "./Shaders/kernelBlur.vertex.ts":
  123807. /*!**************************************!*\
  123808. !*** ./Shaders/kernelBlur.vertex.ts ***!
  123809. \**************************************/
  123810. /*! exports provided: kernelBlurVertexShader */
  123811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123812. "use strict";
  123813. __webpack_require__.r(__webpack_exports__);
  123814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  123815. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123816. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  123817. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  123818. var name = 'kernelBlurVertexShader';
  123819. 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}";
  123820. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123821. /** @hidden */
  123822. var kernelBlurVertexShader = { name: name, shader: shader };
  123823. /***/ }),
  123824. /***/ "./Shaders/layer.fragment.ts":
  123825. /*!***********************************!*\
  123826. !*** ./Shaders/layer.fragment.ts ***!
  123827. \***********************************/
  123828. /*! exports provided: layerPixelShader */
  123829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123830. "use strict";
  123831. __webpack_require__.r(__webpack_exports__);
  123832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  123833. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123834. var name = 'layerPixelShader';
  123835. 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}";
  123836. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123837. /** @hidden */
  123838. var layerPixelShader = { name: name, shader: shader };
  123839. /***/ }),
  123840. /***/ "./Shaders/layer.vertex.ts":
  123841. /*!*********************************!*\
  123842. !*** ./Shaders/layer.vertex.ts ***!
  123843. \*********************************/
  123844. /*! exports provided: layerVertexShader */
  123845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123846. "use strict";
  123847. __webpack_require__.r(__webpack_exports__);
  123848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  123849. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123850. var name = 'layerVertexShader';
  123851. 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}";
  123852. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123853. /** @hidden */
  123854. var layerVertexShader = { name: name, shader: shader };
  123855. /***/ }),
  123856. /***/ "./Shaders/lensFlare.fragment.ts":
  123857. /*!***************************************!*\
  123858. !*** ./Shaders/lensFlare.fragment.ts ***!
  123859. \***************************************/
  123860. /*! exports provided: lensFlarePixelShader */
  123861. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123862. "use strict";
  123863. __webpack_require__.r(__webpack_exports__);
  123864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  123865. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123866. var name = 'lensFlarePixelShader';
  123867. 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}";
  123868. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123869. /** @hidden */
  123870. var lensFlarePixelShader = { name: name, shader: shader };
  123871. /***/ }),
  123872. /***/ "./Shaders/lensFlare.vertex.ts":
  123873. /*!*************************************!*\
  123874. !*** ./Shaders/lensFlare.vertex.ts ***!
  123875. \*************************************/
  123876. /*! exports provided: lensFlareVertexShader */
  123877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123878. "use strict";
  123879. __webpack_require__.r(__webpack_exports__);
  123880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  123881. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123882. var name = 'lensFlareVertexShader';
  123883. 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}";
  123884. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123885. /** @hidden */
  123886. var lensFlareVertexShader = { name: name, shader: shader };
  123887. /***/ }),
  123888. /***/ "./Shaders/lensHighlights.fragment.ts":
  123889. /*!********************************************!*\
  123890. !*** ./Shaders/lensHighlights.fragment.ts ***!
  123891. \********************************************/
  123892. /*! exports provided: lensHighlightsPixelShader */
  123893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123894. "use strict";
  123895. __webpack_require__.r(__webpack_exports__);
  123896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  123897. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123898. var name = 'lensHighlightsPixelShader';
  123899. 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}";
  123900. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123901. /** @hidden */
  123902. var lensHighlightsPixelShader = { name: name, shader: shader };
  123903. /***/ }),
  123904. /***/ "./Shaders/line.fragment.ts":
  123905. /*!**********************************!*\
  123906. !*** ./Shaders/line.fragment.ts ***!
  123907. \**********************************/
  123908. /*! exports provided: linePixelShader */
  123909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123910. "use strict";
  123911. __webpack_require__.r(__webpack_exports__);
  123912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  123913. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123914. var name = 'linePixelShader';
  123915. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  123916. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123917. /** @hidden */
  123918. var linePixelShader = { name: name, shader: shader };
  123919. /***/ }),
  123920. /***/ "./Shaders/line.vertex.ts":
  123921. /*!********************************!*\
  123922. !*** ./Shaders/line.vertex.ts ***!
  123923. \********************************/
  123924. /*! exports provided: lineVertexShader */
  123925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123926. "use strict";
  123927. __webpack_require__.r(__webpack_exports__);
  123928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  123929. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123930. var name = 'lineVertexShader';
  123931. 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}";
  123932. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123933. /** @hidden */
  123934. var lineVertexShader = { name: name, shader: shader };
  123935. /***/ }),
  123936. /***/ "./Shaders/motionBlur.fragment.ts":
  123937. /*!****************************************!*\
  123938. !*** ./Shaders/motionBlur.fragment.ts ***!
  123939. \****************************************/
  123940. /*! exports provided: motionBlurPixelShader */
  123941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123942. "use strict";
  123943. __webpack_require__.r(__webpack_exports__);
  123944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  123945. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123946. var name = 'motionBlurPixelShader';
  123947. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D velocitySampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\nvec2 texelSize=1.0/screenSize;\nvec2 velocityColor=texture2D(velocitySampler,vUV).rg;\nvec2 velocity=vec2(pow(velocityColor.r,1.0/3.0),pow(velocityColor.g,1.0/3.0))*2.0-1.0;\nvelocity*=motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint samplesCount=int(clamp(speed,1.0,SAMPLES));\nvelocity=normalize(velocity)*texelSize;\nfloat hlim=float(-samplesCount)*0.5+0.5;\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i)\n{\nif (i>=samplesCount)\nbreak;\nvec2 offset=vUV+velocity*(hlim+float(i));\nresult+=texture2D(textureSampler,offset);\n}\ngl_FragColor=result/float(samplesCount);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
  123948. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123949. /** @hidden */
  123950. var motionBlurPixelShader = { name: name, shader: shader };
  123951. /***/ }),
  123952. /***/ "./Shaders/noise.fragment.ts":
  123953. /*!***********************************!*\
  123954. !*** ./Shaders/noise.fragment.ts ***!
  123955. \***********************************/
  123956. /*! exports provided: noisePixelShader */
  123957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123958. "use strict";
  123959. __webpack_require__.r(__webpack_exports__);
  123960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  123961. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123962. var name = 'noisePixelShader';
  123963. 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";
  123964. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123965. /** @hidden */
  123966. var noisePixelShader = { name: name, shader: shader };
  123967. /***/ }),
  123968. /***/ "./Shaders/outline.fragment.ts":
  123969. /*!*************************************!*\
  123970. !*** ./Shaders/outline.fragment.ts ***!
  123971. \*************************************/
  123972. /*! exports provided: outlinePixelShader */
  123973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123974. "use strict";
  123975. __webpack_require__.r(__webpack_exports__);
  123976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  123977. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123978. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123979. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123980. var name = 'outlinePixelShader';
  123981. 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}";
  123982. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123983. /** @hidden */
  123984. var outlinePixelShader = { name: name, shader: shader };
  123985. /***/ }),
  123986. /***/ "./Shaders/outline.vertex.ts":
  123987. /*!***********************************!*\
  123988. !*** ./Shaders/outline.vertex.ts ***!
  123989. \***********************************/
  123990. /*! exports provided: outlineVertexShader */
  123991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123992. "use strict";
  123993. __webpack_require__.r(__webpack_exports__);
  123994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  123995. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123996. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123997. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123998. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123999. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124000. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124001. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124002. var name = 'outlineVertexShader';
  124003. 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";
  124004. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124005. /** @hidden */
  124006. var outlineVertexShader = { name: name, shader: shader };
  124007. /***/ }),
  124008. /***/ "./Shaders/particles.fragment.ts":
  124009. /*!***************************************!*\
  124010. !*** ./Shaders/particles.fragment.ts ***!
  124011. \***************************************/
  124012. /*! exports provided: particlesPixelShader */
  124013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124014. "use strict";
  124015. __webpack_require__.r(__webpack_exports__);
  124016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  124017. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124018. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124019. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124020. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124021. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124022. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124023. var name = 'particlesPixelShader';
  124024. 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}";
  124025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124026. /** @hidden */
  124027. var particlesPixelShader = { name: name, shader: shader };
  124028. /***/ }),
  124029. /***/ "./Shaders/particles.vertex.ts":
  124030. /*!*************************************!*\
  124031. !*** ./Shaders/particles.vertex.ts ***!
  124032. \*************************************/
  124033. /*! exports provided: particlesVertexShader */
  124034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124035. "use strict";
  124036. __webpack_require__.r(__webpack_exports__);
  124037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  124038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124039. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124040. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124041. var name = 'particlesVertexShader';
  124042. 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}";
  124043. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124044. /** @hidden */
  124045. var particlesVertexShader = { name: name, shader: shader };
  124046. /***/ }),
  124047. /***/ "./Shaders/pass.fragment.ts":
  124048. /*!**********************************!*\
  124049. !*** ./Shaders/pass.fragment.ts ***!
  124050. \**********************************/
  124051. /*! exports provided: passPixelShader */
  124052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124053. "use strict";
  124054. __webpack_require__.r(__webpack_exports__);
  124055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  124056. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124057. var name = 'passPixelShader';
  124058. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  124059. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124060. /** @hidden */
  124061. var passPixelShader = { name: name, shader: shader };
  124062. /***/ }),
  124063. /***/ "./Shaders/passCube.fragment.ts":
  124064. /*!**************************************!*\
  124065. !*** ./Shaders/passCube.fragment.ts ***!
  124066. \**************************************/
  124067. /*! exports provided: passCubePixelShader */
  124068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124069. "use strict";
  124070. __webpack_require__.r(__webpack_exports__);
  124071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  124072. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124073. var name = 'passCubePixelShader';
  124074. 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}";
  124075. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124076. /** @hidden */
  124077. var passCubePixelShader = { name: name, shader: shader };
  124078. /***/ }),
  124079. /***/ "./Shaders/pbr.fragment.ts":
  124080. /*!*********************************!*\
  124081. !*** ./Shaders/pbr.fragment.ts ***!
  124082. \*********************************/
  124083. /*! exports provided: pbrPixelShader */
  124084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124085. "use strict";
  124086. __webpack_require__.r(__webpack_exports__);
  124087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  124088. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124089. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  124090. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124091. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124092. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124093. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124094. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124095. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124096. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124097. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124098. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  124099. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124100. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  124101. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  124102. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124103. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124104. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124105. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124106. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  124107. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  124108. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124109. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124110. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124111. var name = 'pbrPixelShader';
  124112. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\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#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#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\n#ifdef REFRACTION\n#ifdef 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\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#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\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#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\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\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(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\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#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\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=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),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\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef 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 LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef 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=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\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 RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef 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.);\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#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\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=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\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\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\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\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=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\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.;\nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\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=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\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#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\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(\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 REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef 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\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\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n";
  124113. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124114. /** @hidden */
  124115. var pbrPixelShader = { name: name, shader: shader };
  124116. /***/ }),
  124117. /***/ "./Shaders/pbr.vertex.ts":
  124118. /*!*******************************!*\
  124119. !*** ./Shaders/pbr.vertex.ts ***!
  124120. \*******************************/
  124121. /*! exports provided: pbrVertexShader */
  124122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124123. "use strict";
  124124. __webpack_require__.r(__webpack_exports__);
  124125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  124126. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124127. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  124128. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124129. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124130. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124131. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124132. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124133. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  124134. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124135. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124136. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124137. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124138. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124139. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124140. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124141. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124142. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124143. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124144. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  124145. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124146. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124147. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124148. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124149. var name = 'pbrVertexShader';
  124150. var shader = "precision highp float;\n#include<__decl__pbrVertex>\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\nvarying vec3 vPositionW;\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>\nvoid main(void) {\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#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\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}";
  124151. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124152. /** @hidden */
  124153. var pbrVertexShader = { name: name, shader: shader };
  124154. /***/ }),
  124155. /***/ "./Shaders/postprocess.vertex.ts":
  124156. /*!***************************************!*\
  124157. !*** ./Shaders/postprocess.vertex.ts ***!
  124158. \***************************************/
  124159. /*! exports provided: postprocessVertexShader */
  124160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124161. "use strict";
  124162. __webpack_require__.r(__webpack_exports__);
  124163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  124164. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124165. var name = 'postprocessVertexShader';
  124166. 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}";
  124167. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124168. /** @hidden */
  124169. var postprocessVertexShader = { name: name, shader: shader };
  124170. /***/ }),
  124171. /***/ "./Shaders/procedural.vertex.ts":
  124172. /*!**************************************!*\
  124173. !*** ./Shaders/procedural.vertex.ts ***!
  124174. \**************************************/
  124175. /*! exports provided: proceduralVertexShader */
  124176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124177. "use strict";
  124178. __webpack_require__.r(__webpack_exports__);
  124179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  124180. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124181. var name = 'proceduralVertexShader';
  124182. 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}";
  124183. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124184. /** @hidden */
  124185. var proceduralVertexShader = { name: name, shader: shader };
  124186. /***/ }),
  124187. /***/ "./Shaders/refraction.fragment.ts":
  124188. /*!****************************************!*\
  124189. !*** ./Shaders/refraction.fragment.ts ***!
  124190. \****************************************/
  124191. /*! exports provided: refractionPixelShader */
  124192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124193. "use strict";
  124194. __webpack_require__.r(__webpack_exports__);
  124195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  124196. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124197. var name = 'refractionPixelShader';
  124198. 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}";
  124199. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124200. /** @hidden */
  124201. var refractionPixelShader = { name: name, shader: shader };
  124202. /***/ }),
  124203. /***/ "./Shaders/rgbdDecode.fragment.ts":
  124204. /*!****************************************!*\
  124205. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  124206. \****************************************/
  124207. /*! exports provided: rgbdDecodePixelShader */
  124208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124209. "use strict";
  124210. __webpack_require__.r(__webpack_exports__);
  124211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  124212. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124213. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124214. var name = 'rgbdDecodePixelShader';
  124215. 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}";
  124216. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124217. /** @hidden */
  124218. var rgbdDecodePixelShader = { name: name, shader: shader };
  124219. /***/ }),
  124220. /***/ "./Shaders/rgbdEncode.fragment.ts":
  124221. /*!****************************************!*\
  124222. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  124223. \****************************************/
  124224. /*! exports provided: rgbdEncodePixelShader */
  124225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124226. "use strict";
  124227. __webpack_require__.r(__webpack_exports__);
  124228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  124229. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124230. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124231. var name = 'rgbdEncodePixelShader';
  124232. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  124233. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124234. /** @hidden */
  124235. var rgbdEncodePixelShader = { name: name, shader: shader };
  124236. /***/ }),
  124237. /***/ "./Shaders/shadowMap.fragment.ts":
  124238. /*!***************************************!*\
  124239. !*** ./Shaders/shadowMap.fragment.ts ***!
  124240. \***************************************/
  124241. /*! exports provided: shadowMapPixelShader */
  124242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124243. "use strict";
  124244. __webpack_require__.r(__webpack_exports__);
  124245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  124246. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124247. var name = 'shadowMapPixelShader';
  124248. 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}";
  124249. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124250. /** @hidden */
  124251. var shadowMapPixelShader = { name: name, shader: shader };
  124252. /***/ }),
  124253. /***/ "./Shaders/shadowMap.vertex.ts":
  124254. /*!*************************************!*\
  124255. !*** ./Shaders/shadowMap.vertex.ts ***!
  124256. \*************************************/
  124257. /*! exports provided: shadowMapVertexShader */
  124258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124259. "use strict";
  124260. __webpack_require__.r(__webpack_exports__);
  124261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  124262. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124263. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124264. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124265. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124266. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124267. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124268. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124269. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124270. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124271. var name = 'shadowMapVertexShader';
  124272. 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}";
  124273. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124274. /** @hidden */
  124275. var shadowMapVertexShader = { name: name, shader: shader };
  124276. /***/ }),
  124277. /***/ "./Shaders/sharpen.fragment.ts":
  124278. /*!*************************************!*\
  124279. !*** ./Shaders/sharpen.fragment.ts ***!
  124280. \*************************************/
  124281. /*! exports provided: sharpenPixelShader */
  124282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124283. "use strict";
  124284. __webpack_require__.r(__webpack_exports__);
  124285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  124286. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124287. var name = 'sharpenPixelShader';
  124288. 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}";
  124289. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124290. /** @hidden */
  124291. var sharpenPixelShader = { name: name, shader: shader };
  124292. /***/ }),
  124293. /***/ "./Shaders/sprites.fragment.ts":
  124294. /*!*************************************!*\
  124295. !*** ./Shaders/sprites.fragment.ts ***!
  124296. \*************************************/
  124297. /*! exports provided: spritesPixelShader */
  124298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124299. "use strict";
  124300. __webpack_require__.r(__webpack_exports__);
  124301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  124302. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124303. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124304. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124305. var name = 'spritesPixelShader';
  124306. 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}";
  124307. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124308. /** @hidden */
  124309. var spritesPixelShader = { name: name, shader: shader };
  124310. /***/ }),
  124311. /***/ "./Shaders/sprites.vertex.ts":
  124312. /*!***********************************!*\
  124313. !*** ./Shaders/sprites.vertex.ts ***!
  124314. \***********************************/
  124315. /*! exports provided: spritesVertexShader */
  124316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124317. "use strict";
  124318. __webpack_require__.r(__webpack_exports__);
  124319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  124320. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124321. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124322. var name = 'spritesVertexShader';
  124323. 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}";
  124324. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124325. /** @hidden */
  124326. var spritesVertexShader = { name: name, shader: shader };
  124327. /***/ }),
  124328. /***/ "./Shaders/ssao.fragment.ts":
  124329. /*!**********************************!*\
  124330. !*** ./Shaders/ssao.fragment.ts ***!
  124331. \**********************************/
  124332. /*! exports provided: ssaoPixelShader */
  124333. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124334. "use strict";
  124335. __webpack_require__.r(__webpack_exports__);
  124336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  124337. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124338. var name = 'ssaoPixelShader';
  124339. 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";
  124340. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124341. /** @hidden */
  124342. var ssaoPixelShader = { name: name, shader: shader };
  124343. /***/ }),
  124344. /***/ "./Shaders/ssao2.fragment.ts":
  124345. /*!***********************************!*\
  124346. !*** ./Shaders/ssao2.fragment.ts ***!
  124347. \***********************************/
  124348. /*! exports provided: ssao2PixelShader */
  124349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124350. "use strict";
  124351. __webpack_require__.r(__webpack_exports__);
  124352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  124353. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124354. var name = 'ssao2PixelShader';
  124355. 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";
  124356. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124357. /** @hidden */
  124358. var ssao2PixelShader = { name: name, shader: shader };
  124359. /***/ }),
  124360. /***/ "./Shaders/ssaoCombine.fragment.ts":
  124361. /*!*****************************************!*\
  124362. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  124363. \*****************************************/
  124364. /*! exports provided: ssaoCombinePixelShader */
  124365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124366. "use strict";
  124367. __webpack_require__.r(__webpack_exports__);
  124368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  124369. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124370. var name = 'ssaoCombinePixelShader';
  124371. 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";
  124372. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124373. /** @hidden */
  124374. var ssaoCombinePixelShader = { name: name, shader: shader };
  124375. /***/ }),
  124376. /***/ "./Shaders/standard.fragment.ts":
  124377. /*!**************************************!*\
  124378. !*** ./Shaders/standard.fragment.ts ***!
  124379. \**************************************/
  124380. /*! exports provided: standardPixelShader */
  124381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124382. "use strict";
  124383. __webpack_require__.r(__webpack_exports__);
  124384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  124385. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124386. var name = 'standardPixelShader';
  124387. 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);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\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";
  124388. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124389. /** @hidden */
  124390. var standardPixelShader = { name: name, shader: shader };
  124391. /***/ }),
  124392. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  124393. /*!***************************************************!*\
  124394. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  124395. \***************************************************/
  124396. /*! exports provided: stereoscopicInterlacePixelShader */
  124397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124398. "use strict";
  124399. __webpack_require__.r(__webpack_exports__);
  124400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  124401. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124402. var name = 'stereoscopicInterlacePixelShader';
  124403. 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}";
  124404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124405. /** @hidden */
  124406. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  124407. /***/ }),
  124408. /***/ "./Shaders/tonemap.fragment.ts":
  124409. /*!*************************************!*\
  124410. !*** ./Shaders/tonemap.fragment.ts ***!
  124411. \*************************************/
  124412. /*! exports provided: tonemapPixelShader */
  124413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124414. "use strict";
  124415. __webpack_require__.r(__webpack_exports__);
  124416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  124417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124418. var name = 'tonemapPixelShader';
  124419. 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}";
  124420. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124421. /** @hidden */
  124422. var tonemapPixelShader = { name: name, shader: shader };
  124423. /***/ }),
  124424. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  124425. /*!*******************************************************!*\
  124426. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  124427. \*******************************************************/
  124428. /*! exports provided: volumetricLightScatteringPixelShader */
  124429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124430. "use strict";
  124431. __webpack_require__.r(__webpack_exports__);
  124432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  124433. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124434. var name = 'volumetricLightScatteringPixelShader';
  124435. 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";
  124436. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124437. /** @hidden */
  124438. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  124439. /***/ }),
  124440. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  124441. /*!***********************************************************!*\
  124442. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  124443. \***********************************************************/
  124444. /*! exports provided: volumetricLightScatteringPassPixelShader */
  124445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124446. "use strict";
  124447. __webpack_require__.r(__webpack_exports__);
  124448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  124449. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124450. var name = 'volumetricLightScatteringPassPixelShader';
  124451. 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";
  124452. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124453. /** @hidden */
  124454. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  124455. /***/ }),
  124456. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  124457. /*!****************************************************!*\
  124458. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  124459. \****************************************************/
  124460. /*! exports provided: vrDistortionCorrectionPixelShader */
  124461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124462. "use strict";
  124463. __webpack_require__.r(__webpack_exports__);
  124464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  124465. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124466. var name = 'vrDistortionCorrectionPixelShader';
  124467. 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}";
  124468. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124469. /** @hidden */
  124470. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  124471. /***/ }),
  124472. /***/ "./Sprites/index.ts":
  124473. /*!**************************!*\
  124474. !*** ./Sprites/index.ts ***!
  124475. \**************************/
  124476. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  124477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124478. "use strict";
  124479. __webpack_require__.r(__webpack_exports__);
  124480. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  124481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  124482. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  124483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  124484. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  124486. /***/ }),
  124487. /***/ "./Sprites/sprite.ts":
  124488. /*!***************************!*\
  124489. !*** ./Sprites/sprite.ts ***!
  124490. \***************************/
  124491. /*! exports provided: Sprite */
  124492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124493. "use strict";
  124494. __webpack_require__.r(__webpack_exports__);
  124495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  124496. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124497. /**
  124498. * Class used to represent a sprite
  124499. * @see http://doc.babylonjs.com/babylon101/sprites
  124500. */
  124501. var Sprite = /** @class */ (function () {
  124502. /**
  124503. * Creates a new Sprite
  124504. * @param name defines the name
  124505. * @param manager defines the manager
  124506. */
  124507. function Sprite(
  124508. /** defines the name */
  124509. name, manager) {
  124510. this.name = name;
  124511. /** Gets or sets the main color */
  124512. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  124513. /** Gets or sets the width */
  124514. this.width = 1.0;
  124515. /** Gets or sets the height */
  124516. this.height = 1.0;
  124517. /** Gets or sets rotation angle */
  124518. this.angle = 0;
  124519. /** Gets or sets the cell index in the sprite sheet */
  124520. this.cellIndex = 0;
  124521. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  124522. this.invertU = 0;
  124523. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  124524. this.invertV = 0;
  124525. /** Gets the list of attached animations */
  124526. this.animations = new Array();
  124527. /** Gets or sets a boolean indicating if the sprite can be picked */
  124528. this.isPickable = false;
  124529. this._animationStarted = false;
  124530. this._loopAnimation = false;
  124531. this._fromIndex = 0;
  124532. this._toIndex = 0;
  124533. this._delay = 0;
  124534. this._direction = 1;
  124535. this._time = 0;
  124536. /**
  124537. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  124538. */
  124539. this.isVisible = true;
  124540. this._manager = manager;
  124541. this._manager.sprites.push(this);
  124542. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  124543. }
  124544. Object.defineProperty(Sprite.prototype, "size", {
  124545. /**
  124546. * Gets or sets the sprite size
  124547. */
  124548. get: function () {
  124549. return this.width;
  124550. },
  124551. set: function (value) {
  124552. this.width = value;
  124553. this.height = value;
  124554. },
  124555. enumerable: true,
  124556. configurable: true
  124557. });
  124558. /**
  124559. * Starts an animation
  124560. * @param from defines the initial key
  124561. * @param to defines the end key
  124562. * @param loop defines if the animation must loop
  124563. * @param delay defines the start delay (in ms)
  124564. * @param onAnimationEnd defines a callback to call when animation ends
  124565. */
  124566. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  124567. this._fromIndex = from;
  124568. this._toIndex = to;
  124569. this._loopAnimation = loop;
  124570. this._delay = delay;
  124571. this._animationStarted = true;
  124572. this._direction = from < to ? 1 : -1;
  124573. this.cellIndex = from;
  124574. this._time = 0;
  124575. this._onAnimationEnd = onAnimationEnd;
  124576. };
  124577. /** Stops current animation (if any) */
  124578. Sprite.prototype.stopAnimation = function () {
  124579. this._animationStarted = false;
  124580. };
  124581. /** @hidden */
  124582. Sprite.prototype._animate = function (deltaTime) {
  124583. if (!this._animationStarted) {
  124584. return;
  124585. }
  124586. this._time += deltaTime;
  124587. if (this._time > this._delay) {
  124588. this._time = this._time % this._delay;
  124589. this.cellIndex += this._direction;
  124590. if (this.cellIndex > this._toIndex) {
  124591. if (this._loopAnimation) {
  124592. this.cellIndex = this._fromIndex;
  124593. }
  124594. else {
  124595. this.cellIndex = this._toIndex;
  124596. this._animationStarted = false;
  124597. if (this._onAnimationEnd) {
  124598. this._onAnimationEnd();
  124599. }
  124600. if (this.disposeWhenFinishedAnimating) {
  124601. this.dispose();
  124602. }
  124603. }
  124604. }
  124605. }
  124606. };
  124607. /** Release associated resources */
  124608. Sprite.prototype.dispose = function () {
  124609. for (var i = 0; i < this._manager.sprites.length; i++) {
  124610. if (this._manager.sprites[i] == this) {
  124611. this._manager.sprites.splice(i, 1);
  124612. }
  124613. }
  124614. };
  124615. return Sprite;
  124616. }());
  124617. /***/ }),
  124618. /***/ "./Sprites/spriteManager.ts":
  124619. /*!**********************************!*\
  124620. !*** ./Sprites/spriteManager.ts ***!
  124621. \**********************************/
  124622. /*! exports provided: SpriteManager */
  124623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124624. "use strict";
  124625. __webpack_require__.r(__webpack_exports__);
  124626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  124627. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124628. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124629. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124630. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124631. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124632. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  124633. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  124634. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124635. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124636. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124637. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  124638. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  124639. /**
  124640. * Class used to manage multiple sprites on the same spritesheet
  124641. * @see http://doc.babylonjs.com/babylon101/sprites
  124642. */
  124643. var SpriteManager = /** @class */ (function () {
  124644. /**
  124645. * Creates a new sprite manager
  124646. * @param name defines the manager's name
  124647. * @param imgUrl defines the sprite sheet url
  124648. * @param capacity defines the maximum allowed number of sprites
  124649. * @param cellSize defines the size of a sprite cell
  124650. * @param scene defines the hosting scene
  124651. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124652. * @param samplingMode defines the smapling mode to use with spritesheet
  124653. */
  124654. function SpriteManager(
  124655. /** defines the manager's name */
  124656. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  124657. if (epsilon === void 0) { epsilon = 0.01; }
  124658. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  124659. this.name = name;
  124660. /** Gets the list of sprites */
  124661. this.sprites = new Array();
  124662. /** Gets or sets the rendering group id (0 by default) */
  124663. this.renderingGroupId = 0;
  124664. /** Gets or sets camera layer mask */
  124665. this.layerMask = 0x0FFFFFFF;
  124666. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  124667. this.fogEnabled = true;
  124668. /** Gets or sets a boolean indicating if the sprites are pickable */
  124669. this.isPickable = false;
  124670. /**
  124671. * An event triggered when the manager is disposed.
  124672. */
  124673. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  124674. this._vertexBuffers = {};
  124675. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  124676. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  124677. }
  124678. this._capacity = capacity;
  124679. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  124680. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  124681. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  124682. if (cellSize.width && cellSize.height) {
  124683. this.cellWidth = cellSize.width;
  124684. this.cellHeight = cellSize.height;
  124685. }
  124686. else if (cellSize !== undefined) {
  124687. this.cellWidth = cellSize;
  124688. this.cellHeight = cellSize;
  124689. }
  124690. else {
  124691. return;
  124692. }
  124693. this._epsilon = epsilon;
  124694. this._scene = scene;
  124695. this._scene.spriteManagers.push(this);
  124696. var indices = [];
  124697. var index = 0;
  124698. for (var count = 0; count < capacity; count++) {
  124699. indices.push(index);
  124700. indices.push(index + 1);
  124701. indices.push(index + 2);
  124702. indices.push(index);
  124703. indices.push(index + 2);
  124704. indices.push(index + 3);
  124705. index += 4;
  124706. }
  124707. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  124708. // VBO
  124709. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  124710. this._vertexData = new Float32Array(capacity * 16 * 4);
  124711. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  124712. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  124713. var options = this._buffer.createVertexBuffer("options", 4, 4);
  124714. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  124715. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  124716. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  124717. this._vertexBuffers["options"] = options;
  124718. this._vertexBuffers["cellInfo"] = cellInfo;
  124719. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  124720. // Effects
  124721. 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"], "");
  124722. 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");
  124723. }
  124724. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  124725. /**
  124726. * Callback called when the manager is disposed
  124727. */
  124728. set: function (callback) {
  124729. if (this._onDisposeObserver) {
  124730. this.onDisposeObservable.remove(this._onDisposeObserver);
  124731. }
  124732. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  124733. },
  124734. enumerable: true,
  124735. configurable: true
  124736. });
  124737. Object.defineProperty(SpriteManager.prototype, "texture", {
  124738. /**
  124739. * Gets or sets the spritesheet texture
  124740. */
  124741. get: function () {
  124742. return this._spriteTexture;
  124743. },
  124744. set: function (value) {
  124745. this._spriteTexture = value;
  124746. },
  124747. enumerable: true,
  124748. configurable: true
  124749. });
  124750. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  124751. var arrayOffset = index * 16;
  124752. if (offsetX === 0) {
  124753. offsetX = this._epsilon;
  124754. }
  124755. else if (offsetX === 1) {
  124756. offsetX = 1 - this._epsilon;
  124757. }
  124758. if (offsetY === 0) {
  124759. offsetY = this._epsilon;
  124760. }
  124761. else if (offsetY === 1) {
  124762. offsetY = 1 - this._epsilon;
  124763. }
  124764. this._vertexData[arrayOffset] = sprite.position.x;
  124765. this._vertexData[arrayOffset + 1] = sprite.position.y;
  124766. this._vertexData[arrayOffset + 2] = sprite.position.z;
  124767. this._vertexData[arrayOffset + 3] = sprite.angle;
  124768. this._vertexData[arrayOffset + 4] = sprite.width;
  124769. this._vertexData[arrayOffset + 5] = sprite.height;
  124770. this._vertexData[arrayOffset + 6] = offsetX;
  124771. this._vertexData[arrayOffset + 7] = offsetY;
  124772. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  124773. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  124774. var offset = (sprite.cellIndex / rowSize) >> 0;
  124775. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  124776. this._vertexData[arrayOffset + 11] = offset;
  124777. // Color
  124778. this._vertexData[arrayOffset + 12] = sprite.color.r;
  124779. this._vertexData[arrayOffset + 13] = sprite.color.g;
  124780. this._vertexData[arrayOffset + 14] = sprite.color.b;
  124781. this._vertexData[arrayOffset + 15] = sprite.color.a;
  124782. };
  124783. /**
  124784. * Intersects the sprites with a ray
  124785. * @param ray defines the ray to intersect with
  124786. * @param camera defines the current active camera
  124787. * @param predicate defines a predicate used to select candidate sprites
  124788. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  124789. * @returns null if no hit or a PickingInfo
  124790. */
  124791. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  124792. var count = Math.min(this._capacity, this.sprites.length);
  124793. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124794. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124795. var distance = Number.MAX_VALUE;
  124796. var currentSprite = null;
  124797. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124798. var cameraView = camera.getViewMatrix();
  124799. for (var index = 0; index < count; index++) {
  124800. var sprite = this.sprites[index];
  124801. if (!sprite) {
  124802. continue;
  124803. }
  124804. if (predicate) {
  124805. if (!predicate(sprite)) {
  124806. continue;
  124807. }
  124808. }
  124809. else if (!sprite.isPickable) {
  124810. continue;
  124811. }
  124812. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  124813. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  124814. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  124815. if (ray.intersectsBoxMinMax(min, max)) {
  124816. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  124817. if (distance > currentDistance) {
  124818. distance = currentDistance;
  124819. currentSprite = sprite;
  124820. if (fastCheck) {
  124821. break;
  124822. }
  124823. }
  124824. }
  124825. }
  124826. if (currentSprite) {
  124827. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  124828. result.hit = true;
  124829. result.pickedSprite = currentSprite;
  124830. result.distance = distance;
  124831. return result;
  124832. }
  124833. return null;
  124834. };
  124835. /**
  124836. * Render all child sprites
  124837. */
  124838. SpriteManager.prototype.render = function () {
  124839. // Check
  124840. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  124841. || !this._spriteTexture.isReady() || !this.sprites.length) {
  124842. return;
  124843. }
  124844. var engine = this._scene.getEngine();
  124845. var baseSize = this._spriteTexture.getBaseSize();
  124846. // Sprites
  124847. var deltaTime = engine.getDeltaTime();
  124848. var max = Math.min(this._capacity, this.sprites.length);
  124849. var rowSize = baseSize.width / this.cellWidth;
  124850. var offset = 0;
  124851. for (var index = 0; index < max; index++) {
  124852. var sprite = this.sprites[index];
  124853. if (!sprite || !sprite.isVisible) {
  124854. continue;
  124855. }
  124856. sprite._animate(deltaTime);
  124857. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  124858. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  124859. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  124860. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  124861. }
  124862. this._buffer.update(this._vertexData);
  124863. // Render
  124864. var effect = this._effectBase;
  124865. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  124866. effect = this._effectFog;
  124867. }
  124868. engine.enableEffect(effect);
  124869. var viewMatrix = this._scene.getViewMatrix();
  124870. effect.setTexture("diffuseSampler", this._spriteTexture);
  124871. effect.setMatrix("view", viewMatrix);
  124872. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  124873. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  124874. // Fog
  124875. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  124876. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  124877. effect.setColor3("vFogColor", this._scene.fogColor);
  124878. }
  124879. // VBOs
  124880. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  124881. // Draw order
  124882. engine.setDepthFunctionToLessOrEqual();
  124883. effect.setBool("alphaTest", true);
  124884. engine.setColorWrite(false);
  124885. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  124886. engine.setColorWrite(true);
  124887. effect.setBool("alphaTest", false);
  124888. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  124889. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  124890. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  124891. };
  124892. /**
  124893. * Release associated resources
  124894. */
  124895. SpriteManager.prototype.dispose = function () {
  124896. if (this._buffer) {
  124897. this._buffer.dispose();
  124898. this._buffer = null;
  124899. }
  124900. if (this._indexBuffer) {
  124901. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  124902. this._indexBuffer = null;
  124903. }
  124904. if (this._spriteTexture) {
  124905. this._spriteTexture.dispose();
  124906. this._spriteTexture = null;
  124907. }
  124908. // Remove from scene
  124909. var index = this._scene.spriteManagers.indexOf(this);
  124910. this._scene.spriteManagers.splice(index, 1);
  124911. // Callback
  124912. this.onDisposeObservable.notifyObservers(this);
  124913. this.onDisposeObservable.clear();
  124914. };
  124915. return SpriteManager;
  124916. }());
  124917. /***/ }),
  124918. /***/ "./Sprites/spriteSceneComponent.ts":
  124919. /*!*****************************************!*\
  124920. !*** ./Sprites/spriteSceneComponent.ts ***!
  124921. \*****************************************/
  124922. /*! exports provided: SpriteSceneComponent */
  124923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124924. "use strict";
  124925. __webpack_require__.r(__webpack_exports__);
  124926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  124927. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124928. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124929. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  124930. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  124931. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124932. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  124933. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124934. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  124935. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  124936. return null;
  124937. }
  124938. var pickingInfo = null;
  124939. if (!camera) {
  124940. if (!this.activeCamera) {
  124941. return null;
  124942. }
  124943. camera = this.activeCamera;
  124944. }
  124945. if (this.spriteManagers.length > 0) {
  124946. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  124947. var spriteManager = this.spriteManagers[spriteIndex];
  124948. if (!spriteManager.isPickable) {
  124949. continue;
  124950. }
  124951. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  124952. if (!result || !result.hit) {
  124953. continue;
  124954. }
  124955. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  124956. continue;
  124957. }
  124958. pickingInfo = result;
  124959. if (fastCheck) {
  124960. break;
  124961. }
  124962. }
  124963. }
  124964. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  124965. };
  124966. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  124967. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  124968. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124969. };
  124970. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  124971. if (!this._tempSpritePickingRay) {
  124972. return null;
  124973. }
  124974. if (!camera) {
  124975. if (!this.activeCamera) {
  124976. return null;
  124977. }
  124978. camera = this.activeCamera;
  124979. }
  124980. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  124981. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124982. };
  124983. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  124984. if (this._pointerOverSprite === sprite) {
  124985. return;
  124986. }
  124987. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124988. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124989. }
  124990. this._pointerOverSprite = sprite;
  124991. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124992. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124993. }
  124994. };
  124995. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  124996. return this._pointerOverSprite;
  124997. };
  124998. /**
  124999. * Defines the sprite scene component responsible to manage sprites
  125000. * in a given scene.
  125001. */
  125002. var SpriteSceneComponent = /** @class */ (function () {
  125003. /**
  125004. * Creates a new instance of the component for the given scene
  125005. * @param scene Defines the scene to register the component in
  125006. */
  125007. function SpriteSceneComponent(scene) {
  125008. /**
  125009. * The component name helpfull to identify the component in the list of scene components.
  125010. */
  125011. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  125012. this.scene = scene;
  125013. this.scene.spriteManagers = new Array();
  125014. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  125015. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125016. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125017. this._spritePredicate = function (sprite) {
  125018. if (!sprite.actionManager) {
  125019. return false;
  125020. }
  125021. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  125022. };
  125023. }
  125024. /**
  125025. * Registers the component in a given scene
  125026. */
  125027. SpriteSceneComponent.prototype.register = function () {
  125028. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  125029. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  125030. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  125031. };
  125032. /**
  125033. * Rebuilds the elements related to this component in case of
  125034. * context lost for instance.
  125035. */
  125036. SpriteSceneComponent.prototype.rebuild = function () {
  125037. /** Nothing to do for sprites */
  125038. };
  125039. /**
  125040. * Disposes the component and the associated ressources.
  125041. */
  125042. SpriteSceneComponent.prototype.dispose = function () {
  125043. this.scene.onBeforeSpritesRenderingObservable.clear();
  125044. this.scene.onAfterSpritesRenderingObservable.clear();
  125045. var spriteManagers = this.scene.spriteManagers;
  125046. while (spriteManagers.length) {
  125047. spriteManagers[0].dispose();
  125048. }
  125049. };
  125050. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  125051. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  125052. if (result) {
  125053. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  125054. }
  125055. return result;
  125056. };
  125057. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  125058. var scene = this.scene;
  125059. if (isMeshPicked) {
  125060. scene.setPointerOverSprite(null);
  125061. }
  125062. else {
  125063. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  125064. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125065. scene.setPointerOverSprite(pickResult.pickedSprite);
  125066. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  125067. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  125068. }
  125069. else {
  125070. canvas.style.cursor = scene.hoverCursor;
  125071. }
  125072. }
  125073. else {
  125074. scene.setPointerOverSprite(null);
  125075. }
  125076. }
  125077. return pickResult;
  125078. };
  125079. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125080. var scene = this.scene;
  125081. scene._pickedDownSprite = null;
  125082. if (scene.spriteManagers.length > 0) {
  125083. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125084. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125085. if (pickResult.pickedSprite.actionManager) {
  125086. scene._pickedDownSprite = pickResult.pickedSprite;
  125087. switch (evt.button) {
  125088. case 0:
  125089. 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));
  125090. break;
  125091. case 1:
  125092. 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));
  125093. break;
  125094. case 2:
  125095. 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));
  125096. break;
  125097. }
  125098. if (pickResult.pickedSprite.actionManager) {
  125099. 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));
  125100. }
  125101. }
  125102. }
  125103. }
  125104. return pickResult;
  125105. };
  125106. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125107. var scene = this.scene;
  125108. if (scene.spriteManagers.length > 0) {
  125109. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125110. if (spritePickResult) {
  125111. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  125112. if (spritePickResult.pickedSprite.actionManager) {
  125113. 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));
  125114. if (spritePickResult.pickedSprite.actionManager) {
  125115. if (!this.scene._isPointerSwiping()) {
  125116. 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));
  125117. }
  125118. }
  125119. }
  125120. }
  125121. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  125122. 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));
  125123. }
  125124. }
  125125. }
  125126. return pickResult;
  125127. };
  125128. return SpriteSceneComponent;
  125129. }());
  125130. /***/ }),
  125131. /***/ "./States/alphaCullingState.ts":
  125132. /*!*************************************!*\
  125133. !*** ./States/alphaCullingState.ts ***!
  125134. \*************************************/
  125135. /*! exports provided: _AlphaState */
  125136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125137. "use strict";
  125138. __webpack_require__.r(__webpack_exports__);
  125139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  125140. /**
  125141. * @hidden
  125142. **/
  125143. var _AlphaState = /** @class */ (function () {
  125144. /**
  125145. * Initializes the state.
  125146. */
  125147. function _AlphaState() {
  125148. this._isAlphaBlendDirty = false;
  125149. this._isBlendFunctionParametersDirty = false;
  125150. this._isBlendEquationParametersDirty = false;
  125151. this._isBlendConstantsDirty = false;
  125152. this._alphaBlend = false;
  125153. this._blendFunctionParameters = new Array(4);
  125154. this._blendEquationParameters = new Array(2);
  125155. this._blendConstants = new Array(4);
  125156. this.reset();
  125157. }
  125158. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  125159. get: function () {
  125160. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  125161. },
  125162. enumerable: true,
  125163. configurable: true
  125164. });
  125165. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  125166. get: function () {
  125167. return this._alphaBlend;
  125168. },
  125169. set: function (value) {
  125170. if (this._alphaBlend === value) {
  125171. return;
  125172. }
  125173. this._alphaBlend = value;
  125174. this._isAlphaBlendDirty = true;
  125175. },
  125176. enumerable: true,
  125177. configurable: true
  125178. });
  125179. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  125180. if (this._blendConstants[0] === r &&
  125181. this._blendConstants[1] === g &&
  125182. this._blendConstants[2] === b &&
  125183. this._blendConstants[3] === a) {
  125184. return;
  125185. }
  125186. this._blendConstants[0] = r;
  125187. this._blendConstants[1] = g;
  125188. this._blendConstants[2] = b;
  125189. this._blendConstants[3] = a;
  125190. this._isBlendConstantsDirty = true;
  125191. };
  125192. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  125193. if (this._blendFunctionParameters[0] === value0 &&
  125194. this._blendFunctionParameters[1] === value1 &&
  125195. this._blendFunctionParameters[2] === value2 &&
  125196. this._blendFunctionParameters[3] === value3) {
  125197. return;
  125198. }
  125199. this._blendFunctionParameters[0] = value0;
  125200. this._blendFunctionParameters[1] = value1;
  125201. this._blendFunctionParameters[2] = value2;
  125202. this._blendFunctionParameters[3] = value3;
  125203. this._isBlendFunctionParametersDirty = true;
  125204. };
  125205. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  125206. if (this._blendEquationParameters[0] === rgb &&
  125207. this._blendEquationParameters[1] === alpha) {
  125208. return;
  125209. }
  125210. this._blendEquationParameters[0] = rgb;
  125211. this._blendEquationParameters[1] = alpha;
  125212. this._isBlendEquationParametersDirty = true;
  125213. };
  125214. _AlphaState.prototype.reset = function () {
  125215. this._alphaBlend = false;
  125216. this._blendFunctionParameters[0] = null;
  125217. this._blendFunctionParameters[1] = null;
  125218. this._blendFunctionParameters[2] = null;
  125219. this._blendFunctionParameters[3] = null;
  125220. this._blendEquationParameters[0] = null;
  125221. this._blendEquationParameters[1] = null;
  125222. this._blendConstants[0] = null;
  125223. this._blendConstants[1] = null;
  125224. this._blendConstants[2] = null;
  125225. this._blendConstants[3] = null;
  125226. this._isAlphaBlendDirty = true;
  125227. this._isBlendFunctionParametersDirty = false;
  125228. this._isBlendEquationParametersDirty = false;
  125229. this._isBlendConstantsDirty = false;
  125230. };
  125231. _AlphaState.prototype.apply = function (gl) {
  125232. if (!this.isDirty) {
  125233. return;
  125234. }
  125235. // Alpha blend
  125236. if (this._isAlphaBlendDirty) {
  125237. if (this._alphaBlend) {
  125238. gl.enable(gl.BLEND);
  125239. }
  125240. else {
  125241. gl.disable(gl.BLEND);
  125242. }
  125243. this._isAlphaBlendDirty = false;
  125244. }
  125245. // Alpha function
  125246. if (this._isBlendFunctionParametersDirty) {
  125247. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  125248. this._isBlendFunctionParametersDirty = false;
  125249. }
  125250. // Alpha equation
  125251. if (this._isBlendEquationParametersDirty) {
  125252. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  125253. this._isBlendEquationParametersDirty = false;
  125254. }
  125255. // Constants
  125256. if (this._isBlendConstantsDirty) {
  125257. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  125258. this._isBlendConstantsDirty = false;
  125259. }
  125260. };
  125261. return _AlphaState;
  125262. }());
  125263. /***/ }),
  125264. /***/ "./States/depthCullingState.ts":
  125265. /*!*************************************!*\
  125266. !*** ./States/depthCullingState.ts ***!
  125267. \*************************************/
  125268. /*! exports provided: _DepthCullingState */
  125269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125270. "use strict";
  125271. __webpack_require__.r(__webpack_exports__);
  125272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  125273. /**
  125274. * @hidden
  125275. **/
  125276. var _DepthCullingState = /** @class */ (function () {
  125277. /**
  125278. * Initializes the state.
  125279. */
  125280. function _DepthCullingState() {
  125281. this._isDepthTestDirty = false;
  125282. this._isDepthMaskDirty = false;
  125283. this._isDepthFuncDirty = false;
  125284. this._isCullFaceDirty = false;
  125285. this._isCullDirty = false;
  125286. this._isZOffsetDirty = false;
  125287. this._isFrontFaceDirty = false;
  125288. this.reset();
  125289. }
  125290. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  125291. get: function () {
  125292. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  125293. },
  125294. enumerable: true,
  125295. configurable: true
  125296. });
  125297. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  125298. get: function () {
  125299. return this._zOffset;
  125300. },
  125301. set: function (value) {
  125302. if (this._zOffset === value) {
  125303. return;
  125304. }
  125305. this._zOffset = value;
  125306. this._isZOffsetDirty = true;
  125307. },
  125308. enumerable: true,
  125309. configurable: true
  125310. });
  125311. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  125312. get: function () {
  125313. return this._cullFace;
  125314. },
  125315. set: function (value) {
  125316. if (this._cullFace === value) {
  125317. return;
  125318. }
  125319. this._cullFace = value;
  125320. this._isCullFaceDirty = true;
  125321. },
  125322. enumerable: true,
  125323. configurable: true
  125324. });
  125325. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  125326. get: function () {
  125327. return this._cull;
  125328. },
  125329. set: function (value) {
  125330. if (this._cull === value) {
  125331. return;
  125332. }
  125333. this._cull = value;
  125334. this._isCullDirty = true;
  125335. },
  125336. enumerable: true,
  125337. configurable: true
  125338. });
  125339. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  125340. get: function () {
  125341. return this._depthFunc;
  125342. },
  125343. set: function (value) {
  125344. if (this._depthFunc === value) {
  125345. return;
  125346. }
  125347. this._depthFunc = value;
  125348. this._isDepthFuncDirty = true;
  125349. },
  125350. enumerable: true,
  125351. configurable: true
  125352. });
  125353. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  125354. get: function () {
  125355. return this._depthMask;
  125356. },
  125357. set: function (value) {
  125358. if (this._depthMask === value) {
  125359. return;
  125360. }
  125361. this._depthMask = value;
  125362. this._isDepthMaskDirty = true;
  125363. },
  125364. enumerable: true,
  125365. configurable: true
  125366. });
  125367. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  125368. get: function () {
  125369. return this._depthTest;
  125370. },
  125371. set: function (value) {
  125372. if (this._depthTest === value) {
  125373. return;
  125374. }
  125375. this._depthTest = value;
  125376. this._isDepthTestDirty = true;
  125377. },
  125378. enumerable: true,
  125379. configurable: true
  125380. });
  125381. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  125382. get: function () {
  125383. return this._frontFace;
  125384. },
  125385. set: function (value) {
  125386. if (this._frontFace === value) {
  125387. return;
  125388. }
  125389. this._frontFace = value;
  125390. this._isFrontFaceDirty = true;
  125391. },
  125392. enumerable: true,
  125393. configurable: true
  125394. });
  125395. _DepthCullingState.prototype.reset = function () {
  125396. this._depthMask = true;
  125397. this._depthTest = true;
  125398. this._depthFunc = null;
  125399. this._cullFace = null;
  125400. this._cull = null;
  125401. this._zOffset = 0;
  125402. this._frontFace = null;
  125403. this._isDepthTestDirty = true;
  125404. this._isDepthMaskDirty = true;
  125405. this._isDepthFuncDirty = false;
  125406. this._isCullFaceDirty = false;
  125407. this._isCullDirty = false;
  125408. this._isZOffsetDirty = false;
  125409. this._isFrontFaceDirty = false;
  125410. };
  125411. _DepthCullingState.prototype.apply = function (gl) {
  125412. if (!this.isDirty) {
  125413. return;
  125414. }
  125415. // Cull
  125416. if (this._isCullDirty) {
  125417. if (this.cull) {
  125418. gl.enable(gl.CULL_FACE);
  125419. }
  125420. else {
  125421. gl.disable(gl.CULL_FACE);
  125422. }
  125423. this._isCullDirty = false;
  125424. }
  125425. // Cull face
  125426. if (this._isCullFaceDirty) {
  125427. gl.cullFace(this.cullFace);
  125428. this._isCullFaceDirty = false;
  125429. }
  125430. // Depth mask
  125431. if (this._isDepthMaskDirty) {
  125432. gl.depthMask(this.depthMask);
  125433. this._isDepthMaskDirty = false;
  125434. }
  125435. // Depth test
  125436. if (this._isDepthTestDirty) {
  125437. if (this.depthTest) {
  125438. gl.enable(gl.DEPTH_TEST);
  125439. }
  125440. else {
  125441. gl.disable(gl.DEPTH_TEST);
  125442. }
  125443. this._isDepthTestDirty = false;
  125444. }
  125445. // Depth func
  125446. if (this._isDepthFuncDirty) {
  125447. gl.depthFunc(this.depthFunc);
  125448. this._isDepthFuncDirty = false;
  125449. }
  125450. // zOffset
  125451. if (this._isZOffsetDirty) {
  125452. if (this.zOffset) {
  125453. gl.enable(gl.POLYGON_OFFSET_FILL);
  125454. gl.polygonOffset(this.zOffset, 0);
  125455. }
  125456. else {
  125457. gl.disable(gl.POLYGON_OFFSET_FILL);
  125458. }
  125459. this._isZOffsetDirty = false;
  125460. }
  125461. // Front face
  125462. if (this._isFrontFaceDirty) {
  125463. gl.frontFace(this.frontFace);
  125464. this._isFrontFaceDirty = false;
  125465. }
  125466. };
  125467. return _DepthCullingState;
  125468. }());
  125469. /***/ }),
  125470. /***/ "./States/index.ts":
  125471. /*!*************************!*\
  125472. !*** ./States/index.ts ***!
  125473. \*************************/
  125474. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  125475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125476. "use strict";
  125477. __webpack_require__.r(__webpack_exports__);
  125478. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  125479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  125480. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  125481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  125482. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  125483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  125484. /***/ }),
  125485. /***/ "./States/stencilState.ts":
  125486. /*!********************************!*\
  125487. !*** ./States/stencilState.ts ***!
  125488. \********************************/
  125489. /*! exports provided: _StencilState */
  125490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125491. "use strict";
  125492. __webpack_require__.r(__webpack_exports__);
  125493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  125494. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125495. /**
  125496. * @hidden
  125497. **/
  125498. var _StencilState = /** @class */ (function () {
  125499. function _StencilState() {
  125500. this._isStencilTestDirty = false;
  125501. this._isStencilMaskDirty = false;
  125502. this._isStencilFuncDirty = false;
  125503. this._isStencilOpDirty = false;
  125504. this.reset();
  125505. }
  125506. Object.defineProperty(_StencilState.prototype, "isDirty", {
  125507. get: function () {
  125508. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  125509. },
  125510. enumerable: true,
  125511. configurable: true
  125512. });
  125513. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  125514. get: function () {
  125515. return this._stencilFunc;
  125516. },
  125517. set: function (value) {
  125518. if (this._stencilFunc === value) {
  125519. return;
  125520. }
  125521. this._stencilFunc = value;
  125522. this._isStencilFuncDirty = true;
  125523. },
  125524. enumerable: true,
  125525. configurable: true
  125526. });
  125527. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  125528. get: function () {
  125529. return this._stencilFuncRef;
  125530. },
  125531. set: function (value) {
  125532. if (this._stencilFuncRef === value) {
  125533. return;
  125534. }
  125535. this._stencilFuncRef = value;
  125536. this._isStencilFuncDirty = true;
  125537. },
  125538. enumerable: true,
  125539. configurable: true
  125540. });
  125541. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  125542. get: function () {
  125543. return this._stencilFuncMask;
  125544. },
  125545. set: function (value) {
  125546. if (this._stencilFuncMask === value) {
  125547. return;
  125548. }
  125549. this._stencilFuncMask = value;
  125550. this._isStencilFuncDirty = true;
  125551. },
  125552. enumerable: true,
  125553. configurable: true
  125554. });
  125555. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  125556. get: function () {
  125557. return this._stencilOpStencilFail;
  125558. },
  125559. set: function (value) {
  125560. if (this._stencilOpStencilFail === value) {
  125561. return;
  125562. }
  125563. this._stencilOpStencilFail = value;
  125564. this._isStencilOpDirty = true;
  125565. },
  125566. enumerable: true,
  125567. configurable: true
  125568. });
  125569. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  125570. get: function () {
  125571. return this._stencilOpDepthFail;
  125572. },
  125573. set: function (value) {
  125574. if (this._stencilOpDepthFail === value) {
  125575. return;
  125576. }
  125577. this._stencilOpDepthFail = value;
  125578. this._isStencilOpDirty = true;
  125579. },
  125580. enumerable: true,
  125581. configurable: true
  125582. });
  125583. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  125584. get: function () {
  125585. return this._stencilOpStencilDepthPass;
  125586. },
  125587. set: function (value) {
  125588. if (this._stencilOpStencilDepthPass === value) {
  125589. return;
  125590. }
  125591. this._stencilOpStencilDepthPass = value;
  125592. this._isStencilOpDirty = true;
  125593. },
  125594. enumerable: true,
  125595. configurable: true
  125596. });
  125597. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  125598. get: function () {
  125599. return this._stencilMask;
  125600. },
  125601. set: function (value) {
  125602. if (this._stencilMask === value) {
  125603. return;
  125604. }
  125605. this._stencilMask = value;
  125606. this._isStencilMaskDirty = true;
  125607. },
  125608. enumerable: true,
  125609. configurable: true
  125610. });
  125611. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  125612. get: function () {
  125613. return this._stencilTest;
  125614. },
  125615. set: function (value) {
  125616. if (this._stencilTest === value) {
  125617. return;
  125618. }
  125619. this._stencilTest = value;
  125620. this._isStencilTestDirty = true;
  125621. },
  125622. enumerable: true,
  125623. configurable: true
  125624. });
  125625. _StencilState.prototype.reset = function () {
  125626. this._stencilTest = false;
  125627. this._stencilMask = 0xFF;
  125628. this._stencilFunc = _StencilState.ALWAYS;
  125629. this._stencilFuncRef = 1;
  125630. this._stencilFuncMask = 0xFF;
  125631. this._stencilOpStencilFail = _StencilState.KEEP;
  125632. this._stencilOpDepthFail = _StencilState.KEEP;
  125633. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  125634. this._isStencilTestDirty = true;
  125635. this._isStencilMaskDirty = true;
  125636. this._isStencilFuncDirty = true;
  125637. this._isStencilOpDirty = true;
  125638. };
  125639. _StencilState.prototype.apply = function (gl) {
  125640. if (!this.isDirty) {
  125641. return;
  125642. }
  125643. // Stencil test
  125644. if (this._isStencilTestDirty) {
  125645. if (this.stencilTest) {
  125646. gl.enable(gl.STENCIL_TEST);
  125647. }
  125648. else {
  125649. gl.disable(gl.STENCIL_TEST);
  125650. }
  125651. this._isStencilTestDirty = false;
  125652. }
  125653. // Stencil mask
  125654. if (this._isStencilMaskDirty) {
  125655. gl.stencilMask(this.stencilMask);
  125656. this._isStencilMaskDirty = false;
  125657. }
  125658. // Stencil func
  125659. if (this._isStencilFuncDirty) {
  125660. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  125661. this._isStencilFuncDirty = false;
  125662. }
  125663. // Stencil op
  125664. if (this._isStencilOpDirty) {
  125665. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  125666. this._isStencilOpDirty = false;
  125667. }
  125668. };
  125669. /** 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 */
  125670. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  125671. /** Passed to stencilOperation to specify that stencil value must be kept */
  125672. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  125673. /** Passed to stencilOperation to specify that stencil value must be replaced */
  125674. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  125675. return _StencilState;
  125676. }());
  125677. /***/ }),
  125678. /***/ "./abstractScene.ts":
  125679. /*!**************************!*\
  125680. !*** ./abstractScene.ts ***!
  125681. \**************************/
  125682. /*! exports provided: AbstractScene */
  125683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125684. "use strict";
  125685. __webpack_require__.r(__webpack_exports__);
  125686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  125687. /**
  125688. * Base class of the scene acting as a container for the different elements composing a scene.
  125689. * This class is dynamically extended by the different components of the scene increasing
  125690. * flexibility and reducing coupling
  125691. */
  125692. var AbstractScene = /** @class */ (function () {
  125693. function AbstractScene() {
  125694. /**
  125695. * Gets the list of root nodes (ie. nodes with no parent)
  125696. */
  125697. this.rootNodes = new Array();
  125698. /** All of the cameras added to this scene
  125699. * @see http://doc.babylonjs.com/babylon101/cameras
  125700. */
  125701. this.cameras = new Array();
  125702. /**
  125703. * All of the lights added to this scene
  125704. * @see http://doc.babylonjs.com/babylon101/lights
  125705. */
  125706. this.lights = new Array();
  125707. /**
  125708. * All of the (abstract) meshes added to this scene
  125709. */
  125710. this.meshes = new Array();
  125711. /**
  125712. * The list of skeletons added to the scene
  125713. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125714. */
  125715. this.skeletons = new Array();
  125716. /**
  125717. * All of the particle systems added to this scene
  125718. * @see http://doc.babylonjs.com/babylon101/particles
  125719. */
  125720. this.particleSystems = new Array();
  125721. /**
  125722. * Gets a list of Animations associated with the scene
  125723. */
  125724. this.animations = [];
  125725. /**
  125726. * All of the animation groups added to this scene
  125727. * @see http://doc.babylonjs.com/how_to/group
  125728. */
  125729. this.animationGroups = new Array();
  125730. /**
  125731. * All of the multi-materials added to this scene
  125732. * @see http://doc.babylonjs.com/how_to/multi_materials
  125733. */
  125734. this.multiMaterials = new Array();
  125735. /**
  125736. * All of the materials added to this scene
  125737. * In the context of a Scene, it is not supposed to be modified manually.
  125738. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  125739. * Note also that the order of the Material wihin the array is not significant and might change.
  125740. * @see http://doc.babylonjs.com/babylon101/materials
  125741. */
  125742. this.materials = new Array();
  125743. /**
  125744. * The list of morph target managers added to the scene
  125745. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125746. */
  125747. this.morphTargetManagers = new Array();
  125748. /**
  125749. * The list of geometries used in the scene.
  125750. */
  125751. this.geometries = new Array();
  125752. /**
  125753. * All of the tranform nodes added to this scene
  125754. * In the context of a Scene, it is not supposed to be modified manually.
  125755. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125756. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125757. * @see http://doc.babylonjs.com/how_to/transformnode
  125758. */
  125759. this.transformNodes = new Array();
  125760. /**
  125761. * ActionManagers available on the scene.
  125762. */
  125763. this.actionManagers = new Array();
  125764. /**
  125765. * Textures to keep.
  125766. */
  125767. this.textures = new Array();
  125768. }
  125769. /**
  125770. * Adds a parser in the list of available ones
  125771. * @param name Defines the name of the parser
  125772. * @param parser Defines the parser to add
  125773. */
  125774. AbstractScene.AddParser = function (name, parser) {
  125775. this._BabylonFileParsers[name] = parser;
  125776. };
  125777. /**
  125778. * Gets a general parser from the list of avaialble ones
  125779. * @param name Defines the name of the parser
  125780. * @returns the requested parser or null
  125781. */
  125782. AbstractScene.GetParser = function (name) {
  125783. if (this._BabylonFileParsers[name]) {
  125784. return this._BabylonFileParsers[name];
  125785. }
  125786. return null;
  125787. };
  125788. /**
  125789. * Adds n individual parser in the list of available ones
  125790. * @param name Defines the name of the parser
  125791. * @param parser Defines the parser to add
  125792. */
  125793. AbstractScene.AddIndividualParser = function (name, parser) {
  125794. this._IndividualBabylonFileParsers[name] = parser;
  125795. };
  125796. /**
  125797. * Gets an individual parser from the list of avaialble ones
  125798. * @param name Defines the name of the parser
  125799. * @returns the requested parser or null
  125800. */
  125801. AbstractScene.GetIndividualParser = function (name) {
  125802. if (this._IndividualBabylonFileParsers[name]) {
  125803. return this._IndividualBabylonFileParsers[name];
  125804. }
  125805. return null;
  125806. };
  125807. /**
  125808. * Parser json data and populate both a scene and its associated container object
  125809. * @param jsonData Defines the data to parse
  125810. * @param scene Defines the scene to parse the data for
  125811. * @param container Defines the container attached to the parsing sequence
  125812. * @param rootUrl Defines the root url of the data
  125813. */
  125814. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  125815. for (var parserName in this._BabylonFileParsers) {
  125816. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  125817. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  125818. }
  125819. }
  125820. };
  125821. /**
  125822. * Stores the list of available parsers in the application.
  125823. */
  125824. AbstractScene._BabylonFileParsers = {};
  125825. /**
  125826. * Stores the list of available individual parsers in the application.
  125827. */
  125828. AbstractScene._IndividualBabylonFileParsers = {};
  125829. return AbstractScene;
  125830. }());
  125831. /***/ }),
  125832. /***/ "./assetContainer.ts":
  125833. /*!***************************!*\
  125834. !*** ./assetContainer.ts ***!
  125835. \***************************/
  125836. /*! exports provided: KeepAssets, AssetContainer */
  125837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125838. "use strict";
  125839. __webpack_require__.r(__webpack_exports__);
  125840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  125841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  125842. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125843. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  125844. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  125845. /**
  125846. * Set of assets to keep when moving a scene into an asset container.
  125847. */
  125848. var KeepAssets = /** @class */ (function (_super) {
  125849. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  125850. function KeepAssets() {
  125851. return _super !== null && _super.apply(this, arguments) || this;
  125852. }
  125853. return KeepAssets;
  125854. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  125855. /**
  125856. * Container with a set of assets that can be added or removed from a scene.
  125857. */
  125858. var AssetContainer = /** @class */ (function (_super) {
  125859. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  125860. /**
  125861. * Instantiates an AssetContainer.
  125862. * @param scene The scene the AssetContainer belongs to.
  125863. */
  125864. function AssetContainer(scene) {
  125865. var _this = _super.call(this) || this;
  125866. _this.scene = scene;
  125867. _this["sounds"] = [];
  125868. _this["effectLayers"] = [];
  125869. _this["layers"] = [];
  125870. _this["lensFlareSystems"] = [];
  125871. _this["proceduralTextures"] = [];
  125872. _this["reflectionProbes"] = [];
  125873. return _this;
  125874. }
  125875. /**
  125876. * Adds all the assets from the container to the scene.
  125877. */
  125878. AssetContainer.prototype.addAllToScene = function () {
  125879. var _this = this;
  125880. this.cameras.forEach(function (o) {
  125881. _this.scene.addCamera(o);
  125882. });
  125883. this.lights.forEach(function (o) {
  125884. _this.scene.addLight(o);
  125885. });
  125886. this.meshes.forEach(function (o) {
  125887. _this.scene.addMesh(o);
  125888. });
  125889. this.skeletons.forEach(function (o) {
  125890. _this.scene.addSkeleton(o);
  125891. });
  125892. this.animations.forEach(function (o) {
  125893. _this.scene.addAnimation(o);
  125894. });
  125895. this.animationGroups.forEach(function (o) {
  125896. _this.scene.addAnimationGroup(o);
  125897. });
  125898. this.multiMaterials.forEach(function (o) {
  125899. _this.scene.addMultiMaterial(o);
  125900. });
  125901. this.materials.forEach(function (o) {
  125902. _this.scene.addMaterial(o);
  125903. });
  125904. this.morphTargetManagers.forEach(function (o) {
  125905. _this.scene.addMorphTargetManager(o);
  125906. });
  125907. this.geometries.forEach(function (o) {
  125908. _this.scene.addGeometry(o);
  125909. });
  125910. this.transformNodes.forEach(function (o) {
  125911. _this.scene.addTransformNode(o);
  125912. });
  125913. this.actionManagers.forEach(function (o) {
  125914. _this.scene.addActionManager(o);
  125915. });
  125916. this.textures.forEach(function (o) {
  125917. _this.scene.addTexture(o);
  125918. });
  125919. this.reflectionProbes.forEach(function (o) {
  125920. _this.scene.addReflectionProbe(o);
  125921. });
  125922. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125923. var component = _a[_i];
  125924. component.addFromContainer(this);
  125925. }
  125926. };
  125927. /**
  125928. * Removes all the assets in the container from the scene
  125929. */
  125930. AssetContainer.prototype.removeAllFromScene = function () {
  125931. var _this = this;
  125932. this.cameras.forEach(function (o) {
  125933. _this.scene.removeCamera(o);
  125934. });
  125935. this.lights.forEach(function (o) {
  125936. _this.scene.removeLight(o);
  125937. });
  125938. this.meshes.forEach(function (o) {
  125939. _this.scene.removeMesh(o);
  125940. });
  125941. this.skeletons.forEach(function (o) {
  125942. _this.scene.removeSkeleton(o);
  125943. });
  125944. this.animations.forEach(function (o) {
  125945. _this.scene.removeAnimation(o);
  125946. });
  125947. this.animationGroups.forEach(function (o) {
  125948. _this.scene.removeAnimationGroup(o);
  125949. });
  125950. this.multiMaterials.forEach(function (o) {
  125951. _this.scene.removeMultiMaterial(o);
  125952. });
  125953. this.materials.forEach(function (o) {
  125954. _this.scene.removeMaterial(o);
  125955. });
  125956. this.morphTargetManagers.forEach(function (o) {
  125957. _this.scene.removeMorphTargetManager(o);
  125958. });
  125959. this.geometries.forEach(function (o) {
  125960. _this.scene.removeGeometry(o);
  125961. });
  125962. this.transformNodes.forEach(function (o) {
  125963. _this.scene.removeTransformNode(o);
  125964. });
  125965. this.actionManagers.forEach(function (o) {
  125966. _this.scene.removeActionManager(o);
  125967. });
  125968. this.textures.forEach(function (o) {
  125969. _this.scene.removeTexture(o);
  125970. });
  125971. this.reflectionProbes.forEach(function (o) {
  125972. _this.scene.removeReflectionProbe(o);
  125973. });
  125974. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125975. var component = _a[_i];
  125976. component.removeFromContainer(this);
  125977. }
  125978. };
  125979. /**
  125980. * Disposes all the assets in the container
  125981. */
  125982. AssetContainer.prototype.dispose = function () {
  125983. this.cameras.forEach(function (o) {
  125984. o.dispose();
  125985. });
  125986. this.lights.forEach(function (o) {
  125987. o.dispose();
  125988. });
  125989. this.meshes.forEach(function (o) {
  125990. o.dispose();
  125991. });
  125992. this.skeletons.forEach(function (o) {
  125993. o.dispose();
  125994. });
  125995. this.animationGroups.forEach(function (o) {
  125996. o.dispose();
  125997. });
  125998. this.multiMaterials.forEach(function (o) {
  125999. o.dispose();
  126000. });
  126001. this.materials.forEach(function (o) {
  126002. o.dispose();
  126003. });
  126004. this.geometries.forEach(function (o) {
  126005. o.dispose();
  126006. });
  126007. this.transformNodes.forEach(function (o) {
  126008. o.dispose();
  126009. });
  126010. this.actionManagers.forEach(function (o) {
  126011. o.dispose();
  126012. });
  126013. this.textures.forEach(function (o) {
  126014. o.dispose();
  126015. });
  126016. this.reflectionProbes.forEach(function (o) {
  126017. o.dispose();
  126018. });
  126019. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126020. var component = _a[_i];
  126021. component.dispose();
  126022. }
  126023. };
  126024. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  126025. if (!sourceAssets) {
  126026. return;
  126027. }
  126028. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  126029. var asset = sourceAssets_1[_i];
  126030. var move = true;
  126031. if (keepAssets) {
  126032. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  126033. var keepAsset = keepAssets_1[_a];
  126034. if (asset === keepAsset) {
  126035. move = false;
  126036. break;
  126037. }
  126038. }
  126039. }
  126040. if (move) {
  126041. targetAssets.push(asset);
  126042. }
  126043. }
  126044. };
  126045. /**
  126046. * Removes all the assets contained in the scene and adds them to the container.
  126047. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126048. */
  126049. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  126050. if (keepAssets === undefined) {
  126051. keepAssets = new KeepAssets();
  126052. }
  126053. for (var key in this) {
  126054. if (this.hasOwnProperty(key)) {
  126055. this[key] = this[key] || [];
  126056. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  126057. }
  126058. }
  126059. this.removeAllFromScene();
  126060. };
  126061. /**
  126062. * 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.
  126063. * @returns the root mesh
  126064. */
  126065. AssetContainer.prototype.createRootMesh = function () {
  126066. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  126067. this.meshes.forEach(function (m) {
  126068. if (!m.parent) {
  126069. rootMesh.addChild(m);
  126070. }
  126071. });
  126072. this.meshes.unshift(rootMesh);
  126073. return rootMesh;
  126074. };
  126075. return AssetContainer;
  126076. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126077. /***/ }),
  126078. /***/ "./index.ts":
  126079. /*!******************!*\
  126080. !*** ./index.ts ***!
  126081. \******************/
  126082. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, 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, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, 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, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, 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, 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, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, 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, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, MultiRenderTarget, ProceduralTexture, ProceduralTextureSceneComponent, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, RibbonBuilder, 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, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  126083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126084. "use strict";
  126085. __webpack_require__.r(__webpack_exports__);
  126086. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  126088. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  126089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  126090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  126091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  126092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  126093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  126094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  126095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  126096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  126097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  126098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  126099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  126100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  126101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  126102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  126103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  126104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  126105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  126106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  126107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  126108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  126109. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  126110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  126111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  126112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  126113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  126114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  126115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  126116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  126117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  126118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  126119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  126120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  126121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  126122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  126123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  126124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  126125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  126126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  126127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  126128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  126129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  126130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  126131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  126132. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  126133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  126134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  126135. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  126136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  126137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  126138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  126139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  126140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  126141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  126142. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  126143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  126144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  126145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  126146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  126147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  126148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  126149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  126150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  126151. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  126152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  126153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  126154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  126155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  126156. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  126157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  126158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  126159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  126160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  126161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  126162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  126163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  126164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  126165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  126166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  126167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  126168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  126169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  126170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  126171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  126172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  126173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  126174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  126175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  126176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  126177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  126178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  126179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  126180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  126181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  126182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  126183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  126184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  126185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  126186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  126187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  126188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  126189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  126190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  126191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  126192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  126193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  126194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  126195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  126196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  126197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  126198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  126199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  126200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  126201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  126202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  126203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  126204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  126205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  126206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  126207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  126208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  126209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  126210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  126211. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  126212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  126213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  126214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  126215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  126216. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  126217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  126218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  126219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  126220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  126221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  126222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  126223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  126224. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  126225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  126226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  126227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  126228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  126229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  126230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  126231. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  126232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  126233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  126234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  126235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  126236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  126237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  126238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  126239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  126240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  126241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  126242. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  126243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  126244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  126245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  126246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  126247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  126248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  126249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  126250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  126251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  126252. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  126253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  126254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  126255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  126256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  126257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  126258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  126259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  126260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  126261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  126262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  126263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  126264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  126265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  126266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  126267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  126268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  126269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  126270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  126271. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  126272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  126273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  126274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  126275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  126276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  126277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  126278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  126279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  126280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  126281. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  126282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  126283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  126284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  126285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  126286. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  126287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  126288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  126289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  126290. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  126291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  126292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  126293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  126294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  126295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  126296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  126297. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  126298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  126299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  126300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  126301. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  126302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  126303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  126304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  126305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  126306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  126307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  126308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  126309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  126310. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  126311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  126312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  126313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  126314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  126315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  126316. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  126317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  126318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  126319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  126320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  126321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  126322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  126323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  126324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  126325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  126326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  126327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  126328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  126329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  126330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  126331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  126332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  126333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  126334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  126335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  126336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  126337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  126338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  126339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  126340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  126341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  126342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  126343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  126344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  126345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  126346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  126347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  126348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  126349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  126350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  126351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  126352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  126353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  126354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  126355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  126356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  126357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  126358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  126359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  126360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  126361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  126362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  126363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  126364. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  126365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  126366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  126367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  126368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  126369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  126370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  126371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  126372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  126373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  126374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  126375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  126376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  126377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  126378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  126379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  126380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  126381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  126382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  126383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  126384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  126385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  126386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  126387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  126388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  126389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  126390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  126391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  126392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  126393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  126394. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  126395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  126396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  126397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  126398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  126399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  126400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  126401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  126402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  126403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  126404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  126405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  126406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  126407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  126408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  126409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  126410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  126411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  126412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  126413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  126414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  126415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  126416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  126417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  126418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  126419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  126420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  126421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  126422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  126423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  126424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  126425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  126426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  126427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  126428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  126429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  126430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  126431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  126432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  126433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  126434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  126435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  126436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  126437. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  126438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  126439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  126440. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  126441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  126442. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  126443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  126444. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  126445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  126446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  126447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  126448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  126449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  126450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  126451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  126452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  126453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  126454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  126455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  126456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  126457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  126458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  126459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  126460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  126461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  126462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  126463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  126464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  126465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  126466. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  126467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  126468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  126469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  126470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  126471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  126472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  126473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  126474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  126475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  126476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  126477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  126478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  126479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  126480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  126481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  126482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  126483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  126484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  126485. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  126486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  126487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  126488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  126489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  126490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  126491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  126492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  126493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  126494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  126495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  126496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  126497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  126498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  126499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  126500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  126501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  126502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  126503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  126504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  126505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  126506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  126507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  126508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  126509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  126510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  126511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  126512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  126513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  126514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  126515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  126516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  126517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  126518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  126519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  126520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  126521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  126522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  126523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  126524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  126525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  126526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  126527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  126528. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  126529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  126530. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  126531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  126532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  126533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  126534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  126535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  126536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  126537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  126538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  126539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  126540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  126541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  126542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  126543. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  126544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  126545. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  126547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  126548. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  126549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  126550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  126551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  126552. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  126553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  126554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  126555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  126556. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  126557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  126558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  126559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  126560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  126561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  126562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  126563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  126564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  126565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  126566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  126567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  126568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  126569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  126570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  126571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  126572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  126573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  126574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  126575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  126576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  126577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  126578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  126579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  126580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  126581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  126582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  126583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  126584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  126585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  126586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  126587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  126588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  126589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  126590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  126591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  126592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  126593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  126594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  126595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  126596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  126597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  126598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  126599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  126600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  126601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  126602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  126603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  126604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  126605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  126606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  126607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  126608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  126609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  126610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  126611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  126612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  126613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  126614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  126615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  126616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  126617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  126618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  126619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  126620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  126621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  126622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  126623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  126624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  126625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  126626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  126627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  126628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  126629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  126630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  126631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  126632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  126633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  126634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  126635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  126636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  126637. /***/ }),
  126638. /***/ "./node.ts":
  126639. /*!*****************!*\
  126640. !*** ./node.ts ***!
  126641. \*****************/
  126642. /*! exports provided: Node */
  126643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126644. "use strict";
  126645. __webpack_require__.r(__webpack_exports__);
  126646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  126647. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126648. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  126649. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  126650. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  126651. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  126652. /**
  126653. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  126654. */
  126655. var Node = /** @class */ (function () {
  126656. /**
  126657. * Creates a new Node
  126658. * @param name the name and id to be given to this node
  126659. * @param scene the scene this node will be added to
  126660. * @param addToRootNodes the node will be added to scene.rootNodes
  126661. */
  126662. function Node(name, scene, addToRootNodes) {
  126663. if (scene === void 0) { scene = null; }
  126664. if (addToRootNodes === void 0) { addToRootNodes = true; }
  126665. /**
  126666. * Gets or sets a string used to store user defined state for the node
  126667. */
  126668. this.state = "";
  126669. /**
  126670. * Gets or sets an object used to store user defined information for the node
  126671. */
  126672. this.metadata = null;
  126673. /**
  126674. * For internal use only. Please do not use.
  126675. */
  126676. this.reservedDataStore = null;
  126677. /**
  126678. * Gets or sets a boolean used to define if the node must be serialized
  126679. */
  126680. this.doNotSerialize = false;
  126681. /** @hidden */
  126682. this._isDisposed = false;
  126683. /**
  126684. * Gets a list of Animations associated with the node
  126685. */
  126686. this.animations = new Array();
  126687. this._ranges = {};
  126688. this._isEnabled = true;
  126689. this._isParentEnabled = true;
  126690. this._isReady = true;
  126691. /** @hidden */
  126692. this._currentRenderId = -1;
  126693. this._parentRenderId = -1;
  126694. this._childRenderId = -1;
  126695. /** @hidden */
  126696. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  126697. /** @hidden */
  126698. this._worldMatrixDeterminant = 0;
  126699. /** @hidden */
  126700. this._sceneRootNodesIndex = -1;
  126701. this._animationPropertiesOverride = null;
  126702. /** @hidden */
  126703. this._isNode = true;
  126704. /**
  126705. * An event triggered when the mesh is disposed
  126706. */
  126707. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126708. // Behaviors
  126709. this._behaviors = new Array();
  126710. this.name = name;
  126711. this.id = name;
  126712. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  126713. this.uniqueId = this._scene.getUniqueId();
  126714. this._initCache();
  126715. if (addToRootNodes) {
  126716. this.addToSceneRootNodes();
  126717. }
  126718. }
  126719. /**
  126720. * Add a new node constructor
  126721. * @param type defines the type name of the node to construct
  126722. * @param constructorFunc defines the constructor function
  126723. */
  126724. Node.AddNodeConstructor = function (type, constructorFunc) {
  126725. this._NodeConstructors[type] = constructorFunc;
  126726. };
  126727. /**
  126728. * Returns a node constructor based on type name
  126729. * @param type defines the type name
  126730. * @param name defines the new node name
  126731. * @param scene defines the hosting scene
  126732. * @param options defines optional options to transmit to constructors
  126733. * @returns the new constructor or null
  126734. */
  126735. Node.Construct = function (type, name, scene, options) {
  126736. var constructorFunc = this._NodeConstructors[type];
  126737. if (!constructorFunc) {
  126738. return null;
  126739. }
  126740. return constructorFunc(name, scene, options);
  126741. };
  126742. /**
  126743. * Gets a boolean indicating if the node has been disposed
  126744. * @returns true if the node was disposed
  126745. */
  126746. Node.prototype.isDisposed = function () {
  126747. return this._isDisposed;
  126748. };
  126749. Object.defineProperty(Node.prototype, "parent", {
  126750. get: function () {
  126751. return this._parentNode;
  126752. },
  126753. /**
  126754. * Gets or sets the parent of the node
  126755. */
  126756. set: function (parent) {
  126757. if (this._parentNode === parent) {
  126758. return;
  126759. }
  126760. var previousParentNode = this._parentNode;
  126761. // Remove self from list of children of parent
  126762. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  126763. var index = this._parentNode._children.indexOf(this);
  126764. if (index !== -1) {
  126765. this._parentNode._children.splice(index, 1);
  126766. }
  126767. if (!parent && !this._isDisposed) {
  126768. this.addToSceneRootNodes();
  126769. }
  126770. }
  126771. // Store new parent
  126772. this._parentNode = parent;
  126773. // Add as child to new parent
  126774. if (this._parentNode) {
  126775. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  126776. this._parentNode._children = new Array();
  126777. }
  126778. this._parentNode._children.push(this);
  126779. if (!previousParentNode) {
  126780. this.removeFromSceneRootNodes();
  126781. }
  126782. }
  126783. // Enabled state
  126784. this._syncParentEnabledState();
  126785. },
  126786. enumerable: true,
  126787. configurable: true
  126788. });
  126789. Node.prototype.addToSceneRootNodes = function () {
  126790. if (this._sceneRootNodesIndex === -1) {
  126791. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  126792. this._scene.rootNodes.push(this);
  126793. }
  126794. };
  126795. Node.prototype.removeFromSceneRootNodes = function () {
  126796. if (this._sceneRootNodesIndex !== -1) {
  126797. var rootNodes = this._scene.rootNodes;
  126798. var lastIdx = rootNodes.length - 1;
  126799. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  126800. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  126801. this._scene.rootNodes.pop();
  126802. this._sceneRootNodesIndex = -1;
  126803. }
  126804. };
  126805. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  126806. /**
  126807. * Gets or sets the animation properties override
  126808. */
  126809. get: function () {
  126810. if (!this._animationPropertiesOverride) {
  126811. return this._scene.animationPropertiesOverride;
  126812. }
  126813. return this._animationPropertiesOverride;
  126814. },
  126815. set: function (value) {
  126816. this._animationPropertiesOverride = value;
  126817. },
  126818. enumerable: true,
  126819. configurable: true
  126820. });
  126821. /**
  126822. * Gets a string idenfifying the name of the class
  126823. * @returns "Node" string
  126824. */
  126825. Node.prototype.getClassName = function () {
  126826. return "Node";
  126827. };
  126828. Object.defineProperty(Node.prototype, "onDispose", {
  126829. /**
  126830. * Sets a callback that will be raised when the node will be disposed
  126831. */
  126832. set: function (callback) {
  126833. if (this._onDisposeObserver) {
  126834. this.onDisposeObservable.remove(this._onDisposeObserver);
  126835. }
  126836. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  126837. },
  126838. enumerable: true,
  126839. configurable: true
  126840. });
  126841. /**
  126842. * Gets the scene of the node
  126843. * @returns a scene
  126844. */
  126845. Node.prototype.getScene = function () {
  126846. return this._scene;
  126847. };
  126848. /**
  126849. * Gets the engine of the node
  126850. * @returns a Engine
  126851. */
  126852. Node.prototype.getEngine = function () {
  126853. return this._scene.getEngine();
  126854. };
  126855. /**
  126856. * Attach a behavior to the node
  126857. * @see http://doc.babylonjs.com/features/behaviour
  126858. * @param behavior defines the behavior to attach
  126859. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  126860. * @returns the current Node
  126861. */
  126862. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  126863. var _this = this;
  126864. if (attachImmediately === void 0) { attachImmediately = false; }
  126865. var index = this._behaviors.indexOf(behavior);
  126866. if (index !== -1) {
  126867. return this;
  126868. }
  126869. behavior.init();
  126870. if (this._scene.isLoading && !attachImmediately) {
  126871. // We defer the attach when the scene will be loaded
  126872. this._scene.onDataLoadedObservable.addOnce(function () {
  126873. behavior.attach(_this);
  126874. });
  126875. }
  126876. else {
  126877. behavior.attach(this);
  126878. }
  126879. this._behaviors.push(behavior);
  126880. return this;
  126881. };
  126882. /**
  126883. * Remove an attached behavior
  126884. * @see http://doc.babylonjs.com/features/behaviour
  126885. * @param behavior defines the behavior to attach
  126886. * @returns the current Node
  126887. */
  126888. Node.prototype.removeBehavior = function (behavior) {
  126889. var index = this._behaviors.indexOf(behavior);
  126890. if (index === -1) {
  126891. return this;
  126892. }
  126893. this._behaviors[index].detach();
  126894. this._behaviors.splice(index, 1);
  126895. return this;
  126896. };
  126897. Object.defineProperty(Node.prototype, "behaviors", {
  126898. /**
  126899. * Gets the list of attached behaviors
  126900. * @see http://doc.babylonjs.com/features/behaviour
  126901. */
  126902. get: function () {
  126903. return this._behaviors;
  126904. },
  126905. enumerable: true,
  126906. configurable: true
  126907. });
  126908. /**
  126909. * Gets an attached behavior by name
  126910. * @param name defines the name of the behavior to look for
  126911. * @see http://doc.babylonjs.com/features/behaviour
  126912. * @returns null if behavior was not found else the requested behavior
  126913. */
  126914. Node.prototype.getBehaviorByName = function (name) {
  126915. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  126916. var behavior = _a[_i];
  126917. if (behavior.name === name) {
  126918. return behavior;
  126919. }
  126920. }
  126921. return null;
  126922. };
  126923. /**
  126924. * Returns the latest update of the World matrix
  126925. * @returns a Matrix
  126926. */
  126927. Node.prototype.getWorldMatrix = function () {
  126928. if (this._currentRenderId !== this._scene.getRenderId()) {
  126929. this.computeWorldMatrix();
  126930. }
  126931. return this._worldMatrix;
  126932. };
  126933. /** @hidden */
  126934. Node.prototype._getWorldMatrixDeterminant = function () {
  126935. return this._worldMatrixDeterminant;
  126936. };
  126937. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  126938. /**
  126939. * Returns directly the latest state of the mesh World matrix.
  126940. * A Matrix is returned.
  126941. */
  126942. get: function () {
  126943. return this._worldMatrix;
  126944. },
  126945. enumerable: true,
  126946. configurable: true
  126947. });
  126948. // override it in derived class if you add new variables to the cache
  126949. // and call the parent class method
  126950. /** @hidden */
  126951. Node.prototype._initCache = function () {
  126952. this._cache = {};
  126953. this._cache.parent = undefined;
  126954. };
  126955. /** @hidden */
  126956. Node.prototype.updateCache = function (force) {
  126957. if (!force && this.isSynchronized()) {
  126958. return;
  126959. }
  126960. this._cache.parent = this.parent;
  126961. this._updateCache();
  126962. };
  126963. // override it in derived class if you add new variables to the cache
  126964. // and call the parent class method if !ignoreParentClass
  126965. /** @hidden */
  126966. Node.prototype._updateCache = function (ignoreParentClass) {
  126967. };
  126968. // override it in derived class if you add new variables to the cache
  126969. /** @hidden */
  126970. Node.prototype._isSynchronized = function () {
  126971. return true;
  126972. };
  126973. /** @hidden */
  126974. Node.prototype._markSyncedWithParent = function () {
  126975. if (this._parentNode) {
  126976. this._parentRenderId = this._parentNode._childRenderId;
  126977. }
  126978. };
  126979. /** @hidden */
  126980. Node.prototype.isSynchronizedWithParent = function () {
  126981. if (!this._parentNode) {
  126982. return true;
  126983. }
  126984. if (this._parentRenderId !== this._parentNode._childRenderId) {
  126985. return false;
  126986. }
  126987. return this._parentNode.isSynchronized();
  126988. };
  126989. /** @hidden */
  126990. Node.prototype.isSynchronized = function () {
  126991. if (this._cache.parent != this._parentNode) {
  126992. this._cache.parent = this._parentNode;
  126993. return false;
  126994. }
  126995. if (this._parentNode && !this.isSynchronizedWithParent()) {
  126996. return false;
  126997. }
  126998. return this._isSynchronized();
  126999. };
  127000. /**
  127001. * Is this node ready to be used/rendered
  127002. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  127003. * @return true if the node is ready
  127004. */
  127005. Node.prototype.isReady = function (completeCheck) {
  127006. if (completeCheck === void 0) { completeCheck = false; }
  127007. return this._isReady;
  127008. };
  127009. /**
  127010. * Is this node enabled?
  127011. * 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
  127012. * @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
  127013. * @return whether this node (and its parent) is enabled
  127014. */
  127015. Node.prototype.isEnabled = function (checkAncestors) {
  127016. if (checkAncestors === void 0) { checkAncestors = true; }
  127017. if (checkAncestors === false) {
  127018. return this._isEnabled;
  127019. }
  127020. if (!this._isEnabled) {
  127021. return false;
  127022. }
  127023. return this._isParentEnabled;
  127024. };
  127025. /** @hidden */
  127026. Node.prototype._syncParentEnabledState = function () {
  127027. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  127028. if (this._children) {
  127029. this._children.forEach(function (c) {
  127030. c._syncParentEnabledState(); // Force children to update accordingly
  127031. });
  127032. }
  127033. };
  127034. /**
  127035. * Set the enabled state of this node
  127036. * @param value defines the new enabled state
  127037. */
  127038. Node.prototype.setEnabled = function (value) {
  127039. this._isEnabled = value;
  127040. this._syncParentEnabledState();
  127041. };
  127042. /**
  127043. * Is this node a descendant of the given node?
  127044. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  127045. * @param ancestor defines the parent node to inspect
  127046. * @returns a boolean indicating if this node is a descendant of the given node
  127047. */
  127048. Node.prototype.isDescendantOf = function (ancestor) {
  127049. if (this.parent) {
  127050. if (this.parent === ancestor) {
  127051. return true;
  127052. }
  127053. return this.parent.isDescendantOf(ancestor);
  127054. }
  127055. return false;
  127056. };
  127057. /** @hidden */
  127058. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  127059. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  127060. if (!this._children) {
  127061. return;
  127062. }
  127063. for (var index = 0; index < this._children.length; index++) {
  127064. var item = this._children[index];
  127065. if (!predicate || predicate(item)) {
  127066. results.push(item);
  127067. }
  127068. if (!directDescendantsOnly) {
  127069. item._getDescendants(results, false, predicate);
  127070. }
  127071. }
  127072. };
  127073. /**
  127074. * Will return all nodes that have this node as ascendant
  127075. * @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
  127076. * @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
  127077. * @return all children nodes of all types
  127078. */
  127079. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  127080. var results = new Array();
  127081. this._getDescendants(results, directDescendantsOnly, predicate);
  127082. return results;
  127083. };
  127084. /**
  127085. * Get all child-meshes of this node
  127086. * @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
  127087. * @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
  127088. * @returns an array of AbstractMesh
  127089. */
  127090. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  127091. var results = [];
  127092. this._getDescendants(results, directDescendantsOnly, function (node) {
  127093. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  127094. });
  127095. return results;
  127096. };
  127097. /**
  127098. * Get all direct children of this node
  127099. * @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
  127100. * @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)
  127101. * @returns an array of Node
  127102. */
  127103. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  127104. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  127105. return this.getDescendants(directDescendantsOnly, predicate);
  127106. };
  127107. /** @hidden */
  127108. Node.prototype._setReady = function (state) {
  127109. if (state === this._isReady) {
  127110. return;
  127111. }
  127112. if (!state) {
  127113. this._isReady = false;
  127114. return;
  127115. }
  127116. if (this.onReady) {
  127117. this.onReady(this);
  127118. }
  127119. this._isReady = true;
  127120. };
  127121. /**
  127122. * Get an animation by name
  127123. * @param name defines the name of the animation to look for
  127124. * @returns null if not found else the requested animation
  127125. */
  127126. Node.prototype.getAnimationByName = function (name) {
  127127. for (var i = 0; i < this.animations.length; i++) {
  127128. var animation = this.animations[i];
  127129. if (animation.name === name) {
  127130. return animation;
  127131. }
  127132. }
  127133. return null;
  127134. };
  127135. /**
  127136. * Creates an animation range for this node
  127137. * @param name defines the name of the range
  127138. * @param from defines the starting key
  127139. * @param to defines the end key
  127140. */
  127141. Node.prototype.createAnimationRange = function (name, from, to) {
  127142. // check name not already in use
  127143. if (!this._ranges[name]) {
  127144. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  127145. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127146. if (this.animations[i]) {
  127147. this.animations[i].createRange(name, from, to);
  127148. }
  127149. }
  127150. }
  127151. };
  127152. /**
  127153. * Delete a specific animation range
  127154. * @param name defines the name of the range to delete
  127155. * @param deleteFrames defines if animation frames from the range must be deleted as well
  127156. */
  127157. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  127158. if (deleteFrames === void 0) { deleteFrames = true; }
  127159. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127160. if (this.animations[i]) {
  127161. this.animations[i].deleteRange(name, deleteFrames);
  127162. }
  127163. }
  127164. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  127165. };
  127166. /**
  127167. * Get an animation range by name
  127168. * @param name defines the name of the animation range to look for
  127169. * @returns null if not found else the requested animation range
  127170. */
  127171. Node.prototype.getAnimationRange = function (name) {
  127172. return this._ranges[name];
  127173. };
  127174. /**
  127175. * Will start the animation sequence
  127176. * @param name defines the range frames for animation sequence
  127177. * @param loop defines if the animation should loop (false by default)
  127178. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  127179. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  127180. * @returns the object created for this animation. If range does not exist, it will return null
  127181. */
  127182. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  127183. var range = this.getAnimationRange(name);
  127184. if (!range) {
  127185. return null;
  127186. }
  127187. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  127188. };
  127189. /**
  127190. * Serialize animation ranges into a JSON compatible object
  127191. * @returns serialization object
  127192. */
  127193. Node.prototype.serializeAnimationRanges = function () {
  127194. var serializationRanges = [];
  127195. for (var name in this._ranges) {
  127196. var localRange = this._ranges[name];
  127197. if (!localRange) {
  127198. continue;
  127199. }
  127200. var range = {};
  127201. range.name = name;
  127202. range.from = localRange.from;
  127203. range.to = localRange.to;
  127204. serializationRanges.push(range);
  127205. }
  127206. return serializationRanges;
  127207. };
  127208. /**
  127209. * Computes the world matrix of the node
  127210. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  127211. * @returns the world matrix
  127212. */
  127213. Node.prototype.computeWorldMatrix = function (force) {
  127214. if (!this._worldMatrix) {
  127215. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127216. }
  127217. return this._worldMatrix;
  127218. };
  127219. /**
  127220. * Releases resources associated with this node.
  127221. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127222. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127223. */
  127224. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  127225. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  127226. this._isDisposed = true;
  127227. if (!doNotRecurse) {
  127228. var nodes = this.getDescendants(true);
  127229. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  127230. var node = nodes_1[_i];
  127231. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  127232. }
  127233. }
  127234. if (!this.parent) {
  127235. this.removeFromSceneRootNodes();
  127236. }
  127237. else {
  127238. this.parent = null;
  127239. }
  127240. // Callback
  127241. this.onDisposeObservable.notifyObservers(this);
  127242. this.onDisposeObservable.clear();
  127243. // Behaviors
  127244. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  127245. var behavior = _b[_a];
  127246. behavior.detach();
  127247. }
  127248. this._behaviors = [];
  127249. };
  127250. /**
  127251. * Parse animation range data from a serialization object and store them into a given node
  127252. * @param node defines where to store the animation ranges
  127253. * @param parsedNode defines the serialization object to read data from
  127254. * @param scene defines the hosting scene
  127255. */
  127256. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  127257. if (parsedNode.ranges) {
  127258. for (var index = 0; index < parsedNode.ranges.length; index++) {
  127259. var data = parsedNode.ranges[index];
  127260. node.createAnimationRange(data.name, data.from, data.to);
  127261. }
  127262. }
  127263. };
  127264. /** @hidden */
  127265. Node._AnimationRangeFactory = function (name, from, to) {
  127266. throw "AnimationRange needs to be imported from animation before being created.";
  127267. };
  127268. Node._NodeConstructors = {};
  127269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127271. ], Node.prototype, "name", void 0);
  127272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127274. ], Node.prototype, "id", void 0);
  127275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127277. ], Node.prototype, "uniqueId", void 0);
  127278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127280. ], Node.prototype, "state", void 0);
  127281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127283. ], Node.prototype, "metadata", void 0);
  127284. return Node;
  127285. }());
  127286. /***/ }),
  127287. /***/ "./scene.ts":
  127288. /*!******************!*\
  127289. !*** ./scene.ts ***!
  127290. \******************/
  127291. /*! exports provided: Scene */
  127292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127293. "use strict";
  127294. __webpack_require__.r(__webpack_exports__);
  127295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  127296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127297. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  127298. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  127299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127300. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  127301. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  127302. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  127303. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127304. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127305. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  127306. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127307. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  127308. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  127309. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  127310. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127311. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  127312. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  127313. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  127314. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  127315. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  127316. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127317. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Culling/ray */ "./Culling/ray.ts");
  127318. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  127319. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  127320. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  127321. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127322. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  127323. /** @hidden */
  127324. var ClickInfo = /** @class */ (function () {
  127325. function ClickInfo() {
  127326. this._singleClick = false;
  127327. this._doubleClick = false;
  127328. this._hasSwiped = false;
  127329. this._ignore = false;
  127330. }
  127331. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  127332. get: function () {
  127333. return this._singleClick;
  127334. },
  127335. set: function (b) {
  127336. this._singleClick = b;
  127337. },
  127338. enumerable: true,
  127339. configurable: true
  127340. });
  127341. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  127342. get: function () {
  127343. return this._doubleClick;
  127344. },
  127345. set: function (b) {
  127346. this._doubleClick = b;
  127347. },
  127348. enumerable: true,
  127349. configurable: true
  127350. });
  127351. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  127352. get: function () {
  127353. return this._hasSwiped;
  127354. },
  127355. set: function (b) {
  127356. this._hasSwiped = b;
  127357. },
  127358. enumerable: true,
  127359. configurable: true
  127360. });
  127361. Object.defineProperty(ClickInfo.prototype, "ignore", {
  127362. get: function () {
  127363. return this._ignore;
  127364. },
  127365. set: function (b) {
  127366. this._ignore = b;
  127367. },
  127368. enumerable: true,
  127369. configurable: true
  127370. });
  127371. return ClickInfo;
  127372. }());
  127373. /**
  127374. * Represents a scene to be rendered by the engine.
  127375. * @see http://doc.babylonjs.com/features/scene
  127376. */
  127377. var Scene = /** @class */ (function (_super) {
  127378. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  127379. /**
  127380. * Creates a new Scene
  127381. * @param engine defines the engine to use to render this scene
  127382. * @param options defines the scene options
  127383. */
  127384. function Scene(engine, options) {
  127385. var _this = _super.call(this) || this;
  127386. // Members
  127387. /** @hidden */
  127388. _this._isScene = true;
  127389. /**
  127390. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  127391. */
  127392. _this.autoClear = true;
  127393. /**
  127394. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  127395. */
  127396. _this.autoClearDepthAndStencil = true;
  127397. /**
  127398. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  127399. */
  127400. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  127401. /**
  127402. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  127403. */
  127404. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  127405. _this._forceWireframe = false;
  127406. _this._forcePointsCloud = false;
  127407. /**
  127408. * Gets or sets a boolean indicating if animations are enabled
  127409. */
  127410. _this.animationsEnabled = true;
  127411. _this._animationPropertiesOverride = null;
  127412. /**
  127413. * Gets or sets a boolean indicating if a constant deltatime has to be used
  127414. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  127415. */
  127416. _this.useConstantAnimationDeltaTime = false;
  127417. /**
  127418. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  127419. * Please note that it requires to run a ray cast through the scene on every frame
  127420. */
  127421. _this.constantlyUpdateMeshUnderPointer = false;
  127422. /**
  127423. * Defines the HTML cursor to use when hovering over interactive elements
  127424. */
  127425. _this.hoverCursor = "pointer";
  127426. /**
  127427. * Defines the HTML default cursor to use (empty by default)
  127428. */
  127429. _this.defaultCursor = "";
  127430. /**
  127431. * This is used to call preventDefault() on pointer down
  127432. * in order to block unwanted artifacts like system double clicks
  127433. */
  127434. _this.preventDefaultOnPointerDown = true;
  127435. /**
  127436. * This is used to call preventDefault() on pointer up
  127437. * in order to block unwanted artifacts like system double clicks
  127438. */
  127439. _this.preventDefaultOnPointerUp = true;
  127440. // Metadata
  127441. /**
  127442. * Gets or sets user defined metadata
  127443. */
  127444. _this.metadata = null;
  127445. /**
  127446. * For internal use only. Please do not use.
  127447. */
  127448. _this.reservedDataStore = null;
  127449. /**
  127450. * Use this array to add regular expressions used to disable offline support for specific urls
  127451. */
  127452. _this.disableOfflineSupportExceptionRules = new Array();
  127453. /**
  127454. * An event triggered when the scene is disposed.
  127455. */
  127456. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127457. _this._onDisposeObserver = null;
  127458. /**
  127459. * An event triggered before rendering the scene (right after animations and physics)
  127460. */
  127461. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127462. _this._onBeforeRenderObserver = null;
  127463. /**
  127464. * An event triggered after rendering the scene
  127465. */
  127466. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127467. _this._onAfterRenderObserver = null;
  127468. /**
  127469. * An event triggered before animating the scene
  127470. */
  127471. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127472. /**
  127473. * An event triggered after animations processing
  127474. */
  127475. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127476. /**
  127477. * An event triggered before draw calls are ready to be sent
  127478. */
  127479. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127480. /**
  127481. * An event triggered after draw calls have been sent
  127482. */
  127483. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127484. /**
  127485. * An event triggered when the scene is ready
  127486. */
  127487. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127488. /**
  127489. * An event triggered before rendering a camera
  127490. */
  127491. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127492. _this._onBeforeCameraRenderObserver = null;
  127493. /**
  127494. * An event triggered after rendering a camera
  127495. */
  127496. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127497. _this._onAfterCameraRenderObserver = null;
  127498. /**
  127499. * An event triggered when active meshes evaluation is about to start
  127500. */
  127501. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127502. /**
  127503. * An event triggered when active meshes evaluation is done
  127504. */
  127505. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127506. /**
  127507. * An event triggered when particles rendering is about to start
  127508. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127509. */
  127510. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127511. /**
  127512. * An event triggered when particles rendering is done
  127513. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127514. */
  127515. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127516. /**
  127517. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  127518. */
  127519. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127520. /**
  127521. * An event triggered when a camera is created
  127522. */
  127523. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127524. /**
  127525. * An event triggered when a camera is removed
  127526. */
  127527. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127528. /**
  127529. * An event triggered when a light is created
  127530. */
  127531. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127532. /**
  127533. * An event triggered when a light is removed
  127534. */
  127535. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127536. /**
  127537. * An event triggered when a geometry is created
  127538. */
  127539. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127540. /**
  127541. * An event triggered when a geometry is removed
  127542. */
  127543. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127544. /**
  127545. * An event triggered when a transform node is created
  127546. */
  127547. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127548. /**
  127549. * An event triggered when a transform node is removed
  127550. */
  127551. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127552. /**
  127553. * An event triggered when a mesh is created
  127554. */
  127555. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127556. /**
  127557. * An event triggered when a mesh is removed
  127558. */
  127559. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127560. /**
  127561. * An event triggered when a material is created
  127562. */
  127563. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127564. /**
  127565. * An event triggered when a material is removed
  127566. */
  127567. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127568. /**
  127569. * An event triggered when a texture is created
  127570. */
  127571. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127572. /**
  127573. * An event triggered when a texture is removed
  127574. */
  127575. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127576. /**
  127577. * An event triggered when render targets are about to be rendered
  127578. * Can happen multiple times per frame.
  127579. */
  127580. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127581. /**
  127582. * An event triggered when render targets were rendered.
  127583. * Can happen multiple times per frame.
  127584. */
  127585. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127586. /**
  127587. * An event triggered before calculating deterministic simulation step
  127588. */
  127589. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127590. /**
  127591. * An event triggered after calculating deterministic simulation step
  127592. */
  127593. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127594. /**
  127595. * An event triggered when the activeCamera property is updated
  127596. */
  127597. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127598. /**
  127599. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  127600. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  127601. * 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)
  127602. */
  127603. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127604. /**
  127605. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  127606. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  127607. * 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)
  127608. */
  127609. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127610. /**
  127611. * This Observable will when a mesh has been imported into the scene.
  127612. */
  127613. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127614. // Animations
  127615. /** @hidden */
  127616. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127617. /**
  127618. * 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).
  127619. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  127620. */
  127621. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127622. /**
  127623. * Observable event triggered each time an input event is received from the rendering canvas
  127624. */
  127625. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127626. _this._meshPickProceed = false;
  127627. _this._currentPickResult = null;
  127628. _this._previousPickResult = null;
  127629. _this._totalPointersPressed = 0;
  127630. _this._doubleClickOccured = false;
  127631. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  127632. _this.cameraToUseForPointers = null;
  127633. _this._pointerX = 0;
  127634. _this._pointerY = 0;
  127635. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  127636. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  127637. _this._startingPointerTime = 0;
  127638. _this._previousStartingPointerTime = 0;
  127639. _this._pointerCaptures = {};
  127640. // Deterministic lockstep
  127641. _this._timeAccumulator = 0;
  127642. _this._currentStepId = 0;
  127643. _this._currentInternalStep = 0;
  127644. // Keyboard
  127645. /**
  127646. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  127647. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  127648. */
  127649. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127650. /**
  127651. * Observable event triggered each time an keyboard event is received from the hosting window
  127652. */
  127653. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127654. // Coordinates system
  127655. _this._useRightHandedSystem = false;
  127656. // Fog
  127657. _this._fogEnabled = true;
  127658. _this._fogMode = Scene.FOGMODE_NONE;
  127659. /**
  127660. * Gets or sets the fog color to use
  127661. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127662. * (Default is Color3(0.2, 0.2, 0.3))
  127663. */
  127664. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  127665. /**
  127666. * Gets or sets the fog density to use
  127667. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127668. * (Default is 0.1)
  127669. */
  127670. _this.fogDensity = 0.1;
  127671. /**
  127672. * Gets or sets the fog start distance to use
  127673. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127674. * (Default is 0)
  127675. */
  127676. _this.fogStart = 0;
  127677. /**
  127678. * Gets or sets the fog end distance to use
  127679. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127680. * (Default is 1000)
  127681. */
  127682. _this.fogEnd = 1000.0;
  127683. // Lights
  127684. _this._shadowsEnabled = true;
  127685. _this._lightsEnabled = true;
  127686. /** All of the active cameras added to this scene. */
  127687. _this.activeCameras = new Array();
  127688. // Textures
  127689. _this._texturesEnabled = true;
  127690. // Particles
  127691. /**
  127692. * Gets or sets a boolean indicating if particles are enabled on this scene
  127693. */
  127694. _this.particlesEnabled = true;
  127695. // Sprites
  127696. /**
  127697. * Gets or sets a boolean indicating if sprites are enabled on this scene
  127698. */
  127699. _this.spritesEnabled = true;
  127700. // Skeletons
  127701. _this._skeletonsEnabled = true;
  127702. // Lens flares
  127703. /**
  127704. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  127705. */
  127706. _this.lensFlaresEnabled = true;
  127707. // Collisions
  127708. /**
  127709. * Gets or sets a boolean indicating if collisions are enabled on this scene
  127710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  127711. */
  127712. _this.collisionsEnabled = true;
  127713. /**
  127714. * Defines the gravity applied to this scene (used only for collisions)
  127715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  127716. */
  127717. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  127718. // Postprocesses
  127719. /**
  127720. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  127721. */
  127722. _this.postProcessesEnabled = true;
  127723. /**
  127724. * The list of postprocesses added to the scene
  127725. */
  127726. _this.postProcesses = new Array();
  127727. // Customs render targets
  127728. /**
  127729. * Gets or sets a boolean indicating if render targets are enabled on this scene
  127730. */
  127731. _this.renderTargetsEnabled = true;
  127732. /**
  127733. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  127734. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  127735. */
  127736. _this.dumpNextRenderTargets = false;
  127737. /**
  127738. * The list of user defined render targets added to the scene
  127739. */
  127740. _this.customRenderTargets = new Array();
  127741. /**
  127742. * Gets the list of meshes imported to the scene through SceneLoader
  127743. */
  127744. _this.importedMeshesFiles = new Array();
  127745. // Probes
  127746. /**
  127747. * Gets or sets a boolean indicating if probes are enabled on this scene
  127748. */
  127749. _this.probesEnabled = true;
  127750. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127751. // Procedural textures
  127752. /**
  127753. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  127754. */
  127755. _this.proceduralTexturesEnabled = true;
  127756. // Performance counters
  127757. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127758. /** @hidden */
  127759. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127760. /** @hidden */
  127761. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127762. /** @hidden */
  127763. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  127764. /** @hidden */
  127765. _this._animationTime = 0;
  127766. /**
  127767. * Gets or sets a general scale for animation speed
  127768. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  127769. */
  127770. _this.animationTimeScale = 1;
  127771. _this._renderId = 0;
  127772. _this._frameId = 0;
  127773. _this._executeWhenReadyTimeoutId = -1;
  127774. _this._intermediateRendering = false;
  127775. _this._viewUpdateFlag = -1;
  127776. _this._projectionUpdateFlag = -1;
  127777. _this._alternateViewUpdateFlag = -1;
  127778. _this._alternateProjectionUpdateFlag = -1;
  127779. /** @hidden */
  127780. _this._toBeDisposed = new Array(256);
  127781. _this._activeRequests = new Array();
  127782. /** @hidden */
  127783. _this._pendingData = new Array();
  127784. _this._isDisposed = false;
  127785. /**
  127786. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  127787. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  127788. */
  127789. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  127790. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127791. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127792. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  127793. /** @hidden */
  127794. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  127795. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  127796. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  127797. /** @hidden */
  127798. _this._activeAnimatables = new Array();
  127799. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  127800. _this._useAlternateCameraConfiguration = false;
  127801. _this._alternateRendering = false;
  127802. _this._wheelEventName = "";
  127803. /**
  127804. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  127805. * This is useful if there are more lights that the maximum simulteanous authorized
  127806. */
  127807. _this.requireLightSorting = false;
  127808. /**
  127809. * @hidden
  127810. * Backing store of defined scene components.
  127811. */
  127812. _this._components = [];
  127813. /**
  127814. * @hidden
  127815. * Backing store of defined scene components.
  127816. */
  127817. _this._serializableComponents = [];
  127818. /**
  127819. * List of components to register on the next registration step.
  127820. */
  127821. _this._transientComponents = [];
  127822. /**
  127823. * @hidden
  127824. * Defines the actions happening before camera updates.
  127825. */
  127826. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127827. /**
  127828. * @hidden
  127829. * Defines the actions happening before clear the canvas.
  127830. */
  127831. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127832. /**
  127833. * @hidden
  127834. * Defines the actions when collecting render targets for the frame.
  127835. */
  127836. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127837. /**
  127838. * @hidden
  127839. * Defines the actions happening for one camera in the frame.
  127840. */
  127841. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127842. /**
  127843. * @hidden
  127844. * Defines the actions happening during the per mesh ready checks.
  127845. */
  127846. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127847. /**
  127848. * @hidden
  127849. * Defines the actions happening before evaluate active mesh checks.
  127850. */
  127851. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127852. /**
  127853. * @hidden
  127854. * Defines the actions happening during the evaluate sub mesh checks.
  127855. */
  127856. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127857. /**
  127858. * @hidden
  127859. * Defines the actions happening during the active mesh stage.
  127860. */
  127861. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127862. /**
  127863. * @hidden
  127864. * Defines the actions happening during the per camera render target step.
  127865. */
  127866. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127867. /**
  127868. * @hidden
  127869. * Defines the actions happening just before the active camera is drawing.
  127870. */
  127871. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127872. /**
  127873. * @hidden
  127874. * Defines the actions happening just before a render target is drawing.
  127875. */
  127876. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127877. /**
  127878. * @hidden
  127879. * Defines the actions happening just before a rendering group is drawing.
  127880. */
  127881. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127882. /**
  127883. * @hidden
  127884. * Defines the actions happening just before a mesh is drawing.
  127885. */
  127886. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127887. /**
  127888. * @hidden
  127889. * Defines the actions happening just after a mesh has been drawn.
  127890. */
  127891. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127892. /**
  127893. * @hidden
  127894. * Defines the actions happening just after a rendering group has been drawn.
  127895. */
  127896. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127897. /**
  127898. * @hidden
  127899. * Defines the actions happening just after the active camera has been drawn.
  127900. */
  127901. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127902. /**
  127903. * @hidden
  127904. * Defines the actions happening just after a render target has been drawn.
  127905. */
  127906. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127907. /**
  127908. * @hidden
  127909. * Defines the actions happening just after rendering all cameras and computing intersections.
  127910. */
  127911. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127912. /**
  127913. * @hidden
  127914. * Defines the actions happening when a pointer move event happens.
  127915. */
  127916. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127917. /**
  127918. * @hidden
  127919. * Defines the actions happening when a pointer down event happens.
  127920. */
  127921. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127922. /**
  127923. * @hidden
  127924. * Defines the actions happening when a pointer up event happens.
  127925. */
  127926. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  127927. /**
  127928. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  127929. */
  127930. _this.geometriesByUniqueId = null;
  127931. _this._defaultMeshCandidates = {
  127932. data: [],
  127933. length: 0
  127934. };
  127935. _this._defaultSubMeshCandidates = {
  127936. data: [],
  127937. length: 0
  127938. };
  127939. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  127940. _this._activeMeshesFrozen = false;
  127941. /** @hidden */
  127942. _this._allowPostProcessClearColor = true;
  127943. /**
  127944. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  127945. */
  127946. _this.getDeterministicFrameTime = function () {
  127947. return 1000.0 / 60.0; // frame time in ms
  127948. };
  127949. _this._tempPickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].Zero() : null;
  127950. _this._blockMaterialDirtyMechanism = false;
  127951. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__["EngineStore"].LastCreatedEngine;
  127952. _this._engine.scenes.push(_this);
  127953. _this._uid = null;
  127954. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  127955. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  127956. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  127957. }
  127958. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__["DomManagement"].IsWindowObjectExist()) {
  127959. _this.attachControl();
  127960. }
  127961. // Uniform Buffer
  127962. _this._createUbo();
  127963. // Default Image processing definition
  127964. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  127965. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  127966. }
  127967. _this.setDefaultCandidateProviders();
  127968. if (options && options.useGeometryUniqueIdsMap === true) {
  127969. _this.geometriesByUniqueId = {};
  127970. }
  127971. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  127972. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  127973. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  127974. return _this;
  127975. }
  127976. /**
  127977. * Factory used to create the default material.
  127978. * @param name The name of the material to create
  127979. * @param scene The scene to create the material for
  127980. * @returns The default material
  127981. */
  127982. Scene.DefaultMaterialFactory = function (scene) {
  127983. throw "Import StandardMaterial or set DefaultMaterialFactory static property on scene before relying on default material creation.";
  127984. };
  127985. /**
  127986. * Factory used to create the a collision coordinator.
  127987. * @returns The collision coordinator
  127988. */
  127989. Scene.CollisionCoordinatorFactory = function () {
  127990. throw "Import DefaultCollisionCoordinator or set CollisionCoordinatorFactory static property on scene to enable collisions.";
  127991. };
  127992. Object.defineProperty(Scene.prototype, "environmentTexture", {
  127993. /**
  127994. * Texture used in all pbr material as the reflection texture.
  127995. * As in the majority of the scene they are the same (exception for multi room and so on),
  127996. * this is easier to reference from here than from all the materials.
  127997. */
  127998. get: function () {
  127999. return this._environmentTexture;
  128000. },
  128001. /**
  128002. * Texture used in all pbr material as the reflection texture.
  128003. * As in the majority of the scene they are the same (exception for multi room and so on),
  128004. * this is easier to set here than in all the materials.
  128005. */
  128006. set: function (value) {
  128007. if (this._environmentTexture === value) {
  128008. return;
  128009. }
  128010. this._environmentTexture = value;
  128011. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  128012. },
  128013. enumerable: true,
  128014. configurable: true
  128015. });
  128016. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  128017. /**
  128018. * Default image processing configuration used either in the rendering
  128019. * Forward main pass or through the imageProcessingPostProcess if present.
  128020. * As in the majority of the scene they are the same (exception for multi camera),
  128021. * this is easier to reference from here than from all the materials and post process.
  128022. *
  128023. * No setter as we it is a shared configuration, you can set the values instead.
  128024. */
  128025. get: function () {
  128026. return this._imageProcessingConfiguration;
  128027. },
  128028. enumerable: true,
  128029. configurable: true
  128030. });
  128031. Object.defineProperty(Scene.prototype, "forceWireframe", {
  128032. get: function () {
  128033. return this._forceWireframe;
  128034. },
  128035. /**
  128036. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  128037. */
  128038. set: function (value) {
  128039. if (this._forceWireframe === value) {
  128040. return;
  128041. }
  128042. this._forceWireframe = value;
  128043. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  128044. },
  128045. enumerable: true,
  128046. configurable: true
  128047. });
  128048. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  128049. get: function () {
  128050. return this._forcePointsCloud;
  128051. },
  128052. /**
  128053. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  128054. */
  128055. set: function (value) {
  128056. if (this._forcePointsCloud === value) {
  128057. return;
  128058. }
  128059. this._forcePointsCloud = value;
  128060. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  128061. },
  128062. enumerable: true,
  128063. configurable: true
  128064. });
  128065. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  128066. /**
  128067. * Gets or sets the animation properties override
  128068. */
  128069. get: function () {
  128070. return this._animationPropertiesOverride;
  128071. },
  128072. set: function (value) {
  128073. this._animationPropertiesOverride = value;
  128074. },
  128075. enumerable: true,
  128076. configurable: true
  128077. });
  128078. Object.defineProperty(Scene.prototype, "onDispose", {
  128079. /** Sets a function to be executed when this scene is disposed. */
  128080. set: function (callback) {
  128081. if (this._onDisposeObserver) {
  128082. this.onDisposeObservable.remove(this._onDisposeObserver);
  128083. }
  128084. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  128085. },
  128086. enumerable: true,
  128087. configurable: true
  128088. });
  128089. Object.defineProperty(Scene.prototype, "beforeRender", {
  128090. /** Sets a function to be executed before rendering this scene */
  128091. set: function (callback) {
  128092. if (this._onBeforeRenderObserver) {
  128093. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  128094. }
  128095. if (callback) {
  128096. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  128097. }
  128098. },
  128099. enumerable: true,
  128100. configurable: true
  128101. });
  128102. Object.defineProperty(Scene.prototype, "afterRender", {
  128103. /** Sets a function to be executed after rendering this scene */
  128104. set: function (callback) {
  128105. if (this._onAfterRenderObserver) {
  128106. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  128107. }
  128108. if (callback) {
  128109. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  128110. }
  128111. },
  128112. enumerable: true,
  128113. configurable: true
  128114. });
  128115. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  128116. /** Sets a function to be executed before rendering a camera*/
  128117. set: function (callback) {
  128118. if (this._onBeforeCameraRenderObserver) {
  128119. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  128120. }
  128121. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  128122. },
  128123. enumerable: true,
  128124. configurable: true
  128125. });
  128126. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  128127. /** Sets a function to be executed after rendering a camera*/
  128128. set: function (callback) {
  128129. if (this._onAfterCameraRenderObserver) {
  128130. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  128131. }
  128132. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  128133. },
  128134. enumerable: true,
  128135. configurable: true
  128136. });
  128137. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  128138. /**
  128139. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  128140. */
  128141. get: function () {
  128142. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  128143. },
  128144. enumerable: true,
  128145. configurable: true
  128146. });
  128147. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  128148. get: function () {
  128149. return this._useRightHandedSystem;
  128150. },
  128151. /**
  128152. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  128153. */
  128154. set: function (value) {
  128155. if (this._useRightHandedSystem === value) {
  128156. return;
  128157. }
  128158. this._useRightHandedSystem = value;
  128159. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  128160. },
  128161. enumerable: true,
  128162. configurable: true
  128163. });
  128164. /**
  128165. * Sets the step Id used by deterministic lock step
  128166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128167. * @param newStepId defines the step Id
  128168. */
  128169. Scene.prototype.setStepId = function (newStepId) {
  128170. this._currentStepId = newStepId;
  128171. };
  128172. /**
  128173. * Gets the step Id used by deterministic lock step
  128174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128175. * @returns the step Id
  128176. */
  128177. Scene.prototype.getStepId = function () {
  128178. return this._currentStepId;
  128179. };
  128180. /**
  128181. * Gets the internal step used by deterministic lock step
  128182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128183. * @returns the internal step
  128184. */
  128185. Scene.prototype.getInternalStep = function () {
  128186. return this._currentInternalStep;
  128187. };
  128188. Object.defineProperty(Scene.prototype, "fogEnabled", {
  128189. get: function () {
  128190. return this._fogEnabled;
  128191. },
  128192. /**
  128193. * Gets or sets a boolean indicating if fog is enabled on this scene
  128194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128195. * (Default is true)
  128196. */
  128197. set: function (value) {
  128198. if (this._fogEnabled === value) {
  128199. return;
  128200. }
  128201. this._fogEnabled = value;
  128202. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  128203. },
  128204. enumerable: true,
  128205. configurable: true
  128206. });
  128207. Object.defineProperty(Scene.prototype, "fogMode", {
  128208. get: function () {
  128209. return this._fogMode;
  128210. },
  128211. /**
  128212. * Gets or sets the fog mode to use
  128213. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128214. * | mode | value |
  128215. * | --- | --- |
  128216. * | FOGMODE_NONE | 0 |
  128217. * | FOGMODE_EXP | 1 |
  128218. * | FOGMODE_EXP2 | 2 |
  128219. * | FOGMODE_LINEAR | 3 |
  128220. */
  128221. set: function (value) {
  128222. if (this._fogMode === value) {
  128223. return;
  128224. }
  128225. this._fogMode = value;
  128226. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  128227. },
  128228. enumerable: true,
  128229. configurable: true
  128230. });
  128231. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  128232. get: function () {
  128233. return this._shadowsEnabled;
  128234. },
  128235. /**
  128236. * Gets or sets a boolean indicating if shadows are enabled on this scene
  128237. */
  128238. set: function (value) {
  128239. if (this._shadowsEnabled === value) {
  128240. return;
  128241. }
  128242. this._shadowsEnabled = value;
  128243. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  128244. },
  128245. enumerable: true,
  128246. configurable: true
  128247. });
  128248. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  128249. get: function () {
  128250. return this._lightsEnabled;
  128251. },
  128252. /**
  128253. * Gets or sets a boolean indicating if lights are enabled on this scene
  128254. */
  128255. set: function (value) {
  128256. if (this._lightsEnabled === value) {
  128257. return;
  128258. }
  128259. this._lightsEnabled = value;
  128260. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  128261. },
  128262. enumerable: true,
  128263. configurable: true
  128264. });
  128265. Object.defineProperty(Scene.prototype, "activeCamera", {
  128266. /** Gets or sets the current active camera */
  128267. get: function () {
  128268. return this._activeCamera;
  128269. },
  128270. set: function (value) {
  128271. if (value === this._activeCamera) {
  128272. return;
  128273. }
  128274. this._activeCamera = value;
  128275. this.onActiveCameraChanged.notifyObservers(this);
  128276. },
  128277. enumerable: true,
  128278. configurable: true
  128279. });
  128280. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  128281. /** The default material used on meshes when no material is affected */
  128282. get: function () {
  128283. if (!this._defaultMaterial) {
  128284. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  128285. }
  128286. return this._defaultMaterial;
  128287. },
  128288. /** The default material used on meshes when no material is affected */
  128289. set: function (value) {
  128290. this._defaultMaterial = value;
  128291. },
  128292. enumerable: true,
  128293. configurable: true
  128294. });
  128295. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  128296. get: function () {
  128297. return this._texturesEnabled;
  128298. },
  128299. /**
  128300. * Gets or sets a boolean indicating if textures are enabled on this scene
  128301. */
  128302. set: function (value) {
  128303. if (this._texturesEnabled === value) {
  128304. return;
  128305. }
  128306. this._texturesEnabled = value;
  128307. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  128308. },
  128309. enumerable: true,
  128310. configurable: true
  128311. });
  128312. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  128313. get: function () {
  128314. return this._skeletonsEnabled;
  128315. },
  128316. /**
  128317. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  128318. */
  128319. set: function (value) {
  128320. if (this._skeletonsEnabled === value) {
  128321. return;
  128322. }
  128323. this._skeletonsEnabled = value;
  128324. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AttributesDirtyFlag);
  128325. },
  128326. enumerable: true,
  128327. configurable: true
  128328. });
  128329. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  128330. /** @hidden */
  128331. get: function () {
  128332. if (!this._collisionCoordinator) {
  128333. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  128334. this._collisionCoordinator.init(this);
  128335. }
  128336. return this._collisionCoordinator;
  128337. },
  128338. enumerable: true,
  128339. configurable: true
  128340. });
  128341. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  128342. /** @hidden */
  128343. get: function () {
  128344. return this._alternateRendering;
  128345. },
  128346. enumerable: true,
  128347. configurable: true
  128348. });
  128349. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  128350. /**
  128351. * Gets the list of frustum planes (built from the active camera)
  128352. */
  128353. get: function () {
  128354. return this._frustumPlanes;
  128355. },
  128356. enumerable: true,
  128357. configurable: true
  128358. });
  128359. /**
  128360. * Registers the transient components if needed.
  128361. */
  128362. Scene.prototype._registerTransientComponents = function () {
  128363. // Register components that have been associated lately to the scene.
  128364. if (this._transientComponents.length > 0) {
  128365. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  128366. var component = _a[_i];
  128367. component.register();
  128368. }
  128369. this._transientComponents = [];
  128370. }
  128371. };
  128372. /**
  128373. * @hidden
  128374. * Add a component to the scene.
  128375. * Note that the ccomponent could be registered on th next frame if this is called after
  128376. * the register component stage.
  128377. * @param component Defines the component to add to the scene
  128378. */
  128379. Scene.prototype._addComponent = function (component) {
  128380. this._components.push(component);
  128381. this._transientComponents.push(component);
  128382. var serializableComponent = component;
  128383. if (serializableComponent.addFromContainer) {
  128384. this._serializableComponents.push(serializableComponent);
  128385. }
  128386. };
  128387. /**
  128388. * @hidden
  128389. * Gets a component from the scene.
  128390. * @param name defines the name of the component to retrieve
  128391. * @returns the component or null if not present
  128392. */
  128393. Scene.prototype._getComponent = function (name) {
  128394. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  128395. var component = _a[_i];
  128396. if (component.name === name) {
  128397. return component;
  128398. }
  128399. }
  128400. return null;
  128401. };
  128402. /**
  128403. * @hidden
  128404. */
  128405. Scene.prototype._getDefaultMeshCandidates = function () {
  128406. this._defaultMeshCandidates.data = this.meshes;
  128407. this._defaultMeshCandidates.length = this.meshes.length;
  128408. return this._defaultMeshCandidates;
  128409. };
  128410. /**
  128411. * @hidden
  128412. */
  128413. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  128414. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  128415. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  128416. return this._defaultSubMeshCandidates;
  128417. };
  128418. /**
  128419. * Sets the default candidate providers for the scene.
  128420. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  128421. * and getCollidingSubMeshCandidates to their default function
  128422. */
  128423. Scene.prototype.setDefaultCandidateProviders = function () {
  128424. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  128425. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128426. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128427. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128428. };
  128429. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  128430. /**
  128431. * Gets the mesh that is currently under the pointer
  128432. */
  128433. get: function () {
  128434. return this._pointerOverMesh;
  128435. },
  128436. enumerable: true,
  128437. configurable: true
  128438. });
  128439. Object.defineProperty(Scene.prototype, "pointerX", {
  128440. /**
  128441. * Gets or sets the current on-screen X position of the pointer
  128442. */
  128443. get: function () {
  128444. return this._pointerX;
  128445. },
  128446. set: function (value) {
  128447. this._pointerX = value;
  128448. },
  128449. enumerable: true,
  128450. configurable: true
  128451. });
  128452. Object.defineProperty(Scene.prototype, "pointerY", {
  128453. /**
  128454. * Gets or sets the current on-screen Y position of the pointer
  128455. */
  128456. get: function () {
  128457. return this._pointerY;
  128458. },
  128459. set: function (value) {
  128460. this._pointerY = value;
  128461. },
  128462. enumerable: true,
  128463. configurable: true
  128464. });
  128465. /**
  128466. * Gets the cached material (ie. the latest rendered one)
  128467. * @returns the cached material
  128468. */
  128469. Scene.prototype.getCachedMaterial = function () {
  128470. return this._cachedMaterial;
  128471. };
  128472. /**
  128473. * Gets the cached effect (ie. the latest rendered one)
  128474. * @returns the cached effect
  128475. */
  128476. Scene.prototype.getCachedEffect = function () {
  128477. return this._cachedEffect;
  128478. };
  128479. /**
  128480. * Gets the cached visibility state (ie. the latest rendered one)
  128481. * @returns the cached visibility state
  128482. */
  128483. Scene.prototype.getCachedVisibility = function () {
  128484. return this._cachedVisibility;
  128485. };
  128486. /**
  128487. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  128488. * @param material defines the current material
  128489. * @param effect defines the current effect
  128490. * @param visibility defines the current visibility state
  128491. * @returns true if one parameter is not cached
  128492. */
  128493. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  128494. if (visibility === void 0) { visibility = 1; }
  128495. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  128496. };
  128497. /**
  128498. * Gets the engine associated with the scene
  128499. * @returns an Engine
  128500. */
  128501. Scene.prototype.getEngine = function () {
  128502. return this._engine;
  128503. };
  128504. /**
  128505. * Gets the total number of vertices rendered per frame
  128506. * @returns the total number of vertices rendered per frame
  128507. */
  128508. Scene.prototype.getTotalVertices = function () {
  128509. return this._totalVertices.current;
  128510. };
  128511. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  128512. /**
  128513. * Gets the performance counter for total vertices
  128514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128515. */
  128516. get: function () {
  128517. return this._totalVertices;
  128518. },
  128519. enumerable: true,
  128520. configurable: true
  128521. });
  128522. /**
  128523. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  128524. * @returns the total number of active indices rendered per frame
  128525. */
  128526. Scene.prototype.getActiveIndices = function () {
  128527. return this._activeIndices.current;
  128528. };
  128529. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  128530. /**
  128531. * Gets the performance counter for active indices
  128532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128533. */
  128534. get: function () {
  128535. return this._activeIndices;
  128536. },
  128537. enumerable: true,
  128538. configurable: true
  128539. });
  128540. /**
  128541. * Gets the total number of active particles rendered per frame
  128542. * @returns the total number of active particles rendered per frame
  128543. */
  128544. Scene.prototype.getActiveParticles = function () {
  128545. return this._activeParticles.current;
  128546. };
  128547. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  128548. /**
  128549. * Gets the performance counter for active particles
  128550. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128551. */
  128552. get: function () {
  128553. return this._activeParticles;
  128554. },
  128555. enumerable: true,
  128556. configurable: true
  128557. });
  128558. /**
  128559. * Gets the total number of active bones rendered per frame
  128560. * @returns the total number of active bones rendered per frame
  128561. */
  128562. Scene.prototype.getActiveBones = function () {
  128563. return this._activeBones.current;
  128564. };
  128565. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  128566. /**
  128567. * Gets the performance counter for active bones
  128568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128569. */
  128570. get: function () {
  128571. return this._activeBones;
  128572. },
  128573. enumerable: true,
  128574. configurable: true
  128575. });
  128576. /**
  128577. * Gets the array of active meshes
  128578. * @returns an array of AbstractMesh
  128579. */
  128580. Scene.prototype.getActiveMeshes = function () {
  128581. return this._activeMeshes;
  128582. };
  128583. /**
  128584. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  128585. * @returns a number
  128586. */
  128587. Scene.prototype.getAnimationRatio = function () {
  128588. return this._animationRatio !== undefined ? this._animationRatio : 1;
  128589. };
  128590. /**
  128591. * Gets an unique Id for the current render phase
  128592. * @returns a number
  128593. */
  128594. Scene.prototype.getRenderId = function () {
  128595. return this._renderId;
  128596. };
  128597. /**
  128598. * Gets an unique Id for the current frame
  128599. * @returns a number
  128600. */
  128601. Scene.prototype.getFrameId = function () {
  128602. return this._frameId;
  128603. };
  128604. /** Call this function if you want to manually increment the render Id*/
  128605. Scene.prototype.incrementRenderId = function () {
  128606. this._renderId++;
  128607. };
  128608. Scene.prototype._updatePointerPosition = function (evt) {
  128609. var canvasRect = this._engine.getRenderingCanvasClientRect();
  128610. if (!canvasRect) {
  128611. return;
  128612. }
  128613. this._pointerX = evt.clientX - canvasRect.left;
  128614. this._pointerY = evt.clientY - canvasRect.top;
  128615. this._unTranslatedPointerX = this._pointerX;
  128616. this._unTranslatedPointerY = this._pointerY;
  128617. };
  128618. Scene.prototype._createUbo = function () {
  128619. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  128620. this._sceneUbo.addUniform("viewProjection", 16);
  128621. this._sceneUbo.addUniform("view", 16);
  128622. };
  128623. Scene.prototype._createAlternateUbo = function () {
  128624. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  128625. this._alternateSceneUbo.addUniform("viewProjection", 16);
  128626. this._alternateSceneUbo.addUniform("view", 16);
  128627. };
  128628. // Pointers handling
  128629. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  128630. if (pointerInfo.pickInfo) {
  128631. if (!pointerInfo.pickInfo.ray) {
  128632. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  128633. }
  128634. }
  128635. };
  128636. /**
  128637. * Use this method to simulate a pointer move on a mesh
  128638. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128639. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128640. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128641. * @returns the current scene
  128642. */
  128643. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  128644. var evt = new PointerEvent("pointermove", pointerEventInit);
  128645. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  128646. return this;
  128647. }
  128648. return this._processPointerMove(pickResult, evt);
  128649. };
  128650. Scene.prototype._processPointerMove = function (pickResult, evt) {
  128651. var canvas = this._engine.getRenderingCanvas();
  128652. if (!canvas) {
  128653. return this;
  128654. }
  128655. // Restore pointer
  128656. canvas.style.cursor = this.defaultCursor;
  128657. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  128658. if (isMeshPicked) {
  128659. this.setPointerOverMesh(pickResult.pickedMesh);
  128660. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  128661. if (this._pointerOverMesh.actionManager.hoverCursor) {
  128662. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  128663. }
  128664. else {
  128665. canvas.style.cursor = this.hoverCursor;
  128666. }
  128667. }
  128668. }
  128669. else {
  128670. this.setPointerOverMesh(null);
  128671. }
  128672. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  128673. var step = _a[_i];
  128674. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  128675. }
  128676. if (pickResult) {
  128677. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  128678. if (this.onPointerMove) {
  128679. this.onPointerMove(evt, pickResult, type);
  128680. }
  128681. if (this.onPointerObservable.hasObservers()) {
  128682. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  128683. this._setRayOnPointerInfo(pi);
  128684. this.onPointerObservable.notifyObservers(pi, type);
  128685. }
  128686. }
  128687. return this;
  128688. };
  128689. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  128690. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  128691. if (pickResult) {
  128692. pi.ray = pickResult.ray;
  128693. }
  128694. this.onPrePointerObservable.notifyObservers(pi, type);
  128695. if (pi.skipOnPointerObservable) {
  128696. return true;
  128697. }
  128698. else {
  128699. return false;
  128700. }
  128701. };
  128702. /**
  128703. * Use this method to simulate a pointer down on a mesh
  128704. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128705. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128706. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128707. * @returns the current scene
  128708. */
  128709. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  128710. var evt = new PointerEvent("pointerdown", pointerEventInit);
  128711. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  128712. return this;
  128713. }
  128714. return this._processPointerDown(pickResult, evt);
  128715. };
  128716. Scene.prototype._processPointerDown = function (pickResult, evt) {
  128717. var _this = this;
  128718. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  128719. this._pickedDownMesh = pickResult.pickedMesh;
  128720. var actionManager = pickResult.pickedMesh.actionManager;
  128721. if (actionManager) {
  128722. if (actionManager.hasPickTriggers) {
  128723. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128724. switch (evt.button) {
  128725. case 0:
  128726. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128727. break;
  128728. case 1:
  128729. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128730. break;
  128731. case 2:
  128732. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128733. break;
  128734. }
  128735. }
  128736. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger)) {
  128737. window.setTimeout(function () {
  128738. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  128739. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  128740. if (_this._totalPointersPressed !== 0 &&
  128741. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  128742. !_this._isPointerSwiping()) {
  128743. _this._startingPointerTime = 0;
  128744. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128745. }
  128746. }
  128747. }, Scene.LongPressDelay);
  128748. }
  128749. }
  128750. }
  128751. else {
  128752. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  128753. var step = _a[_i];
  128754. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  128755. }
  128756. }
  128757. if (pickResult) {
  128758. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  128759. if (this.onPointerDown) {
  128760. this.onPointerDown(evt, pickResult, type);
  128761. }
  128762. if (this.onPointerObservable.hasObservers()) {
  128763. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  128764. this._setRayOnPointerInfo(pi);
  128765. this.onPointerObservable.notifyObservers(pi, type);
  128766. }
  128767. }
  128768. return this;
  128769. };
  128770. /**
  128771. * Use this method to simulate a pointer up on a mesh
  128772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128775. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128776. * @returns the current scene
  128777. */
  128778. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  128779. var evt = new PointerEvent("pointerup", pointerEventInit);
  128780. var clickInfo = new ClickInfo();
  128781. if (doubleTap) {
  128782. clickInfo.doubleClick = true;
  128783. }
  128784. else {
  128785. clickInfo.singleClick = true;
  128786. }
  128787. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  128788. return this;
  128789. }
  128790. return this._processPointerUp(pickResult, evt, clickInfo);
  128791. };
  128792. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  128793. if (pickResult && pickResult && pickResult.pickedMesh) {
  128794. this._pickedUpMesh = pickResult.pickedMesh;
  128795. if (this._pickedDownMesh === this._pickedUpMesh) {
  128796. if (this.onPointerPick) {
  128797. this.onPointerPick(evt, pickResult);
  128798. }
  128799. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  128800. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  128801. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  128802. this._setRayOnPointerInfo(pi);
  128803. this.onPointerObservable.notifyObservers(pi, type_1);
  128804. }
  128805. }
  128806. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  128807. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128808. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  128809. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128810. }
  128811. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  128812. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128813. }
  128814. }
  128815. }
  128816. else {
  128817. if (!clickInfo.ignore) {
  128818. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  128819. var step = _a[_i];
  128820. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  128821. }
  128822. }
  128823. }
  128824. if (this._pickedDownMesh &&
  128825. this._pickedDownMesh.actionManager &&
  128826. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger) &&
  128827. this._pickedDownMesh !== this._pickedUpMesh) {
  128828. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  128829. }
  128830. var type = 0;
  128831. if (this.onPointerObservable.hasObservers()) {
  128832. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  128833. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  128834. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  128835. }
  128836. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128837. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  128838. }
  128839. if (type) {
  128840. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  128841. this._setRayOnPointerInfo(pi);
  128842. this.onPointerObservable.notifyObservers(pi, type);
  128843. }
  128844. }
  128845. if (!clickInfo.ignore) {
  128846. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  128847. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  128848. this._setRayOnPointerInfo(pi);
  128849. this.onPointerObservable.notifyObservers(pi, type);
  128850. }
  128851. }
  128852. if (this.onPointerUp && !clickInfo.ignore) {
  128853. this.onPointerUp(evt, pickResult, type);
  128854. }
  128855. return this;
  128856. };
  128857. /**
  128858. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128859. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128860. * @returns true if the pointer was captured
  128861. */
  128862. Scene.prototype.isPointerCaptured = function (pointerId) {
  128863. if (pointerId === void 0) { pointerId = 0; }
  128864. return this._pointerCaptures[pointerId];
  128865. };
  128866. /** @hidden */
  128867. Scene.prototype._isPointerSwiping = function () {
  128868. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  128869. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  128870. };
  128871. /**
  128872. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128873. * @param attachUp defines if you want to attach events to pointerup
  128874. * @param attachDown defines if you want to attach events to pointerdown
  128875. * @param attachMove defines if you want to attach events to pointermove
  128876. */
  128877. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  128878. var _this = this;
  128879. if (attachUp === void 0) { attachUp = true; }
  128880. if (attachDown === void 0) { attachDown = true; }
  128881. if (attachMove === void 0) { attachMove = true; }
  128882. this._initActionManager = function (act, clickInfo) {
  128883. if (!_this._meshPickProceed) {
  128884. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  128885. _this._currentPickResult = pickResult;
  128886. if (pickResult) {
  128887. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  128888. }
  128889. _this._meshPickProceed = true;
  128890. }
  128891. return act;
  128892. };
  128893. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  128894. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  128895. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  128896. btn !== _this._previousButtonPressed) {
  128897. _this._doubleClickOccured = false;
  128898. clickInfo.singleClick = true;
  128899. clickInfo.ignore = false;
  128900. cb(clickInfo, _this._currentPickResult);
  128901. }
  128902. };
  128903. this._initClickEvent = function (obs1, obs2, evt, cb) {
  128904. var clickInfo = new ClickInfo();
  128905. _this._currentPickResult = null;
  128906. var act = null;
  128907. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  128908. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  128909. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  128910. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"]) {
  128911. act = _this._initActionManager(act, clickInfo);
  128912. if (act) {
  128913. checkPicking = act.hasPickTriggers;
  128914. }
  128915. }
  128916. var needToIgnoreNext = false;
  128917. if (checkPicking) {
  128918. var btn = evt.button;
  128919. clickInfo.hasSwiped = _this._isPointerSwiping();
  128920. if (!clickInfo.hasSwiped) {
  128921. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  128922. if (!checkSingleClickImmediately) {
  128923. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  128924. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  128925. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  128926. act = _this._initActionManager(act, clickInfo);
  128927. if (act) {
  128928. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  128929. }
  128930. }
  128931. }
  128932. if (checkSingleClickImmediately) {
  128933. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  128934. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  128935. btn !== _this._previousButtonPressed) {
  128936. clickInfo.singleClick = true;
  128937. cb(clickInfo, _this._currentPickResult);
  128938. needToIgnoreNext = true;
  128939. }
  128940. }
  128941. // at least one double click is required to be check and exclusive double click is enabled
  128942. else {
  128943. // wait that no double click has been raised during the double click delay
  128944. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128945. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  128946. }
  128947. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  128948. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  128949. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  128950. act = _this._initActionManager(act, clickInfo);
  128951. if (act) {
  128952. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  128953. }
  128954. }
  128955. if (checkDoubleClick) {
  128956. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  128957. if (btn === _this._previousButtonPressed &&
  128958. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  128959. !_this._doubleClickOccured) {
  128960. // pointer has not moved for 2 clicks, it's a double click
  128961. if (!clickInfo.hasSwiped &&
  128962. !_this._isPointerSwiping()) {
  128963. _this._previousStartingPointerTime = 0;
  128964. _this._doubleClickOccured = true;
  128965. clickInfo.doubleClick = true;
  128966. clickInfo.ignore = false;
  128967. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  128968. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128969. }
  128970. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128971. cb(clickInfo, _this._currentPickResult);
  128972. }
  128973. // if the two successive clicks are too far, it's just two simple clicks
  128974. else {
  128975. _this._doubleClickOccured = false;
  128976. _this._previousStartingPointerTime = _this._startingPointerTime;
  128977. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128978. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128979. _this._previousButtonPressed = btn;
  128980. if (Scene.ExclusiveDoubleClickMode) {
  128981. if (_this._previousDelayedSimpleClickTimeout) {
  128982. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128983. }
  128984. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128985. cb(clickInfo, _this._previousPickResult);
  128986. }
  128987. else {
  128988. cb(clickInfo, _this._currentPickResult);
  128989. }
  128990. }
  128991. needToIgnoreNext = true;
  128992. }
  128993. // just the first click of the double has been raised
  128994. else {
  128995. _this._doubleClickOccured = false;
  128996. _this._previousStartingPointerTime = _this._startingPointerTime;
  128997. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128998. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128999. _this._previousButtonPressed = btn;
  129000. }
  129001. }
  129002. }
  129003. }
  129004. if (!needToIgnoreNext) {
  129005. cb(clickInfo, _this._currentPickResult);
  129006. }
  129007. };
  129008. this._onPointerMove = function (evt) {
  129009. _this._updatePointerPosition(evt);
  129010. // PreObservable support
  129011. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  129012. return;
  129013. }
  129014. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129015. return;
  129016. }
  129017. if (!_this.pointerMovePredicate) {
  129018. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  129019. }
  129020. // Meshes
  129021. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  129022. _this._processPointerMove(pickResult, evt);
  129023. };
  129024. this._onPointerDown = function (evt) {
  129025. _this._totalPointersPressed++;
  129026. _this._pickedDownMesh = null;
  129027. _this._meshPickProceed = false;
  129028. _this._updatePointerPosition(evt);
  129029. if (_this.preventDefaultOnPointerDown && canvas) {
  129030. evt.preventDefault();
  129031. canvas.focus();
  129032. }
  129033. _this._startingPointerPosition.x = _this._pointerX;
  129034. _this._startingPointerPosition.y = _this._pointerY;
  129035. _this._startingPointerTime = Date.now();
  129036. // PreObservable support
  129037. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129038. return;
  129039. }
  129040. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129041. return;
  129042. }
  129043. _this._pointerCaptures[evt.pointerId] = true;
  129044. if (!_this.pointerDownPredicate) {
  129045. _this.pointerDownPredicate = function (mesh) {
  129046. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129047. };
  129048. }
  129049. // Meshes
  129050. _this._pickedDownMesh = null;
  129051. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129052. _this._processPointerDown(pickResult, evt);
  129053. };
  129054. this._onPointerUp = function (evt) {
  129055. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  129056. return; // So we need to test it the pointer down was pressed before.
  129057. }
  129058. _this._totalPointersPressed--;
  129059. _this._pickedUpMesh = null;
  129060. _this._meshPickProceed = false;
  129061. _this._updatePointerPosition(evt);
  129062. if (_this.preventDefaultOnPointerUp && canvas) {
  129063. evt.preventDefault();
  129064. canvas.focus();
  129065. }
  129066. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  129067. _this._pointerCaptures[evt.pointerId] = false;
  129068. // PreObservable support
  129069. if (_this.onPrePointerObservable.hasObservers()) {
  129070. if (!clickInfo.ignore) {
  129071. if (!clickInfo.hasSwiped) {
  129072. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129073. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129074. return;
  129075. }
  129076. }
  129077. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129078. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129079. return;
  129080. }
  129081. }
  129082. }
  129083. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129084. return;
  129085. }
  129086. }
  129087. }
  129088. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129089. return;
  129090. }
  129091. if (!_this.pointerUpPredicate) {
  129092. _this.pointerUpPredicate = function (mesh) {
  129093. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129094. };
  129095. }
  129096. // Meshes
  129097. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  129098. _this._initActionManager(null, clickInfo);
  129099. }
  129100. if (!pickResult) {
  129101. pickResult = _this._currentPickResult;
  129102. }
  129103. _this._processPointerUp(pickResult, evt, clickInfo);
  129104. _this._previousPickResult = _this._currentPickResult;
  129105. });
  129106. };
  129107. this._onKeyDown = function (evt) {
  129108. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  129109. if (_this.onPreKeyboardObservable.hasObservers()) {
  129110. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129111. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129112. if (pi.skipOnPointerObservable) {
  129113. return;
  129114. }
  129115. }
  129116. if (_this.onKeyboardObservable.hasObservers()) {
  129117. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129118. _this.onKeyboardObservable.notifyObservers(pi, type);
  129119. }
  129120. if (_this.actionManager) {
  129121. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129122. }
  129123. };
  129124. this._onKeyUp = function (evt) {
  129125. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  129126. if (_this.onPreKeyboardObservable.hasObservers()) {
  129127. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129128. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129129. if (pi.skipOnPointerObservable) {
  129130. return;
  129131. }
  129132. }
  129133. if (_this.onKeyboardObservable.hasObservers()) {
  129134. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129135. _this.onKeyboardObservable.notifyObservers(pi, type);
  129136. }
  129137. if (_this.actionManager) {
  129138. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129139. }
  129140. };
  129141. var engine = this.getEngine();
  129142. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  129143. if (!canvas) {
  129144. return;
  129145. }
  129146. canvas.addEventListener("keydown", _this._onKeyDown, false);
  129147. canvas.addEventListener("keyup", _this._onKeyUp, false);
  129148. });
  129149. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  129150. if (!canvas) {
  129151. return;
  129152. }
  129153. canvas.removeEventListener("keydown", _this._onKeyDown);
  129154. canvas.removeEventListener("keyup", _this._onKeyUp);
  129155. });
  129156. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129157. var canvas = this._engine.getRenderingCanvas();
  129158. if (!canvas) {
  129159. return;
  129160. }
  129161. if (attachMove) {
  129162. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  129163. // Wheel
  129164. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  129165. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  129166. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  129167. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  129168. }
  129169. if (attachDown) {
  129170. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  129171. }
  129172. if (attachUp) {
  129173. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  129174. }
  129175. canvas.tabIndex = 1;
  129176. };
  129177. /** Detaches all event handlers*/
  129178. Scene.prototype.detachControl = function () {
  129179. var engine = this.getEngine();
  129180. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129181. var canvas = engine.getRenderingCanvas();
  129182. if (!canvas) {
  129183. return;
  129184. }
  129185. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  129186. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  129187. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  129188. if (this._onCanvasBlurObserver) {
  129189. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  129190. }
  129191. if (this._onCanvasFocusObserver) {
  129192. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  129193. }
  129194. // Wheel
  129195. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  129196. // Keyboard
  129197. canvas.removeEventListener("keydown", this._onKeyDown);
  129198. canvas.removeEventListener("keyup", this._onKeyUp);
  129199. // Observables
  129200. this.onKeyboardObservable.clear();
  129201. this.onPreKeyboardObservable.clear();
  129202. this.onPointerObservable.clear();
  129203. this.onPrePointerObservable.clear();
  129204. };
  129205. /**
  129206. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  129207. * Delay loaded resources are not taking in account
  129208. * @return true if all required resources are ready
  129209. */
  129210. Scene.prototype.isReady = function () {
  129211. if (this._isDisposed) {
  129212. return false;
  129213. }
  129214. var index;
  129215. var engine = this.getEngine();
  129216. // Effects
  129217. if (!engine.areAllEffectsReady()) {
  129218. return false;
  129219. }
  129220. // Pending data
  129221. if (this._pendingData.length > 0) {
  129222. return false;
  129223. }
  129224. // Meshes
  129225. for (index = 0; index < this.meshes.length; index++) {
  129226. var mesh = this.meshes[index];
  129227. if (!mesh.isEnabled()) {
  129228. continue;
  129229. }
  129230. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  129231. continue;
  129232. }
  129233. if (!mesh.isReady(true)) {
  129234. return false;
  129235. }
  129236. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  129237. // Is Ready For Mesh
  129238. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  129239. var step = _a[_i];
  129240. if (!step.action(mesh, hardwareInstancedRendering)) {
  129241. return false;
  129242. }
  129243. }
  129244. }
  129245. // Geometries
  129246. for (index = 0; index < this.geometries.length; index++) {
  129247. var geometry = this.geometries[index];
  129248. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].DELAYLOADSTATE_LOADING) {
  129249. return false;
  129250. }
  129251. }
  129252. // Post-processes
  129253. if (this.activeCameras && this.activeCameras.length > 0) {
  129254. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  129255. var camera = _c[_b];
  129256. if (!camera.isReady(true)) {
  129257. return false;
  129258. }
  129259. }
  129260. }
  129261. else if (this.activeCamera) {
  129262. if (!this.activeCamera.isReady(true)) {
  129263. return false;
  129264. }
  129265. }
  129266. // Particles
  129267. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  129268. var particleSystem = _e[_d];
  129269. if (!particleSystem.isReady()) {
  129270. return false;
  129271. }
  129272. }
  129273. return true;
  129274. };
  129275. /** Resets all cached information relative to material (including effect and visibility) */
  129276. Scene.prototype.resetCachedMaterial = function () {
  129277. this._cachedMaterial = null;
  129278. this._cachedEffect = null;
  129279. this._cachedVisibility = null;
  129280. };
  129281. /**
  129282. * Registers a function to be called before every frame render
  129283. * @param func defines the function to register
  129284. */
  129285. Scene.prototype.registerBeforeRender = function (func) {
  129286. this.onBeforeRenderObservable.add(func);
  129287. };
  129288. /**
  129289. * Unregisters a function called before every frame render
  129290. * @param func defines the function to unregister
  129291. */
  129292. Scene.prototype.unregisterBeforeRender = function (func) {
  129293. this.onBeforeRenderObservable.removeCallback(func);
  129294. };
  129295. /**
  129296. * Registers a function to be called after every frame render
  129297. * @param func defines the function to register
  129298. */
  129299. Scene.prototype.registerAfterRender = function (func) {
  129300. this.onAfterRenderObservable.add(func);
  129301. };
  129302. /**
  129303. * Unregisters a function called after every frame render
  129304. * @param func defines the function to unregister
  129305. */
  129306. Scene.prototype.unregisterAfterRender = function (func) {
  129307. this.onAfterRenderObservable.removeCallback(func);
  129308. };
  129309. Scene.prototype._executeOnceBeforeRender = function (func) {
  129310. var _this = this;
  129311. var execFunc = function () {
  129312. func();
  129313. setTimeout(function () {
  129314. _this.unregisterBeforeRender(execFunc);
  129315. });
  129316. };
  129317. this.registerBeforeRender(execFunc);
  129318. };
  129319. /**
  129320. * The provided function will run before render once and will be disposed afterwards.
  129321. * A timeout delay can be provided so that the function will be executed in N ms.
  129322. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  129323. * @param func The function to be executed.
  129324. * @param timeout optional delay in ms
  129325. */
  129326. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  129327. var _this = this;
  129328. if (timeout !== undefined) {
  129329. setTimeout(function () {
  129330. _this._executeOnceBeforeRender(func);
  129331. }, timeout);
  129332. }
  129333. else {
  129334. this._executeOnceBeforeRender(func);
  129335. }
  129336. };
  129337. /** @hidden */
  129338. Scene.prototype._addPendingData = function (data) {
  129339. this._pendingData.push(data);
  129340. };
  129341. /** @hidden */
  129342. Scene.prototype._removePendingData = function (data) {
  129343. var wasLoading = this.isLoading;
  129344. var index = this._pendingData.indexOf(data);
  129345. if (index !== -1) {
  129346. this._pendingData.splice(index, 1);
  129347. }
  129348. if (wasLoading && !this.isLoading) {
  129349. this.onDataLoadedObservable.notifyObservers(this);
  129350. }
  129351. };
  129352. /**
  129353. * Returns the number of items waiting to be loaded
  129354. * @returns the number of items waiting to be loaded
  129355. */
  129356. Scene.prototype.getWaitingItemsCount = function () {
  129357. return this._pendingData.length;
  129358. };
  129359. Object.defineProperty(Scene.prototype, "isLoading", {
  129360. /**
  129361. * Returns a boolean indicating if the scene is still loading data
  129362. */
  129363. get: function () {
  129364. return this._pendingData.length > 0;
  129365. },
  129366. enumerable: true,
  129367. configurable: true
  129368. });
  129369. /**
  129370. * Registers a function to be executed when the scene is ready
  129371. * @param {Function} func - the function to be executed
  129372. */
  129373. Scene.prototype.executeWhenReady = function (func) {
  129374. var _this = this;
  129375. this.onReadyObservable.add(func);
  129376. if (this._executeWhenReadyTimeoutId !== -1) {
  129377. return;
  129378. }
  129379. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129380. _this._checkIsReady();
  129381. }, 150);
  129382. };
  129383. /**
  129384. * Returns a promise that resolves when the scene is ready
  129385. * @returns A promise that resolves when the scene is ready
  129386. */
  129387. Scene.prototype.whenReadyAsync = function () {
  129388. var _this = this;
  129389. return new Promise(function (resolve) {
  129390. _this.executeWhenReady(function () {
  129391. resolve();
  129392. });
  129393. });
  129394. };
  129395. /** @hidden */
  129396. Scene.prototype._checkIsReady = function () {
  129397. var _this = this;
  129398. this._registerTransientComponents();
  129399. if (this.isReady()) {
  129400. this.onReadyObservable.notifyObservers(this);
  129401. this.onReadyObservable.clear();
  129402. this._executeWhenReadyTimeoutId = -1;
  129403. return;
  129404. }
  129405. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129406. _this._checkIsReady();
  129407. }, 150);
  129408. };
  129409. Object.defineProperty(Scene.prototype, "animatables", {
  129410. /**
  129411. * Gets all animatable attached to the scene
  129412. */
  129413. get: function () {
  129414. return this._activeAnimatables;
  129415. },
  129416. enumerable: true,
  129417. configurable: true
  129418. });
  129419. /**
  129420. * Resets the last animation time frame.
  129421. * Useful to override when animations start running when loading a scene for the first time.
  129422. */
  129423. Scene.prototype.resetLastAnimationTimeFrame = function () {
  129424. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  129425. };
  129426. // Matrix
  129427. /** @hidden */
  129428. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129429. this._useAlternateCameraConfiguration = active;
  129430. };
  129431. /**
  129432. * Gets the current view matrix
  129433. * @returns a Matrix
  129434. */
  129435. Scene.prototype.getViewMatrix = function () {
  129436. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129437. };
  129438. /**
  129439. * Gets the current projection matrix
  129440. * @returns a Matrix
  129441. */
  129442. Scene.prototype.getProjectionMatrix = function () {
  129443. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129444. };
  129445. /**
  129446. * Gets the current transform matrix
  129447. * @returns a Matrix made of View * Projection
  129448. */
  129449. Scene.prototype.getTransformMatrix = function () {
  129450. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129451. };
  129452. /**
  129453. * Sets the current transform matrix
  129454. * @param view defines the View matrix to use
  129455. * @param projection defines the Projection matrix to use
  129456. */
  129457. Scene.prototype.setTransformMatrix = function (view, projection) {
  129458. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129459. return;
  129460. }
  129461. this._viewUpdateFlag = view.updateFlag;
  129462. this._projectionUpdateFlag = projection.updateFlag;
  129463. this._viewMatrix = view;
  129464. this._projectionMatrix = projection;
  129465. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129466. // Update frustum
  129467. if (!this._frustumPlanes) {
  129468. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129469. }
  129470. else {
  129471. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129472. }
  129473. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129474. var otherCamera = this.activeCamera._alternateCamera;
  129475. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129476. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetRightPlaneToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  129477. }
  129478. if (this._sceneUbo.useUbo) {
  129479. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129480. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129481. this._sceneUbo.update();
  129482. }
  129483. };
  129484. /** @hidden */
  129485. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129486. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129487. return;
  129488. }
  129489. this._alternateViewUpdateFlag = view.updateFlag;
  129490. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129491. this._alternateViewMatrix = view;
  129492. this._alternateProjectionMatrix = projection;
  129493. if (!this._alternateTransformMatrix) {
  129494. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129495. }
  129496. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129497. if (!this._alternateSceneUbo) {
  129498. this._createAlternateUbo();
  129499. }
  129500. if (this._alternateSceneUbo.useUbo) {
  129501. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129502. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129503. this._alternateSceneUbo.update();
  129504. }
  129505. };
  129506. /**
  129507. * Gets the uniform buffer used to store scene data
  129508. * @returns a UniformBuffer
  129509. */
  129510. Scene.prototype.getSceneUniformBuffer = function () {
  129511. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129512. };
  129513. /**
  129514. * Gets an unique (relatively to the current scene) Id
  129515. * @returns an unique number for the scene
  129516. */
  129517. Scene.prototype.getUniqueId = function () {
  129518. var result = Scene._uniqueIdCounter;
  129519. Scene._uniqueIdCounter++;
  129520. return result;
  129521. };
  129522. /**
  129523. * Add a mesh to the list of scene's meshes
  129524. * @param newMesh defines the mesh to add
  129525. * @param recursive if all child meshes should also be added to the scene
  129526. */
  129527. Scene.prototype.addMesh = function (newMesh, recursive) {
  129528. var _this = this;
  129529. if (recursive === void 0) { recursive = false; }
  129530. this.meshes.push(newMesh);
  129531. newMesh._resyncLightSources();
  129532. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  129533. if (recursive) {
  129534. newMesh.getChildMeshes().forEach(function (m) {
  129535. _this.addMesh(m);
  129536. });
  129537. }
  129538. };
  129539. /**
  129540. * Remove a mesh for the list of scene's meshes
  129541. * @param toRemove defines the mesh to remove
  129542. * @param recursive if all child meshes should also be removed from the scene
  129543. * @returns the index where the mesh was in the mesh list
  129544. */
  129545. Scene.prototype.removeMesh = function (toRemove, recursive) {
  129546. var _this = this;
  129547. if (recursive === void 0) { recursive = false; }
  129548. var index = this.meshes.indexOf(toRemove);
  129549. if (index !== -1) {
  129550. // Remove from the scene if mesh found
  129551. this.meshes[index] = this.meshes[this.meshes.length - 1];
  129552. this.meshes.pop();
  129553. }
  129554. this.onMeshRemovedObservable.notifyObservers(toRemove);
  129555. if (recursive) {
  129556. toRemove.getChildMeshes().forEach(function (m) {
  129557. _this.removeMesh(m);
  129558. });
  129559. }
  129560. return index;
  129561. };
  129562. /**
  129563. * Add a transform node to the list of scene's transform nodes
  129564. * @param newTransformNode defines the transform node to add
  129565. */
  129566. Scene.prototype.addTransformNode = function (newTransformNode) {
  129567. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  129568. this.transformNodes.push(newTransformNode);
  129569. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  129570. };
  129571. /**
  129572. * Remove a transform node for the list of scene's transform nodes
  129573. * @param toRemove defines the transform node to remove
  129574. * @returns the index where the transform node was in the transform node list
  129575. */
  129576. Scene.prototype.removeTransformNode = function (toRemove) {
  129577. var index = toRemove._indexInSceneTransformNodesArray;
  129578. if (index !== -1) {
  129579. if (index !== this.transformNodes.length - 1) {
  129580. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  129581. this.transformNodes[index] = lastNode;
  129582. lastNode._indexInSceneTransformNodesArray = index;
  129583. }
  129584. toRemove._indexInSceneTransformNodesArray = -1;
  129585. this.transformNodes.pop();
  129586. }
  129587. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  129588. return index;
  129589. };
  129590. /**
  129591. * Remove a skeleton for the list of scene's skeletons
  129592. * @param toRemove defines the skeleton to remove
  129593. * @returns the index where the skeleton was in the skeleton list
  129594. */
  129595. Scene.prototype.removeSkeleton = function (toRemove) {
  129596. var index = this.skeletons.indexOf(toRemove);
  129597. if (index !== -1) {
  129598. // Remove from the scene if found
  129599. this.skeletons.splice(index, 1);
  129600. }
  129601. return index;
  129602. };
  129603. /**
  129604. * Remove a morph target for the list of scene's morph targets
  129605. * @param toRemove defines the morph target to remove
  129606. * @returns the index where the morph target was in the morph target list
  129607. */
  129608. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  129609. var index = this.morphTargetManagers.indexOf(toRemove);
  129610. if (index !== -1) {
  129611. // Remove from the scene if found
  129612. this.morphTargetManagers.splice(index, 1);
  129613. }
  129614. return index;
  129615. };
  129616. /**
  129617. * Remove a light for the list of scene's lights
  129618. * @param toRemove defines the light to remove
  129619. * @returns the index where the light was in the light list
  129620. */
  129621. Scene.prototype.removeLight = function (toRemove) {
  129622. var index = this.lights.indexOf(toRemove);
  129623. if (index !== -1) {
  129624. // Remove from meshes
  129625. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129626. var mesh = _a[_i];
  129627. mesh._removeLightSource(toRemove);
  129628. }
  129629. // Remove from the scene if mesh found
  129630. this.lights.splice(index, 1);
  129631. this.sortLightsByPriority();
  129632. }
  129633. this.onLightRemovedObservable.notifyObservers(toRemove);
  129634. return index;
  129635. };
  129636. /**
  129637. * Remove a camera for the list of scene's cameras
  129638. * @param toRemove defines the camera to remove
  129639. * @returns the index where the camera was in the camera list
  129640. */
  129641. Scene.prototype.removeCamera = function (toRemove) {
  129642. var index = this.cameras.indexOf(toRemove);
  129643. if (index !== -1) {
  129644. // Remove from the scene if mesh found
  129645. this.cameras.splice(index, 1);
  129646. }
  129647. // Remove from activeCameras
  129648. var index2 = this.activeCameras.indexOf(toRemove);
  129649. if (index2 !== -1) {
  129650. // Remove from the scene if mesh found
  129651. this.activeCameras.splice(index2, 1);
  129652. }
  129653. // Reset the activeCamera
  129654. if (this.activeCamera === toRemove) {
  129655. if (this.cameras.length > 0) {
  129656. this.activeCamera = this.cameras[0];
  129657. }
  129658. else {
  129659. this.activeCamera = null;
  129660. }
  129661. }
  129662. this.onCameraRemovedObservable.notifyObservers(toRemove);
  129663. return index;
  129664. };
  129665. /**
  129666. * Remove a particle system for the list of scene's particle systems
  129667. * @param toRemove defines the particle system to remove
  129668. * @returns the index where the particle system was in the particle system list
  129669. */
  129670. Scene.prototype.removeParticleSystem = function (toRemove) {
  129671. var index = this.particleSystems.indexOf(toRemove);
  129672. if (index !== -1) {
  129673. this.particleSystems.splice(index, 1);
  129674. }
  129675. return index;
  129676. };
  129677. /**
  129678. * Remove a animation for the list of scene's animations
  129679. * @param toRemove defines the animation to remove
  129680. * @returns the index where the animation was in the animation list
  129681. */
  129682. Scene.prototype.removeAnimation = function (toRemove) {
  129683. var index = this.animations.indexOf(toRemove);
  129684. if (index !== -1) {
  129685. this.animations.splice(index, 1);
  129686. }
  129687. return index;
  129688. };
  129689. /**
  129690. * Removes the given animation group from this scene.
  129691. * @param toRemove The animation group to remove
  129692. * @returns The index of the removed animation group
  129693. */
  129694. Scene.prototype.removeAnimationGroup = function (toRemove) {
  129695. var index = this.animationGroups.indexOf(toRemove);
  129696. if (index !== -1) {
  129697. this.animationGroups.splice(index, 1);
  129698. }
  129699. return index;
  129700. };
  129701. /**
  129702. * Removes the given multi-material from this scene.
  129703. * @param toRemove The multi-material to remove
  129704. * @returns The index of the removed multi-material
  129705. */
  129706. Scene.prototype.removeMultiMaterial = function (toRemove) {
  129707. var index = this.multiMaterials.indexOf(toRemove);
  129708. if (index !== -1) {
  129709. this.multiMaterials.splice(index, 1);
  129710. }
  129711. return index;
  129712. };
  129713. /**
  129714. * Removes the given material from this scene.
  129715. * @param toRemove The material to remove
  129716. * @returns The index of the removed material
  129717. */
  129718. Scene.prototype.removeMaterial = function (toRemove) {
  129719. var index = toRemove._indexInSceneMaterialArray;
  129720. if (index !== -1 && index < this.materials.length) {
  129721. if (index !== this.materials.length - 1) {
  129722. var lastMaterial = this.materials[this.materials.length - 1];
  129723. this.materials[index] = lastMaterial;
  129724. lastMaterial._indexInSceneMaterialArray = index;
  129725. }
  129726. toRemove._indexInSceneMaterialArray = -1;
  129727. this.materials.pop();
  129728. }
  129729. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  129730. return index;
  129731. };
  129732. /**
  129733. * Removes the given action manager from this scene.
  129734. * @param toRemove The action manager to remove
  129735. * @returns The index of the removed action manager
  129736. */
  129737. Scene.prototype.removeActionManager = function (toRemove) {
  129738. var index = this.actionManagers.indexOf(toRemove);
  129739. if (index !== -1) {
  129740. this.actionManagers.splice(index, 1);
  129741. }
  129742. return index;
  129743. };
  129744. /**
  129745. * Removes the given texture from this scene.
  129746. * @param toRemove The texture to remove
  129747. * @returns The index of the removed texture
  129748. */
  129749. Scene.prototype.removeTexture = function (toRemove) {
  129750. var index = this.textures.indexOf(toRemove);
  129751. if (index !== -1) {
  129752. this.textures.splice(index, 1);
  129753. }
  129754. this.onTextureRemovedObservable.notifyObservers(toRemove);
  129755. return index;
  129756. };
  129757. /**
  129758. * Adds the given light to this scene
  129759. * @param newLight The light to add
  129760. */
  129761. Scene.prototype.addLight = function (newLight) {
  129762. this.lights.push(newLight);
  129763. this.sortLightsByPriority();
  129764. // Add light to all meshes (To support if the light is removed and then readded)
  129765. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129766. var mesh = _a[_i];
  129767. if (mesh._lightSources.indexOf(newLight) === -1) {
  129768. mesh._lightSources.push(newLight);
  129769. mesh._resyncLightSources();
  129770. }
  129771. }
  129772. this.onNewLightAddedObservable.notifyObservers(newLight);
  129773. };
  129774. /**
  129775. * Sorts the list list based on light priorities
  129776. */
  129777. Scene.prototype.sortLightsByPriority = function () {
  129778. if (this.requireLightSorting) {
  129779. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  129780. }
  129781. };
  129782. /**
  129783. * Adds the given camera to this scene
  129784. * @param newCamera The camera to add
  129785. */
  129786. Scene.prototype.addCamera = function (newCamera) {
  129787. this.cameras.push(newCamera);
  129788. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  129789. };
  129790. /**
  129791. * Adds the given skeleton to this scene
  129792. * @param newSkeleton The skeleton to add
  129793. */
  129794. Scene.prototype.addSkeleton = function (newSkeleton) {
  129795. this.skeletons.push(newSkeleton);
  129796. };
  129797. /**
  129798. * Adds the given particle system to this scene
  129799. * @param newParticleSystem The particle system to add
  129800. */
  129801. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  129802. this.particleSystems.push(newParticleSystem);
  129803. };
  129804. /**
  129805. * Adds the given animation to this scene
  129806. * @param newAnimation The animation to add
  129807. */
  129808. Scene.prototype.addAnimation = function (newAnimation) {
  129809. this.animations.push(newAnimation);
  129810. };
  129811. /**
  129812. * Adds the given animation group to this scene.
  129813. * @param newAnimationGroup The animation group to add
  129814. */
  129815. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  129816. this.animationGroups.push(newAnimationGroup);
  129817. };
  129818. /**
  129819. * Adds the given multi-material to this scene
  129820. * @param newMultiMaterial The multi-material to add
  129821. */
  129822. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  129823. this.multiMaterials.push(newMultiMaterial);
  129824. };
  129825. /**
  129826. * Adds the given material to this scene
  129827. * @param newMaterial The material to add
  129828. */
  129829. Scene.prototype.addMaterial = function (newMaterial) {
  129830. newMaterial._indexInSceneMaterialArray = this.materials.length;
  129831. this.materials.push(newMaterial);
  129832. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  129833. };
  129834. /**
  129835. * Adds the given morph target to this scene
  129836. * @param newMorphTargetManager The morph target to add
  129837. */
  129838. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  129839. this.morphTargetManagers.push(newMorphTargetManager);
  129840. };
  129841. /**
  129842. * Adds the given geometry to this scene
  129843. * @param newGeometry The geometry to add
  129844. */
  129845. Scene.prototype.addGeometry = function (newGeometry) {
  129846. if (this.geometriesByUniqueId) {
  129847. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  129848. }
  129849. this.geometries.push(newGeometry);
  129850. };
  129851. /**
  129852. * Adds the given action manager to this scene
  129853. * @param newActionManager The action manager to add
  129854. */
  129855. Scene.prototype.addActionManager = function (newActionManager) {
  129856. this.actionManagers.push(newActionManager);
  129857. };
  129858. /**
  129859. * Adds the given texture to this scene.
  129860. * @param newTexture The texture to add
  129861. */
  129862. Scene.prototype.addTexture = function (newTexture) {
  129863. this.textures.push(newTexture);
  129864. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  129865. };
  129866. /**
  129867. * Switch active camera
  129868. * @param newCamera defines the new active camera
  129869. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  129870. */
  129871. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  129872. if (attachControl === void 0) { attachControl = true; }
  129873. var canvas = this._engine.getRenderingCanvas();
  129874. if (!canvas) {
  129875. return;
  129876. }
  129877. if (this.activeCamera) {
  129878. this.activeCamera.detachControl(canvas);
  129879. }
  129880. this.activeCamera = newCamera;
  129881. if (attachControl) {
  129882. newCamera.attachControl(canvas);
  129883. }
  129884. };
  129885. /**
  129886. * sets the active camera of the scene using its ID
  129887. * @param id defines the camera's ID
  129888. * @return the new active camera or null if none found.
  129889. */
  129890. Scene.prototype.setActiveCameraByID = function (id) {
  129891. var camera = this.getCameraByID(id);
  129892. if (camera) {
  129893. this.activeCamera = camera;
  129894. return camera;
  129895. }
  129896. return null;
  129897. };
  129898. /**
  129899. * sets the active camera of the scene using its name
  129900. * @param name defines the camera's name
  129901. * @returns the new active camera or null if none found.
  129902. */
  129903. Scene.prototype.setActiveCameraByName = function (name) {
  129904. var camera = this.getCameraByName(name);
  129905. if (camera) {
  129906. this.activeCamera = camera;
  129907. return camera;
  129908. }
  129909. return null;
  129910. };
  129911. /**
  129912. * get an animation group using its name
  129913. * @param name defines the material's name
  129914. * @return the animation group or null if none found.
  129915. */
  129916. Scene.prototype.getAnimationGroupByName = function (name) {
  129917. for (var index = 0; index < this.animationGroups.length; index++) {
  129918. if (this.animationGroups[index].name === name) {
  129919. return this.animationGroups[index];
  129920. }
  129921. }
  129922. return null;
  129923. };
  129924. /**
  129925. * get a material using its id
  129926. * @param id defines the material's ID
  129927. * @return the material or null if none found.
  129928. */
  129929. Scene.prototype.getMaterialByID = function (id) {
  129930. for (var index = 0; index < this.materials.length; index++) {
  129931. if (this.materials[index].id === id) {
  129932. return this.materials[index];
  129933. }
  129934. }
  129935. return null;
  129936. };
  129937. /**
  129938. * Gets a material using its name
  129939. * @param name defines the material's name
  129940. * @return the material or null if none found.
  129941. */
  129942. Scene.prototype.getMaterialByName = function (name) {
  129943. for (var index = 0; index < this.materials.length; index++) {
  129944. if (this.materials[index].name === name) {
  129945. return this.materials[index];
  129946. }
  129947. }
  129948. return null;
  129949. };
  129950. /**
  129951. * Gets a camera using its id
  129952. * @param id defines the id to look for
  129953. * @returns the camera or null if not found
  129954. */
  129955. Scene.prototype.getCameraByID = function (id) {
  129956. for (var index = 0; index < this.cameras.length; index++) {
  129957. if (this.cameras[index].id === id) {
  129958. return this.cameras[index];
  129959. }
  129960. }
  129961. return null;
  129962. };
  129963. /**
  129964. * Gets a camera using its unique id
  129965. * @param uniqueId defines the unique id to look for
  129966. * @returns the camera or null if not found
  129967. */
  129968. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  129969. for (var index = 0; index < this.cameras.length; index++) {
  129970. if (this.cameras[index].uniqueId === uniqueId) {
  129971. return this.cameras[index];
  129972. }
  129973. }
  129974. return null;
  129975. };
  129976. /**
  129977. * Gets a camera using its name
  129978. * @param name defines the camera's name
  129979. * @return the camera or null if none found.
  129980. */
  129981. Scene.prototype.getCameraByName = function (name) {
  129982. for (var index = 0; index < this.cameras.length; index++) {
  129983. if (this.cameras[index].name === name) {
  129984. return this.cameras[index];
  129985. }
  129986. }
  129987. return null;
  129988. };
  129989. /**
  129990. * Gets a bone using its id
  129991. * @param id defines the bone's id
  129992. * @return the bone or null if not found
  129993. */
  129994. Scene.prototype.getBoneByID = function (id) {
  129995. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129996. var skeleton = this.skeletons[skeletonIndex];
  129997. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129998. if (skeleton.bones[boneIndex].id === id) {
  129999. return skeleton.bones[boneIndex];
  130000. }
  130001. }
  130002. }
  130003. return null;
  130004. };
  130005. /**
  130006. * Gets a bone using its id
  130007. * @param name defines the bone's name
  130008. * @return the bone or null if not found
  130009. */
  130010. Scene.prototype.getBoneByName = function (name) {
  130011. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130012. var skeleton = this.skeletons[skeletonIndex];
  130013. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130014. if (skeleton.bones[boneIndex].name === name) {
  130015. return skeleton.bones[boneIndex];
  130016. }
  130017. }
  130018. }
  130019. return null;
  130020. };
  130021. /**
  130022. * Gets a light node using its name
  130023. * @param name defines the the light's name
  130024. * @return the light or null if none found.
  130025. */
  130026. Scene.prototype.getLightByName = function (name) {
  130027. for (var index = 0; index < this.lights.length; index++) {
  130028. if (this.lights[index].name === name) {
  130029. return this.lights[index];
  130030. }
  130031. }
  130032. return null;
  130033. };
  130034. /**
  130035. * Gets a light node using its id
  130036. * @param id defines the light's id
  130037. * @return the light or null if none found.
  130038. */
  130039. Scene.prototype.getLightByID = function (id) {
  130040. for (var index = 0; index < this.lights.length; index++) {
  130041. if (this.lights[index].id === id) {
  130042. return this.lights[index];
  130043. }
  130044. }
  130045. return null;
  130046. };
  130047. /**
  130048. * Gets a light node using its scene-generated unique ID
  130049. * @param uniqueId defines the light's unique id
  130050. * @return the light or null if none found.
  130051. */
  130052. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  130053. for (var index = 0; index < this.lights.length; index++) {
  130054. if (this.lights[index].uniqueId === uniqueId) {
  130055. return this.lights[index];
  130056. }
  130057. }
  130058. return null;
  130059. };
  130060. /**
  130061. * Gets a particle system by id
  130062. * @param id defines the particle system id
  130063. * @return the corresponding system or null if none found
  130064. */
  130065. Scene.prototype.getParticleSystemByID = function (id) {
  130066. for (var index = 0; index < this.particleSystems.length; index++) {
  130067. if (this.particleSystems[index].id === id) {
  130068. return this.particleSystems[index];
  130069. }
  130070. }
  130071. return null;
  130072. };
  130073. /**
  130074. * Gets a geometry using its ID
  130075. * @param id defines the geometry's id
  130076. * @return the geometry or null if none found.
  130077. */
  130078. Scene.prototype.getGeometryByID = function (id) {
  130079. for (var index = 0; index < this.geometries.length; index++) {
  130080. if (this.geometries[index].id === id) {
  130081. return this.geometries[index];
  130082. }
  130083. }
  130084. return null;
  130085. };
  130086. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  130087. if (this.geometriesByUniqueId) {
  130088. var index_1 = this.geometriesByUniqueId[uniqueId];
  130089. if (index_1 !== undefined) {
  130090. return this.geometries[index_1];
  130091. }
  130092. }
  130093. else {
  130094. for (var index = 0; index < this.geometries.length; index++) {
  130095. if (this.geometries[index].uniqueId === uniqueId) {
  130096. return this.geometries[index];
  130097. }
  130098. }
  130099. }
  130100. return null;
  130101. };
  130102. /**
  130103. * Add a new geometry to this scene
  130104. * @param geometry defines the geometry to be added to the scene.
  130105. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  130106. * @return a boolean defining if the geometry was added or not
  130107. */
  130108. Scene.prototype.pushGeometry = function (geometry, force) {
  130109. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  130110. return false;
  130111. }
  130112. this.addGeometry(geometry);
  130113. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  130114. return true;
  130115. };
  130116. /**
  130117. * Removes an existing geometry
  130118. * @param geometry defines the geometry to be removed from the scene
  130119. * @return a boolean defining if the geometry was removed or not
  130120. */
  130121. Scene.prototype.removeGeometry = function (geometry) {
  130122. var index;
  130123. if (this.geometriesByUniqueId) {
  130124. index = this.geometriesByUniqueId[geometry.uniqueId];
  130125. if (index === undefined) {
  130126. return false;
  130127. }
  130128. }
  130129. else {
  130130. index = this.geometries.indexOf(geometry);
  130131. if (index < 0) {
  130132. return false;
  130133. }
  130134. }
  130135. if (index !== this.geometries.length - 1) {
  130136. var lastGeometry = this.geometries[this.geometries.length - 1];
  130137. this.geometries[index] = lastGeometry;
  130138. if (this.geometriesByUniqueId) {
  130139. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  130140. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  130141. }
  130142. }
  130143. this.geometries.pop();
  130144. this.onGeometryRemovedObservable.notifyObservers(geometry);
  130145. return true;
  130146. };
  130147. /**
  130148. * Gets the list of geometries attached to the scene
  130149. * @returns an array of Geometry
  130150. */
  130151. Scene.prototype.getGeometries = function () {
  130152. return this.geometries;
  130153. };
  130154. /**
  130155. * Gets the first added mesh found of a given ID
  130156. * @param id defines the id to search for
  130157. * @return the mesh found or null if not found at all
  130158. */
  130159. Scene.prototype.getMeshByID = function (id) {
  130160. for (var index = 0; index < this.meshes.length; index++) {
  130161. if (this.meshes[index].id === id) {
  130162. return this.meshes[index];
  130163. }
  130164. }
  130165. return null;
  130166. };
  130167. /**
  130168. * Gets a list of meshes using their id
  130169. * @param id defines the id to search for
  130170. * @returns a list of meshes
  130171. */
  130172. Scene.prototype.getMeshesByID = function (id) {
  130173. return this.meshes.filter(function (m) {
  130174. return m.id === id;
  130175. });
  130176. };
  130177. /**
  130178. * Gets the first added transform node found of a given ID
  130179. * @param id defines the id to search for
  130180. * @return the found transform node or null if not found at all.
  130181. */
  130182. Scene.prototype.getTransformNodeByID = function (id) {
  130183. for (var index = 0; index < this.transformNodes.length; index++) {
  130184. if (this.transformNodes[index].id === id) {
  130185. return this.transformNodes[index];
  130186. }
  130187. }
  130188. return null;
  130189. };
  130190. /**
  130191. * Gets a list of transform nodes using their id
  130192. * @param id defines the id to search for
  130193. * @returns a list of transform nodes
  130194. */
  130195. Scene.prototype.getTransformNodesByID = function (id) {
  130196. return this.transformNodes.filter(function (m) {
  130197. return m.id === id;
  130198. });
  130199. };
  130200. /**
  130201. * Gets a mesh with its auto-generated unique id
  130202. * @param uniqueId defines the unique id to search for
  130203. * @return the found mesh or null if not found at all.
  130204. */
  130205. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  130206. for (var index = 0; index < this.meshes.length; index++) {
  130207. if (this.meshes[index].uniqueId === uniqueId) {
  130208. return this.meshes[index];
  130209. }
  130210. }
  130211. return null;
  130212. };
  130213. /**
  130214. * Gets a the last added mesh using a given id
  130215. * @param id defines the id to search for
  130216. * @return the found mesh or null if not found at all.
  130217. */
  130218. Scene.prototype.getLastMeshByID = function (id) {
  130219. for (var index = this.meshes.length - 1; index >= 0; index--) {
  130220. if (this.meshes[index].id === id) {
  130221. return this.meshes[index];
  130222. }
  130223. }
  130224. return null;
  130225. };
  130226. /**
  130227. * Gets a the last added node (Mesh, Camera, Light) using a given id
  130228. * @param id defines the id to search for
  130229. * @return the found node or null if not found at all
  130230. */
  130231. Scene.prototype.getLastEntryByID = function (id) {
  130232. var index;
  130233. for (index = this.meshes.length - 1; index >= 0; index--) {
  130234. if (this.meshes[index].id === id) {
  130235. return this.meshes[index];
  130236. }
  130237. }
  130238. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  130239. if (this.transformNodes[index].id === id) {
  130240. return this.transformNodes[index];
  130241. }
  130242. }
  130243. for (index = this.cameras.length - 1; index >= 0; index--) {
  130244. if (this.cameras[index].id === id) {
  130245. return this.cameras[index];
  130246. }
  130247. }
  130248. for (index = this.lights.length - 1; index >= 0; index--) {
  130249. if (this.lights[index].id === id) {
  130250. return this.lights[index];
  130251. }
  130252. }
  130253. return null;
  130254. };
  130255. /**
  130256. * Gets a node (Mesh, Camera, Light) using a given id
  130257. * @param id defines the id to search for
  130258. * @return the found node or null if not found at all
  130259. */
  130260. Scene.prototype.getNodeByID = function (id) {
  130261. var mesh = this.getMeshByID(id);
  130262. if (mesh) {
  130263. return mesh;
  130264. }
  130265. var transformNode = this.getTransformNodeByID(id);
  130266. if (transformNode) {
  130267. return transformNode;
  130268. }
  130269. var light = this.getLightByID(id);
  130270. if (light) {
  130271. return light;
  130272. }
  130273. var camera = this.getCameraByID(id);
  130274. if (camera) {
  130275. return camera;
  130276. }
  130277. var bone = this.getBoneByID(id);
  130278. if (bone) {
  130279. return bone;
  130280. }
  130281. return null;
  130282. };
  130283. /**
  130284. * Gets a node (Mesh, Camera, Light) using a given name
  130285. * @param name defines the name to search for
  130286. * @return the found node or null if not found at all.
  130287. */
  130288. Scene.prototype.getNodeByName = function (name) {
  130289. var mesh = this.getMeshByName(name);
  130290. if (mesh) {
  130291. return mesh;
  130292. }
  130293. var transformNode = this.getTransformNodeByName(name);
  130294. if (transformNode) {
  130295. return transformNode;
  130296. }
  130297. var light = this.getLightByName(name);
  130298. if (light) {
  130299. return light;
  130300. }
  130301. var camera = this.getCameraByName(name);
  130302. if (camera) {
  130303. return camera;
  130304. }
  130305. var bone = this.getBoneByName(name);
  130306. if (bone) {
  130307. return bone;
  130308. }
  130309. return null;
  130310. };
  130311. /**
  130312. * Gets a mesh using a given name
  130313. * @param name defines the name to search for
  130314. * @return the found mesh or null if not found at all.
  130315. */
  130316. Scene.prototype.getMeshByName = function (name) {
  130317. for (var index = 0; index < this.meshes.length; index++) {
  130318. if (this.meshes[index].name === name) {
  130319. return this.meshes[index];
  130320. }
  130321. }
  130322. return null;
  130323. };
  130324. /**
  130325. * Gets a transform node using a given name
  130326. * @param name defines the name to search for
  130327. * @return the found transform node or null if not found at all.
  130328. */
  130329. Scene.prototype.getTransformNodeByName = function (name) {
  130330. for (var index = 0; index < this.transformNodes.length; index++) {
  130331. if (this.transformNodes[index].name === name) {
  130332. return this.transformNodes[index];
  130333. }
  130334. }
  130335. return null;
  130336. };
  130337. /**
  130338. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  130339. * @param id defines the id to search for
  130340. * @return the found skeleton or null if not found at all.
  130341. */
  130342. Scene.prototype.getLastSkeletonByID = function (id) {
  130343. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  130344. if (this.skeletons[index].id === id) {
  130345. return this.skeletons[index];
  130346. }
  130347. }
  130348. return null;
  130349. };
  130350. /**
  130351. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  130352. * @param id defines the id to search for
  130353. * @return the found skeleton or null if not found at all.
  130354. */
  130355. Scene.prototype.getSkeletonById = function (id) {
  130356. for (var index = 0; index < this.skeletons.length; index++) {
  130357. if (this.skeletons[index].id === id) {
  130358. return this.skeletons[index];
  130359. }
  130360. }
  130361. return null;
  130362. };
  130363. /**
  130364. * Gets a skeleton using a given name
  130365. * @param name defines the name to search for
  130366. * @return the found skeleton or null if not found at all.
  130367. */
  130368. Scene.prototype.getSkeletonByName = function (name) {
  130369. for (var index = 0; index < this.skeletons.length; index++) {
  130370. if (this.skeletons[index].name === name) {
  130371. return this.skeletons[index];
  130372. }
  130373. }
  130374. return null;
  130375. };
  130376. /**
  130377. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  130378. * @param id defines the id to search for
  130379. * @return the found morph target manager or null if not found at all.
  130380. */
  130381. Scene.prototype.getMorphTargetManagerById = function (id) {
  130382. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  130383. if (this.morphTargetManagers[index].uniqueId === id) {
  130384. return this.morphTargetManagers[index];
  130385. }
  130386. }
  130387. return null;
  130388. };
  130389. /**
  130390. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  130391. * @param id defines the id to search for
  130392. * @return the found morph target or null if not found at all.
  130393. */
  130394. Scene.prototype.getMorphTargetById = function (id) {
  130395. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  130396. var morphTargetManager = this.morphTargetManagers[managerIndex];
  130397. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  130398. var target = morphTargetManager.getTarget(index);
  130399. if (target.id === id) {
  130400. return target;
  130401. }
  130402. }
  130403. }
  130404. return null;
  130405. };
  130406. /**
  130407. * Gets a boolean indicating if the given mesh is active
  130408. * @param mesh defines the mesh to look for
  130409. * @returns true if the mesh is in the active list
  130410. */
  130411. Scene.prototype.isActiveMesh = function (mesh) {
  130412. return (this._activeMeshes.indexOf(mesh) !== -1);
  130413. };
  130414. Object.defineProperty(Scene.prototype, "uid", {
  130415. /**
  130416. * Return a unique id as a string which can serve as an identifier for the scene
  130417. */
  130418. get: function () {
  130419. if (!this._uid) {
  130420. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130421. }
  130422. return this._uid;
  130423. },
  130424. enumerable: true,
  130425. configurable: true
  130426. });
  130427. /**
  130428. * Add an externaly attached data from its key.
  130429. * This method call will fail and return false, if such key already exists.
  130430. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130431. * @param key the unique key that identifies the data
  130432. * @param data the data object to associate to the key for this Engine instance
  130433. * @return true if no such key were already present and the data was added successfully, false otherwise
  130434. */
  130435. Scene.prototype.addExternalData = function (key, data) {
  130436. if (!this._externalData) {
  130437. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130438. }
  130439. return this._externalData.add(key, data);
  130440. };
  130441. /**
  130442. * Get an externaly attached data from its key
  130443. * @param key the unique key that identifies the data
  130444. * @return the associated data, if present (can be null), or undefined if not present
  130445. */
  130446. Scene.prototype.getExternalData = function (key) {
  130447. if (!this._externalData) {
  130448. return null;
  130449. }
  130450. return this._externalData.get(key);
  130451. };
  130452. /**
  130453. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130454. * @param key the unique key that identifies the data
  130455. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130456. * @return the associated data, can be null if the factory returned null.
  130457. */
  130458. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130459. if (!this._externalData) {
  130460. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130461. }
  130462. return this._externalData.getOrAddWithFactory(key, factory);
  130463. };
  130464. /**
  130465. * Remove an externaly attached data from the Engine instance
  130466. * @param key the unique key that identifies the data
  130467. * @return true if the data was successfully removed, false if it doesn't exist
  130468. */
  130469. Scene.prototype.removeExternalData = function (key) {
  130470. return this._externalData.remove(key);
  130471. };
  130472. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130473. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130474. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130475. var step = _a[_i];
  130476. step.action(mesh, subMesh);
  130477. }
  130478. var material = subMesh.getMaterial();
  130479. if (material !== null && material !== undefined) {
  130480. // Render targets
  130481. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130482. if (this._processedMaterials.indexOf(material) === -1) {
  130483. this._processedMaterials.push(material);
  130484. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130485. }
  130486. }
  130487. // Dispatch
  130488. this._activeIndices.addCount(subMesh.indexCount, false);
  130489. this._renderingManager.dispatch(subMesh, mesh, material);
  130490. }
  130491. }
  130492. };
  130493. /**
  130494. * Clear the processed materials smart array preventing retention point in material dispose.
  130495. */
  130496. Scene.prototype.freeProcessedMaterials = function () {
  130497. this._processedMaterials.dispose();
  130498. };
  130499. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130500. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130501. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130502. * when disposing several meshes in a row or a hierarchy of meshes.
  130503. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130504. */
  130505. get: function () {
  130506. return this._preventFreeActiveMeshesAndRenderingGroups;
  130507. },
  130508. set: function (value) {
  130509. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130510. return;
  130511. }
  130512. if (value) {
  130513. this.freeActiveMeshes();
  130514. this.freeRenderingGroups();
  130515. }
  130516. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130517. },
  130518. enumerable: true,
  130519. configurable: true
  130520. });
  130521. /**
  130522. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130523. */
  130524. Scene.prototype.freeActiveMeshes = function () {
  130525. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130526. return;
  130527. }
  130528. this._activeMeshes.dispose();
  130529. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130530. this.activeCamera._activeMeshes.dispose();
  130531. }
  130532. if (this.activeCameras) {
  130533. for (var i = 0; i < this.activeCameras.length; i++) {
  130534. var activeCamera = this.activeCameras[i];
  130535. if (activeCamera && activeCamera._activeMeshes) {
  130536. activeCamera._activeMeshes.dispose();
  130537. }
  130538. }
  130539. }
  130540. };
  130541. /**
  130542. * Clear the info related to rendering groups preventing retention points during dispose.
  130543. */
  130544. Scene.prototype.freeRenderingGroups = function () {
  130545. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130546. return;
  130547. }
  130548. if (this._renderingManager) {
  130549. this._renderingManager.freeRenderingGroups();
  130550. }
  130551. if (this.textures) {
  130552. for (var i = 0; i < this.textures.length; i++) {
  130553. var texture = this.textures[i];
  130554. if (texture && texture.renderList) {
  130555. texture.freeRenderingGroups();
  130556. }
  130557. }
  130558. }
  130559. };
  130560. /** @hidden */
  130561. Scene.prototype._isInIntermediateRendering = function () {
  130562. return this._intermediateRendering;
  130563. };
  130564. /**
  130565. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  130566. * @returns the current scene
  130567. */
  130568. Scene.prototype.freezeActiveMeshes = function () {
  130569. if (!this.activeCamera) {
  130570. return this;
  130571. }
  130572. if (!this._frustumPlanes) {
  130573. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130574. }
  130575. this._evaluateActiveMeshes();
  130576. this._activeMeshesFrozen = true;
  130577. return this;
  130578. };
  130579. /**
  130580. * Use this function to restart evaluating active meshes on every frame
  130581. * @returns the current scene
  130582. */
  130583. Scene.prototype.unfreezeActiveMeshes = function () {
  130584. this._activeMeshesFrozen = false;
  130585. return this;
  130586. };
  130587. Scene.prototype._evaluateActiveMeshes = function () {
  130588. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130589. return;
  130590. }
  130591. if (!this.activeCamera) {
  130592. return;
  130593. }
  130594. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130595. this.activeCamera._activeMeshes.reset();
  130596. this._activeMeshes.reset();
  130597. this._renderingManager.reset();
  130598. this._processedMaterials.reset();
  130599. this._activeParticleSystems.reset();
  130600. this._activeSkeletons.reset();
  130601. this._softwareSkinnedMeshes.reset();
  130602. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  130603. var step = _a[_i];
  130604. step.action();
  130605. }
  130606. // Determine mesh candidates
  130607. var meshes = this.getActiveMeshCandidates();
  130608. // Check each mesh
  130609. var len = meshes.length;
  130610. for (var i = 0; i < len; i++) {
  130611. var mesh = meshes.data[i];
  130612. if (mesh.isBlocked) {
  130613. continue;
  130614. }
  130615. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  130616. if (!mesh.isReady() || !mesh.isEnabled()) {
  130617. continue;
  130618. }
  130619. mesh.computeWorldMatrix();
  130620. // Intersections
  130621. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  130622. this._meshesForIntersections.pushNoDuplicate(mesh);
  130623. }
  130624. // Switch to current LOD
  130625. var meshLOD = mesh.getLOD(this.activeCamera);
  130626. if (meshLOD === undefined || meshLOD === null) {
  130627. continue;
  130628. }
  130629. mesh._preActivate();
  130630. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  130631. this._activeMeshes.push(mesh);
  130632. this.activeCamera._activeMeshes.push(mesh);
  130633. mesh._activate(this._renderId);
  130634. if (meshLOD !== mesh) {
  130635. meshLOD._activate(this._renderId);
  130636. }
  130637. this._activeMesh(mesh, meshLOD);
  130638. }
  130639. }
  130640. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  130641. // Particle systems
  130642. if (this.particlesEnabled) {
  130643. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  130644. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  130645. var particleSystem = this.particleSystems[particleIndex];
  130646. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  130647. continue;
  130648. }
  130649. var emitter = particleSystem.emitter;
  130650. if (!emitter.position || emitter.isEnabled()) {
  130651. this._activeParticleSystems.push(particleSystem);
  130652. particleSystem.animate();
  130653. this._renderingManager.dispatchParticles(particleSystem);
  130654. }
  130655. }
  130656. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  130657. }
  130658. };
  130659. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  130660. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  130661. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  130662. mesh.skeleton.prepare();
  130663. }
  130664. if (!mesh.computeBonesUsingShaders) {
  130665. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  130666. }
  130667. }
  130668. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  130669. var step = _a[_i];
  130670. step.action(sourceMesh, mesh);
  130671. }
  130672. if (mesh !== undefined && mesh !== null
  130673. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  130674. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  130675. var len = subMeshes.length;
  130676. for (var i = 0; i < len; i++) {
  130677. var subMesh = subMeshes.data[i];
  130678. this._evaluateSubMesh(subMesh, mesh);
  130679. }
  130680. }
  130681. };
  130682. /**
  130683. * Update the transform matrix to update from the current active camera
  130684. * @param force defines a boolean used to force the update even if cache is up to date
  130685. */
  130686. Scene.prototype.updateTransformMatrix = function (force) {
  130687. if (!this.activeCamera) {
  130688. return;
  130689. }
  130690. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  130691. };
  130692. /**
  130693. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  130694. * @param alternateCamera defines the camera to use
  130695. */
  130696. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  130697. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  130698. };
  130699. Scene.prototype._renderForCamera = function (camera, rigParent) {
  130700. if (camera && camera._skipRendering) {
  130701. return;
  130702. }
  130703. var engine = this._engine;
  130704. this.activeCamera = camera;
  130705. if (!this.activeCamera) {
  130706. throw new Error("Active camera not set");
  130707. }
  130708. // Viewport
  130709. engine.setViewport(this.activeCamera.viewport);
  130710. // Camera
  130711. this.resetCachedMaterial();
  130712. this._renderId++;
  130713. this.updateTransformMatrix();
  130714. if (camera._alternateCamera) {
  130715. this.updateAlternateTransformMatrix(camera._alternateCamera);
  130716. this._alternateRendering = true;
  130717. }
  130718. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  130719. // Meshes
  130720. this._evaluateActiveMeshes();
  130721. // Software skinning
  130722. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  130723. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  130724. mesh.applySkeleton(mesh.skeleton);
  130725. }
  130726. // Render targets
  130727. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130728. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  130729. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  130730. }
  130731. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  130732. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  130733. }
  130734. // Collects render targets from external components.
  130735. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  130736. var step = _a[_i];
  130737. step.action(this._renderTargets);
  130738. }
  130739. if (this.renderTargetsEnabled) {
  130740. this._intermediateRendering = true;
  130741. if (this._renderTargets.length > 0) {
  130742. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130743. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  130744. var renderTarget = this._renderTargets.data[renderIndex];
  130745. if (renderTarget._shouldRender()) {
  130746. this._renderId++;
  130747. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  130748. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  130749. }
  130750. }
  130751. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130752. this._renderId++;
  130753. }
  130754. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  130755. var step = _c[_b];
  130756. step.action(this.activeCamera);
  130757. }
  130758. this._intermediateRendering = false;
  130759. if (this.activeCamera.outputRenderTarget) {
  130760. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  130761. if (internalTexture) {
  130762. engine.bindFramebuffer(internalTexture);
  130763. }
  130764. else {
  130765. _Misc_logger__WEBPACK_IMPORTED_MODULE_24__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  130766. }
  130767. }
  130768. else {
  130769. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  130770. }
  130771. }
  130772. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130773. // Prepare Frame
  130774. if (this.postProcessManager) {
  130775. this.postProcessManager._prepareFrame();
  130776. }
  130777. // Before Camera Draw
  130778. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  130779. var step = _e[_d];
  130780. step.action(this.activeCamera);
  130781. }
  130782. // Render
  130783. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  130784. this._renderingManager.render(null, null, true, true);
  130785. this.onAfterDrawPhaseObservable.notifyObservers(this);
  130786. // After Camera Draw
  130787. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  130788. var step = _g[_f];
  130789. step.action(this.activeCamera);
  130790. }
  130791. // Finalize frame
  130792. if (this.postProcessManager) {
  130793. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  130794. }
  130795. // Reset some special arrays
  130796. this._renderTargets.reset();
  130797. this._alternateRendering = false;
  130798. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  130799. };
  130800. Scene.prototype._processSubCameras = function (camera) {
  130801. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130802. this._renderForCamera(camera);
  130803. return;
  130804. }
  130805. // rig cameras
  130806. for (var index = 0; index < camera._rigCameras.length; index++) {
  130807. this._renderForCamera(camera._rigCameras[index], camera);
  130808. }
  130809. this.activeCamera = camera;
  130810. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130811. };
  130812. Scene.prototype._checkIntersections = function () {
  130813. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  130814. var sourceMesh = this._meshesForIntersections.data[index];
  130815. if (!sourceMesh.actionManager) {
  130816. continue;
  130817. }
  130818. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  130819. var action = sourceMesh.actionManager.actions[actionIndex];
  130820. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130821. var parameters = action.getTriggerParameter();
  130822. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  130823. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  130824. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  130825. if (areIntersecting && currentIntersectionInProgress === -1) {
  130826. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  130827. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130828. sourceMesh._intersectionsInProgress.push(otherMesh);
  130829. }
  130830. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130831. sourceMesh._intersectionsInProgress.push(otherMesh);
  130832. }
  130833. }
  130834. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  130835. //They intersected, and now they don't.
  130836. //is this trigger an exit trigger? execute an event.
  130837. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130838. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130839. }
  130840. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  130841. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  130842. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  130843. return otherMesh === parameterMesh;
  130844. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130845. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  130846. }
  130847. }
  130848. }
  130849. }
  130850. }
  130851. };
  130852. /** @hidden */
  130853. Scene.prototype._advancePhysicsEngineStep = function (step) {
  130854. // Do nothing. Code will be replaced if physics engine component is referenced
  130855. };
  130856. /**
  130857. * Render the scene
  130858. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  130859. */
  130860. Scene.prototype.render = function (updateCameras) {
  130861. if (updateCameras === void 0) { updateCameras = true; }
  130862. if (this.isDisposed) {
  130863. return;
  130864. }
  130865. this._frameId++;
  130866. // Register components that have been associated lately to the scene.
  130867. this._registerTransientComponents();
  130868. this._activeParticles.fetchNewFrame();
  130869. this._totalVertices.fetchNewFrame();
  130870. this._activeIndices.fetchNewFrame();
  130871. this._activeBones.fetchNewFrame();
  130872. this._meshesForIntersections.reset();
  130873. this.resetCachedMaterial();
  130874. this.onBeforeAnimationsObservable.notifyObservers(this);
  130875. // Actions
  130876. if (this.actionManager) {
  130877. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnEveryFrameTrigger);
  130878. }
  130879. if (this._engine.isDeterministicLockStep()) {
  130880. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  130881. var defaultFPS = (60.0 / 1000.0);
  130882. var defaultFrameTime = this.getDeterministicFrameTime();
  130883. var stepsTaken = 0;
  130884. var maxSubSteps = this._engine.getLockstepMaxSteps();
  130885. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  130886. internalSteps = Math.min(internalSteps, maxSubSteps);
  130887. do {
  130888. this.onBeforeStepObservable.notifyObservers(this);
  130889. // Animations
  130890. this._animationRatio = defaultFrameTime * defaultFPS;
  130891. this._animate();
  130892. this.onAfterAnimationsObservable.notifyObservers(this);
  130893. // Physics
  130894. this._advancePhysicsEngineStep(defaultFrameTime);
  130895. this.onAfterStepObservable.notifyObservers(this);
  130896. this._currentStepId++;
  130897. stepsTaken++;
  130898. deltaTime -= defaultFrameTime;
  130899. } while (deltaTime > 0 && stepsTaken < internalSteps);
  130900. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  130901. }
  130902. else {
  130903. // Animations
  130904. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  130905. this._animationRatio = deltaTime * (60.0 / 1000.0);
  130906. this._animate();
  130907. this.onAfterAnimationsObservable.notifyObservers(this);
  130908. // Physics
  130909. this._advancePhysicsEngineStep(deltaTime);
  130910. }
  130911. // Before camera update steps
  130912. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  130913. var step = _a[_i];
  130914. step.action();
  130915. }
  130916. // Update Cameras
  130917. if (updateCameras) {
  130918. if (this.activeCameras.length > 0) {
  130919. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130920. var camera = this.activeCameras[cameraIndex];
  130921. camera.update();
  130922. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130923. // rig cameras
  130924. for (var index = 0; index < camera._rigCameras.length; index++) {
  130925. camera._rigCameras[index].update();
  130926. }
  130927. }
  130928. }
  130929. }
  130930. else if (this.activeCamera) {
  130931. this.activeCamera.update();
  130932. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130933. // rig cameras
  130934. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  130935. this.activeCamera._rigCameras[index].update();
  130936. }
  130937. }
  130938. }
  130939. }
  130940. // Before render
  130941. this.onBeforeRenderObservable.notifyObservers(this);
  130942. // Customs render targets
  130943. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130944. var engine = this.getEngine();
  130945. var currentActiveCamera = this.activeCamera;
  130946. if (this.renderTargetsEnabled) {
  130947. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130948. this._intermediateRendering = true;
  130949. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  130950. var renderTarget = this.customRenderTargets[customIndex];
  130951. if (renderTarget._shouldRender()) {
  130952. this._renderId++;
  130953. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  130954. if (!this.activeCamera) {
  130955. throw new Error("Active camera not set");
  130956. }
  130957. // Viewport
  130958. engine.setViewport(this.activeCamera.viewport);
  130959. // Camera
  130960. this.updateTransformMatrix();
  130961. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  130962. }
  130963. }
  130964. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130965. this._intermediateRendering = false;
  130966. this._renderId++;
  130967. }
  130968. // Restore back buffer
  130969. if (this.customRenderTargets.length > 0) {
  130970. engine.restoreDefaultFramebuffer();
  130971. }
  130972. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130973. this.activeCamera = currentActiveCamera;
  130974. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  130975. var step = _c[_b];
  130976. step.action();
  130977. }
  130978. // Clear
  130979. if (this.autoClearDepthAndStencil || this.autoClear) {
  130980. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  130981. }
  130982. // Collects render targets from external components.
  130983. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  130984. var step = _e[_d];
  130985. step.action(this._renderTargets);
  130986. }
  130987. // Multi-cameras?
  130988. if (this.activeCameras.length > 0) {
  130989. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130990. if (cameraIndex > 0) {
  130991. this._engine.clear(null, false, true, true);
  130992. }
  130993. this._processSubCameras(this.activeCameras[cameraIndex]);
  130994. }
  130995. }
  130996. else {
  130997. if (!this.activeCamera) {
  130998. throw new Error("No camera defined");
  130999. }
  131000. this._processSubCameras(this.activeCamera);
  131001. }
  131002. // Intersection checks
  131003. this._checkIntersections();
  131004. // Executes the after render stage actions.
  131005. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  131006. var step = _g[_f];
  131007. step.action();
  131008. }
  131009. // After render
  131010. if (this.afterRender) {
  131011. this.afterRender();
  131012. }
  131013. this.onAfterRenderObservable.notifyObservers(this);
  131014. // Cleaning
  131015. if (this._toBeDisposed.length) {
  131016. for (var index = 0; index < this._toBeDisposed.length; index++) {
  131017. var data = this._toBeDisposed[index];
  131018. if (data) {
  131019. data.dispose();
  131020. }
  131021. }
  131022. this._toBeDisposed = [];
  131023. }
  131024. if (this.dumpNextRenderTargets) {
  131025. this.dumpNextRenderTargets = false;
  131026. }
  131027. this._activeBones.addCount(0, true);
  131028. this._activeIndices.addCount(0, true);
  131029. this._activeParticles.addCount(0, true);
  131030. };
  131031. /**
  131032. * Freeze all materials
  131033. * A frozen material will not be updatable but should be faster to render
  131034. */
  131035. Scene.prototype.freezeMaterials = function () {
  131036. for (var i = 0; i < this.materials.length; i++) {
  131037. this.materials[i].freeze();
  131038. }
  131039. };
  131040. /**
  131041. * Unfreeze all materials
  131042. * A frozen material will not be updatable but should be faster to render
  131043. */
  131044. Scene.prototype.unfreezeMaterials = function () {
  131045. for (var i = 0; i < this.materials.length; i++) {
  131046. this.materials[i].unfreeze();
  131047. }
  131048. };
  131049. /**
  131050. * Releases all held ressources
  131051. */
  131052. Scene.prototype.dispose = function () {
  131053. this.beforeRender = null;
  131054. this.afterRender = null;
  131055. this.skeletons = [];
  131056. this.morphTargetManagers = [];
  131057. this._transientComponents = [];
  131058. this._isReadyForMeshStage.clear();
  131059. this._beforeEvaluateActiveMeshStage.clear();
  131060. this._evaluateSubMeshStage.clear();
  131061. this._activeMeshStage.clear();
  131062. this._cameraDrawRenderTargetStage.clear();
  131063. this._beforeCameraDrawStage.clear();
  131064. this._beforeRenderTargetDrawStage.clear();
  131065. this._beforeRenderingGroupDrawStage.clear();
  131066. this._beforeRenderingMeshStage.clear();
  131067. this._afterRenderingMeshStage.clear();
  131068. this._afterRenderingGroupDrawStage.clear();
  131069. this._afterCameraDrawStage.clear();
  131070. this._afterRenderTargetDrawStage.clear();
  131071. this._afterRenderStage.clear();
  131072. this._beforeCameraUpdateStage.clear();
  131073. this._beforeClearStage.clear();
  131074. this._gatherRenderTargetsStage.clear();
  131075. this._gatherActiveCameraRenderTargetsStage.clear();
  131076. this._pointerMoveStage.clear();
  131077. this._pointerDownStage.clear();
  131078. this._pointerUpStage.clear();
  131079. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  131080. var component = _a[_i];
  131081. component.dispose();
  131082. }
  131083. this.importedMeshesFiles = new Array();
  131084. this.stopAllAnimations();
  131085. this.resetCachedMaterial();
  131086. // Smart arrays
  131087. if (this.activeCamera) {
  131088. this.activeCamera._activeMeshes.dispose();
  131089. this.activeCamera = null;
  131090. }
  131091. this._activeMeshes.dispose();
  131092. this._renderingManager.dispose();
  131093. this._processedMaterials.dispose();
  131094. this._activeParticleSystems.dispose();
  131095. this._activeSkeletons.dispose();
  131096. this._softwareSkinnedMeshes.dispose();
  131097. this._renderTargets.dispose();
  131098. this._registeredForLateAnimationBindings.dispose();
  131099. this._meshesForIntersections.dispose();
  131100. this._toBeDisposed = [];
  131101. // Abort active requests
  131102. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  131103. var request = _c[_b];
  131104. request.abort();
  131105. }
  131106. // Events
  131107. this.onDisposeObservable.notifyObservers(this);
  131108. this.onDisposeObservable.clear();
  131109. this.onBeforeRenderObservable.clear();
  131110. this.onAfterRenderObservable.clear();
  131111. this.onBeforeRenderTargetsRenderObservable.clear();
  131112. this.onAfterRenderTargetsRenderObservable.clear();
  131113. this.onAfterStepObservable.clear();
  131114. this.onBeforeStepObservable.clear();
  131115. this.onBeforeActiveMeshesEvaluationObservable.clear();
  131116. this.onAfterActiveMeshesEvaluationObservable.clear();
  131117. this.onBeforeParticlesRenderingObservable.clear();
  131118. this.onAfterParticlesRenderingObservable.clear();
  131119. this.onBeforeDrawPhaseObservable.clear();
  131120. this.onAfterDrawPhaseObservable.clear();
  131121. this.onBeforeAnimationsObservable.clear();
  131122. this.onAfterAnimationsObservable.clear();
  131123. this.onDataLoadedObservable.clear();
  131124. this.onBeforeRenderingGroupObservable.clear();
  131125. this.onAfterRenderingGroupObservable.clear();
  131126. this.onMeshImportedObservable.clear();
  131127. this.onBeforeCameraRenderObservable.clear();
  131128. this.onAfterCameraRenderObservable.clear();
  131129. this.onReadyObservable.clear();
  131130. this.onNewCameraAddedObservable.clear();
  131131. this.onCameraRemovedObservable.clear();
  131132. this.onNewLightAddedObservable.clear();
  131133. this.onLightRemovedObservable.clear();
  131134. this.onNewGeometryAddedObservable.clear();
  131135. this.onGeometryRemovedObservable.clear();
  131136. this.onNewTransformNodeAddedObservable.clear();
  131137. this.onTransformNodeRemovedObservable.clear();
  131138. this.onNewMeshAddedObservable.clear();
  131139. this.onMeshRemovedObservable.clear();
  131140. this.onNewMaterialAddedObservable.clear();
  131141. this.onMaterialRemovedObservable.clear();
  131142. this.onNewTextureAddedObservable.clear();
  131143. this.onTextureRemovedObservable.clear();
  131144. this.onPrePointerObservable.clear();
  131145. this.onPointerObservable.clear();
  131146. this.onPreKeyboardObservable.clear();
  131147. this.onKeyboardObservable.clear();
  131148. this.onActiveCameraChanged.clear();
  131149. this.detachControl();
  131150. // Detach cameras
  131151. var canvas = this._engine.getRenderingCanvas();
  131152. if (canvas) {
  131153. var index;
  131154. for (index = 0; index < this.cameras.length; index++) {
  131155. this.cameras[index].detachControl(canvas);
  131156. }
  131157. }
  131158. // Release animation groups
  131159. while (this.animationGroups.length) {
  131160. this.animationGroups[0].dispose();
  131161. }
  131162. // Release lights
  131163. while (this.lights.length) {
  131164. this.lights[0].dispose();
  131165. }
  131166. // Release meshes
  131167. while (this.meshes.length) {
  131168. this.meshes[0].dispose(true);
  131169. }
  131170. while (this.transformNodes.length) {
  131171. this.removeTransformNode(this.transformNodes[0]);
  131172. }
  131173. // Release cameras
  131174. while (this.cameras.length) {
  131175. this.cameras[0].dispose();
  131176. }
  131177. // Release materials
  131178. if (this.defaultMaterial) {
  131179. this.defaultMaterial.dispose();
  131180. }
  131181. while (this.multiMaterials.length) {
  131182. this.multiMaterials[0].dispose();
  131183. }
  131184. while (this.materials.length) {
  131185. this.materials[0].dispose();
  131186. }
  131187. // Release particles
  131188. while (this.particleSystems.length) {
  131189. this.particleSystems[0].dispose();
  131190. }
  131191. // Release postProcesses
  131192. while (this.postProcesses.length) {
  131193. this.postProcesses[0].dispose();
  131194. }
  131195. // Release textures
  131196. while (this.textures.length) {
  131197. this.textures[0].dispose();
  131198. }
  131199. // Release UBO
  131200. this._sceneUbo.dispose();
  131201. if (this._alternateSceneUbo) {
  131202. this._alternateSceneUbo.dispose();
  131203. }
  131204. // Post-processes
  131205. this.postProcessManager.dispose();
  131206. // Remove from engine
  131207. index = this._engine.scenes.indexOf(this);
  131208. if (index > -1) {
  131209. this._engine.scenes.splice(index, 1);
  131210. }
  131211. this._engine.wipeCaches(true);
  131212. this._isDisposed = true;
  131213. };
  131214. Object.defineProperty(Scene.prototype, "isDisposed", {
  131215. /**
  131216. * Gets if the scene is already disposed
  131217. */
  131218. get: function () {
  131219. return this._isDisposed;
  131220. },
  131221. enumerable: true,
  131222. configurable: true
  131223. });
  131224. /**
  131225. * Call this function to reduce memory footprint of the scene.
  131226. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131227. */
  131228. Scene.prototype.clearCachedVertexData = function () {
  131229. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131230. var mesh = this.meshes[meshIndex];
  131231. var geometry = mesh.geometry;
  131232. if (geometry) {
  131233. geometry._indices = [];
  131234. for (var vbName in geometry._vertexBuffers) {
  131235. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  131236. continue;
  131237. }
  131238. geometry._vertexBuffers[vbName]._buffer._data = null;
  131239. }
  131240. }
  131241. }
  131242. };
  131243. /**
  131244. * This function will remove the local cached buffer data from texture.
  131245. * It will save memory but will prevent the texture from being rebuilt
  131246. */
  131247. Scene.prototype.cleanCachedTextureBuffer = function () {
  131248. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131249. var baseTexture = _a[_i];
  131250. var buffer = baseTexture._buffer;
  131251. if (buffer) {
  131252. baseTexture._buffer = null;
  131253. }
  131254. }
  131255. };
  131256. /**
  131257. * Get the world extend vectors with an optional filter
  131258. *
  131259. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131260. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131261. */
  131262. Scene.prototype.getWorldExtends = function (filterPredicate) {
  131263. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  131264. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  131265. filterPredicate = filterPredicate || (function () { return true; });
  131266. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  131267. mesh.computeWorldMatrix(true);
  131268. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  131269. return;
  131270. }
  131271. var boundingInfo = mesh.getBoundingInfo();
  131272. var minBox = boundingInfo.boundingBox.minimumWorld;
  131273. var maxBox = boundingInfo.boundingBox.maximumWorld;
  131274. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  131275. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  131276. });
  131277. return {
  131278. min: min,
  131279. max: max
  131280. };
  131281. };
  131282. // Picking
  131283. /**
  131284. * Creates a ray that can be used to pick in the scene
  131285. * @param x defines the x coordinate of the origin (on-screen)
  131286. * @param y defines the y coordinate of the origin (on-screen)
  131287. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131288. * @param camera defines the camera to use for the picking
  131289. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131290. * @returns a Ray
  131291. */
  131292. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  131293. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131294. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].Zero();
  131295. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  131296. return result;
  131297. };
  131298. /**
  131299. * Creates a ray that can be used to pick in the scene
  131300. * @param x defines the x coordinate of the origin (on-screen)
  131301. * @param y defines the y coordinate of the origin (on-screen)
  131302. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131303. * @param result defines the ray where to store the picking ray
  131304. * @param camera defines the camera to use for the picking
  131305. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131306. * @returns the current scene
  131307. */
  131308. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  131309. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131310. var engine = this._engine;
  131311. if (!camera) {
  131312. if (!this.activeCamera) {
  131313. throw new Error("Active camera not set");
  131314. }
  131315. camera = this.activeCamera;
  131316. }
  131317. var cameraViewport = camera.viewport;
  131318. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  131319. // Moving coordinates to local viewport world
  131320. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  131321. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  131322. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  131323. return this;
  131324. };
  131325. /**
  131326. * Creates a ray that can be used to pick in the scene
  131327. * @param x defines the x coordinate of the origin (on-screen)
  131328. * @param y defines the y coordinate of the origin (on-screen)
  131329. * @param camera defines the camera to use for the picking
  131330. * @returns a Ray
  131331. */
  131332. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  131333. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].Zero();
  131334. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  131335. return result;
  131336. };
  131337. /**
  131338. * Creates a ray that can be used to pick in the scene
  131339. * @param x defines the x coordinate of the origin (on-screen)
  131340. * @param y defines the y coordinate of the origin (on-screen)
  131341. * @param result defines the ray where to store the picking ray
  131342. * @param camera defines the camera to use for the picking
  131343. * @returns the current scene
  131344. */
  131345. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  131346. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]) {
  131347. return this;
  131348. }
  131349. var engine = this._engine;
  131350. if (!camera) {
  131351. if (!this.activeCamera) {
  131352. throw new Error("Active camera not set");
  131353. }
  131354. camera = this.activeCamera;
  131355. }
  131356. var cameraViewport = camera.viewport;
  131357. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  131358. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131359. // Moving coordinates to local viewport world
  131360. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  131361. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  131362. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  131363. return this;
  131364. };
  131365. Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  131366. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]) {
  131367. return null;
  131368. }
  131369. var pickingInfo = null;
  131370. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131371. var mesh = this.meshes[meshIndex];
  131372. if (predicate) {
  131373. if (!predicate(mesh)) {
  131374. continue;
  131375. }
  131376. }
  131377. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  131378. continue;
  131379. }
  131380. var world = mesh.getWorldMatrix();
  131381. var ray = rayFunction(world);
  131382. var result = mesh.intersects(ray, fastCheck);
  131383. if (!result || !result.hit) {
  131384. continue;
  131385. }
  131386. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  131387. continue;
  131388. }
  131389. pickingInfo = result;
  131390. if (fastCheck) {
  131391. break;
  131392. }
  131393. }
  131394. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  131395. };
  131396. Scene.prototype._internalMultiPick = function (rayFunction, predicate) {
  131397. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]) {
  131398. return null;
  131399. }
  131400. var pickingInfos = new Array();
  131401. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131402. var mesh = this.meshes[meshIndex];
  131403. if (predicate) {
  131404. if (!predicate(mesh)) {
  131405. continue;
  131406. }
  131407. }
  131408. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  131409. continue;
  131410. }
  131411. var world = mesh.getWorldMatrix();
  131412. var ray = rayFunction(world);
  131413. var result = mesh.intersects(ray, false);
  131414. if (!result || !result.hit) {
  131415. continue;
  131416. }
  131417. pickingInfos.push(result);
  131418. }
  131419. return pickingInfos;
  131420. };
  131421. /** Launch a ray to try to pick a mesh in the scene
  131422. * @param x position on screen
  131423. * @param y position on screen
  131424. * @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
  131425. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131426. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131427. * @returns a PickingInfo
  131428. */
  131429. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131430. var _this = this;
  131431. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]) {
  131432. return null;
  131433. }
  131434. var result = this._internalPick(function (world) {
  131435. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  131436. return _this._tempPickingRay;
  131437. }, predicate, fastCheck);
  131438. if (result) {
  131439. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), camera || null);
  131440. }
  131441. return result;
  131442. };
  131443. /** Use the given ray to pick a mesh in the scene
  131444. * @param ray The ray to use to pick meshes
  131445. * @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
  131446. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131447. * @returns a PickingInfo
  131448. */
  131449. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131450. var _this = this;
  131451. var result = this._internalPick(function (world) {
  131452. if (!_this._pickWithRayInverseMatrix) {
  131453. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131454. }
  131455. world.invertToRef(_this._pickWithRayInverseMatrix);
  131456. if (!_this._cachedRayForTransform) {
  131457. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].Zero();
  131458. }
  131459. _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  131460. return _this._cachedRayForTransform;
  131461. }, predicate, fastCheck);
  131462. if (result) {
  131463. result.ray = ray;
  131464. }
  131465. return result;
  131466. };
  131467. /**
  131468. * Launch a ray to try to pick a mesh in the scene
  131469. * @param x X position on screen
  131470. * @param y Y position on screen
  131471. * @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
  131472. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131473. * @returns an array of PickingInfo
  131474. */
  131475. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131476. var _this = this;
  131477. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  131478. };
  131479. /**
  131480. * Launch a ray to try to pick a mesh in the scene
  131481. * @param ray Ray to use
  131482. * @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
  131483. * @returns an array of PickingInfo
  131484. */
  131485. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131486. var _this = this;
  131487. return this._internalMultiPick(function (world) {
  131488. if (!_this._pickWithRayInverseMatrix) {
  131489. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131490. }
  131491. world.invertToRef(_this._pickWithRayInverseMatrix);
  131492. if (!_this._cachedRayForTransform) {
  131493. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].Zero();
  131494. }
  131495. _Culling_ray__WEBPACK_IMPORTED_MODULE_21__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  131496. return _this._cachedRayForTransform;
  131497. }, predicate);
  131498. };
  131499. /**
  131500. * Force the value of meshUnderPointer
  131501. * @param mesh defines the mesh to use
  131502. */
  131503. Scene.prototype.setPointerOverMesh = function (mesh) {
  131504. if (this._pointerOverMesh === mesh) {
  131505. return;
  131506. }
  131507. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131508. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131509. }
  131510. this._pointerOverMesh = mesh;
  131511. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131512. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131513. }
  131514. };
  131515. /**
  131516. * Gets the mesh under the pointer
  131517. * @returns a Mesh or null if no mesh is under the pointer
  131518. */
  131519. Scene.prototype.getPointerOverMesh = function () {
  131520. return this._pointerOverMesh;
  131521. };
  131522. // Misc.
  131523. /** @hidden */
  131524. Scene.prototype._rebuildGeometries = function () {
  131525. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131526. var geometry = _a[_i];
  131527. geometry._rebuild();
  131528. }
  131529. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131530. var mesh = _c[_b];
  131531. mesh._rebuild();
  131532. }
  131533. if (this.postProcessManager) {
  131534. this.postProcessManager._rebuild();
  131535. }
  131536. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131537. var component = _e[_d];
  131538. component.rebuild();
  131539. }
  131540. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131541. var system = _g[_f];
  131542. system.rebuild();
  131543. }
  131544. };
  131545. /** @hidden */
  131546. Scene.prototype._rebuildTextures = function () {
  131547. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131548. var texture = _a[_i];
  131549. texture._rebuild();
  131550. }
  131551. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  131552. };
  131553. // Tags
  131554. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131555. if (tagsQuery === undefined) {
  131556. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131557. return list;
  131558. }
  131559. var listByTags = [];
  131560. forEach = forEach || (function (item) { return; });
  131561. for (var i in list) {
  131562. var item = list[i];
  131563. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131564. listByTags.push(item);
  131565. forEach(item);
  131566. }
  131567. }
  131568. return listByTags;
  131569. };
  131570. /**
  131571. * Get a list of meshes by tags
  131572. * @param tagsQuery defines the tags query to use
  131573. * @param forEach defines a predicate used to filter results
  131574. * @returns an array of Mesh
  131575. */
  131576. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131577. return this._getByTags(this.meshes, tagsQuery, forEach);
  131578. };
  131579. /**
  131580. * Get a list of cameras by tags
  131581. * @param tagsQuery defines the tags query to use
  131582. * @param forEach defines a predicate used to filter results
  131583. * @returns an array of Camera
  131584. */
  131585. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131586. return this._getByTags(this.cameras, tagsQuery, forEach);
  131587. };
  131588. /**
  131589. * Get a list of lights by tags
  131590. * @param tagsQuery defines the tags query to use
  131591. * @param forEach defines a predicate used to filter results
  131592. * @returns an array of Light
  131593. */
  131594. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131595. return this._getByTags(this.lights, tagsQuery, forEach);
  131596. };
  131597. /**
  131598. * Get a list of materials by tags
  131599. * @param tagsQuery defines the tags query to use
  131600. * @param forEach defines a predicate used to filter results
  131601. * @returns an array of Material
  131602. */
  131603. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131604. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131605. };
  131606. /**
  131607. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131608. * This allowed control for front to back rendering or reversly depending of the special needs.
  131609. *
  131610. * @param renderingGroupId The rendering group id corresponding to its index
  131611. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131612. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131613. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131614. */
  131615. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131616. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131617. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131618. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131619. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131620. };
  131621. /**
  131622. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131623. *
  131624. * @param renderingGroupId The rendering group id corresponding to its index
  131625. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131626. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131627. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131628. */
  131629. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131630. if (depth === void 0) { depth = true; }
  131631. if (stencil === void 0) { stencil = true; }
  131632. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131633. };
  131634. /**
  131635. * Gets the current auto clear configuration for one rendering group of the rendering
  131636. * manager.
  131637. * @param index the rendering group index to get the information for
  131638. * @returns The auto clear setup for the requested rendering group
  131639. */
  131640. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131641. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131642. };
  131643. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131644. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131645. get: function () {
  131646. return this._blockMaterialDirtyMechanism;
  131647. },
  131648. set: function (value) {
  131649. if (this._blockMaterialDirtyMechanism === value) {
  131650. return;
  131651. }
  131652. this._blockMaterialDirtyMechanism = value;
  131653. if (!value) { // Do a complete update
  131654. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AllDirtyFlag);
  131655. }
  131656. },
  131657. enumerable: true,
  131658. configurable: true
  131659. });
  131660. /**
  131661. * Will flag all materials as dirty to trigger new shader compilation
  131662. * @param flag defines the flag used to specify which material part must be marked as dirty
  131663. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131664. */
  131665. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131666. if (this._blockMaterialDirtyMechanism) {
  131667. return;
  131668. }
  131669. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131670. var material = _a[_i];
  131671. if (predicate && !predicate(material)) {
  131672. continue;
  131673. }
  131674. material.markAsDirty(flag);
  131675. }
  131676. };
  131677. /** @hidden */
  131678. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131679. var _this = this;
  131680. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131681. this._activeRequests.push(request);
  131682. request.onCompleteObservable.add(function (request) {
  131683. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131684. });
  131685. return request;
  131686. };
  131687. /** @hidden */
  131688. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131689. var _this = this;
  131690. return new Promise(function (resolve, reject) {
  131691. _this._loadFile(url, function (data) {
  131692. resolve(data);
  131693. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131694. reject(exception);
  131695. });
  131696. });
  131697. };
  131698. // Statics
  131699. Scene._uniqueIdCounter = 0;
  131700. /** The fog is deactivated */
  131701. Scene.FOGMODE_NONE = 0;
  131702. /** The fog density is following an exponential function */
  131703. Scene.FOGMODE_EXP = 1;
  131704. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131705. Scene.FOGMODE_EXP2 = 2;
  131706. /** The fog density is following a linear function. */
  131707. Scene.FOGMODE_LINEAR = 3;
  131708. /**
  131709. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131710. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131711. */
  131712. Scene.MinDeltaTime = 1.0;
  131713. /**
  131714. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131715. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131716. */
  131717. Scene.MaxDeltaTime = 1000.0;
  131718. /** The distance in pixel that you have to move to prevent some events */
  131719. Scene.DragMovementThreshold = 10; // in pixels
  131720. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  131721. Scene.LongPressDelay = 500; // in milliseconds
  131722. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  131723. Scene.DoubleClickDelay = 300; // in milliseconds
  131724. /** If you need to check double click without raising a single click at first click, enable this flag */
  131725. Scene.ExclusiveDoubleClickMode = false;
  131726. return Scene;
  131727. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  131728. /***/ }),
  131729. /***/ "./sceneComponent.ts":
  131730. /*!***************************!*\
  131731. !*** ./sceneComponent.ts ***!
  131732. \***************************/
  131733. /*! exports provided: SceneComponentConstants, Stage */
  131734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131735. "use strict";
  131736. __webpack_require__.r(__webpack_exports__);
  131737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  131738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  131739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131740. /**
  131741. * Groups all the scene component constants in one place to ease maintenance.
  131742. * @hidden
  131743. */
  131744. var SceneComponentConstants = /** @class */ (function () {
  131745. function SceneComponentConstants() {
  131746. }
  131747. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  131748. SceneComponentConstants.NAME_LAYER = "Layer";
  131749. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  131750. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  131751. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  131752. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  131753. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  131754. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  131755. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  131756. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  131757. SceneComponentConstants.NAME_SPRITE = "Sprite";
  131758. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  131759. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  131760. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  131761. SceneComponentConstants.NAME_OCTREE = "Octree";
  131762. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  131763. SceneComponentConstants.NAME_AUDIO = "Audio";
  131764. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  131765. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131766. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  131767. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131768. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  131769. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  131770. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  131771. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  131772. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  131773. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  131774. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  131775. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  131776. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  131777. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  131778. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  131779. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  131780. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  131781. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  131782. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  131783. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  131784. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  131785. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  131786. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  131787. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  131788. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  131789. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  131790. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  131791. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  131792. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  131793. return SceneComponentConstants;
  131794. }());
  131795. /**
  131796. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  131797. * @hidden
  131798. */
  131799. var Stage = /** @class */ (function (_super) {
  131800. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  131801. /**
  131802. * Hide ctor from the rest of the world.
  131803. * @param items The items to add.
  131804. */
  131805. function Stage(items) {
  131806. return _super.apply(this, items) || this;
  131807. }
  131808. /**
  131809. * Creates a new Stage.
  131810. * @returns A new instance of a Stage
  131811. */
  131812. Stage.Create = function () {
  131813. return Object.create(Stage.prototype);
  131814. };
  131815. /**
  131816. * Registers a step in an ordered way in the targeted stage.
  131817. * @param index Defines the position to register the step in
  131818. * @param component Defines the component attached to the step
  131819. * @param action Defines the action to launch during the step
  131820. */
  131821. Stage.prototype.registerStep = function (index, component, action) {
  131822. var i = 0;
  131823. var maxIndex = Number.MAX_VALUE;
  131824. for (; i < this.length; i++) {
  131825. var step = this[i];
  131826. maxIndex = step.index;
  131827. if (index < maxIndex) {
  131828. break;
  131829. }
  131830. }
  131831. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  131832. };
  131833. /**
  131834. * Clears all the steps from the stage.
  131835. */
  131836. Stage.prototype.clear = function () {
  131837. this.length = 0;
  131838. };
  131839. return Stage;
  131840. }(Array));
  131841. /***/ })
  131842. /******/ });
  131843. });
  131844. //# sourceMappingURL=babylon.max.js.map